@fluentui/react-charts 0.0.0-nightly-20250821-0406.1 → 0.0.0-nightly-20250822-0407.1

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.
@@ -132,6 +132,47 @@ function getTitles(layout) {
132
132
  };
133
133
  return titles;
134
134
  }
135
+ const getXAxisTickFormat = (series, layout)=>{
136
+ const xAxis = getXAxisProperties(series, layout);
137
+ if (xAxis === null || xAxis === void 0 ? void 0 : xAxis.tickformat) {
138
+ return {
139
+ tickFormat: xAxis === null || xAxis === void 0 ? void 0 : xAxis.tickformat
140
+ };
141
+ }
142
+ return {};
143
+ };
144
+ const getYAxisTickFormat = (series, layout)=>{
145
+ const yAxis = getYAxisProperties(series, layout);
146
+ if (yAxis === null || yAxis === void 0 ? void 0 : yAxis.tickformat) {
147
+ return {
148
+ yAxisTickFormat: (0, _d3format.format)(yAxis === null || yAxis === void 0 ? void 0 : yAxis.tickformat)
149
+ };
150
+ }
151
+ return {};
152
+ };
153
+ const getYMinMaxValues = (series, layout)=>{
154
+ var _getYAxisProperties;
155
+ const range = (_getYAxisProperties = getYAxisProperties(series, layout)) === null || _getYAxisProperties === void 0 ? void 0 : _getYAxisProperties.range;
156
+ if (range && range.length === 2) {
157
+ return {
158
+ yMinValue: range[0],
159
+ yMaxValue: range[1]
160
+ };
161
+ }
162
+ return {};
163
+ };
164
+ const getYAxisProperties = (series, layout)=>{
165
+ return layout === null || layout === void 0 ? void 0 : layout.yaxis;
166
+ };
167
+ const getXAxisProperties = (series, layout)=>{
168
+ return layout === null || layout === void 0 ? void 0 : layout.xaxis;
169
+ };
170
+ const getFormattedCalloutYData = (yVal, yAxisFormat)=>{
171
+ if (typeof (yAxisFormat === null || yAxisFormat === void 0 ? void 0 : yAxisFormat.yAxisTickFormat) === 'function' && typeof yVal === 'number') {
172
+ return yAxisFormat.yAxisTickFormat(yVal);
173
+ }
174
+ return (0, _chartutilities.formatToLocaleString)(yVal);
175
+ };
135
176
  const correctYearMonth = (xValues)=>{
136
177
  const presentYear = new Date().getFullYear();
137
178
  if (xValues.length > 0 && Array.isArray(xValues[0])) {
@@ -294,6 +335,7 @@ const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayTy
294
335
  const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
295
336
  const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
296
337
  let colorScale = undefined;
338
+ const yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
297
339
  let yMinValue = 0;
298
340
  input.data.forEach((series, index1)=>{
299
341
  var _input_layout_coloraxis_colorscale, _input_layout_coloraxis, _input_layout, _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout1, _series_marker3, _input_layout_template_layout1, _input_layout_template1, _input_layout2, _series_line;
@@ -327,6 +369,7 @@ const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayTy
327
369
  const color = colorScale ? colorScale((0, _chartutilities.isArrayOrTypedArray)((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) ? (_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[index2 % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : (0, _PlotlyColorAdapter.resolveColor)(extractedBarColors, index2, legend, colorMap, isDarkTheme);
328
370
  const opacity = (0, _PlotlyColorAdapter.getOpacity)(series, index2);
329
371
  const yVal = rangeYValues[index2];
372
+ const yAxisCalloutData = getFormattedCalloutYData(yVal, yAxisTickFormat);
330
373
  if (series.type === 'bar') {
331
374
  var _rgb_copy_formatHex8;
332
375
  mapXToDataPoints[x].chartData.push({
@@ -334,7 +377,8 @@ const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayTy
334
377
  data: yVal,
335
378
  color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(color).copy({
336
379
  opacity
337
- }).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
380
+ }).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
381
+ yAxisCalloutData
338
382
  });
339
383
  if (typeof yVal === 'number') {
340
384
  yMaxValue = Math.max(yMaxValue, yVal);
@@ -356,7 +400,8 @@ const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayTy
356
400
  ...lineOptions !== null && lineOptions !== void 0 ? lineOptions : {},
357
401
  mode: series.mode
358
402
  },
359
- useSecondaryYScale: usesSecondaryYScale(series, input.layout)
403
+ useSecondaryYScale: usesSecondaryYScale(series, input.layout),
404
+ yAxisCalloutData
360
405
  });
361
406
  if (!usesSecondaryYScale(series, input.layout) && typeof yVal === 'number') {
362
407
  yMaxValue = Math.max(yMaxValue, yVal);
@@ -367,7 +412,6 @@ const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayTy
367
412
  });
368
413
  });
369
414
  });
370
- const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
371
415
  const vsbcData = Object.values(mapXToDataPoints);
372
416
  var _input_layout_height;
373
417
  return {
@@ -377,9 +421,6 @@ const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayTy
377
421
  barWidth: 'auto',
378
422
  yMaxValue,
379
423
  yMinValue,
380
- chartTitle,
381
- xAxisTitle,
382
- yAxisTitle,
383
424
  mode: 'plotly',
384
425
  ...secondaryYAxisValues,
385
426
  wrapXAxisLables: typeof ((_vsbcData_ = vsbcData[0]) === null || _vsbcData_ === void 0 ? void 0 : _vsbcData_.xAxisPoint) === 'string',
@@ -390,6 +431,9 @@ const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayTy
390
431
  showYAxisLables: true,
391
432
  noOfCharsToTruncate: 20,
392
433
  showYAxisLablesTooltip: true,
434
+ ...getTitles(input.layout),
435
+ ...getXAxisTickFormat(input.data[0], input.layout),
436
+ ...yAxisTickFormat,
393
437
  ...getAxisCategoryOrderProps(input.data, input.layout)
394
438
  };
395
439
  };
@@ -413,6 +457,7 @@ const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, colorwayTy
413
457
  const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, 0, 0);
414
458
  const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
415
459
  let colorScale = undefined;
460
+ const yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
416
461
  input.data.forEach((series, index1)=>{
417
462
  var _input_layout_coloraxis_colorscale, _input_layout_coloraxis, _input_layout, _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout1, _series_marker3, _series_x;
418
463
  if (((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_coloraxis = _input_layout.coloraxis) === null || _input_layout_coloraxis === void 0 ? void 0 : (_input_layout_coloraxis_colorscale = _input_layout_coloraxis.colorscale) === null || _input_layout_coloraxis_colorscale === void 0 ? void 0 : _input_layout_coloraxis_colorscale.length) && (0, _chartutilities.isArrayOrTypedArray)((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) && ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length > 0 && typeof ((_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[0]) === 'number') {
@@ -437,21 +482,22 @@ const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, colorwayTy
437
482
  // resolve color for each legend's bars from the colorscale or extracted colors
438
483
  const color = colorScale ? colorScale((0, _chartutilities.isArrayOrTypedArray)((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) ? (_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[index2 % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : (0, _PlotlyColorAdapter.resolveColor)(extractedColors, index2, legend, colorMap, isDarkTheme);
439
484
  const opacity = (0, _PlotlyColorAdapter.getOpacity)(series, index2);
485
+ const yVal = series.y[index2];
440
486
  var _rgb_copy_formatHex8;
441
487
  mapXToDataPoints[x].series.push({
442
488
  key: legend,
443
- data: series.y[index2],
489
+ data: yVal,
444
490
  xAxisCalloutData: x,
445
491
  color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(color).copy({
446
492
  opacity
447
493
  }).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
448
494
  legend,
449
- useSecondaryYScale: usesSecondaryYScale(series, input.layout)
495
+ useSecondaryYScale: usesSecondaryYScale(series, input.layout),
496
+ yAxisCalloutData: getFormattedCalloutYData(yVal, yAxisTickFormat)
450
497
  });
451
498
  }
452
499
  });
453
500
  });
454
- const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
455
501
  const gvbcData = Object.values(mapXToDataPoints);
456
502
  var _input_layout_height;
457
503
  return {
@@ -459,15 +505,16 @@ const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, colorwayTy
459
505
  width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
460
506
  height: (_input_layout_height = (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
461
507
  barWidth: 'auto',
462
- chartTitle,
463
- xAxisTitle,
464
- yAxisTitle,
465
508
  mode: 'plotly',
466
509
  ...secondaryYAxisValues,
467
510
  hideTickOverlap: true,
468
511
  wrapXAxisLables: typeof ((_gvbcData_ = gvbcData[0]) === null || _gvbcData_ === void 0 ? void 0 : _gvbcData_.name) === 'string',
469
512
  hideLegend,
470
513
  roundCorners: true,
514
+ ...getTitles(input.layout),
515
+ ...getYMinMaxValues(input.data[0], input.layout),
516
+ ...getXAxisTickFormat(input.data[0], input.layout),
517
+ ...yAxisTickFormat,
471
518
  ...getAxisCategoryOrderProps(input.data, input.layout)
472
519
  };
473
520
  };
@@ -534,21 +581,19 @@ const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colorwayTyp
534
581
  });
535
582
  });
536
583
  });
537
- const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
538
584
  var _input_layout_height;
539
585
  return {
540
586
  data: vbcData,
541
587
  width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
542
588
  height: (_input_layout_height = (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
543
- chartTitle,
544
- xAxisTitle,
545
- yAxisTitle,
546
589
  mode: 'histogram',
547
590
  hideTickOverlap: true,
548
591
  wrapXAxisLables: typeof ((_vbcData_ = vbcData[0]) === null || _vbcData_ === void 0 ? void 0 : _vbcData_.x) === 'string',
549
592
  maxBarWidth: 50,
550
593
  hideLegend,
551
594
  roundCorners: true,
595
+ ...getTitles(input.layout),
596
+ ...getYMinMaxValues(input.data[0], input.layout),
552
597
  ...getAxisCategoryOrderProps(input.data, input.layout)
553
598
  };
554
599
  };
@@ -562,7 +607,7 @@ const transformPlotlyJsonToScatterChartProps = (input, isMultiPlot, colorMap, co
562
607
  return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'scatter', colorMap, colorwayType, isDarkTheme);
563
608
  };
564
609
  const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme)=>{
565
- var _input_data_;
610
+ var _input_data_, _input_layout, _input_layout1;
566
611
  const isScatterMarkers = [
567
612
  'markers',
568
613
  'text+markers',
@@ -576,6 +621,7 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
576
621
  const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
577
622
  let mode = 'tonexty';
578
623
  const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
624
+ const yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
579
625
  const chartData = input.data.map((series, index)=>{
580
626
  var _series_mode, _series_line, _series_marker, _series_line1, _input_layout_template_layout, _input_layout_template, _input_layout, _series_mode1;
581
627
  const colors = isScatterMarkers ? (series === null || series === void 0 ? void 0 : (_series_mode = series.mode) === null || _series_mode === void 0 ? void 0 : _series_mode.includes('line')) ? (_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.color : (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color : (_series_line1 = series.line) === null || _series_line1 === void 0 ? void 0 : _series_line1.color;
@@ -616,7 +662,8 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
616
662
  } : {},
617
663
  ...textValues ? {
618
664
  text: textValues[i]
619
- } : {}
665
+ } : {},
666
+ yAxisCalloutData: getFormattedCalloutYData(rangeYValues[i], yAxisTickFormat)
620
667
  };
621
668
  }),
622
669
  color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(seriesColor).copy({
@@ -630,52 +677,45 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
630
677
  };
631
678
  });
632
679
  }).flat();
633
- const yMinMaxValues = (0, _utilities.findNumericMinMaxOfY)(chartData);
634
- const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
680
+ const yMinMax = getYMinMaxValues(input.data[0], input.layout);
681
+ if (yMinMax.yMinValue === undefined && yMinMax.yMaxValue === undefined) {
682
+ const yMinMaxValues = (0, _utilities.findNumericMinMaxOfY)(chartData);
683
+ yMinMax.yMinValue = yMinMaxValues.startValue;
684
+ yMinMax.yMaxValue = yMinMaxValues.endValue;
685
+ }
635
686
  const numDataPoints = chartData.reduce((total, lineChartPoints)=>total + lineChartPoints.data.length, 0);
636
687
  const chartProps = {
637
- chartTitle,
638
688
  lineChartData: chartData
639
689
  };
640
690
  const scatterChartProps = {
641
- chartTitle,
642
691
  scatterChartData: chartData
643
692
  };
693
+ var _input_layout_height;
694
+ const commonProps = {
695
+ supportNegativeData: true,
696
+ ...secondaryYAxisValues,
697
+ width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
698
+ height: (_input_layout_height = (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
699
+ hideTickOverlap: true,
700
+ hideLegend,
701
+ useUTC: false,
702
+ optimizeLargeData: numDataPoints > 1000,
703
+ ...getTitles(input.layout),
704
+ ...getXAxisTickFormat(input.data[0], input.layout),
705
+ ...yAxisTickFormat
706
+ };
644
707
  if (isAreaChart) {
645
- var _input_layout, _input_layout1;
646
- var _input_layout_height;
647
708
  return {
648
709
  data: chartProps,
649
- supportNegativeData: true,
650
- xAxisTitle,
651
- yAxisTitle,
652
- ...secondaryYAxisValues,
653
710
  mode,
654
- width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
655
- height: (_input_layout_height = (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
656
- hideTickOverlap: true,
657
- useUTC: false,
658
- hideLegend,
659
- optimizeLargeData: numDataPoints > 1000
711
+ ...commonProps
660
712
  };
661
713
  } else {
662
- var _input_layout2, _input_layout3;
663
- var _input_layout_height1;
664
714
  return {
665
715
  data: isScatterChart ? scatterChartProps : chartProps,
666
- supportNegativeData: true,
667
- xAxisTitle,
668
- yAxisTitle,
669
- ...secondaryYAxisValues,
670
716
  roundedTicks: true,
671
- yMinValue: yMinMaxValues.startValue,
672
- yMaxValue: yMinMaxValues.endValue,
673
- width: (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.width,
674
- height: (_input_layout_height1 = (_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : _input_layout3.height) !== null && _input_layout_height1 !== void 0 ? _input_layout_height1 : 350,
675
- hideTickOverlap: true,
676
- useUTC: false,
677
- hideLegend,
678
- optimizeLargeData: numDataPoints > 1000
717
+ ...commonProps,
718
+ ...yMinMax
679
719
  };
680
720
  }
681
721
  };
@@ -721,12 +761,8 @@ const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPlot, col
721
761
  const scalingFactor = 0.01;
722
762
  const gapFactor = 1 / (1 + scalingFactor * numberOfRows);
723
763
  const barHeight = availableHeight / (numberOfRows * (1 + gapFactor));
724
- const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
725
764
  return {
726
765
  data: chartData,
727
- chartTitle,
728
- xAxisTitle,
729
- yAxisTitle,
730
766
  secondaryYAxistitle: typeof ((_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : (_input_layout_yaxis2 = _input_layout3.yaxis2) === null || _input_layout_yaxis2 === void 0 ? void 0 : _input_layout_yaxis2.title) === 'string' ? (_input_layout4 = input.layout) === null || _input_layout4 === void 0 ? void 0 : (_input_layout_yaxis21 = _input_layout4.yaxis2) === null || _input_layout_yaxis21 === void 0 ? void 0 : _input_layout_yaxis21.title : ((_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : (_input_layout_yaxis22 = _input_layout5.yaxis2) === null || _input_layout_yaxis22 === void 0 ? void 0 : (_input_layout_yaxis2_title = _input_layout_yaxis22.title) === null || _input_layout_yaxis2_title === void 0 ? void 0 : _input_layout_yaxis2_title.text) || '',
731
767
  barHeight,
732
768
  showYAxisLables: true,
@@ -737,6 +773,7 @@ const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPlot, col
737
773
  showYAxisLablesTooltip: true,
738
774
  hideLegend,
739
775
  roundCorners: true,
776
+ ...getTitles(input.layout),
740
777
  ...getAxisCategoryOrderProps(input.data, input.layout)
741
778
  };
742
779
  };
@@ -850,7 +887,6 @@ const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap, colorwa
850
887
  }
851
888
  const domainValuesForColorScale = Array.isArray(colorscale) ? colorscale.map((arr)=>arr[0] * (zMax - zMin) + zMin) : defaultDomain;
852
889
  const rangeValuesForColorScale = Array.isArray(colorscale) ? colorscale.map((arr)=>arr[1]) : defaultRange;
853
- const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
854
890
  var _input_layout_height;
855
891
  return {
856
892
  data: [
@@ -860,9 +896,6 @@ const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap, colorwa
860
896
  rangeValuesForColorScale,
861
897
  hideLegend: true,
862
898
  showYAxisLables: true,
863
- chartTitle,
864
- xAxisTitle,
865
- yAxisTitle,
866
899
  sortOrder: 'none',
867
900
  width: (_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : _input_layout5.width,
868
901
  height: (_input_layout_height = (_input_layout6 = input.layout) === null || _input_layout6 === void 0 ? void 0 : _input_layout6.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
@@ -870,6 +903,7 @@ const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap, colorwa
870
903
  noOfCharsToTruncate: 20,
871
904
  showYAxisLablesTooltip: true,
872
905
  wrapXAxisLables: true,
906
+ ...getTitles(input.layout),
873
907
  ...getAxisCategoryOrderProps([
874
908
  firstData
875
909
  ], input.layout)