@bagelink/vue 0.0.282 → 0.0.287

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,301 +0,0 @@
1
- <template>
2
- <div class="bar-chart">
3
- <div class="graph-wrap" v-for="(item, i) in dataArray" :key="i">
4
- <div class="group-wrap" v-if="item.group">
5
- <p class="group-title">
6
- {{ item.group }}
7
- </p>
8
- <div v-for="(nested, i) in item?.data || []" :key="i" class="bar-wrap">
9
- <div
10
- class="bar"
11
- :style="{ height: loaded ? `${percent(nested.value)}%` : '0' }"
12
- />
13
- <div
14
- class="bar compare"
15
- v-if="nested.compareValue"
16
- :style="{
17
- height: loaded ? `${percent(nested.compareValue)}%` : '0',
18
- }"
19
- />
20
- <!-- <p class="bar-txt">{{ nested.title }}</p> -->
21
- </div>
22
- </div>
23
- <div v-else class="bar-wrap">
24
- <div
25
- class="bar"
26
- :style="{ height: loaded ? `${percent(item.value)}%` : '0' }"
27
- />
28
- <div
29
- class="bar compare"
30
- v-if="item?.compareValue"
31
- :style="{ height: loaded ? `${percent(item.compareValue)}%` : '0' }"
32
- />
33
- <p class="bar-txt">
34
- {{ item.title }}
35
- </p>
36
- </div>
37
- </div>
38
- <p class="factor">
39
- {{ title }}
40
- </p>
41
- <div class="red-bar" />
42
- <div class="bar-lines">
43
- <p v-for="mark in marks" :key="mark">
44
- {{ mark.toLocaleString() }}
45
- </p>
46
- </div>
47
- </div>
48
- </template>
49
-
50
- <script setup lang="ts">
51
- import { ref, onMounted, computed } from "vue";
52
-
53
- const props = defineProps<{
54
- title?: string;
55
- showMarks?: boolean;
56
- flood?: number;
57
- modelValue: {
58
- value: number;
59
- title?: string;
60
- compareValue?: number;
61
- group?: string;
62
- data?: Record<string, any>[];
63
- }[];
64
- // | {
65
- // group: string;
66
- // data: {
67
- // value: number;
68
- // title: string;
69
- // compareValue?: number | undefined;
70
- // group?: string | undefined;
71
- // data?: Record<string, any>[] | undefined;
72
- // }[]
73
- // }[]
74
- }>();
75
- const loaded = ref(false);
76
-
77
- onMounted(() => {
78
- setTimeout(() => {
79
- loaded.value = true;
80
- }, 400);
81
- });
82
-
83
- const dataArray = computed(
84
- () => props.modelValue
85
- // const allData = []
86
- // for (const item of props.modelValue) {
87
- // if (item.group) {
88
- // let groupIndex = allData.findIndex(d => d.group === item.group)
89
- // if (groupIndex > -1) allData[groupIndex].data?.push(item);
90
- // else allData.push({ group: item.group, data: [item] })
91
- // } else {
92
- // allData.push(item)
93
- // }
94
- // }
95
- // return allData;
96
- );
97
-
98
- const maxValue = computed(() =>
99
- Math.ceil(
100
- Math.max(
101
- ...dataArray.value.map((d) => d.value),
102
- ...dataArray.value.map((d) => d?.compareValue || 0)
103
- )
104
- )
105
- );
106
-
107
- const marks = computed(() => {
108
- const marksArray: number[] = [];
109
- for (let i = 0; i <= 5; i += 1) {
110
- const step = (i * maxValue.value) / 5;
111
- marksArray.push(Math.round(step / 10) * 10);
112
- }
113
- return marksArray;
114
- });
115
-
116
- const percent = (val: number) => (val / maxValue.value) * 100;
117
- const floodPercent = computed(() => `${props.flood}%`);
118
- </script>
119
-
120
- <style scoped>
121
- /* .group-wrap * {
122
- outline: 1px solid red;
123
- } */
124
-
125
- .group-wrap {
126
- height: 100%;
127
- display: flex;
128
- align-items: center;
129
- justify-content: center;
130
- flex-wrap: wrap;
131
- gap: 2px;
132
- }
133
-
134
- .group-wrap .bar-wrap {
135
- gap: 2px;
136
- }
137
-
138
- .group-title {
139
- font-size: 0.6em;
140
- width: 100%;
141
- }
142
-
143
- .bar-txt {
144
- font-size: 11px;
145
- font-weight: 200;
146
- /* max-width: 95%; */
147
- width: max-content;
148
- height: 20px;
149
- line-height: 1.2;
150
- margin: 5px auto 0;
151
- position: absolute;
152
- transform: rotate(300deg);
153
- transform-origin: 40px 40px;
154
- }
155
-
156
- .graph-wrap {
157
- display: flex;
158
- flex-direction: row;
159
- align-items: flex-end;
160
- padding: 0 10px;
161
- }
162
-
163
- .bar-wrap {
164
- text-align: center;
165
- height: 100%;
166
- /* flex: 0 1 16.6%; */
167
- display: flex;
168
- flex-direction: row;
169
- align-items: flex-end;
170
- position: relative;
171
- }
172
-
173
- .bar {
174
- background: var(--bgl-primary);
175
- position: relative;
176
- min-width: 10px;
177
- min-height: 5px;
178
- width: 4px;
179
- margin: 0 auto;
180
- transition: all ease-out 0.8s;
181
- }
182
-
183
- .bar.compare {
184
- background-color: #cf2135;
185
- }
186
-
187
- .bar-chart {
188
- height: calc(100vh - 500px);
189
- width: 90%;
190
- margin: 30px auto;
191
- display: flex;
192
- justify-content: space-between;
193
- position: relative;
194
- }
195
-
196
- .graps .bar-chart {
197
- aspect-ratio: 9/5;
198
- height: auto;
199
- max-height: calc(100vh - 500px);
200
- }
201
-
202
- .bar-lines {
203
- position: absolute;
204
- /* font-size: 20px; */
205
- display: flex;
206
- flex-direction: column-reverse;
207
- top: -15px;
208
- bottom: -12px;
209
- left: -30px;
210
- justify-content: space-between;
211
- width: calc(100% + 20px);
212
- text-align: start;
213
- }
214
-
215
- .bar-lines p {
216
- margin: 0;
217
- position: relative;
218
- }
219
-
220
- .bar-lines p::after {
221
- content: "";
222
- background: var(--bgl-primary-tint);
223
- height: 1px;
224
- position: absolute;
225
- width: calc(100% - 20px);
226
- margin: 14px 0 0 10px;
227
- opacity: 0.5;
228
- }
229
-
230
- .bar-lines p:first-child:after {
231
- content: "";
232
- background: var(--bgl-primary-tint);
233
- height: 1px;
234
- position: absolute;
235
- width: calc(100% - 10px);
236
- margin: 8px 0 0 10px;
237
- opacity: 0.5;
238
- }
239
-
240
- .red-bar {
241
- background: #cf2135;
242
- height: v-bind(floodPercent);
243
- width: 100%;
244
- position: absolute;
245
- left: 0px;
246
- bottom: 0;
247
- opacity: 0.6;
248
- transition: all 200ms ease;
249
- }
250
-
251
- .red-bar.open-redbar {
252
- height: 7%;
253
- }
254
-
255
- .factor {
256
- position: absolute;
257
- transform: rotate(270deg);
258
- height: 0px;
259
- width: 0;
260
- left: -60px;
261
- font-size: 22px;
262
- text-align: center;
263
- white-space: nowrap;
264
- top: 60%;
265
- }
266
-
267
- .dash-hor {
268
- /* border-bottom: 1px dashed white; */
269
- position: absolute;
270
- background-image: linear-gradient(to right, #cf2134 53%, transparent 0%);
271
- height: 10px;
272
- bottom: 41.5%;
273
- width: 100%;
274
- animation: 1s linear 0s infinite dash;
275
- background-position: left;
276
- background-repeat: repeat-x;
277
- background-size: 15px 4px;
278
- }
279
-
280
- .dash-hor::after {
281
- content: "Average Speedup = 25x";
282
- position: absolute;
283
- left: 0;
284
- bottom: 10px;
285
- font-size: 22px;
286
- background: #cf2134;
287
- z-index: 2;
288
- padding: 1px 4px;
289
- border-radius: 3px;
290
- }
291
-
292
- @keyframes dash {
293
- 0% {
294
- background-position: 0;
295
- }
296
-
297
- 100% {
298
- background-position: 15px;
299
- }
300
- }
301
- </style>
@@ -1 +0,0 @@
1
- export { default as BarChart } from './BarChart.vue';