From 7db1b4e90e7d0206d570558184d9377835ffdeac Mon Sep 17 00:00:00 2001 From: graphieros Date: Sun, 26 Nov 2023 09:01:41 +0100 Subject: [PATCH] VueUiSparkline add bar type --- package-lock.json | 4 ++-- package.json | 2 +- src/App.vue | 29 +++++++++++++--------------- src/components/vue-ui-sparkline.vue | 30 +++++++++++++++++++++++++---- src/default_configs.json | 5 +++++ types/vue-data-ui.d.ts | 5 +++++ 6 files changed, 52 insertions(+), 23 deletions(-) diff --git a/package-lock.json b/package-lock.json index cae9f7d4..2086c099 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "vue-data-ui", - "version": "1.9.4", + "version": "1.9.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "vue-data-ui", - "version": "1.9.4", + "version": "1.9.5", "license": "MIT", "devDependencies": { "@vitejs/plugin-vue": "^4.2.3", diff --git a/package.json b/package.json index b9e3abc5..2427f672 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vue-data-ui", "private": false, - "version": "1.9.5", + "version": "1.9.6", "type": "module", "description": "A user-empowering data visualization Vue components library", "keywords": [ diff --git a/src/App.vue b/src/App.vue index d70b4417..73dd2e58 100644 --- a/src/App.vue +++ b/src/App.vue @@ -2186,6 +2186,7 @@ const skeletonConfig = ref({ }); const sparklineConfig = ref({ + type: 'bar', style: { backgroundColor: "#1A1A1A", sparkline: { @@ -2243,7 +2244,7 @@ const sparklineDataset = ref([ }, { period: "period2", - value: -1, + value: 1, }, { period: "period3", @@ -2255,7 +2256,7 @@ const sparklineDataset = ref([ }, { period: "period5", - value: -4, + value: 4, }, { period: "period6", @@ -2263,7 +2264,7 @@ const sparklineDataset = ref([ }, { period: "period6", - value: -6, + value: 6, }, { period: "period8", @@ -2271,40 +2272,36 @@ const sparklineDataset = ref([ }, { period: "period9", - value: -8, + value: -7, }, { period: "period10", - value: 9, + value: -6, }, { period: "period11", - value: -10, + value: -5, }, { period: "period12", - value: 11, + value: -4, }, { period: "period13", - value: -12, + value: -3, }, { period: "period14", - value: 13, + value: -2, }, { period: "period15", - value: -14, + value: -1, }, { period: "period16", - value: 15, - }, - { - period: "period17", - value: -16, - }, + value: 0, + } ]); const heatmapDataset = computed(() => { diff --git a/src/components/vue-ui-sparkline.vue b/src/components/vue-ui-sparkline.vue index a2c26b55..9e2915e9 100644 --- a/src/components/vue-ui-sparkline.vue +++ b/src/components/vue-ui-sparkline.vue @@ -91,7 +91,8 @@ const mutableDataset = computed(() => { x: drawingArea.value.start + (i * (drawingArea.value.width / len.value)), y: drawingArea.value.bottom - (drawingArea.value.height * ratioToMax(absoluteValue + bottomPadding.value + absoluteMin.value)), id: `plot_${uid}_${i}`, - color: sparklineConfig.value.style.area.useGradient ? shiftHue(sparklineConfig.value.style.line.color, 0.05 * ( 1 - (i / len.value))) : sparklineConfig.value.style.line.color + color: isBar.value ? sparklineConfig.value.style.bar.color : sparklineConfig.value.style.area.useGradient ? shiftHue(sparklineConfig.value.style.line.color, 0.05 * ( 1 - (i / len.value))) : sparklineConfig.value.style.line.color, + width: drawingArea.value.width / len.value } }) }); @@ -126,6 +127,10 @@ const dataLabel = computed(() => { } }); +const isBar = computed(() => { + return sparklineConfig.value.type && sparklineConfig.value.type === 'bar'; +}); +