@fluentui/react-charts 0.0.0-nightly-20251021-0406.1 → 0.0.0-nightly-20251023-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.
@@ -417,7 +417,7 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
417
417
  const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
418
418
  let colorScale = undefined;
419
419
  const yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
420
- const resolveXAxisValue = getAxisValueResolver(input.data, input.layout, 'x');
420
+ const resolveXValue = getAxisValueResolver(getAxisType(input.data, getAxisObjects(input.data, input.layout).x));
421
421
  input.data.forEach((series, index1)=>{
422
422
  var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _input_layout_template_layout1, _input_layout_template1, _input_layout1, _series_line;
423
423
  colorScale = createColorScale(input.layout, series, colorScale);
@@ -425,7 +425,7 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
425
425
  const extractedBarColors = 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);
426
426
  // extract line colors for each series only once
427
427
  const extractedLineColors = 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);
428
- const validXYRanges = getValidXYRanges(series, resolveXAxisValue);
428
+ const validXYRanges = getValidXYRanges(series, resolveXValue);
429
429
  validXYRanges.forEach(([rangeStart, rangeEnd], rangeIdx)=>{
430
430
  const rangeXValues = series.x.slice(rangeStart, rangeEnd);
431
431
  const rangeYValues = series.y.slice(rangeStart, rangeEnd);
@@ -433,7 +433,7 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
433
433
  var _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout;
434
434
  if (!mapXToDataPoints[x]) {
435
435
  mapXToDataPoints[x] = {
436
- xAxisPoint: resolveXAxisValue(x),
436
+ xAxisPoint: resolveXValue(x),
437
437
  chartData: [],
438
438
  lineData: []
439
439
  };
@@ -813,8 +813,9 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
813
813
  let mode = 'tonexty';
814
814
  const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
815
815
  const yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
816
- const resolveXAxisValue = getAxisValueResolver(input.data, input.layout, 'x');
817
- const shouldWrapLabels = getAxisType(input.data, input.layout, 'x') === 'category';
816
+ const xAxisType = getAxisType(input.data, getAxisObjects(input.data, input.layout).x);
817
+ const resolveXValue = getAxisValueResolver(xAxisType);
818
+ const shouldWrapLabels = xAxisType === 'category';
818
819
  const chartData = input.data.map((series, index)=>{
819
820
  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;
820
821
  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;
@@ -829,7 +830,7 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
829
830
  // if mode contains 'text', we prioritize showing the text over curving the line
830
831
  const lineOptions = !((_series_mode1 = series.mode) === null || _series_mode1 === void 0 ? void 0 : _series_mode1.includes('text')) && series.type !== 'scatterpolar' ? getLineOptions(series.line) : undefined;
831
832
  const legendShape = getLegendShape(series);
832
- const validXYRanges = getValidXYRanges(series, resolveXAxisValue);
833
+ const validXYRanges = getValidXYRanges(series, resolveXValue);
833
834
  return validXYRanges.map(([rangeStart, rangeEnd], rangeIdx)=>{
834
835
  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;
835
836
  const rangeXValues = xValues.slice(rangeStart, rangeEnd);
@@ -844,7 +845,7 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
844
845
  data: rangeXValues.map((x, i)=>{
845
846
  var _series_marker, _series_marker1;
846
847
  return {
847
- x: resolveXAxisValue(x),
848
+ x: resolveXValue(x),
848
849
  y: rangeYValues[i],
849
850
  ...Array.isArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.size) ? {
850
851
  markerSize: markerSizes[i]
@@ -1054,46 +1055,71 @@ export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPl
1054
1055
  };
1055
1056
  export const transformPlotlyJsonToGanttChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
1056
1057
  var _input_layout, _input_layout1;
1057
- const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
1058
+ const data = input.data.filter((series)=>series.type !== 'scatter' || series.mode !== 'markers');
1059
+ const { legends, hideLegend } = getLegendProps(data, input.layout, isMultiPlot);
1058
1060
  let colorScale = undefined;
1059
- const isXDate = getAxisType(input.data, input.layout, 'x') === 'date';
1060
- const chartData = input.data.map((series, index)=>{
1061
- var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker;
1062
- colorScale = createColorScale(input.layout, series, colorScale);
1063
- // extract colors for each series only once
1064
- const extractedColors = 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);
1061
+ const xAxisType = getAxisType(data, getAxisObjects(data, input.layout).x);
1062
+ const resolveXValue = getAxisValueResolver(xAxisType, parseLocalDate);
1063
+ const resolveGanttXValue = (value)=>{
1064
+ const resolvedValue = resolveXValue(value);
1065
+ return typeof resolvedValue === 'string' ? 0 : resolvedValue !== null && resolvedValue !== void 0 ? resolvedValue : 0;
1066
+ };
1067
+ const isXDate = xAxisType === 'date';
1068
+ const ganttData = [];
1069
+ data.forEach((series, index)=>{
1065
1070
  const legend = legends[index];
1066
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1067
- const convertXValueToNumber = (value)=>{
1068
- return isInvalidValue(value) ? 0 : isXDate ? +parseLocalDate(value) : +value;
1069
- };
1070
- return series.y.map((yVal, i)=>{
1071
- var _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout, _series_base, _series_x;
1072
- if (isInvalidValue(yVal)) {
1073
- return null;
1071
+ if (series.type === 'bar') {
1072
+ var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker;
1073
+ colorScale = createColorScale(input.layout, series, colorScale);
1074
+ // extract colors for each series only once
1075
+ const extractedColors = 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);
1076
+ series.y.forEach((yVal, i)=>{
1077
+ var _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout, _series_base, _series_x;
1078
+ if (isInvalidValue(yVal)) {
1079
+ return;
1080
+ }
1081
+ // resolve color for each legend's bars from the colorscale or extracted colors
1082
+ const color = colorScale ? colorScale(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[i % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : resolveColor(extractedColors, i, legend, colorMap, (_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, isDarkTheme);
1083
+ const opacity = getOpacity(series, i);
1084
+ const base = +resolveGanttXValue((_series_base = series.base) === null || _series_base === void 0 ? void 0 : _series_base[i]);
1085
+ const xVal = +resolveGanttXValue((_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x[i]);
1086
+ var _rgb_copy_formatHex8;
1087
+ ganttData.push({
1088
+ x: {
1089
+ start: isXDate ? new Date(base) : base,
1090
+ end: isXDate ? new Date(base + xVal) : base + xVal
1091
+ },
1092
+ y: yVal,
1093
+ legend,
1094
+ color: (_rgb_copy_formatHex8 = rgb(color).copy({
1095
+ opacity
1096
+ }).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
1097
+ });
1098
+ });
1099
+ } else if (series.type === 'scatter' && series.mode === 'none' && series.fill === 'toself') {
1100
+ for(let i = 0; i < series.y.length; i += 5){
1101
+ if (isInvalidValue(series.y[i]) || isInvalidValue(series.y[i + 3])) {
1102
+ continue;
1103
+ }
1104
+ const x0 = resolveGanttXValue(series.x[i]);
1105
+ const x1 = resolveGanttXValue(series.x[i + 1]);
1106
+ const y0 = series.y[i];
1107
+ const y1 = series.y[i + 3];
1108
+ ganttData.push({
1109
+ x: {
1110
+ start: x0,
1111
+ end: x1
1112
+ },
1113
+ y: Math.round((y0 + y1) / 2),
1114
+ legend,
1115
+ color: series.fillcolor
1116
+ });
1074
1117
  }
1075
- // resolve color for each legend's bars from the colorscale or extracted colors
1076
- const color = colorScale ? colorScale(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[i % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : resolveColor(extractedColors, i, legend, colorMap, (_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, isDarkTheme);
1077
- const opacity = getOpacity(series, i);
1078
- const base = convertXValueToNumber((_series_base = series.base) === null || _series_base === void 0 ? void 0 : _series_base[i]);
1079
- const xVal = convertXValueToNumber((_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x[i]);
1080
- var _rgb_copy_formatHex8;
1081
- return {
1082
- x: {
1083
- start: isXDate ? new Date(base) : base,
1084
- end: isXDate ? new Date(base + xVal) : base + xVal
1085
- },
1086
- y: yVal,
1087
- legend,
1088
- color: (_rgb_copy_formatHex8 = rgb(color).copy({
1089
- opacity
1090
- }).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
1091
- };
1092
- }).filter((point)=>point !== null);
1093
- }).flat();
1118
+ }
1119
+ });
1094
1120
  var _input_layout_height;
1095
1121
  return {
1096
- data: chartData,
1122
+ data: ganttData,
1097
1123
  showYAxisLables: true,
1098
1124
  height: (_input_layout_height = (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
1099
1125
  width: (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.width,
@@ -1104,9 +1130,9 @@ export const transformPlotlyJsonToGanttChartProps = (input, isMultiPlot, colorMa
1104
1130
  roundCorners: true,
1105
1131
  useUTC: false,
1106
1132
  ...getTitles(input.layout),
1107
- ...getAxisCategoryOrderProps(input.data, input.layout),
1108
- ...getBarProps(input.data, input.layout, true),
1109
- ...getAxisTickProps(input.data, input.layout)
1133
+ ...getAxisCategoryOrderProps(data, input.layout),
1134
+ ...getBarProps(data, input.layout, true),
1135
+ ...getAxisTickProps(data, input.layout)
1110
1136
  };
1111
1137
  };
1112
1138
  export const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
@@ -2346,8 +2372,14 @@ const getAxisScaleTypeProps = (data, layout)=>{
2346
2372
  const tickValues = axType === 'date' ? ax.tickvals.map((v)=>new Date(v)) : ax.tickvals;
2347
2373
  if (axId === 'x') {
2348
2374
  props.tickValues = tickValues;
2375
+ props.xAxis = {
2376
+ tickText: ax.ticktext
2377
+ };
2349
2378
  } else if (axId === 'y') {
2350
2379
  props.yAxisTickValues = tickValues;
2380
+ props.yAxis = {
2381
+ tickText: ax.ticktext
2382
+ };
2351
2383
  }
2352
2384
  return;
2353
2385
  }
@@ -2456,14 +2488,7 @@ const getAxisObjects = (data, layout)=>{
2456
2488
  }
2457
2489
  return axisObjects;
2458
2490
  };
2459
- function getAxisType(data, arg2, arg3) {
2460
- let ax;
2461
- if (arg2 && typeof arg2 === 'object' && '_id' in arg2) {
2462
- ax = arg2;
2463
- } else if (typeof arg3 === 'string') {
2464
- const layout = arg2;
2465
- ax = getAxisObjects(data, layout)[arg3];
2466
- }
2491
+ const getAxisType = (data, ax)=>{
2467
2492
  if (!ax) {
2468
2493
  return 'category';
2469
2494
  }
@@ -2496,9 +2521,12 @@ function getAxisType(data, arg2, arg3) {
2496
2521
  return 'date';
2497
2522
  }
2498
2523
  return 'category';
2499
- }
2500
- const getAxisValueResolver = (data, layout, axisId)=>{
2501
- const axType = getAxisType(data, layout, axisId);
2524
+ };
2525
+ const getAxisValueResolver = (axType, dateParser)=>{
2526
+ const toDate = (value)=>{
2527
+ const date = dateParser ? dateParser(value) : new Date(value);
2528
+ return isNaN(date.getTime()) ? null : date;
2529
+ };
2502
2530
  return (value)=>{
2503
2531
  if (isInvalidValue(value)) {
2504
2532
  return null;
@@ -2509,10 +2537,10 @@ const getAxisValueResolver = (data, layout, axisId)=>{
2509
2537
  return isNumber(value) ? +value : null;
2510
2538
  case 'date':
2511
2539
  if (isNumber(value)) {
2512
- return new Date(+value);
2540
+ return toDate(+value);
2513
2541
  }
2514
2542
  if (typeof value === 'string') {
2515
- return new Date(value);
2543
+ return toDate(value);
2516
2544
  }
2517
2545
  return null;
2518
2546
  case 'category':