@spteck/fluentui-react-charts 1.1.4 → 1.1.6
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.
- package/dist/charts/lineChart/LineChart.d.ts +3 -1
- package/dist/fluentui-react-charts.cjs.development.js +22 -8
- package/dist/fluentui-react-charts.cjs.development.js.map +1 -1
- package/dist/fluentui-react-charts.cjs.production.min.js +1 -1
- package/dist/fluentui-react-charts.cjs.production.min.js.map +1 -1
- package/dist/fluentui-react-charts.esm.js +22 -8
- package/dist/fluentui-react-charts.esm.js.map +1 -1
- package/dist/hooks/useChartUtils.d.ts +2 -0
- package/package.json +1 -1
|
@@ -852,6 +852,12 @@ opts) {
|
|
|
852
852
|
var dataset = item.dataset;
|
|
853
853
|
var datasetLabel = 'label' in dataset && typeof dataset.label === 'string' ? dataset.label : 'Value';
|
|
854
854
|
var raw = item.raw;
|
|
855
|
+
// Prepare number formatter based on opts
|
|
856
|
+
var numberFormatter = typeof (opts == null ? void 0 : opts.numberFormat) === 'function' ? opts.numberFormat : new Intl.NumberFormat(opts == null ? void 0 : opts.locale, typeof (opts == null ? void 0 : opts.numberFormat) === 'object' ? opts == null ? void 0 : opts.numberFormat : undefined).format;
|
|
857
|
+
// Helper to format numeric values for tooltips using the configured formatter
|
|
858
|
+
var formatVal = function formatVal(v) {
|
|
859
|
+
return typeof v === 'number' ? numberFormatter(v) : String(v);
|
|
860
|
+
};
|
|
855
861
|
// determine extraField value, precedence: dataset.extraField > opts.extraField
|
|
856
862
|
var extra;
|
|
857
863
|
if (dataset && dataset.extraField !== undefined) {
|
|
@@ -866,28 +872,28 @@ opts) {
|
|
|
866
872
|
extra = opts.extraField;
|
|
867
873
|
}
|
|
868
874
|
}
|
|
869
|
-
var suffix = extra !== undefined && extra !== null ? "
|
|
875
|
+
var suffix = extra !== undefined && extra !== null ? "" + String(extra) : '';
|
|
870
876
|
// Bubble format { x, y, r }
|
|
871
877
|
if (typeof raw === 'object' && raw !== null && 'x' in raw && 'y' in raw && 'r' in raw) {
|
|
872
878
|
var x = raw.x,
|
|
873
879
|
y = raw.y,
|
|
874
880
|
r = raw.r;
|
|
875
|
-
return datasetLabel + " \u2014 x: " + x + ", y: " + y + ", r: " + r + suffix;
|
|
881
|
+
return datasetLabel + " \u2014 x: " + formatVal(x) + ", y: " + formatVal(y) + ", r: " + formatVal(r) + suffix;
|
|
876
882
|
}
|
|
877
883
|
// Scatter format { x, y }
|
|
878
884
|
if (typeof raw === 'object' && raw !== null && 'x' in raw && 'y' in raw) {
|
|
879
885
|
var _x = raw.x,
|
|
880
886
|
_y = raw.y;
|
|
881
|
-
return datasetLabel + " \u2014 x: " + _x + ", y: " + _y + suffix;
|
|
887
|
+
return datasetLabel + " \u2014 x: " + formatVal(_x) + ", y: " + formatVal(_y) + suffix;
|
|
882
888
|
}
|
|
883
889
|
// Floating bar [min, max]
|
|
884
890
|
if (Array.isArray(raw) && raw.length === 2) {
|
|
885
891
|
var min = raw[0],
|
|
886
892
|
max = raw[1];
|
|
887
|
-
return datasetLabel + ": " + min + " \u2013 " + max + suffix;
|
|
893
|
+
return datasetLabel + ": " + formatVal(min) + " \u2013 " + formatVal(max) + suffix;
|
|
888
894
|
}
|
|
889
895
|
// Default: single number or string
|
|
890
|
-
return datasetLabel + ": " + raw + suffix;
|
|
896
|
+
return datasetLabel + ": " + formatVal(raw) + suffix;
|
|
891
897
|
},
|
|
892
898
|
beforeTitle: function beforeTitle() {
|
|
893
899
|
return '';
|
|
@@ -944,6 +950,7 @@ opts) {
|
|
|
944
950
|
}
|
|
945
951
|
};
|
|
946
952
|
return {
|
|
953
|
+
external: undefined,
|
|
947
954
|
enabled: true,
|
|
948
955
|
displayColors: true,
|
|
949
956
|
boxWidth: 10,
|
|
@@ -2379,7 +2386,9 @@ function LineChart(_ref) {
|
|
|
2379
2386
|
theme = _ref$theme === void 0 ? webLightTheme : _ref$theme,
|
|
2380
2387
|
renderTooltipLabel = _ref.renderTooltipLabel,
|
|
2381
2388
|
_ref$paletteId = _ref.paletteId,
|
|
2382
|
-
paletteId = _ref$paletteId === void 0 ? 1 : _ref$paletteId
|
|
2389
|
+
paletteId = _ref$paletteId === void 0 ? 1 : _ref$paletteId,
|
|
2390
|
+
numberFormat = _ref.numberFormat,
|
|
2391
|
+
locale = _ref.locale;
|
|
2383
2392
|
var _useState = useState(function () {
|
|
2384
2393
|
var _data$;
|
|
2385
2394
|
return data.length > 1 ? data.map(function (s) {
|
|
@@ -2488,7 +2497,9 @@ function LineChart(_ref) {
|
|
|
2488
2497
|
display: false
|
|
2489
2498
|
},
|
|
2490
2499
|
tooltip: createFluentTooltip(theme, {
|
|
2491
|
-
extraField: renderTooltipLabel
|
|
2500
|
+
extraField: renderTooltipLabel,
|
|
2501
|
+
numberFormat: numberFormat,
|
|
2502
|
+
locale: locale
|
|
2492
2503
|
})
|
|
2493
2504
|
},
|
|
2494
2505
|
scales: {
|
|
@@ -3568,7 +3579,10 @@ var chartProps = function chartProps(chart) {
|
|
|
3568
3579
|
},
|
|
3569
3580
|
// forward optional renderTooltipLabel if provided on the chart config
|
|
3570
3581
|
renderTooltipLabel: chart.renderTooltipLabel,
|
|
3571
|
-
paletteId: chart.paletteId
|
|
3582
|
+
paletteId: chart.paletteId,
|
|
3583
|
+
// forward optional number formatting options
|
|
3584
|
+
numberFormat: chart.numberFormat,
|
|
3585
|
+
locale: chart.locale
|
|
3572
3586
|
};
|
|
3573
3587
|
};
|
|
3574
3588
|
var getChartComponent = function getChartComponent(chart, theme) {
|