Skip to content

Commit c9cf1fc

Browse files
committed
VueUiSparkline added config options to control chart width and optional dataLabel display
1 parent 82ef430 commit c9cf1fc

File tree

6 files changed

+15
-8
lines changed

6 files changed

+15
-8
lines changed

package-lock.json

Lines changed: 0 additions & 1 deletion
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.59",
4+
"version": "2.0.60",
55
"type": "module",
66
"description": "A user-empowering data visualization Vue components library",
77
"keywords": [

src/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3525,7 +3525,7 @@ const kpiConfig = ref(
35253525
</template>
35263526
</Box>
35273527

3528-
<Box @copy="copyConfig(PROD_CONFIG.vue_ui_sparkline)">
3528+
<Box open @copy="copyConfig(PROD_CONFIG.vue_ui_sparkline)">
35293529
<template #title>
35303530
<BaseIcon name="chartSparkline" />
35313531
VueUiSparkline

src/components/vue-ui-sparkline.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ const drawingArea = computed(() => {
123123
left: 0,
124124
right: svg.value.width,
125125
bottom: svg.value.height - 3,
126-
start: props.showInfo && sparklineConfig.value.style.dataLabel.position === 'left' ? 210 : 0,
127-
width: props.showInfo ? 290 : svg.value.width,
126+
start: props.showInfo && sparklineConfig.value.style.dataLabel.show && sparklineConfig.value.style.dataLabel.position === 'left' ? svg.value.width - sparklineConfig.value.style.chartWidth : 30,
127+
width: props.showInfo && sparklineConfig.value.style.dataLabel.show ? sparklineConfig.value.style.chartWidth : svg.value.width - 30,
128128
height: svg.value.height - topPadding
129129
}
130130
});
@@ -333,10 +333,10 @@ function selectDatapoint(datapoint, index) {
333333

334334
<!-- DATALABEL -->
335335
<text
336-
v-if="showInfo"
336+
v-if="showInfo && sparklineConfig.style.dataLabel.show"
337337
data-cy="sparkline-datalabel"
338-
:x="sparklineConfig.style.dataLabel.position === 'left' ? 12 : drawingArea.width + 12"
339-
:y="svg.height / 2 + sparklineConfig.style.dataLabel.fontSize / 2.5"
338+
:x="sparklineConfig.style.dataLabel.position === 'left' ? 12 + sparklineConfig.style.dataLabel.offsetX : drawingArea.width + 12 + sparklineConfig.style.dataLabel.offsetX"
339+
:y="svg.height / 2 + sparklineConfig.style.dataLabel.fontSize / 2.5 + sparklineConfig.style.dataLabel.offsetY"
340340
:font-size="sparklineConfig.style.dataLabel.fontSize"
341341
:font-weight="sparklineConfig.style.dataLabel.bold ? 'bold' : 'normal'"
342342
:fill="sparklineConfig.style.dataLabel.color"

src/default_configs.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,6 +1685,7 @@
16851685
"vue_ui_sparkline": {
16861686
"type": "line",
16871687
"style": {
1688+
"chartWidth": 290,
16881689
"animation": {
16891690
"show": true,
16901691
"animationFrames": 360
@@ -1717,7 +1718,10 @@
17171718
"strokeDasharray": 3
17181719
},
17191720
"dataLabel": {
1721+
"show": true,
17201722
"position": "left",
1723+
"offsetX": 0,
1724+
"offsetY": 0,
17211725
"fontSize": 20,
17221726
"bold": true,
17231727
"color": "#2D353C",

types/vue-data-ui.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3813,6 +3813,7 @@ declare module 'vue-data-ui' {
38133813
style?: {
38143814
backgroundColor?: string;
38153815
fontFamily?: string;
3816+
chartWidth?: number;
38163817
animation?: {
38173818
show?: boolean;
38183819
animationFrames?: number;
@@ -3847,7 +3848,10 @@ declare module 'vue-data-ui' {
38473848
strokeDasharray?: number;
38483849
};
38493850
dataLabel?: {
3851+
show?: boolean;
38503852
position?: "left" | "right";
3853+
offsetX?: number;
3854+
offsetY?: number;
38513855
fontSize?: number;
38523856
bold?: boolean;
38533857
color?: string;

0 commit comments

Comments
 (0)