@fluentui/react-charts 0.0.0-nightly-20251015-0406.1 → 0.0.0-nightly-20251017-0406.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.
Files changed (25) hide show
  1. package/CHANGELOG.md +15 -15
  2. package/dist/index.d.ts +130 -1
  3. package/lib/components/DeclarativeChart/DeclarativeChart.js +1 -2
  4. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  5. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +249 -103
  6. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  7. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +332 -114
  8. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  9. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js.map +1 -1
  10. package/lib/components/Legends/Legends.js +1 -1
  11. package/lib/components/Legends/Legends.js.map +1 -1
  12. package/lib/types/DataPoint.js +1 -3
  13. package/lib/types/DataPoint.js.map +1 -1
  14. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +1 -2
  15. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  16. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +248 -102
  17. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  18. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +329 -112
  19. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  20. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js.map +1 -1
  21. package/lib-commonjs/components/Legends/Legends.js +1 -1
  22. package/lib-commonjs/components/Legends/Legends.js.map +1 -1
  23. package/lib-commonjs/types/DataPoint.js +1 -3
  24. package/lib-commonjs/types/DataPoint.js.map +1 -1
  25. package/package.json +13 -13
@@ -233,11 +233,12 @@ const usesSecondaryYScale = (series, layout)=>{
233
233
  var _layout_yaxis2, _layout_yaxis21;
234
234
  return series.yaxis === 'y2' && ((layout === null || layout === void 0 ? void 0 : (_layout_yaxis2 = layout.yaxis2) === null || _layout_yaxis2 === void 0 ? void 0 : _layout_yaxis2.anchor) === 'x' || (layout === null || layout === void 0 ? void 0 : (_layout_yaxis21 = layout.yaxis2) === null || _layout_yaxis21 === void 0 ? void 0 : _layout_yaxis21.side) === 'right');
235
235
  };
236
- const getSecondaryYAxisValues = (data, layout, maxAllowedMinY, minAllowedMaxY)=>{
236
+ const getSecondaryYAxisValues = (data, layout)=>{
237
237
  var _layout_yaxis2, _layout_yaxis21, _layout_yaxis2_title, _layout_yaxis22;
238
238
  let containsSecondaryYAxis = false;
239
239
  let yMinValue;
240
240
  let yMaxValue;
241
+ let allLineSeries = true;
241
242
  data.forEach((series)=>{
242
243
  if (usesSecondaryYScale(series, layout)) {
243
244
  containsSecondaryYAxis = true;
@@ -246,16 +247,21 @@ const getSecondaryYAxisValues = (data, layout, maxAllowedMinY, minAllowedMaxY)=>
246
247
  yMinValue = Math.min(...yValues);
247
248
  yMaxValue = Math.max(...yValues);
248
249
  }
250
+ if (series.type !== 'scatter' || (0, _chartutilities.isScatterAreaChart)(series)) {
251
+ allLineSeries = false;
252
+ }
249
253
  }
250
254
  });
251
255
  if (!containsSecondaryYAxis) {
252
256
  return {};
253
257
  }
254
- if (typeof yMinValue === 'number' && typeof maxAllowedMinY === 'number') {
255
- yMinValue = Math.min(yMinValue, maxAllowedMinY);
256
- }
257
- if (typeof yMaxValue === 'number' && typeof minAllowedMaxY === 'number') {
258
- yMaxValue = Math.max(yMaxValue, minAllowedMaxY);
258
+ if (!allLineSeries) {
259
+ if (typeof yMinValue === 'number') {
260
+ yMinValue = Math.min(yMinValue, 0);
261
+ }
262
+ if (typeof yMaxValue === 'number') {
263
+ yMaxValue = Math.max(yMaxValue, 0);
264
+ }
259
265
  }
260
266
  if (layout === null || layout === void 0 ? void 0 : (_layout_yaxis2 = layout.yaxis2) === null || _layout_yaxis2 === void 0 ? void 0 : _layout_yaxis2.range) {
261
267
  yMinValue = layout.yaxis2.range[0];
@@ -491,27 +497,23 @@ const transformPlotlyJsonToDonutProps = (input, isMultiPlot, colorMap, colorwayT
491
497
  };
492
498
  };
493
499
  const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme, fallbackVSBC)=>{
494
- var _input_layout, _input_layout1, _vsbcData_;
500
+ var _input_data_, _input_layout, _input_layout1, _input_layout2, _vsbcData_;
495
501
  const mapXToDataPoints = {};
496
502
  let yMaxValue = 0;
503
+ let yMinValue = 0;
497
504
  const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
498
505
  const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
499
506
  let colorScale = undefined;
500
507
  const yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
501
- let yMinValue = 0;
508
+ const resolveXAxisValue = getAxisValueResolver(input.data, input.layout, 'x');
502
509
  input.data.forEach((series, index1)=>{
503
510
  var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _input_layout_template_layout1, _input_layout_template1, _input_layout1, _series_line;
504
511
  colorScale = (0, _PlotlyColorAdapter.createColorScale)(input.layout, series, colorScale);
505
- const isXYearCategory = (0, _chartutilities.isYearArray)(series.x); // Consider year as categorical not numeric continuous axis
506
512
  // extract bar colors for each series only once
507
513
  const extractedBarColors = (0, _PlotlyColorAdapter.extractColor)((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color, colorMap, isDarkTheme);
508
514
  // extract line colors for each series only once
509
515
  const extractedLineColors = (0, _PlotlyColorAdapter.extractColor)((_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_template1 = _input_layout1.template) === null || _input_layout_template1 === void 0 ? void 0 : (_input_layout_template_layout1 = _input_layout_template1.layout) === null || _input_layout_template_layout1 === void 0 ? void 0 : _input_layout_template_layout1.colorway, colorwayType, (_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.color, colorMap, isDarkTheme);
510
- const xValues = series.x;
511
- const isXDate = (0, _chartutilities.isDateArray)(xValues);
512
- const isXString = (0, _chartutilities.isStringArray)(xValues);
513
- const isXNumber = (0, _chartutilities.isNumberArray)(xValues);
514
- const validXYRanges = getValidXYRanges(series);
516
+ const validXYRanges = getValidXYRanges(series, resolveXAxisValue);
515
517
  validXYRanges.forEach(([rangeStart, rangeEnd], rangeIdx)=>{
516
518
  const rangeXValues = series.x.slice(rangeStart, rangeEnd);
517
519
  const rangeYValues = series.y.slice(rangeStart, rangeEnd);
@@ -519,7 +521,7 @@ const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayTy
519
521
  var _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout;
520
522
  if (!mapXToDataPoints[x]) {
521
523
  mapXToDataPoints[x] = {
522
- xAxisPoint: resolveXAxisPoint(x, isXYearCategory, isXString, isXDate, isXNumber),
524
+ xAxisPoint: resolveXAxisValue(x),
523
525
  chartData: [],
524
526
  lineData: []
525
527
  };
@@ -572,12 +574,59 @@ const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayTy
572
574
  });
573
575
  });
574
576
  });
577
+ var _input_data__x;
578
+ const xCategories = (_input_data__x = (_input_data_ = input.data[0]) === null || _input_data_ === void 0 ? void 0 : _input_data_.x) !== null && _input_data__x !== void 0 ? _input_data__x : [];
579
+ var _input_layout_shapes;
580
+ ((_input_layout_shapes = (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.shapes) !== null && _input_layout_shapes !== void 0 ? _input_layout_shapes : []).filter((shape)=>shape.type === 'line').forEach((shape, shapeIdx)=>{
581
+ var _shape_line;
582
+ const lineColor = (_shape_line = shape.line) === null || _shape_line === void 0 ? void 0 : _shape_line.color;
583
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
584
+ const resolveX = (val)=>{
585
+ if (typeof val === 'number' && Array.isArray(xCategories) && xCategories[val] !== undefined) {
586
+ return xCategories[val];
587
+ }
588
+ return val;
589
+ };
590
+ const x0Key = resolveX(shape.x0);
591
+ const x1Key = resolveX(shape.x1);
592
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
593
+ const resolveY = (val)=>{
594
+ if (shape.yref === 'paper') {
595
+ if (val === 0) {
596
+ return yMinValue;
597
+ }
598
+ if (val === 1) {
599
+ return yMaxValue;
600
+ }
601
+ return yMinValue + val * (yMaxValue - yMinValue);
602
+ }
603
+ return val;
604
+ };
605
+ const y0Val = resolveY(shape.y0);
606
+ const y1Val = resolveY(shape.y1);
607
+ var _rgb_formatHex8;
608
+ mapXToDataPoints[x0Key].lineData.push({
609
+ legend: `Reference_${shapeIdx}`,
610
+ y: y0Val,
611
+ color: (_rgb_formatHex8 = (0, _d3color.rgb)(lineColor).formatHex8()) !== null && _rgb_formatHex8 !== void 0 ? _rgb_formatHex8 : lineColor,
612
+ lineOptions: getLineOptions(shape.line),
613
+ useSecondaryYScale: false
614
+ });
615
+ var _rgb_formatHex81;
616
+ mapXToDataPoints[x1Key].lineData.push({
617
+ legend: `Reference_${shapeIdx}`,
618
+ y: y1Val,
619
+ color: (_rgb_formatHex81 = (0, _d3color.rgb)(lineColor).formatHex8()) !== null && _rgb_formatHex81 !== void 0 ? _rgb_formatHex81 : lineColor,
620
+ lineOptions: getLineOptions(shape.line),
621
+ useSecondaryYScale: false
622
+ });
623
+ });
575
624
  const vsbcData = Object.values(mapXToDataPoints);
576
625
  var _input_layout_height;
577
626
  return {
578
627
  data: vsbcData,
579
- width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
580
- 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,
628
+ width: (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.width,
629
+ height: (_input_layout_height = (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
581
630
  barWidth: 'auto',
582
631
  yMaxValue,
583
632
  yMinValue,
@@ -601,7 +650,7 @@ const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayTy
601
650
  };
602
651
  };
603
652
  const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
604
- var _processedInput_layout, _processedInput_layout1, _gvbcData_;
653
+ var _processedInput_layout, _processedInput_layout1;
605
654
  // Handle object arrays in y values by normalizing the data first
606
655
  let processedInput = {
607
656
  ...input
@@ -630,60 +679,90 @@ const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, colorwayTy
630
679
  data: processedData
631
680
  };
632
681
  }
633
- const mapXToDataPoints = {};
634
- const secondaryYAxisValues = getSecondaryYAxisValues(processedInput.data, processedInput.layout, 0, 0);
682
+ const gvbcDataV2 = [];
683
+ const secondaryYAxisValues = getSecondaryYAxisValues(processedInput.data, processedInput.layout);
635
684
  const { legends, hideLegend } = getLegendProps(processedInput.data, processedInput.layout, isMultiPlot);
636
685
  let colorScale = undefined;
637
686
  const yAxisTickFormat = getYAxisTickFormat(processedInput.data[0], processedInput.layout);
638
687
  processedInput.data.forEach((series, index1)=>{
639
- var _processedInput_layout_template_layout, _processedInput_layout_template, _processedInput_layout, _series_marker, _series_x;
640
688
  colorScale = (0, _PlotlyColorAdapter.createColorScale)(processedInput.layout, series, colorScale);
641
- // extract colors for each series only once
642
- const extractedColors = (0, _PlotlyColorAdapter.extractColor)((_processedInput_layout = processedInput.layout) === null || _processedInput_layout === void 0 ? void 0 : (_processedInput_layout_template = _processedInput_layout.template) === null || _processedInput_layout_template === void 0 ? void 0 : (_processedInput_layout_template_layout = _processedInput_layout_template.layout) === null || _processedInput_layout_template_layout === void 0 ? void 0 : _processedInput_layout_template_layout.colorway, colorwayType, (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color, colorMap, isDarkTheme);
643
- (_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x.forEach((x, index2)=>{
644
- var _series_y;
645
- if ((0, _chartutilities.isInvalidValue)(x) || (0, _chartutilities.isInvalidValue)((_series_y = series.y) === null || _series_y === void 0 ? void 0 : _series_y[index2])) {
646
- return;
647
- }
648
- if (!mapXToDataPoints[x]) {
649
- mapXToDataPoints[x] = {
650
- name: x.toString(),
651
- series: []
652
- };
653
- }
654
- if (series.type === 'bar') {
655
- var _series_marker, _series_marker1, _series_marker_color, _series_marker2, _processedInput_layout_template_layout, _processedInput_layout_template, _processedInput_layout;
656
- const legend = legends[index1];
657
- // resolve color for each legend's bars from the colorscale or extracted colors
658
- 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, (_processedInput_layout = processedInput.layout) === null || _processedInput_layout === void 0 ? void 0 : (_processedInput_layout_template = _processedInput_layout.template) === null || _processedInput_layout_template === void 0 ? void 0 : (_processedInput_layout_template_layout = _processedInput_layout_template.layout) === null || _processedInput_layout_template_layout === void 0 ? void 0 : _processedInput_layout_template_layout.colorway, isDarkTheme);
659
- const opacity = (0, _PlotlyColorAdapter.getOpacity)(series, index2);
660
- const yVal = series.y[index2];
689
+ const legend = legends[index1];
690
+ const legendShape = getLegendShape(series);
691
+ if (series.type === 'bar') {
692
+ var _processedInput_layout_template_layout, _processedInput_layout_template, _processedInput_layout, _series_marker;
693
+ // extract bar colors for each series only once
694
+ const extractedBarColors = (0, _PlotlyColorAdapter.extractColor)((_processedInput_layout = processedInput.layout) === null || _processedInput_layout === void 0 ? void 0 : (_processedInput_layout_template = _processedInput_layout.template) === null || _processedInput_layout_template === void 0 ? void 0 : (_processedInput_layout_template_layout = _processedInput_layout_template.layout) === null || _processedInput_layout_template_layout === void 0 ? void 0 : _processedInput_layout_template_layout.colorway, colorwayType, (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color, colorMap, isDarkTheme);
695
+ gvbcDataV2.push({
696
+ type: 'bar',
697
+ legend,
698
+ key: legend,
699
+ data: series.x.map((x, xIndex)=>{
700
+ var _series_y, _series_marker, _series_marker1, _series_marker_color, _series_marker2, _processedInput_layout_template_layout, _processedInput_layout_template, _processedInput_layout;
701
+ if ((0, _chartutilities.isInvalidValue)(x) || (0, _chartutilities.isInvalidValue)((_series_y = series.y) === null || _series_y === void 0 ? void 0 : _series_y[xIndex])) {
702
+ return;
703
+ }
704
+ // resolve color for each legend's bars from the colorscale or extracted colors
705
+ 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[xIndex % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : (0, _PlotlyColorAdapter.resolveColor)(extractedBarColors, xIndex, legend, colorMap, (_processedInput_layout = processedInput.layout) === null || _processedInput_layout === void 0 ? void 0 : (_processedInput_layout_template = _processedInput_layout.template) === null || _processedInput_layout_template === void 0 ? void 0 : (_processedInput_layout_template_layout = _processedInput_layout_template.layout) === null || _processedInput_layout_template_layout === void 0 ? void 0 : _processedInput_layout_template_layout.colorway, isDarkTheme);
706
+ const opacity = (0, _PlotlyColorAdapter.getOpacity)(series, xIndex);
707
+ const yVal = series.y[xIndex];
708
+ var _rgb_copy_formatHex8;
709
+ return {
710
+ x: x.toString(),
711
+ y: yVal,
712
+ yAxisCalloutData: getFormattedCalloutYData(yVal, yAxisTickFormat),
713
+ color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(color).copy({
714
+ opacity
715
+ }).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
716
+ };
717
+ }).filter((item)=>typeof item !== 'undefined'),
718
+ useSecondaryYScale: usesSecondaryYScale(series, processedInput.layout)
719
+ });
720
+ } else if (series.type === 'scatter') {
721
+ var _processedInput_layout_template_layout1, _processedInput_layout_template1, _processedInput_layout1, _series_line, _processedInput_layout_template_layout2, _processedInput_layout_template2, _processedInput_layout2;
722
+ // extract line colors for each series only once
723
+ const extractedLineColors = (0, _PlotlyColorAdapter.extractColor)((_processedInput_layout1 = processedInput.layout) === null || _processedInput_layout1 === void 0 ? void 0 : (_processedInput_layout_template1 = _processedInput_layout1.template) === null || _processedInput_layout_template1 === void 0 ? void 0 : (_processedInput_layout_template_layout1 = _processedInput_layout_template1.layout) === null || _processedInput_layout_template_layout1 === void 0 ? void 0 : _processedInput_layout_template_layout1.colorway, colorwayType, (_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.color, colorMap, isDarkTheme);
724
+ const lineColor = (0, _PlotlyColorAdapter.resolveColor)(extractedLineColors, index1, legend, colorMap, (_processedInput_layout2 = processedInput.layout) === null || _processedInput_layout2 === void 0 ? void 0 : (_processedInput_layout_template2 = _processedInput_layout2.template) === null || _processedInput_layout_template2 === void 0 ? void 0 : (_processedInput_layout_template_layout2 = _processedInput_layout_template2.layout) === null || _processedInput_layout_template_layout2 === void 0 ? void 0 : _processedInput_layout_template_layout2.colorway, isDarkTheme);
725
+ const lineOptions = getLineOptions(series.line);
726
+ const opacity = (0, _PlotlyColorAdapter.getOpacity)(series, index1);
727
+ const validXYRanges = getValidXYRanges(series);
728
+ validXYRanges.forEach(([rangeStart, rangeEnd])=>{
729
+ const rangeXValues = series.x.slice(rangeStart, rangeEnd);
730
+ const rangeYValues = series.y.slice(rangeStart, rangeEnd);
661
731
  var _rgb_copy_formatHex8;
662
- mapXToDataPoints[x].series.push({
663
- key: legend,
664
- data: yVal,
665
- xAxisCalloutData: x,
666
- color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(color).copy({
667
- opacity
668
- }).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
732
+ gvbcDataV2.push({
733
+ type: 'line',
669
734
  legend,
670
- useSecondaryYScale: usesSecondaryYScale(series, processedInput.layout),
671
- yAxisCalloutData: getFormattedCalloutYData(yVal, yAxisTickFormat)
735
+ legendShape,
736
+ data: rangeXValues.map((x, i)=>{
737
+ const yVal = rangeYValues[i];
738
+ return {
739
+ x: x.toString(),
740
+ y: yVal,
741
+ yAxisCalloutData: getFormattedCalloutYData(yVal, yAxisTickFormat)
742
+ };
743
+ }),
744
+ color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(lineColor).copy({
745
+ opacity
746
+ }).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : lineColor,
747
+ lineOptions: {
748
+ ...lineOptions !== null && lineOptions !== void 0 ? lineOptions : {},
749
+ mode: series.mode
750
+ },
751
+ useSecondaryYScale: usesSecondaryYScale(series, processedInput.layout)
672
752
  });
673
- }
674
- });
753
+ });
754
+ }
675
755
  });
676
- const gvbcData = Object.values(mapXToDataPoints);
677
756
  var _processedInput_layout_height;
678
757
  return {
679
- data: gvbcData,
758
+ dataV2: gvbcDataV2,
680
759
  width: (_processedInput_layout = processedInput.layout) === null || _processedInput_layout === void 0 ? void 0 : _processedInput_layout.width,
681
760
  height: (_processedInput_layout_height = (_processedInput_layout1 = processedInput.layout) === null || _processedInput_layout1 === void 0 ? void 0 : _processedInput_layout1.height) !== null && _processedInput_layout_height !== void 0 ? _processedInput_layout_height : 350,
682
761
  barWidth: 'auto',
683
762
  mode: 'plotly',
684
763
  ...secondaryYAxisValues,
685
764
  hideTickOverlap: true,
686
- wrapXAxisLables: typeof ((_gvbcData_ = gvbcData[0]) === null || _gvbcData_ === void 0 ? void 0 : _gvbcData_.name) === 'string',
765
+ wrapXAxisLables: true,
687
766
  hideLegend,
688
767
  roundCorners: true,
689
768
  ...getTitles(processedInput.layout),
@@ -711,8 +790,9 @@ const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colorwayTyp
711
790
  const xValues = [];
712
791
  const yValues = [];
713
792
  series.x.forEach((xVal, index)=>{
714
- const yVal = getNumberAtIndexOrDefault(series.y, index);
715
- if ((0, _chartutilities.isInvalidValue)(xVal) || (0, _chartutilities.isInvalidValue)(yVal)) {
793
+ var _getNumberAtIndexOrDefault;
794
+ const yVal = (_getNumberAtIndexOrDefault = getNumberAtIndexOrDefault(series.y, index)) !== null && _getNumberAtIndexOrDefault !== void 0 ? _getNumberAtIndexOrDefault : 0;
795
+ if ((0, _chartutilities.isInvalidValue)(xVal)) {
716
796
  return;
717
797
  }
718
798
  xValues.push(xVal);
@@ -782,7 +862,7 @@ const transformPlotlyJsonToScatterChartProps = (input, isMultiPlot, colorMap, co
782
862
  return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'scatter', colorMap, colorwayType, isDarkTheme);
783
863
  };
784
864
  const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme)=>{
785
- var _input_data_, _input_layout, _input_layout1;
865
+ var _input_data_, _input_layout, _input_layout1, _input_layout2;
786
866
  const isScatterMarkers = [
787
867
  'text',
788
868
  'markers',
@@ -795,22 +875,18 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
795
875
  ].includes((_input_data_ = input.data[0]) === null || _input_data_ === void 0 ? void 0 : _input_data_.mode);
796
876
  const isAreaChart = chartType === 'area';
797
877
  const isScatterChart = chartType === 'scatter';
798
- const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
878
+ const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
799
879
  let mode = 'tonexty';
800
880
  const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
801
881
  const yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
802
- var shouldWrapLabels = false;
882
+ const resolveXAxisValue = getAxisValueResolver(input.data, input.layout, 'x');
883
+ const shouldWrapLabels = getAxisType(input.data, input.layout, 'x') === 'category';
803
884
  const chartData = input.data.map((series, index)=>{
804
885
  var _series_mode, _series_line, _series_marker, _series_line1, _input_layout_template_layout, _input_layout_template, _input_layout, _input_layout_template_layout1, _input_layout_template1, _input_layout1, _series_mode1;
805
886
  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;
806
887
  // extract colors for each series only once
807
888
  const extractedColors = (0, _PlotlyColorAdapter.extractColor)((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, colors, colorMap, isDarkTheme);
808
889
  const xValues = series.x;
809
- const isXString = (0, _chartutilities.isStringArray)(xValues);
810
- const isXDate = (0, _chartutilities.isDateArray)(xValues);
811
- const isXNumber = (0, _chartutilities.isNumberArray)(xValues);
812
- const isXYearCategory = (0, _chartutilities.isYearArray)(series.x); // Consider year as categorical not numeric continuous axis
813
- shouldWrapLabels = shouldWrapLabels || isXString && !isXDate;
814
890
  const legend = legends[index];
815
891
  // resolve color for each legend's lines from the extracted colors
816
892
  const seriesColor = (0, _PlotlyColorAdapter.resolveColor)(extractedColors, index, legend, colorMap, (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_template1 = _input_layout1.template) === null || _input_layout_template1 === void 0 ? void 0 : (_input_layout_template_layout1 = _input_layout_template1.layout) === null || _input_layout_template_layout1 === void 0 ? void 0 : _input_layout_template_layout1.colorway, isDarkTheme);
@@ -819,7 +895,7 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
819
895
  // if mode contains 'text', we prioritize showing the text over curving the line
820
896
  const lineOptions = !((_series_mode1 = series.mode) === null || _series_mode1 === void 0 ? void 0 : _series_mode1.includes('text')) && series.type !== 'scatterpolar' ? getLineOptions(series.line) : undefined;
821
897
  const legendShape = getLegendShape(series);
822
- const validXYRanges = getValidXYRanges(series);
898
+ const validXYRanges = getValidXYRanges(series, resolveXAxisValue);
823
899
  return validXYRanges.map(([rangeStart, rangeEnd], rangeIdx)=>{
824
900
  var _series_marker, _series_marker1, _series_marker2, _input_layout, _input_layout_polar_angularaxis, _input_layout_polar, _input_layout1, _input_layout_polar_angularaxis1, _input_layout_polar1, _input_layout2;
825
901
  const rangeXValues = xValues.slice(rangeStart, rangeEnd);
@@ -834,7 +910,7 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
834
910
  data: rangeXValues.map((x, i)=>{
835
911
  var _series_marker, _series_marker1;
836
912
  return {
837
- x: resolveXAxisPoint(x, isXYearCategory, isXString, isXDate, isXNumber),
913
+ x: resolveXAxisValue(x),
838
914
  y: rangeYValues[i],
839
915
  ...Array.isArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.size) ? {
840
916
  markerSize: markerSizes[i]
@@ -870,6 +946,28 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
870
946
  };
871
947
  });
872
948
  }).flat();
949
+ var _input_layout_shapes;
950
+ const lineShape = ((_input_layout_shapes = (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.shapes) !== null && _input_layout_shapes !== void 0 ? _input_layout_shapes : []).filter((shape)=>shape.type === 'line').map((shape, shapeIdx)=>{
951
+ var _shape_line;
952
+ const lineColor = (_shape_line = shape.line) === null || _shape_line === void 0 ? void 0 : _shape_line.color;
953
+ var _rgb_formatHex8;
954
+ return {
955
+ legend: `Reference_${shapeIdx}`,
956
+ data: [
957
+ {
958
+ x: shape.x0,
959
+ y: shape.y0
960
+ },
961
+ {
962
+ x: shape.x1,
963
+ y: shape.y1
964
+ }
965
+ ],
966
+ color: (_rgb_formatHex8 = (0, _d3color.rgb)(lineColor).formatHex8()) !== null && _rgb_formatHex8 !== void 0 ? _rgb_formatHex8 : lineColor,
967
+ lineOptions: getLineOptions(shape.line),
968
+ useSecondaryYScale: false
969
+ };
970
+ });
873
971
  const yMinMax = getYMinMaxValues(input.data[0], input.layout);
874
972
  if (yMinMax.yMinValue === undefined && yMinMax.yMaxValue === undefined) {
875
973
  const yMinMaxValues = (0, _utilities.findNumericMinMaxOfY)(chartData);
@@ -878,7 +976,10 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
878
976
  }
879
977
  const numDataPoints = chartData.reduce((total, lineChartPoints)=>total + lineChartPoints.data.length, 0);
880
978
  const chartProps = {
881
- lineChartData: chartData
979
+ lineChartData: [
980
+ ...chartData,
981
+ ...lineShape
982
+ ]
882
983
  };
883
984
  const scatterChartProps = {
884
985
  scatterChartData: chartData
@@ -887,8 +988,8 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
887
988
  const commonProps = {
888
989
  supportNegativeData: true,
889
990
  ...secondaryYAxisValues,
890
- width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
891
- 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,
991
+ width: (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.width,
992
+ height: (_input_layout_height = (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
892
993
  hideTickOverlap: true,
893
994
  hideLegend,
894
995
  useUTC: false,
@@ -930,8 +1031,8 @@ const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPlot, col
930
1031
  const extractedColors = (0, _PlotlyColorAdapter.extractColor)((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color, colorMap, isDarkTheme);
931
1032
  const legend = legends[index];
932
1033
  return series.y.map((yValue, i)=>{
933
- var _series_x, _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout;
934
- if ((0, _chartutilities.isInvalidValue)((_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x[i]) || (0, _chartutilities.isInvalidValue)(yValue)) {
1034
+ var _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout, _series_x;
1035
+ if ((0, _chartutilities.isInvalidValue)(yValue)) {
935
1036
  return null;
936
1037
  }
937
1038
  // resolve color for each legend's bars from the colorscale or extracted colors
@@ -939,7 +1040,7 @@ const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPlot, col
939
1040
  const opacity = (0, _PlotlyColorAdapter.getOpacity)(series, i);
940
1041
  var _rgb_copy_formatHex8;
941
1042
  return {
942
- x: series.x[i],
1043
+ x: (0, _chartutilities.isInvalidValue)((_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x[i]) ? 0 : series.x[i],
943
1044
  y: yValue,
944
1045
  legend,
945
1046
  color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(color).copy({
@@ -981,13 +1082,13 @@ const transformPlotlyJsonToGanttChartProps = (input, isMultiPlot, colorMap, colo
981
1082
  var _input_layout, _input_layout1;
982
1083
  const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
983
1084
  let colorScale = undefined;
1085
+ const isXDate = getAxisType(input.data, input.layout, 'x') === 'date';
984
1086
  const chartData = input.data.map((series, index)=>{
985
- var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _input_layout_xaxis, _input_layout1;
1087
+ var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker;
986
1088
  colorScale = (0, _PlotlyColorAdapter.createColorScale)(input.layout, series, colorScale);
987
1089
  // extract colors for each series only once
988
1090
  const extractedColors = (0, _PlotlyColorAdapter.extractColor)((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color, colorMap, isDarkTheme);
989
1091
  const legend = legends[index];
990
- const isXDate = ((_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_xaxis = _input_layout1.xaxis) === null || _input_layout_xaxis === void 0 ? void 0 : _input_layout_xaxis.type) === 'date' || (0, _chartutilities.isDateArray)(series.x);
991
1092
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
992
1093
  const convertXValueToNumber = (value)=>{
993
1094
  return (0, _chartutilities.isInvalidValue)(value) ? 0 : isXDate ? +parseLocalDate(value) : +value;
@@ -1047,8 +1148,9 @@ const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap, colorwa
1047
1148
  const zValues = [];
1048
1149
  (_firstData_x = firstData.x) === null || _firstData_x === void 0 ? void 0 : _firstData_x.forEach((xVal, index)=>{
1049
1150
  var _firstData_y;
1050
- const zVal = getNumberAtIndexOrDefault(firstData.z, index);
1051
- if ((0, _chartutilities.isInvalidValue)(xVal) || (0, _chartutilities.isInvalidValue)((_firstData_y = firstData.y) === null || _firstData_y === void 0 ? void 0 : _firstData_y[index]) || (0, _chartutilities.isInvalidValue)(zVal)) {
1151
+ var _getNumberAtIndexOrDefault;
1152
+ const zVal = (_getNumberAtIndexOrDefault = getNumberAtIndexOrDefault(firstData.z, index)) !== null && _getNumberAtIndexOrDefault !== void 0 ? _getNumberAtIndexOrDefault : 0;
1153
+ if ((0, _chartutilities.isInvalidValue)(xVal) || (0, _chartutilities.isInvalidValue)((_firstData_y = firstData.y) === null || _firstData_y === void 0 ? void 0 : _firstData_y[index])) {
1052
1154
  return;
1053
1155
  }
1054
1156
  xValues.push(xVal);
@@ -1963,7 +2065,7 @@ const getNumberAtIndexOrDefault = (data, index)=>{
1963
2065
  }
1964
2066
  return 1;
1965
2067
  };
1966
- const getValidXYRanges = (series)=>{
2068
+ const getValidXYRanges = (series, resolveX, resolveY)=>{
1967
2069
  if (!(0, _chartutilities.isArrayOrTypedArray)(series.x) || !(0, _chartutilities.isArrayOrTypedArray)(series.y)) {
1968
2070
  return [];
1969
2071
  }
@@ -1971,7 +2073,7 @@ const getValidXYRanges = (series)=>{
1971
2073
  let start = 0;
1972
2074
  let end = 0;
1973
2075
  for(; end < series.x.length; end++){
1974
- if ((0, _chartutilities.isInvalidValue)(series.x[end]) || (0, _chartutilities.isInvalidValue)(series.y[end])) {
2076
+ if ((0, _chartutilities.isInvalidValue)(series.x[end]) || typeof resolveX === 'function' && (0, _chartutilities.isInvalidValue)(resolveX(series.x[end])) || (0, _chartutilities.isInvalidValue)(series.y[end]) || typeof resolveY === 'function' && (0, _chartutilities.isInvalidValue)(resolveY(series.y[end]))) {
1975
2077
  if (end - start > 0) {
1976
2078
  ranges.push([
1977
2079
  start,
@@ -2259,7 +2361,7 @@ const getAxisScaleTypeProps = (data, layout)=>{
2259
2361
  if (!ax) {
2260
2362
  return;
2261
2363
  }
2262
- const axType = getAxisType(data, axId[0], ax);
2364
+ const axType = getAxisType(data, ax);
2263
2365
  if ((!ax.tickmode || ax.tickmode === 'array') && (0, _chartutilities.isArrayOrTypedArray)(ax.tickvals)) {
2264
2366
  const tickValues = axType === 'date' ? ax.tickvals.map((v)=>new Date(v)) : ax.tickvals;
2265
2367
  if (axId === 'x') {
@@ -2275,12 +2377,12 @@ const getAxisScaleTypeProps = (data, layout)=>{
2275
2377
  if (axId === 'x') {
2276
2378
  props.xAxis = {
2277
2379
  tickStep: dtick,
2278
- tick0: tick0
2380
+ tick0
2279
2381
  };
2280
2382
  } else if (axId === 'y') {
2281
2383
  props.yAxis = {
2282
2384
  tickStep: dtick,
2283
- tick0: tick0
2385
+ tick0
2284
2386
  };
2285
2387
  }
2286
2388
  return;
@@ -2356,44 +2458,88 @@ const getAxisObjects = (data, layout)=>{
2356
2458
  xAxisId = axisIds.x;
2357
2459
  yAxisIds.add(axisIds.y);
2358
2460
  });
2461
+ const makeAxisObject = (axLetter, axId)=>({
2462
+ ...layout === null || layout === void 0 ? void 0 : layout[(0, _chartutilities.getAxisKey)(axLetter, axId)],
2463
+ _id: `${axLetter}${axId > 1 ? axId : ''}`
2464
+ });
2359
2465
  const axisObjects = {};
2360
2466
  if (typeof xAxisId === 'number') {
2361
- axisObjects.x = layout === null || layout === void 0 ? void 0 : layout[(0, _chartutilities.getAxisKey)('x', xAxisId)];
2467
+ axisObjects.x = makeAxisObject('x', xAxisId);
2362
2468
  }
2363
2469
  const sortedYAxisIds = Array.from(yAxisIds).sort();
2364
2470
  if (sortedYAxisIds.length > 0) {
2365
- axisObjects.y = layout === null || layout === void 0 ? void 0 : layout[(0, _chartutilities.getAxisKey)('y', sortedYAxisIds[0])];
2471
+ axisObjects.y = makeAxisObject('y', sortedYAxisIds[0]);
2366
2472
  }
2367
2473
  if (sortedYAxisIds.length > 1) {
2368
- axisObjects.y2 = layout === null || layout === void 0 ? void 0 : layout[(0, _chartutilities.getAxisKey)('y', sortedYAxisIds[1])];
2474
+ axisObjects.y2 = makeAxisObject('y', sortedYAxisIds[1]);
2369
2475
  }
2370
2476
  return axisObjects;
2371
2477
  };
2372
- const getAxisType = (data, axLetter, ax)=>{
2478
+ function getAxisType(data, arg2, arg3) {
2479
+ let ax;
2480
+ if (arg2 && typeof arg2 === 'object' && '_id' in arg2) {
2481
+ ax = arg2;
2482
+ } else if (typeof arg3 === 'string') {
2483
+ const layout = arg2;
2484
+ ax = getAxisObjects(data, layout)[arg3];
2485
+ }
2486
+ if (!ax) {
2487
+ return 'category';
2488
+ }
2489
+ var _ax_type;
2490
+ if ([
2491
+ 'linear',
2492
+ 'log',
2493
+ 'date',
2494
+ 'category'
2495
+ ].includes((_ax_type = ax.type) !== null && _ax_type !== void 0 ? _ax_type : '')) {
2496
+ return ax.type;
2497
+ }
2498
+ const axLetter = ax._id[0];
2373
2499
  const values = [];
2374
2500
  data.forEach((series)=>{
2375
- var _series_axLetter;
2376
- (_series_axLetter = series[axLetter]) === null || _series_axLetter === void 0 ? void 0 : _series_axLetter.forEach((val)=>{
2377
- if (!(0, _chartutilities.isInvalidValue)(val)) {
2378
- values.push(val);
2379
- }
2380
- });
2381
- });
2382
- // Note: When ax.type is explicitly specified, Plotly casts the values to match that type.
2383
- // Therefore, simply checking the type of the values may not be sufficient. At the moment,
2384
- // we don’t always perform this casting ourselves and instead use the values as provided.
2385
- if ((0, _chartutilities.isNumberArray)(values)) {
2386
- if ((ax === null || ax === void 0 ? void 0 : ax.type) === 'log') {
2387
- return 'log';
2501
+ const axId = series[`${axLetter}axis`];
2502
+ if (axId === ax._id || !axId && ax._id === axLetter) {
2503
+ var _series_axLetter;
2504
+ (_series_axLetter = series[axLetter]) === null || _series_axLetter === void 0 ? void 0 : _series_axLetter.forEach((val)=>{
2505
+ if (!(0, _chartutilities.isInvalidValue)(val)) {
2506
+ values.push(val);
2507
+ }
2508
+ });
2388
2509
  }
2510
+ });
2511
+ if ((0, _chartutilities.isNumberArray)(values) && !(0, _chartutilities.isYearArray)(values)) {
2389
2512
  return 'linear';
2390
2513
  }
2391
2514
  if ((0, _chartutilities.isDateArray)(values)) {
2392
2515
  return 'date';
2393
2516
  }
2394
- if ((0, _chartutilities.isStringArray)(values)) {
2395
- return 'category';
2396
- }
2517
+ return 'category';
2518
+ }
2519
+ const getAxisValueResolver = (data, layout, axisId)=>{
2520
+ const axType = getAxisType(data, layout, axisId);
2521
+ return (value)=>{
2522
+ if ((0, _chartutilities.isInvalidValue)(value)) {
2523
+ return null;
2524
+ }
2525
+ switch(axType){
2526
+ case 'linear':
2527
+ case 'log':
2528
+ return (0, _chartutilities.isNumber)(value) ? +value : null;
2529
+ case 'date':
2530
+ if ((0, _chartutilities.isNumber)(value)) {
2531
+ return new Date(+value);
2532
+ }
2533
+ if (typeof value === 'string') {
2534
+ return new Date(value);
2535
+ }
2536
+ return null;
2537
+ case 'category':
2538
+ return `${value}`;
2539
+ default:
2540
+ return null;
2541
+ }
2542
+ };
2397
2543
  };
2398
2544
  /**
2399
2545
  * This is experimental. Use it only with valid datetime strings to verify if they conform to the ISO 8601 format.