@juspay/svelte-ui-components 2.100.2 → 2.102.0
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.
|
@@ -246,6 +246,9 @@
|
|
|
246
246
|
let isStackedMode = $derived(isMulti && groupMode === 'stacked');
|
|
247
247
|
|
|
248
248
|
function getDisplayValue(bar: BarRect): string {
|
|
249
|
+
if (typeof bar.dataPoint.valueLabel === 'string' && bar.dataPoint.valueLabel.length > 0) {
|
|
250
|
+
return bar.dataPoint.valueLabel;
|
|
251
|
+
}
|
|
249
252
|
if (isNormalized && bar.normalizedValue != null) {
|
|
250
253
|
return normalizedFormat(bar.normalizedValue);
|
|
251
254
|
}
|
|
@@ -641,7 +644,25 @@
|
|
|
641
644
|
right: dims.margin.right,
|
|
642
645
|
bottom: dims.margin.bottom,
|
|
643
646
|
left: dims.margin.left
|
|
644
|
-
}
|
|
647
|
+
},
|
|
648
|
+
bars: bars.map((bar, index) => {
|
|
649
|
+
// barLabels is index-aligned with bars (both derive from the same list);
|
|
650
|
+
// fall back to the bar's top-centre when value labels are hidden.
|
|
651
|
+
const barLabel = barLabels[index];
|
|
652
|
+
return {
|
|
653
|
+
index,
|
|
654
|
+
seriesIndex: bar.si,
|
|
655
|
+
pointIndex: bar.pi,
|
|
656
|
+
x: bar.x,
|
|
657
|
+
y: bar.y,
|
|
658
|
+
width: bar.width,
|
|
659
|
+
height: bar.height,
|
|
660
|
+
value: bar.dataPoint.value,
|
|
661
|
+
label: bar.dataPoint.label ?? '',
|
|
662
|
+
labelX: barLabel ? barLabel.p.x : bar.x + bar.width / 2,
|
|
663
|
+
labelY: barLabel ? barLabel.p.y : bar.y
|
|
664
|
+
};
|
|
665
|
+
})
|
|
645
666
|
});
|
|
646
667
|
|
|
647
668
|
// ── Interactions ───────────────────────────────────────────────
|
|
@@ -40,6 +40,12 @@ export type BarChartDataPoint = {
|
|
|
40
40
|
range?: [number, number];
|
|
41
41
|
/** Per-bar fill: plain color, pattern, or gradient. Overrides series color. */
|
|
42
42
|
color?: BarFill;
|
|
43
|
+
/**
|
|
44
|
+
* Custom text for this bar's value label, rendered verbatim instead of the
|
|
45
|
+
* `valueFormat(value)` output. Lets a caller label a single bar differently —
|
|
46
|
+
* e.g. a funnel baseline showing a raw count while the rest show a percentage.
|
|
47
|
+
*/
|
|
48
|
+
valueLabel?: string;
|
|
43
49
|
};
|
|
44
50
|
export type BarChartSeries = {
|
|
45
51
|
name: string;
|
|
@@ -47,6 +53,36 @@ export type BarChartSeries = {
|
|
|
47
53
|
/** Series-level fill: plain color, pattern, or gradient. */
|
|
48
54
|
color?: BarFill;
|
|
49
55
|
};
|
|
56
|
+
/**
|
|
57
|
+
* Geometry for a single rendered bar, in inner (post-margin) coordinates — the
|
|
58
|
+
* same space the overlay `<g>` draws in, so values map 1:1 without re-applying
|
|
59
|
+
* the margin. `labelX`/`labelY` are the value-label anchor when `showValues` is
|
|
60
|
+
* on, otherwise the bar's top-centre.
|
|
61
|
+
*/
|
|
62
|
+
export type BarChartBarPosition = {
|
|
63
|
+
/** Zero-based index in render order. */
|
|
64
|
+
index: number;
|
|
65
|
+
/** Series index (0-based). */
|
|
66
|
+
seriesIndex: number;
|
|
67
|
+
/** Category / point index (0-based). */
|
|
68
|
+
pointIndex: number;
|
|
69
|
+
/** Bar rectangle x (left edge). */
|
|
70
|
+
x: number;
|
|
71
|
+
/** Bar rectangle y (top edge). */
|
|
72
|
+
y: number;
|
|
73
|
+
/** Bar rectangle width. */
|
|
74
|
+
width: number;
|
|
75
|
+
/** Bar rectangle height. */
|
|
76
|
+
height: number;
|
|
77
|
+
/** The datum's numeric value. */
|
|
78
|
+
value: number;
|
|
79
|
+
/** The datum's category label. */
|
|
80
|
+
label: string;
|
|
81
|
+
/** Value-label anchor x. */
|
|
82
|
+
labelX: number;
|
|
83
|
+
/** Value-label anchor y. */
|
|
84
|
+
labelY: number;
|
|
85
|
+
};
|
|
50
86
|
export type BarChartRenderContext = {
|
|
51
87
|
/** Inner drawing width (pixels) */
|
|
52
88
|
innerWidth: number;
|
|
@@ -65,6 +101,12 @@ export type BarChartRenderContext = {
|
|
|
65
101
|
bottom: number;
|
|
66
102
|
left: number;
|
|
67
103
|
};
|
|
104
|
+
/**
|
|
105
|
+
* Per-bar geometry in render order. Lets an overlay anchor annotations
|
|
106
|
+
* (e.g. an icon above the first funnel step's value) to a specific bar
|
|
107
|
+
* without re-deriving the band scale from innerWidth.
|
|
108
|
+
*/
|
|
109
|
+
bars: BarChartBarPosition[];
|
|
68
110
|
};
|
|
69
111
|
export type BarChartProperties = OptionalBarChartProperties & BarChartEventProperties;
|
|
70
112
|
export type OptionalBarChartProperties = {
|