Skip to content

Commit ad47075

Browse files
committed
VueUiSparkHistogram added optional animation; improved VueUiSparkline animation consistency
1 parent 6ab1343 commit ad47075

File tree

9 files changed

+115
-14
lines changed

9 files changed

+115
-14
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vue-data-ui",
33
"private": false,
4-
"version": "2.0.55",
4+
"version": "2.0.56",
55
"type": "module",
66
"description": "A user-empowering data visualization Vue components library",
77
"keywords": [

src/App.vue

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,46 @@ const sparklineDataset2 = ref([
965965
period: "period2",
966966
value: 2,
967967
},
968+
{
969+
period: "period2",
970+
value: 6,
971+
},
972+
{
973+
period: "period2",
974+
value: 3,
975+
},
976+
{
977+
period: "period2",
978+
value: 1,
979+
},
980+
{
981+
period: "period2",
982+
value: 5,
983+
},
984+
{
985+
period: "period2",
986+
value: 2,
987+
},
988+
{
989+
period: "period2",
990+
value: 8,
991+
},
992+
{
993+
period: "period2",
994+
value: 9,
995+
},
996+
{
997+
period: "period2",
998+
value: 3,
999+
},
1000+
{
1001+
period: "period2",
1002+
value: 5,
1003+
},
1004+
{
1005+
period: "period2",
1006+
value: 2,
1007+
},
9681008
9691009
]);
9701010
@@ -1905,7 +1945,7 @@ const histoConfig = ref({
19051945
}
19061946
},
19071947
"bars": {
1908-
"shape": "star",
1948+
"shape": "square",
19091949
"strokeWidth": 0,
19101950
"colors": {
19111951
"positive": "#3366cc",
@@ -3100,7 +3140,7 @@ const kpiConfig = ref(
31003140
</template>
31013141
</Box>
31023142

3103-
<Box @copy="copyConfig(PROD_CONFIG.vue_ui_table_sparkline)">
3143+
<Box open @copy="copyConfig(PROD_CONFIG.vue_ui_table_sparkline)">
31043144
<template #title>
31053145
<BaseIcon name="chartTable"/>
31063146
VueUiTableSparkline
@@ -3459,7 +3499,7 @@ const kpiConfig = ref(
34593499
</template>
34603500
</Box>
34613501

3462-
<Box open @copy="copyConfig(PROD_CONFIG.vue_ui_sparkline)">
3502+
<Box @copy="copyConfig(PROD_CONFIG.vue_ui_sparkline)">
34633503
<template #title>
34643504
<BaseIcon name="chartSparkline" />
34653505
VueUiSparkline
@@ -3570,7 +3610,7 @@ const kpiConfig = ref(
35703610
</template>
35713611
</Box>
35723612

3573-
<Box @copy="copyConfig(PROD_CONFIG.vue_ui_sparkhistogram)">
3613+
<Box open @copy="copyConfig(PROD_CONFIG.vue_ui_sparkhistogram)">
35743614
<template #title>
35753615
<BaseIcon name="chartSparkHistogram" />
35763616
VueUiSparkHistogram

src/components/vue-ui-radar.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ const sparkBarConfig = computed(() => {
8282
return {
8383
style: {
8484
backgroundColor: radarConfig.value.style.chart.tooltip.backgroundColor,
85+
animation: {
86+
show: radarConfig.value.style.chart.tooltip.animation.show,
87+
animationFrames: radarConfig.value.style.chart.tooltip.animation.animationFrames
88+
},
8589
labels: {
8690
fontSize: radarConfig.value.style.chart.tooltip.fontSize,
8791
name: {

src/components/vue-ui-sparkhistogram.vue

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ function selectDatapoint(datapoint, index) {
128128
emits('selectDatapoint', { datapoint, index })
129129
}
130130
131+
const animation = computed(() => {
132+
return `${histoConfig.value.style.animation.speedMs}ms`
133+
})
134+
131135
</script>
132136

133137
<template>
@@ -166,15 +170,17 @@ function selectDatapoint(datapoint, index) {
166170
:stroke="rect.stroke"
167171
:stroke-width="histoConfig.style.bars.strokeWidth"
168172
:rx="`${histoConfig.style.bars.borderRadius * rect.proportion / 12}%`"
173+
:class="{'vue-ui-sparkhistogram-shape' : histoConfig.style.animation.show }"
169174
/>
170175
</g>
171-
<g v-else>
176+
<g v-else>
172177
<Shape
173178
v-for="(rect, i) in computedDataset"
174179
:plot="{ x: rect.x + rect.width / 2, y: rect.y + rect.height / 2 }"
175180
:color="histoConfig.style.bars.colors.gradient.show ? rect.gradient : rect.color"
176181
:shape="histoConfig.style.bars.shape"
177182
:radius="rect.height * 0.4"
183+
:class="{'vue-ui-sparkhistogram-shape' : histoConfig.style.animation.show }"
178184
/>
179185
</g>
180186

@@ -238,4 +244,27 @@ function selectDatapoint(datapoint, index) {
238244

239245
</svg>
240246
</div>
241-
</template>
247+
</template>
248+
249+
<style scoped>
250+
.vue-ui-sparkhistogram-shape {
251+
animation: expand v-bind(animation) ease-in forwards;
252+
transform-origin: center;
253+
transform: scale(1, 0);
254+
}
255+
256+
@keyframes expand {
257+
80% {
258+
transform: scale(1, 1.1);
259+
}
260+
90% {
261+
transform: scale(1, 0.95);
262+
}
263+
95% {
264+
transform: scale(1, 1.03);
265+
}
266+
100% {
267+
transform: scale(1, 1);
268+
}
269+
}
270+
</style>

src/components/vue-ui-sparkline.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ onMounted(() => {
8686
})
8787
}
8888
89-
if (sparklineConfig.value.style.animation.show) {
89+
if (sparklineConfig.value.style.animation.show && props.dataset.length > 1) {
9090
safeDatasetCopy.value = [];
91-
const chunks = sparklineConfig.value.style.animation.animationFrames;
91+
const chunks = sparklineConfig.value.style.animation.animationFrames / props.dataset.length;
9292
let start = 0;
9393
9494
function animate() {

src/components/vue-ui-table-sparkline.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,10 @@ defineExpose({
434434
type: tableConfig.sparkline.type,
435435
style: {
436436
backgroundColor: tableConfig.tbody.backgroundColor,
437+
animation: {
438+
show: tableConfig.sparkline.animation.show,
439+
animationFrames: tableConfig.sparkline.animation.animationFrames
440+
},
437441
line: {
438442
color: tr.color,
439443
smooth: tableConfig.sparkline.smooth,

src/default_configs.json

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,11 @@
745745
"showPercentage": true,
746746
"roundingValue": 0,
747747
"roundingPercentage": 0,
748-
"customFormat": null
748+
"customFormat": null,
749+
"animation": {
750+
"show": true,
751+
"animationFrames": 60
752+
}
749753
},
750754
"legend": {
751755
"show": true,
@@ -1683,7 +1687,7 @@
16831687
"style": {
16841688
"animation": {
16851689
"show": true,
1686-
"animationFrames": 60
1690+
"animationFrames": 360
16871691
},
16881692
"backgroundColor":"#FFFFFF",
16891693
"fontFamily": "inherit",
@@ -2596,6 +2600,10 @@
25962600
"style": {
25972601
"backgroundColor":"#FFFFFF",
25982602
"fontFamily":"inherit",
2603+
"animation": {
2604+
"show": true,
2605+
"speedMs": 500
2606+
},
25992607
"layout": {
26002608
"height": 96,
26012609
"width": 640,
@@ -3202,7 +3210,11 @@
32023210
"showArea": true,
32033211
"strokeWidth": 3,
32043212
"type": "line",
3205-
"smooth": true
3213+
"smooth": true,
3214+
"animation": {
3215+
"show": true,
3216+
"animationFrames": 360
3217+
}
32063218
},
32073219
"translations": {
32083220
"serie": "Serie",

types/vue-data-ui.d.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,10 @@ declare module 'vue-data-ui' {
291291
strokeWidth?: number;
292292
type?: "line" | "bar",
293293
smooth?: boolean;
294+
animation?: {
295+
show?: boolean;
296+
animationFrames?: number;
297+
};
294298
};
295299
translations?: {
296300
serie?: string;
@@ -983,6 +987,10 @@ declare module 'vue-data-ui' {
983987
style?: {
984988
backgroundColor?: string;
985989
fontFamily?: string;
990+
animation?: {
991+
show?: boolean;
992+
speedMs?: number;
993+
};
986994
layout?: {
987995
height?: number;
988996
width?: number;
@@ -2863,6 +2871,10 @@ declare module 'vue-data-ui' {
28632871
showPercentage?: boolean;
28642872
roundingValue?: number;
28652873
roundingPercentage?: number;
2874+
animation?: {
2875+
show?: boolean;
2876+
animationFrames?: number;
2877+
};
28662878
customFormat?: (params: VueUiTooltipParams<VueUiRadarDatapoint, VueUiRadarSeries, VueUiRadarConfig>) => string;
28672879
};
28682880
legend?: {

0 commit comments

Comments
 (0)