@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.
@@ -13,6 +13,8 @@ export interface LineChartProps<T> {
13
13
  theme?: Theme;
14
14
  paletteId?: number;
15
15
  renderTooltipLabel?: (item: TooltipItem<'line'>) => string | number | undefined;
16
+ numberFormat?: Intl.NumberFormatOptions | ((v: number) => string);
17
+ locale?: string | string[];
16
18
  }
17
- export declare function LineChart<T extends object>({ data, getPrimary, getSecondary, title, showDataLabels, theme, renderTooltipLabel, paletteId, }: LineChartProps<T>): React.JSX.Element;
19
+ export declare function LineChart<T extends object>({ data, getPrimary, getSecondary, title, showDataLabels, theme, renderTooltipLabel, paletteId, numberFormat, locale, }: LineChartProps<T>): React.JSX.Element;
18
20
  export default LineChart;
@@ -859,6 +859,12 @@ opts) {
859
859
  var dataset = item.dataset;
860
860
  var datasetLabel = 'label' in dataset && typeof dataset.label === 'string' ? dataset.label : 'Value';
861
861
  var raw = item.raw;
862
+ // Prepare number formatter based on opts
863
+ 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;
864
+ // Helper to format numeric values for tooltips using the configured formatter
865
+ var formatVal = function formatVal(v) {
866
+ return typeof v === 'number' ? numberFormatter(v) : String(v);
867
+ };
862
868
  // determine extraField value, precedence: dataset.extraField > opts.extraField
863
869
  var extra;
864
870
  if (dataset && dataset.extraField !== undefined) {
@@ -879,22 +885,22 @@ opts) {
879
885
  var x = raw.x,
880
886
  y = raw.y,
881
887
  r = raw.r;
882
- return datasetLabel + " \u2014 x: " + x + ", y: " + y + ", r: " + r + suffix;
888
+ return datasetLabel + " \u2014 x: " + formatVal(x) + ", y: " + formatVal(y) + ", r: " + formatVal(r) + suffix;
883
889
  }
884
890
  // Scatter format { x, y }
885
891
  if (typeof raw === 'object' && raw !== null && 'x' in raw && 'y' in raw) {
886
892
  var _x = raw.x,
887
893
  _y = raw.y;
888
- return datasetLabel + " \u2014 x: " + _x + ", y: " + _y + suffix;
894
+ return datasetLabel + " \u2014 x: " + formatVal(_x) + ", y: " + formatVal(_y) + suffix;
889
895
  }
890
896
  // Floating bar [min, max]
891
897
  if (Array.isArray(raw) && raw.length === 2) {
892
898
  var min = raw[0],
893
899
  max = raw[1];
894
- return datasetLabel + ": " + min + " \u2013 " + max + suffix;
900
+ return datasetLabel + ": " + formatVal(min) + " \u2013 " + formatVal(max) + suffix;
895
901
  }
896
902
  // Default: single number or string
897
- return datasetLabel + ": " + raw + suffix;
903
+ return datasetLabel + ": " + formatVal(raw) + suffix;
898
904
  },
899
905
  beforeTitle: function beforeTitle() {
900
906
  return '';
@@ -2387,7 +2393,9 @@ function LineChart(_ref) {
2387
2393
  theme = _ref$theme === void 0 ? reactComponents.webLightTheme : _ref$theme,
2388
2394
  renderTooltipLabel = _ref.renderTooltipLabel,
2389
2395
  _ref$paletteId = _ref.paletteId,
2390
- paletteId = _ref$paletteId === void 0 ? 1 : _ref$paletteId;
2396
+ paletteId = _ref$paletteId === void 0 ? 1 : _ref$paletteId,
2397
+ numberFormat = _ref.numberFormat,
2398
+ locale = _ref.locale;
2391
2399
  var _useState = React.useState(function () {
2392
2400
  var _data$;
2393
2401
  return data.length > 1 ? data.map(function (s) {
@@ -2496,7 +2504,9 @@ function LineChart(_ref) {
2496
2504
  display: false
2497
2505
  },
2498
2506
  tooltip: createFluentTooltip(theme, {
2499
- extraField: renderTooltipLabel
2507
+ extraField: renderTooltipLabel,
2508
+ numberFormat: numberFormat,
2509
+ locale: locale
2500
2510
  })
2501
2511
  },
2502
2512
  scales: {
@@ -3576,7 +3586,10 @@ var chartProps = function chartProps(chart) {
3576
3586
  },
3577
3587
  // forward optional renderTooltipLabel if provided on the chart config
3578
3588
  renderTooltipLabel: chart.renderTooltipLabel,
3579
- paletteId: chart.paletteId
3589
+ paletteId: chart.paletteId,
3590
+ // forward optional number formatting options
3591
+ numberFormat: chart.numberFormat,
3592
+ locale: chart.locale
3580
3593
  };
3581
3594
  };
3582
3595
  var getChartComponent = function getChartComponent(chart, theme) {