Skip to content

Commit 067b07a

Browse files
committed
Improvement - VueUiXy - Add prefix and suffix optional dataset serie attribute
1 parent d030471 commit 067b07a

File tree

2 files changed

+41
-18
lines changed

2 files changed

+41
-18
lines changed

src/components/vue-ui-xy.vue

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -414,11 +414,12 @@
414414
FINAL_CONFIG.chart.grid.labels.yAxis.formatter,
415415
yLabel.value,
416416
dataLabel({
417-
p:FINAL_CONFIG.chart.labels.prefix,
417+
p: yLabel.prefix,
418418
v: yLabel.value,
419-
s: FINAL_CONFIG.chart.labels.suffix,
419+
s: yLabel.suffix,
420420
r: 1,
421-
})
421+
}),
422+
{ datapoint: yLabel.datapoint, seriesIndex: j }
422423
)
423424
}}
424425
</text>
@@ -449,9 +450,9 @@
449450
FINAL_CONFIG.chart.grid.labels.yAxis.formatter,
450451
yLabel.value,
451452
dataLabel({
452-
p:FINAL_CONFIG.chart.labels.prefix,
453+
p: yLabel.prefix,
453454
v: yLabel.value,
454-
s: FINAL_CONFIG.chart.labels.suffix,
455+
s: yLabel.suffix,
455456
r: 1,
456457
})) : ''
457458
}}
@@ -669,9 +670,9 @@
669670
FINAL_CONFIG.bar.labels.formatter,
670671
plot.value,
671672
dataLabel({
672-
p:FINAL_CONFIG.chart.labels.prefix,
673+
p: serie.prefix || FINAL_CONFIG.chart.labels.prefix,
673674
v: plot.value,
674-
s: FINAL_CONFIG.chart.labels.suffix,
675+
s: serie.suffix || FINAL_CONFIG.chart.labels.suffix,
675676
r: FINAL_CONFIG.bar.labels.rounding,
676677
}),
677678
{
@@ -713,9 +714,9 @@
713714
FINAL_CONFIG.plot.labels.formatter,
714715
plot.value,
715716
dataLabel({
716-
p:FINAL_CONFIG.chart.labels.prefix,
717+
p: serie.prefix || FINAL_CONFIG.chart.labels.prefix,
717718
v: plot.value,
718-
s: FINAL_CONFIG.chart.labels.suffix,
719+
s: serie.suffix || FINAL_CONFIG.chart.labels.suffix,
719720
r: FINAL_CONFIG.plot.labels.rounding,
720721
}),
721722
{
@@ -772,9 +773,9 @@
772773
FINAL_CONFIG.line.labels.formatter,
773774
plot.value,
774775
dataLabel({
775-
p:FINAL_CONFIG.chart.labels.prefix,
776+
p: serie.prefix || FINAL_CONFIG.chart.labels.prefix,
776777
v: plot.value,
777-
s: FINAL_CONFIG.chart.labels.suffix,
778+
s: serie.suffix || FINAL_CONFIG.chart.labels.suffix,
778779
r: FINAL_CONFIG.line.labels.rounding,
779780
}),
780781
{
@@ -1648,15 +1649,21 @@ export default {
16481649
const scaleYLabels = individualScale.ticks.map(t => {
16491650
return {
16501651
y: t >= 0 ? zeroPosition - (individualHeight * (t / individualMax)) : zeroPosition + (individualHeight * Math.abs(t) / individualMax),
1651-
value: t
1652+
value: t,
1653+
prefix: datapoint.prefix || this.FINAL_CONFIG.chart.labels.prefix,
1654+
suffix: datapoint.suffix || this.FINAL_CONFIG.chart.labels.suffix,
1655+
datapoint
16521656
}
16531657
})
16541658
16551659
const autoScaleYLabels = autoScaleSteps.ticks.map(t => {
16561660
const v = (t - autoScaleSteps.min) / (autoScaleSteps.max - autoScaleSteps.min);
16571661
return {
16581662
y: t >= 0 ? autoScaleZeroPosition - (individualHeight * v) : autoScaleZeroPosition + (individualHeight * v),
1659-
value: t
1663+
value: t,
1664+
prefix: datapoint.prefix || this.FINAL_CONFIG.chart.labels.prefix,
1665+
suffix: datapoint.suffix || this.FINAL_CONFIG.chart.labels.suffix,
1666+
datapoint
16601667
}
16611668
});
16621669
@@ -1758,15 +1765,21 @@ export default {
17581765
const scaleYLabels = individualScale.ticks.map(t => {
17591766
return {
17601767
y: t >= 0 ? zeroPosition - (individualHeight * (t / individualMax)) : zeroPosition + (individualHeight * Math.abs(t) / individualMax),
1761-
value: t
1768+
value: t,
1769+
prefix: datapoint.prefix || this.FINAL_CONFIG.chart.labels.prefix,
1770+
suffix: datapoint.suffix || this.FINAL_CONFIG.chart.labels.suffix,
1771+
datapoint
17621772
}
17631773
})
17641774
17651775
const autoScaleYLabels = autoScaleSteps.ticks.map(t => {
17661776
const v = (t - autoScaleSteps.min) / (autoScaleSteps.max - autoScaleSteps.min);
17671777
return {
17681778
y: t >= 0 ? autoScaleZeroPosition - (individualHeight * v) : autoScaleZeroPosition + (individualHeight * v),
1769-
value: t
1779+
value: t,
1780+
prefix: datapoint.prefix || this.FINAL_CONFIG.chart.labels.prefix,
1781+
suffix: datapoint.suffix || this.FINAL_CONFIG.chart.labels.suffix,
1782+
datapoint
17701783
}
17711784
});
17721785
@@ -1856,15 +1869,21 @@ export default {
18561869
const scaleYLabels = individualScale.ticks.map(t => {
18571870
return {
18581871
y: t >= 0 ? zeroPosition - (individualHeight * (t / individualMax)) : zeroPosition + (individualHeight * Math.abs(t) / individualMax),
1859-
value: t
1872+
value: t,
1873+
prefix: datapoint.prefix || this.FINAL_CONFIG.chart.labels.prefix,
1874+
suffix: datapoint.suffix || this.FINAL_CONFIG.chart.labels.suffix,
1875+
datapoint,
18601876
}
18611877
})
18621878
18631879
const autoScaleYLabels = autoScaleSteps.ticks.map(t => {
18641880
const v = (t - autoScaleSteps.min) / (autoScaleSteps.max - autoScaleSteps.min);
18651881
return {
18661882
y: t >= 0 ? autoScaleZeroPosition - (individualHeight * v) : autoScaleZeroPosition + (individualHeight * v),
1867-
value: t
1883+
value: t,
1884+
prefix: datapoint.prefix || this.FINAL_CONFIG.chart.labels.prefix,
1885+
suffix: datapoint.suffix || this.FINAL_CONFIG.chart.labels.suffix,
1886+
datapoint
18681887
}
18691888
});
18701889
@@ -2135,7 +2154,9 @@ export default {
21352154
return this.niceScale.ticks.map(t => {
21362155
return {
21372156
y: t >= 0 ? this.zero - (this.drawingArea.height * this.ratioToMax(t)) : this.zero + (this.drawingArea.height * this.ratioToMax(Math.abs(t))),
2138-
value: t
2157+
value: t,
2158+
prefix: this.FINAL_CONFIG.chart.labels.prefix,
2159+
suffix: this.FINAL_CONFIG.chart.labels.suffix,
21392160
}
21402161
})
21412162
},

types/vue-data-ui.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2327,6 +2327,8 @@ declare module 'vue-data-ui' {
23272327
comments?: string[];
23282328
shape?: Shape;
23292329
smooth?: boolean;
2330+
prefix?: string;
2331+
suffix?: string;
23302332
};
23312333

23322334
export type VueUiXyDatasetBarItem = {

0 commit comments

Comments
 (0)