@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.
@@ -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) {
@@ -873,28 +879,28 @@ opts) {
873
879
  extra = opts.extraField;
874
880
  }
875
881
  }
876
- var suffix = extra !== undefined && extra !== null ? " (" + String(extra) + ")" : '';
882
+ var suffix = extra !== undefined && extra !== null ? "" + String(extra) : '';
877
883
  // Bubble format { x, y, r }
878
884
  if (typeof raw === 'object' && raw !== null && 'x' in raw && 'y' in raw && 'r' in raw) {
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 '';
@@ -951,6 +957,7 @@ opts) {
951
957
  }
952
958
  };
953
959
  return {
960
+ external: undefined,
954
961
  enabled: true,
955
962
  displayColors: true,
956
963
  boxWidth: 10,
@@ -2386,7 +2393,9 @@ function LineChart(_ref) {
2386
2393
  theme = _ref$theme === void 0 ? reactComponents.webLightTheme : _ref$theme,
2387
2394
  renderTooltipLabel = _ref.renderTooltipLabel,
2388
2395
  _ref$paletteId = _ref.paletteId,
2389
- 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;
2390
2399
  var _useState = React.useState(function () {
2391
2400
  var _data$;
2392
2401
  return data.length > 1 ? data.map(function (s) {
@@ -2495,7 +2504,9 @@ function LineChart(_ref) {
2495
2504
  display: false
2496
2505
  },
2497
2506
  tooltip: createFluentTooltip(theme, {
2498
- extraField: renderTooltipLabel
2507
+ extraField: renderTooltipLabel,
2508
+ numberFormat: numberFormat,
2509
+ locale: locale
2499
2510
  })
2500
2511
  },
2501
2512
  scales: {
@@ -3575,7 +3586,10 @@ var chartProps = function chartProps(chart) {
3575
3586
  },
3576
3587
  // forward optional renderTooltipLabel if provided on the chart config
3577
3588
  renderTooltipLabel: chart.renderTooltipLabel,
3578
- paletteId: chart.paletteId
3589
+ paletteId: chart.paletteId,
3590
+ // forward optional number formatting options
3591
+ numberFormat: chart.numberFormat,
3592
+ locale: chart.locale
3579
3593
  };
3580
3594
  };
3581
3595
  var getChartComponent = function getChartComponent(chart, theme) {