@spteck/fluentui-react-charts 1.1.5 → 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 +20 -7
- 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 +20 -7
- 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) {
|
|
@@ -872,22 +878,22 @@ opts) {
|
|
|
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 '';
|
|
@@ -2380,7 +2386,9 @@ function LineChart(_ref) {
|
|
|
2380
2386
|
theme = _ref$theme === void 0 ? webLightTheme : _ref$theme,
|
|
2381
2387
|
renderTooltipLabel = _ref.renderTooltipLabel,
|
|
2382
2388
|
_ref$paletteId = _ref.paletteId,
|
|
2383
|
-
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;
|
|
2384
2392
|
var _useState = useState(function () {
|
|
2385
2393
|
var _data$;
|
|
2386
2394
|
return data.length > 1 ? data.map(function (s) {
|
|
@@ -2489,7 +2497,9 @@ function LineChart(_ref) {
|
|
|
2489
2497
|
display: false
|
|
2490
2498
|
},
|
|
2491
2499
|
tooltip: createFluentTooltip(theme, {
|
|
2492
|
-
extraField: renderTooltipLabel
|
|
2500
|
+
extraField: renderTooltipLabel,
|
|
2501
|
+
numberFormat: numberFormat,
|
|
2502
|
+
locale: locale
|
|
2493
2503
|
})
|
|
2494
2504
|
},
|
|
2495
2505
|
scales: {
|
|
@@ -3569,7 +3579,10 @@ var chartProps = function chartProps(chart) {
|
|
|
3569
3579
|
},
|
|
3570
3580
|
// forward optional renderTooltipLabel if provided on the chart config
|
|
3571
3581
|
renderTooltipLabel: chart.renderTooltipLabel,
|
|
3572
|
-
paletteId: chart.paletteId
|
|
3582
|
+
paletteId: chart.paletteId,
|
|
3583
|
+
// forward optional number formatting options
|
|
3584
|
+
numberFormat: chart.numberFormat,
|
|
3585
|
+
locale: chart.locale
|
|
3573
3586
|
};
|
|
3574
3587
|
};
|
|
3575
3588
|
var getChartComponent = function getChartComponent(chart, theme) {
|