@fluentui/react-charts 9.2.0 → 9.2.2

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 (103) hide show
  1. package/CHANGELOG.md +38 -3
  2. package/dist/index.d.ts +84 -5
  3. package/lib/ChartTable.js +1 -0
  4. package/lib/ChartTable.js.map +1 -0
  5. package/lib/components/AreaChart/AreaChart.js.map +1 -1
  6. package/lib/components/ChartTable/ChartTable.js +57 -0
  7. package/lib/components/ChartTable/ChartTable.js.map +1 -0
  8. package/lib/components/ChartTable/ChartTable.types.js +1 -0
  9. package/lib/components/ChartTable/ChartTable.types.js.map +1 -0
  10. package/lib/components/ChartTable/index.js +3 -0
  11. package/lib/components/ChartTable/index.js.map +1 -0
  12. package/lib/components/ChartTable/useChartTableStyles.styles.js +93 -0
  13. package/lib/components/ChartTable/useChartTableStyles.styles.js.map +1 -0
  14. package/lib/components/ChartTable/useChartTableStyles.styles.raw.js +55 -0
  15. package/lib/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -0
  16. package/lib/components/CommonComponents/CartesianChart.js +110 -81
  17. package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
  18. package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
  19. package/lib/components/CommonComponents/ChartPopover.types.js.map +1 -1
  20. package/lib/components/DeclarativeChart/DeclarativeChart.js +20 -10
  21. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  22. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +95 -0
  23. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
  24. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +204 -87
  25. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  26. package/lib/components/DonutChart/DonutChart.js.map +1 -1
  27. package/lib/components/DonutChart/DonutChart.types.js.map +1 -1
  28. package/lib/components/DonutChart/Pie/Pie.js.map +1 -1
  29. package/lib/components/FunnelChart/FunnelChart.js.map +1 -1
  30. package/lib/components/GanttChart/GanttChart.js.map +1 -1
  31. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +161 -141
  32. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  33. package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
  34. package/lib/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
  35. package/lib/components/HorizontalBarChart/HorizontalBarChart.types.js.map +1 -1
  36. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  37. package/lib/components/Legends/Legends.js.map +1 -1
  38. package/lib/components/Legends/OverflowMenu.js.map +1 -1
  39. package/lib/components/LineChart/LineChart.js.map +1 -1
  40. package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
  41. package/lib/components/VerticalBarChart/VerticalBarChart.js +12 -11
  42. package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  43. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +57 -51
  44. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  45. package/lib/index.js +1 -0
  46. package/lib/index.js.map +1 -1
  47. package/lib/types/DataPoint.js.map +1 -1
  48. package/lib/utilities/FocusableTooltipText.js.map +1 -1
  49. package/lib/utilities/utilities.js +26 -37
  50. package/lib/utilities/utilities.js.map +1 -1
  51. package/lib/utilities/vbc-utils.js +24 -0
  52. package/lib/utilities/vbc-utils.js.map +1 -1
  53. package/lib-commonjs/ChartTable.js +6 -0
  54. package/lib-commonjs/ChartTable.js.map +1 -0
  55. package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
  56. package/lib-commonjs/components/ChartTable/ChartTable.js +68 -0
  57. package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -0
  58. package/lib-commonjs/components/ChartTable/ChartTable.types.js +6 -0
  59. package/lib-commonjs/components/ChartTable/ChartTable.types.js.map +1 -0
  60. package/lib-commonjs/components/ChartTable/index.js +8 -0
  61. package/lib-commonjs/components/ChartTable/index.js.map +1 -0
  62. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js +196 -0
  63. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js.map +1 -0
  64. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js +69 -0
  65. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -0
  66. package/lib-commonjs/components/CommonComponents/CartesianChart.js +109 -80
  67. package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
  68. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
  69. package/lib-commonjs/components/CommonComponents/ChartPopover.types.js.map +1 -1
  70. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +19 -9
  71. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  72. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +120 -0
  73. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
  74. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +204 -87
  75. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  76. package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
  77. package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -1
  78. package/lib-commonjs/components/DonutChart/Pie/Pie.js.map +1 -1
  79. package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -1
  80. package/lib-commonjs/components/GanttChart/GanttChart.js.map +1 -1
  81. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +159 -139
  82. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  83. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
  84. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
  85. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.types.js.map +1 -1
  86. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  87. package/lib-commonjs/components/Legends/Legends.js.map +1 -1
  88. package/lib-commonjs/components/Legends/OverflowMenu.js.map +1 -1
  89. package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
  90. package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
  91. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +11 -10
  92. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  93. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +56 -50
  94. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  95. package/lib-commonjs/index.js +1 -0
  96. package/lib-commonjs/index.js.map +1 -1
  97. package/lib-commonjs/types/DataPoint.js.map +1 -1
  98. package/lib-commonjs/utilities/FocusableTooltipText.js.map +1 -1
  99. package/lib-commonjs/utilities/utilities.js +29 -37
  100. package/lib-commonjs/utilities/utilities.js.map +1 -1
  101. package/lib-commonjs/utilities/vbc-utils.js +27 -0
  102. package/lib-commonjs/utilities/vbc-utils.js.map +1 -1
  103. package/package.json +9 -9
@@ -1,10 +1,11 @@
1
- /* eslint-disable one-var */ /* eslint-disable vars-on-top */ /* eslint-disable no-var */ /* eslint-disable @typescript-eslint/no-explicit-any */ import * as React from 'react';
1
+ /* eslint-disable one-var */ /* eslint-disable vars-on-top */ /* eslint-disable no-var */ import * as React from 'react';
2
2
  import { bin as d3Bin, extent as d3Extent, sum as d3Sum, min as d3Min, max as d3Max, range as d3Range } from 'd3-array';
3
3
  import { scaleLinear as d3ScaleLinear } from 'd3-scale';
4
- import { DataVizPalette, getColorFromToken, getNextColor } from '../../utilities/colors';
4
+ import { DataVizPalette, getColorFromToken } from '../../utilities/colors';
5
5
  import { findNumericMinMaxOfY } from '../../utilities/utilities';
6
6
  import { isArrayOfType, isArrayOrTypedArray, isDate, isDateArray, isNumberArray, isYearArray } from '@fluentui/chart-utilities';
7
7
  import { curveCardinal as d3CurveCardinal } from 'd3-shape';
8
+ import { extractColor, resolveColor } from './PlotlyColorAdapter';
8
9
  const dashOptions = {
9
10
  dot: {
10
11
  strokeDasharray: '1, 5',
@@ -43,9 +44,6 @@ const dashOptions = {
43
44
  lineBorderWidth: '4'
44
45
  }
45
46
  };
46
- const getLegend = (series, index)=>{
47
- return series.name || `Series ${index + 1}`;
48
- };
49
47
  function getTitles(layout) {
50
48
  var _layout_title, _layout_xaxis, _layout_xaxis1, _layout_xaxis_title, _layout_xaxis2, _layout_yaxis, _layout_yaxis1, _layout_yaxis_title, _layout_yaxis2;
51
49
  var _layout_title_text, _layout_xaxis_title_text, _layout_yaxis_title_text;
@@ -56,6 +54,7 @@ function getTitles(layout) {
56
54
  };
57
55
  return titles;
58
56
  }
57
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
59
58
  export const correctYearMonth = (xValues)=>{
60
59
  const presentYear = new Date().getFullYear();
61
60
  if (xValues.length > 0 && Array.isArray(xValues[0])) {
@@ -81,14 +80,6 @@ export const correctYearMonth = (xValues)=>{
81
80
  });
82
81
  return xValues;
83
82
  };
84
- export const getColor = (legendLabel, colorMap, isDarkTheme)=>{
85
- if (!colorMap.current.has(legendLabel)) {
86
- const nextColor = getNextColor(colorMap.current.size + 1, 0, isDarkTheme);
87
- colorMap.current.set(legendLabel, nextColor);
88
- return nextColor;
89
- }
90
- return colorMap.current.get(legendLabel);
91
- };
92
83
  const usesSecondaryYScale = (series)=>{
93
84
  return series.yaxis === 'y2';
94
85
  };
@@ -128,13 +119,20 @@ const getSecondaryYAxisValues = (data, layout, maxAllowedMinY, minAllowedMaxY)=>
128
119
  }
129
120
  };
130
121
  };
131
- export const transformPlotlyJsonToDonutProps = (input, colorMap, isDarkTheme)=>{
132
- var _firstData_labels, _input_layout, _input_layout1, _input_layout2, _input_layout3;
122
+ export const _getGaugeAxisColor = (colorway, colorwayType, color, colorMap, isDarkTheme)=>{
123
+ const extractedColors = extractColor(colorway, colorwayType, color, colorMap, isDarkTheme);
124
+ return resolveColor(extractedColors, 0, '', colorMap, isDarkTheme);
125
+ };
126
+ export const transformPlotlyJsonToDonutProps = (input, colorMap, colorwayType, isDarkTheme)=>{
127
+ var _input_layout_template_layout, _input_layout_template, _input_layout, _firstData_marker, _firstData_labels, _input_layout1, _input_layout2, _input_layout3, _input_layout4;
133
128
  const firstData = input.data[0];
129
+ // extract colors for each series only once
130
+ const colors = 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, firstData === null || firstData === void 0 ? void 0 : (_firstData_marker = firstData.marker) === null || _firstData_marker === void 0 ? void 0 : _firstData_marker.colors, colorMap, isDarkTheme);
134
131
  const mapLegendToDataPoint = {};
135
132
  (_firstData_labels = firstData.labels) === null || _firstData_labels === void 0 ? void 0 : _firstData_labels.forEach((label, index)=>{
136
133
  var _firstData_values;
137
- const color = getColor(label, colorMap, isDarkTheme);
134
+ // resolve color for each legend from the extracted colors
135
+ const color = resolveColor(colors, index, label, colorMap, isDarkTheme);
138
136
  //ToDo how to handle string data?
139
137
  const value = typeof ((_firstData_values = firstData.values) === null || _firstData_values === void 0 ? void 0 : _firstData_values[index]) === 'number' ? firstData.values[index] : 1;
140
138
  if (!mapLegendToDataPoint[label]) {
@@ -148,9 +146,9 @@ export const transformPlotlyJsonToDonutProps = (input, colorMap, isDarkTheme)=>{
148
146
  }
149
147
  });
150
148
  var _input_layout_width;
151
- const width = (_input_layout_width = (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width) !== null && _input_layout_width !== void 0 ? _input_layout_width : 440;
149
+ const width = (_input_layout_width = (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.width) !== null && _input_layout_width !== void 0 ? _input_layout_width : 440;
152
150
  var _input_layout_height;
153
- const 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 : 220;
151
+ const 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 : 220;
154
152
  const hideLabels = firstData.textinfo ? ![
155
153
  'value',
156
154
  'percent',
@@ -165,26 +163,32 @@ export const transformPlotlyJsonToDonutProps = (input, colorMap, isDarkTheme)=>{
165
163
  chartTitle,
166
164
  chartData: Object.values(mapLegendToDataPoint)
167
165
  },
168
- hideLegend: ((_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.showlegend) === false ? true : false,
169
- width: (_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : _input_layout3.width,
166
+ hideLegend: ((_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : _input_layout3.showlegend) === false ? true : false,
167
+ width: (_input_layout4 = input.layout) === null || _input_layout4 === void 0 ? void 0 : _input_layout4.width,
170
168
  height,
171
169
  innerRadius,
172
170
  hideLabels,
173
171
  showLabelsInPercent: firstData.textinfo ? [
174
172
  'percent',
175
173
  'label+percent'
176
- ].includes(firstData.textinfo) : true
174
+ ].includes(firstData.textinfo) : true,
175
+ roundCorners: true
177
176
  };
178
177
  };
179
- export const transformPlotlyJsonToVSBCProps = (input, colorMap, isDarkTheme, fallbackVSBC)=>{
180
- var _input_layout, _input_layout1;
178
+ export const transformPlotlyJsonToVSBCProps = (input, colorMap, colorwayType, isDarkTheme, fallbackVSBC)=>{
179
+ var _input_layout, _input_layout1, _vsbcData_;
181
180
  const mapXToDataPoints = {};
182
181
  let yMaxValue = 0;
183
182
  const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
183
+ const { legends, hideLegend } = getLegendProps(input.data, input.layout);
184
184
  let yMinValue = 0;
185
185
  input.data.forEach((series, index1)=>{
186
- var _series_x;
186
+ var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _input_layout_template_layout1, _input_layout_template1, _input_layout1, _series_line, _series_x;
187
187
  const isXYearCategory = isYearArray(series.x); // Consider year as categorical not numeric continuous axis
188
+ // extract bar colors for each series only once
189
+ 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);
190
+ // extract line colors for each series only once
191
+ 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);
188
192
  (_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x.forEach((x, index2)=>{
189
193
  var _series_y;
190
194
  if (!mapXToDataPoints[x]) {
@@ -194,11 +198,12 @@ export const transformPlotlyJsonToVSBCProps = (input, colorMap, isDarkTheme, fal
194
198
  lineData: []
195
199
  };
196
200
  }
197
- const legend = getLegend(series, index1);
201
+ const legend = legends[index1];
202
+ // resolve color for each legend's bars from the extracted colors
203
+ const color = resolveColor(extractedBarColors, index1, legend, colorMap, isDarkTheme);
198
204
  var _series_y_index2;
199
205
  const yVal = (_series_y_index2 = (_series_y = series.y) === null || _series_y === void 0 ? void 0 : _series_y[index2]) !== null && _series_y_index2 !== void 0 ? _series_y_index2 : 0;
200
206
  if (series.type === 'bar') {
201
- const color = getColor(legend, colorMap, isDarkTheme);
202
207
  mapXToDataPoints[x].chartData.push({
203
208
  legend,
204
209
  data: yVal,
@@ -206,12 +211,16 @@ export const transformPlotlyJsonToVSBCProps = (input, colorMap, isDarkTheme, fal
206
211
  });
207
212
  yMaxValue = Math.max(yMaxValue, yVal);
208
213
  } else if (series.type === 'scatter' || !!fallbackVSBC) {
209
- const color = getColor(legend, colorMap, isDarkTheme);
214
+ var _series_line;
215
+ const lineColor = resolveColor(extractedLineColors, index1, legend, colorMap, isDarkTheme);
210
216
  const lineOptions = getLineOptions(series.line);
217
+ const dashType = ((_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.dash) || 'solid';
218
+ const legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot' ? 'dottedLine' : 'default';
211
219
  mapXToDataPoints[x].lineData.push({
212
220
  legend,
221
+ legendShape,
213
222
  y: yVal,
214
- color,
223
+ color: lineColor,
215
224
  ...lineOptions ? {
216
225
  lineOptions
217
226
  } : {},
@@ -226,9 +235,10 @@ export const transformPlotlyJsonToVSBCProps = (input, colorMap, isDarkTheme, fal
226
235
  });
227
236
  });
228
237
  const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
238
+ const vsbcData = Object.values(mapXToDataPoints);
229
239
  var _input_layout_height;
230
240
  return {
231
- data: Object.values(mapXToDataPoints),
241
+ data: vsbcData,
232
242
  width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
233
243
  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,
234
244
  barWidth: 'auto',
@@ -239,16 +249,22 @@ export const transformPlotlyJsonToVSBCProps = (input, colorMap, isDarkTheme, fal
239
249
  yAxisTitle,
240
250
  mode: 'plotly',
241
251
  ...secondaryYAxisValues,
252
+ wrapXAxisLables: typeof ((_vsbcData_ = vsbcData[0]) === null || _vsbcData_ === void 0 ? void 0 : _vsbcData_.xAxisPoint) === 'string',
242
253
  hideTickOverlap: true,
243
- barGapMax: 2
254
+ barGapMax: 2,
255
+ hideLegend,
256
+ roundCorners: true
244
257
  };
245
258
  };
246
- export const transformPlotlyJsonToGVBCProps = (input, colorMap, isDarkTheme)=>{
247
- var _input_layout, _input_layout1;
259
+ export const transformPlotlyJsonToGVBCProps = (input, colorMap, colorwayType, isDarkTheme)=>{
260
+ var _input_layout, _input_layout1, _gvbcData_;
248
261
  const mapXToDataPoints = {};
249
262
  const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, 0, 0);
263
+ const { legends, hideLegend } = getLegendProps(input.data, input.layout);
250
264
  input.data.forEach((series, index1)=>{
251
- var _series_x;
265
+ var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _series_x;
266
+ // extract colors for each series only once
267
+ 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);
252
268
  (_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x.forEach((x, index2)=>{
253
269
  if (!mapXToDataPoints[x]) {
254
270
  mapXToDataPoints[x] = {
@@ -258,8 +274,9 @@ export const transformPlotlyJsonToGVBCProps = (input, colorMap, isDarkTheme)=>{
258
274
  }
259
275
  if (series.type === 'bar') {
260
276
  var _series_y;
261
- const legend = getLegend(series, index1);
262
- const color = getColor(legend, colorMap, isDarkTheme);
277
+ const legend = legends[index1];
278
+ // resolve color for each legend's bars from the extracted colors
279
+ const color = resolveColor(extractedColors, index1, legend, colorMap, isDarkTheme);
263
280
  var _series_y_index2;
264
281
  mapXToDataPoints[x].series.push({
265
282
  key: legend,
@@ -273,9 +290,10 @@ export const transformPlotlyJsonToGVBCProps = (input, colorMap, isDarkTheme)=>{
273
290
  });
274
291
  });
275
292
  const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
293
+ const gvbcData = Object.values(mapXToDataPoints);
276
294
  var _input_layout_height;
277
295
  return {
278
- data: Object.values(mapXToDataPoints),
296
+ data: gvbcData,
279
297
  width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
280
298
  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,
281
299
  barWidth: 'auto',
@@ -284,17 +302,23 @@ export const transformPlotlyJsonToGVBCProps = (input, colorMap, isDarkTheme)=>{
284
302
  yAxisTitle,
285
303
  mode: 'plotly',
286
304
  ...secondaryYAxisValues,
287
- hideTickOverlap: true
305
+ hideTickOverlap: true,
306
+ wrapXAxisLables: typeof ((_gvbcData_ = gvbcData[0]) === null || _gvbcData_ === void 0 ? void 0 : _gvbcData_.name) === 'string',
307
+ hideLegend,
308
+ roundCorners: true
288
309
  };
289
310
  };
290
- export const transformPlotlyJsonToVBCProps = (input, colorMap, isDarkTheme)=>{
291
- var _input_layout, _input_layout1;
311
+ export const transformPlotlyJsonToVBCProps = (input, colorMap, colorwayType, isDarkTheme)=>{
312
+ var _input_layout, _input_layout1, _vbcData_;
292
313
  const vbcData = [];
314
+ const { legends, hideLegend } = getLegendProps(input.data, input.layout);
293
315
  input.data.forEach((series, seriesIdx)=>{
294
- var _series_xbins, _series_xbins1, _series_xbins2;
316
+ var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _series_xbins, _series_xbins1, _series_xbins2;
295
317
  if (!series.x) {
296
318
  return;
297
319
  }
320
+ // extract colors for each series only once
321
+ 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);
298
322
  const isXString = isStringArray(series.x);
299
323
  // TODO: In case of a single bin, add an empty bin of the same size to prevent the
300
324
  // default bar width from being used and ensure the bar spans the full intended range.
@@ -315,8 +339,9 @@ export const transformPlotlyJsonToVBCProps = (input, colorMap, isDarkTheme)=>{
315
339
  return yVal;
316
340
  });
317
341
  xBins.forEach((bin, index)=>{
318
- const legend = getLegend(series, seriesIdx);
319
- const color = getColor(legend, colorMap, isDarkTheme);
342
+ const legend = legends[seriesIdx];
343
+ // resolve color for each legend's bars from the extracted colors
344
+ const color = resolveColor(extractedColors, seriesIdx, legend, colorMap, isDarkTheme);
320
345
  const yVal = calculateHistNorm(series.histnorm, y[index], total, isXString ? bin.length : getBinSize(bin));
321
346
  vbcData.push({
322
347
  x: isXString ? bin.join(', ') : getBinCenter(bin),
@@ -340,23 +365,34 @@ export const transformPlotlyJsonToVBCProps = (input, colorMap, isDarkTheme)=>{
340
365
  yAxisTitle,
341
366
  mode: 'histogram',
342
367
  hideTickOverlap: true,
343
- maxBarWidth: 50
368
+ wrapXAxisLables: typeof ((_vbcData_ = vbcData[0]) === null || _vbcData_ === void 0 ? void 0 : _vbcData_.x) === 'string',
369
+ maxBarWidth: 50,
370
+ hideLegend,
371
+ roundCorners: true
344
372
  };
345
373
  };
346
- export const transformPlotlyJsonToScatterChartProps = (input, isAreaChart, colorMap, isDarkTheme)=>{
374
+ export const transformPlotlyJsonToScatterChartProps = (input, isAreaChart, isScatterMarkers, colorMap, colorwayType, isDarkTheme)=>{
347
375
  const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
348
376
  let mode = 'tonexty';
377
+ const { legends, hideLegend } = getLegendProps(input.data, input.layout);
349
378
  const chartData = input.data.map((series, index)=>{
379
+ var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _series_line, _series_line1;
380
+ // extract colors for each series only once
381
+ 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, isScatterMarkers ? (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color : (_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.color, colorMap, isDarkTheme);
350
382
  const xValues = series.x;
351
383
  const isString = typeof xValues[0] === 'string';
352
384
  const isXDate = isDateArray(xValues);
353
385
  const isXNumber = isNumberArray(xValues);
354
- const legend = getLegend(series, index);
355
- const lineColor = getColor(legend, colorMap, isDarkTheme);
386
+ const legend = legends[index];
387
+ // resolve color for each legend's lines from the extracted colors
388
+ const seriesColor = resolveColor(extractedColors, index, legend, colorMap, isDarkTheme);
356
389
  mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
357
390
  const lineOptions = getLineOptions(series.line);
391
+ const dashType = ((_series_line1 = series.line) === null || _series_line1 === void 0 ? void 0 : _series_line1.dash) || 'solid';
392
+ const legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot' ? 'dottedLine' : 'default';
358
393
  return {
359
394
  legend,
395
+ legendShape,
360
396
  data: xValues.map((x, i)=>{
361
397
  var _series_marker, _series_marker1;
362
398
  return {
@@ -369,7 +405,7 @@ export const transformPlotlyJsonToScatterChartProps = (input, isAreaChart, color
369
405
  } : {}
370
406
  };
371
407
  }),
372
- color: lineColor,
408
+ color: seriesColor,
373
409
  ...lineOptions ? {
374
410
  lineOptions
375
411
  } : {},
@@ -395,7 +431,8 @@ export const transformPlotlyJsonToScatterChartProps = (input, isAreaChart, color
395
431
  width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
396
432
  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,
397
433
  hideTickOverlap: true,
398
- useUTC: false
434
+ useUTC: false,
435
+ hideLegend
399
436
  };
400
437
  } else {
401
438
  var _input_layout2, _input_layout3;
@@ -412,21 +449,26 @@ export const transformPlotlyJsonToScatterChartProps = (input, isAreaChart, color
412
449
  width: (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.width,
413
450
  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,
414
451
  hideTickOverlap: true,
415
- useUTC: false
452
+ useUTC: false,
453
+ hideLegend
416
454
  };
417
455
  }
418
456
  };
419
- export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, colorMap, isDarkTheme)=>{
457
+ export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, colorMap, colorwayType, isDarkTheme)=>{
420
458
  var _input_layout, _input_layout_margin, _input_layout1, _input_layout_margin1, _input_layout2, _input_layout_yaxis2, _input_layout3, _input_layout_yaxis21, _input_layout4, _input_layout_yaxis2_title, _input_layout_yaxis22, _input_layout5, _input_layout6;
459
+ const { legends, hideLegend } = getLegendProps(input.data, input.layout);
421
460
  const chartData = input.data.map((series, index)=>{
461
+ var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker;
462
+ // extract colors for each series only once
463
+ 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);
464
+ const legend = legends[index];
465
+ // resolve color for each legend's bars from the extracted colors
466
+ const color = resolveColor(extractedColors, index, legend, colorMap, isDarkTheme);
422
467
  return series.y.map((yValue, i)=>{
423
- var _series_name;
424
- const legendName = (_series_name = series.name) !== null && _series_name !== void 0 ? _series_name : yValue;
425
- const color = getColor(legendName, colorMap, isDarkTheme);
426
468
  return {
427
469
  x: series.x[i],
428
470
  y: yValue,
429
- legend: legendName,
471
+ legend,
430
472
  color
431
473
  };
432
474
  });
@@ -456,7 +498,9 @@ export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, colorMap,
456
498
  width: (_input_layout6 = input.layout) === null || _input_layout6 === void 0 ? void 0 : _input_layout6.width,
457
499
  hideTickOverlap: true,
458
500
  noOfCharsToTruncate: 20,
459
- showYAxisLablesTooltip: true
501
+ showYAxisLablesTooltip: true,
502
+ hideLegend,
503
+ roundCorners: true
460
504
  };
461
505
  };
462
506
  export const transformPlotlyJsonToHeatmapProps = (input)=>{
@@ -508,7 +552,8 @@ export const transformPlotlyJsonToHeatmapProps = (input)=>{
508
552
  } else {
509
553
  var _firstData_x1;
510
554
  (_firstData_x1 = firstData.x) === null || _firstData_x1 === void 0 ? void 0 : _firstData_x1.forEach((xVal, xIdx)=>{
511
- var _firstData_y;
555
+ var // eslint-disable-next-line @typescript-eslint/no-explicit-any
556
+ _firstData_y;
512
557
  (_firstData_y = firstData.y) === null || _firstData_y === void 0 ? void 0 : _firstData_y.forEach((yVal, yIdx)=>{
513
558
  var _firstData_z_yIdx, _firstData_z, _input_layout_xaxis, _input_layout, _input_layout_yaxis, _input_layout1;
514
559
  const zVal = (_firstData_z = firstData.z) === null || _firstData_z === void 0 ? void 0 : (_firstData_z_yIdx = _firstData_z[yIdx]) === null || _firstData_z_yIdx === void 0 ? void 0 : _firstData_z_yIdx[xIdx];
@@ -562,29 +607,31 @@ export const transformPlotlyJsonToHeatmapProps = (input)=>{
562
607
  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,
563
608
  hideTickOverlap: true,
564
609
  noOfCharsToTruncate: 20,
565
- showYAxisLablesTooltip: true
610
+ showYAxisLablesTooltip: true,
611
+ wrapXAxisLables: true
566
612
  };
567
613
  };
568
- export const transformPlotlyJsonToSankeyProps = (input, colorMap, isDarkTheme)=>{
569
- var _node_label, _input_layout, _input_layout1;
614
+ export const transformPlotlyJsonToSankeyProps = (input, colorMap, colorwayType, isDarkTheme)=>{
615
+ var _input_layout_template_layout, _input_layout_template, _input_layout, _node_label, _input_layout1, _input_layout2;
570
616
  const { link, node } = input.data[0];
571
617
  var _link_value;
572
618
  const validLinks = ((_link_value = link === null || link === void 0 ? void 0 : link.value) !== null && _link_value !== void 0 ? _link_value : []).map((val, index)=>({
573
619
  value: val,
574
620
  source: link === null || link === void 0 ? void 0 : link.source[index],
575
621
  target: link === null || link === void 0 ? void 0 : link.target[index]
576
- }))// eslint-disable-next-line @typescript-eslint/no-shadow
577
- // Filter out negative nodes, unequal nodes and self-references (circular links)
622
+ }))// Filter out negative nodes, unequal nodes and self-references (circular links)
578
623
  .filter((x)=>x.source >= 0 && x.target >= 0 && x.source !== x.target);
624
+ const extractedNodeColors = 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, node === null || node === void 0 ? void 0 : node.color, colorMap, isDarkTheme);
579
625
  const sankeyChartData = {
580
626
  nodes: (_node_label = node.label) === null || _node_label === void 0 ? void 0 : _node_label.map((label, index)=>{
581
- const color = getColor(label, colorMap, isDarkTheme);
627
+ const color = resolveColor(extractedNodeColors, index, label, colorMap, isDarkTheme);
582
628
  return {
583
629
  nodeId: index,
584
630
  name: label,
585
631
  color
586
632
  };
587
633
  }),
634
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
588
635
  links: validLinks.map((validLink, index)=>{
589
636
  return {
590
637
  ...validLink
@@ -603,18 +650,20 @@ export const transformPlotlyJsonToSankeyProps = (input, colorMap, isDarkTheme)=>
603
650
  chartTitle,
604
651
  SankeyChartData: sankeyChartData
605
652
  },
606
- width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
607
- 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 : 468
653
+ width: (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.width,
654
+ 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 : 468
608
655
  };
609
656
  };
610
- export const transformPlotlyJsonToGaugeProps = (input, colorMap, isDarkTheme)=>{
611
- var _firstData_gauge_steps, _firstData_gauge, _firstData_gauge_axis_range, _firstData_gauge_axis, _firstData_gauge1, _firstData_gauge_axis_range1, _firstData_gauge_axis1, _firstData_gauge2, _firstData_delta, _firstData_gauge_axis_range2, _firstData_gauge_axis2, _firstData_gauge3, _firstData_gauge_axis_range3, _firstData_gauge_axis3, _firstData_gauge4, _firstData_gauge_axis_range4, _firstData_gauge_axis4, _firstData_gauge5, _firstData_gauge_axis_range5, _firstData_gauge_axis5, _firstData_gauge6, _input_layout, _input_layout1, _firstData_gauge_steps1, _firstData_gauge7;
657
+ export const transformPlotlyJsonToGaugeProps = (input, colorMap, colorwayType, isDarkTheme)=>{
658
+ var _firstData_gauge, _input_layout_template_layout, _input_layout_template, _input_layout, _firstData_gauge_steps, _firstData_gauge1, _firstData_gauge_axis_range, _firstData_gauge_axis, _firstData_gauge2, _input_layout_template_layout1, _input_layout_template1, _input_layout1, _firstData_gauge_axis1, _firstData_gauge3, _firstData_gauge_axis_range1, _firstData_gauge_axis2, _firstData_gauge4, _firstData_delta, _firstData_gauge_axis_range2, _firstData_gauge_axis3, _firstData_gauge5, _firstData_gauge_axis_range3, _firstData_gauge_axis4, _firstData_gauge6, _firstData_gauge_axis_range4, _firstData_gauge_axis5, _firstData_gauge7, _firstData_gauge_axis_range5, _firstData_gauge_axis6, _firstData_gauge8, _input_layout2, _input_layout3, _firstData_gauge_steps1, _firstData_gauge9;
612
659
  const firstData = input.data[0];
660
+ const stepsColors = ((_firstData_gauge = firstData.gauge) === null || _firstData_gauge === void 0 ? void 0 : _firstData_gauge.steps) ? firstData.gauge.steps.map((step)=>step.color) : undefined;
661
+ 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, stepsColors, colorMap, isDarkTheme);
613
662
  var _firstData_gauge_axis_range_, _firstData_value, _firstData_gauge_axis_range_1, _firstData_value1;
614
- const segments = ((_firstData_gauge = firstData.gauge) === null || _firstData_gauge === void 0 ? void 0 : (_firstData_gauge_steps = _firstData_gauge.steps) === null || _firstData_gauge_steps === void 0 ? void 0 : _firstData_gauge_steps.length) ? firstData.gauge.steps.map((step, index)=>{
663
+ const segments = ((_firstData_gauge1 = firstData.gauge) === null || _firstData_gauge1 === void 0 ? void 0 : (_firstData_gauge_steps = _firstData_gauge1.steps) === null || _firstData_gauge_steps === void 0 ? void 0 : _firstData_gauge_steps.length) ? firstData.gauge.steps.map((step, index)=>{
615
664
  var _step_range, _step_range1;
616
665
  const legend = step.name || `Segment ${index + 1}`;
617
- const color = getColor(legend, colorMap, isDarkTheme);
666
+ const color = resolveColor(extractedColors, index, legend, colorMap, isDarkTheme);
618
667
  return {
619
668
  legend,
620
669
  size: ((_step_range = step.range) === null || _step_range === void 0 ? void 0 : _step_range[1]) - ((_step_range1 = step.range) === null || _step_range1 === void 0 ? void 0 : _step_range1[0]),
@@ -623,34 +672,36 @@ export const transformPlotlyJsonToGaugeProps = (input, colorMap, isDarkTheme)=>{
623
672
  }) : [
624
673
  {
625
674
  legend: 'Current',
626
- size: (_firstData_value = firstData.value) !== null && _firstData_value !== void 0 ? _firstData_value : 0 - ((_firstData_gauge_axis_range_ = (_firstData_gauge1 = firstData.gauge) === null || _firstData_gauge1 === void 0 ? void 0 : (_firstData_gauge_axis = _firstData_gauge1.axis) === null || _firstData_gauge_axis === void 0 ? void 0 : (_firstData_gauge_axis_range = _firstData_gauge_axis.range) === null || _firstData_gauge_axis_range === void 0 ? void 0 : _firstData_gauge_axis_range[0]) !== null && _firstData_gauge_axis_range_ !== void 0 ? _firstData_gauge_axis_range_ : 0),
627
- color: getColor('Current', colorMap, isDarkTheme)
675
+ size: (_firstData_value = firstData.value) !== null && _firstData_value !== void 0 ? _firstData_value : 0 - ((_firstData_gauge_axis_range_ = (_firstData_gauge2 = firstData.gauge) === null || _firstData_gauge2 === void 0 ? void 0 : (_firstData_gauge_axis = _firstData_gauge2.axis) === null || _firstData_gauge_axis === void 0 ? void 0 : (_firstData_gauge_axis_range = _firstData_gauge_axis.range) === null || _firstData_gauge_axis_range === void 0 ? void 0 : _firstData_gauge_axis_range[0]) !== null && _firstData_gauge_axis_range_ !== void 0 ? _firstData_gauge_axis_range_ : 0),
676
+ color: _getGaugeAxisColor((_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, (_firstData_gauge3 = firstData.gauge) === null || _firstData_gauge3 === void 0 ? void 0 : (_firstData_gauge_axis1 = _firstData_gauge3.axis) === null || _firstData_gauge_axis1 === void 0 ? void 0 : _firstData_gauge_axis1.color, colorMap, isDarkTheme)
628
677
  },
629
678
  {
630
679
  legend: 'Target',
631
- size: ((_firstData_gauge_axis_range_1 = (_firstData_gauge2 = firstData.gauge) === null || _firstData_gauge2 === void 0 ? void 0 : (_firstData_gauge_axis1 = _firstData_gauge2.axis) === null || _firstData_gauge_axis1 === void 0 ? void 0 : (_firstData_gauge_axis_range1 = _firstData_gauge_axis1.range) === null || _firstData_gauge_axis_range1 === void 0 ? void 0 : _firstData_gauge_axis_range1[1]) !== null && _firstData_gauge_axis_range_1 !== void 0 ? _firstData_gauge_axis_range_1 : 100) - ((_firstData_value1 = firstData.value) !== null && _firstData_value1 !== void 0 ? _firstData_value1 : 0),
680
+ size: ((_firstData_gauge_axis_range_1 = (_firstData_gauge4 = firstData.gauge) === null || _firstData_gauge4 === void 0 ? void 0 : (_firstData_gauge_axis2 = _firstData_gauge4.axis) === null || _firstData_gauge_axis2 === void 0 ? void 0 : (_firstData_gauge_axis_range1 = _firstData_gauge_axis2.range) === null || _firstData_gauge_axis_range1 === void 0 ? void 0 : _firstData_gauge_axis_range1[1]) !== null && _firstData_gauge_axis_range_1 !== void 0 ? _firstData_gauge_axis_range_1 : 100) - ((_firstData_value1 = firstData.value) !== null && _firstData_value1 !== void 0 ? _firstData_value1 : 0),
632
681
  color: DataVizPalette.disabled
633
682
  }
634
683
  ];
635
684
  let sublabel;
636
- // let sublabelColor: string | undefined;
685
+ let sublabelColor;
637
686
  if ((_firstData_delta = firstData.delta) === null || _firstData_delta === void 0 ? void 0 : _firstData_delta.reference) {
638
687
  const diff = firstData.value - firstData.delta.reference;
639
688
  if (diff >= 0) {
689
+ var _input_layout_template_layout2, _input_layout_template2, _input_layout4, _firstData_delta_increasing, _firstData_delta1;
640
690
  sublabel = `\u25B2 ${diff}`;
641
- // const color = getColorFromToken(DataVizPalette.success, isDarkTheme);
642
- // sublabelColor = color;
691
+ const extractedIncreasingDeltaColors = extractColor((_input_layout4 = input.layout) === null || _input_layout4 === void 0 ? void 0 : (_input_layout_template2 = _input_layout4.template) === null || _input_layout_template2 === void 0 ? void 0 : (_input_layout_template_layout2 = _input_layout_template2.layout) === null || _input_layout_template_layout2 === void 0 ? void 0 : _input_layout_template_layout2.colorway, colorwayType, (_firstData_delta1 = firstData.delta) === null || _firstData_delta1 === void 0 ? void 0 : (_firstData_delta_increasing = _firstData_delta1.increasing) === null || _firstData_delta_increasing === void 0 ? void 0 : _firstData_delta_increasing.color, colorMap, isDarkTheme);
692
+ const color = resolveColor(extractedIncreasingDeltaColors, 0, '', colorMap, isDarkTheme);
693
+ sublabelColor = color;
643
694
  } else {
695
+ var _input_layout_template_layout3, _input_layout_template3, _input_layout5, _firstData_delta_decreasing, _firstData_delta2;
644
696
  sublabel = `\u25BC ${Math.abs(diff)}`;
645
- // const color = getColorFromToken(DataVizPalette.error, isDarkTheme);
646
- // sublabelColor = color;
697
+ const extractedDecreasingDeltaColors = extractColor((_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : (_input_layout_template3 = _input_layout5.template) === null || _input_layout_template3 === void 0 ? void 0 : (_input_layout_template_layout3 = _input_layout_template3.layout) === null || _input_layout_template_layout3 === void 0 ? void 0 : _input_layout_template_layout3.colorway, colorwayType, (_firstData_delta2 = firstData.delta) === null || _firstData_delta2 === void 0 ? void 0 : (_firstData_delta_decreasing = _firstData_delta2.decreasing) === null || _firstData_delta_decreasing === void 0 ? void 0 : _firstData_delta_decreasing.color, colorMap, isDarkTheme);
698
+ const color = resolveColor(extractedDecreasingDeltaColors, 0, '', colorMap, isDarkTheme);
699
+ sublabelColor = color;
647
700
  }
648
701
  }
649
- // const styles: GaugeChartProps['styles'] = {
650
- // sublabel: {
651
- // fill: sublabelColor,
652
- // },
653
- // };
702
+ const styles = {
703
+ sublabel: sublabelColor
704
+ };
654
705
  const { chartTitle } = getTitles(input.layout);
655
706
  var _firstData_value2, _input_layout_height;
656
707
  return {
@@ -659,18 +710,60 @@ export const transformPlotlyJsonToGaugeProps = (input, colorMap, isDarkTheme)=>{
659
710
  chartTitle,
660
711
  sublabel,
661
712
  // range values can be null
662
- minValue: typeof ((_firstData_gauge3 = firstData.gauge) === null || _firstData_gauge3 === void 0 ? void 0 : (_firstData_gauge_axis2 = _firstData_gauge3.axis) === null || _firstData_gauge_axis2 === void 0 ? void 0 : (_firstData_gauge_axis_range2 = _firstData_gauge_axis2.range) === null || _firstData_gauge_axis_range2 === void 0 ? void 0 : _firstData_gauge_axis_range2[0]) === 'number' ? (_firstData_gauge4 = firstData.gauge) === null || _firstData_gauge4 === void 0 ? void 0 : (_firstData_gauge_axis3 = _firstData_gauge4.axis) === null || _firstData_gauge_axis3 === void 0 ? void 0 : (_firstData_gauge_axis_range3 = _firstData_gauge_axis3.range) === null || _firstData_gauge_axis_range3 === void 0 ? void 0 : _firstData_gauge_axis_range3[0] : undefined,
663
- maxValue: typeof ((_firstData_gauge5 = firstData.gauge) === null || _firstData_gauge5 === void 0 ? void 0 : (_firstData_gauge_axis4 = _firstData_gauge5.axis) === null || _firstData_gauge_axis4 === void 0 ? void 0 : (_firstData_gauge_axis_range4 = _firstData_gauge_axis4.range) === null || _firstData_gauge_axis_range4 === void 0 ? void 0 : _firstData_gauge_axis_range4[1]) === 'number' ? (_firstData_gauge6 = firstData.gauge) === null || _firstData_gauge6 === void 0 ? void 0 : (_firstData_gauge_axis5 = _firstData_gauge6.axis) === null || _firstData_gauge_axis5 === void 0 ? void 0 : (_firstData_gauge_axis_range5 = _firstData_gauge_axis5.range) === null || _firstData_gauge_axis_range5 === void 0 ? void 0 : _firstData_gauge_axis_range5[1] : undefined,
713
+ minValue: typeof ((_firstData_gauge5 = firstData.gauge) === null || _firstData_gauge5 === void 0 ? void 0 : (_firstData_gauge_axis3 = _firstData_gauge5.axis) === null || _firstData_gauge_axis3 === void 0 ? void 0 : (_firstData_gauge_axis_range2 = _firstData_gauge_axis3.range) === null || _firstData_gauge_axis_range2 === void 0 ? void 0 : _firstData_gauge_axis_range2[0]) === 'number' ? (_firstData_gauge6 = firstData.gauge) === null || _firstData_gauge6 === void 0 ? void 0 : (_firstData_gauge_axis4 = _firstData_gauge6.axis) === null || _firstData_gauge_axis4 === void 0 ? void 0 : (_firstData_gauge_axis_range3 = _firstData_gauge_axis4.range) === null || _firstData_gauge_axis_range3 === void 0 ? void 0 : _firstData_gauge_axis_range3[0] : undefined,
714
+ maxValue: typeof ((_firstData_gauge7 = firstData.gauge) === null || _firstData_gauge7 === void 0 ? void 0 : (_firstData_gauge_axis5 = _firstData_gauge7.axis) === null || _firstData_gauge_axis5 === void 0 ? void 0 : (_firstData_gauge_axis_range4 = _firstData_gauge_axis5.range) === null || _firstData_gauge_axis_range4 === void 0 ? void 0 : _firstData_gauge_axis_range4[1]) === 'number' ? (_firstData_gauge8 = firstData.gauge) === null || _firstData_gauge8 === void 0 ? void 0 : (_firstData_gauge_axis6 = _firstData_gauge8.axis) === null || _firstData_gauge_axis6 === void 0 ? void 0 : (_firstData_gauge_axis_range5 = _firstData_gauge_axis6.range) === null || _firstData_gauge_axis_range5 === void 0 ? void 0 : _firstData_gauge_axis_range5[1] : undefined,
664
715
  chartValueFormat: ()=>{
665
716
  var _firstData_value;
666
717
  var _firstData_value_toString;
667
718
  return (_firstData_value_toString = (_firstData_value = firstData.value) === null || _firstData_value === void 0 ? void 0 : _firstData_value.toString()) !== null && _firstData_value_toString !== void 0 ? _firstData_value_toString : '';
668
719
  },
669
- width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
670
- 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 : 220,
720
+ width: (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.width,
721
+ height: (_input_layout_height = (_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : _input_layout3.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 220,
671
722
  // TODO
672
723
  // styles,
673
- variant: ((_firstData_gauge7 = firstData.gauge) === null || _firstData_gauge7 === void 0 ? void 0 : (_firstData_gauge_steps1 = _firstData_gauge7.steps) === null || _firstData_gauge_steps1 === void 0 ? void 0 : _firstData_gauge_steps1.length) ? 'multiple-segments' : 'single-segment'
724
+ variant: ((_firstData_gauge9 = firstData.gauge) === null || _firstData_gauge9 === void 0 ? void 0 : (_firstData_gauge_steps1 = _firstData_gauge9.steps) === null || _firstData_gauge_steps1 === void 0 ? void 0 : _firstData_gauge_steps1.length) ? 'multiple-segments' : 'single-segment',
725
+ styles,
726
+ roundCorners: true
727
+ };
728
+ };
729
+ const cleanText = (text)=>{
730
+ return text.replace(/&lt;[^&]*?&gt;/g, '').replace(/<[^>]*>/g, '').replace(/&lt;br&gt;|\\u003cbr\\u003e|<br>/gi, '').replace(/\$[^$]*\$/g, '$').trim();
731
+ };
732
+ export const transformPlotlyJsonToChartTableProps = (input, colorMap, isDarkTheme)=>{
733
+ var _tableData_cells, _input_layout_font, _input_layout, _tableData_header, _input_layout1, _input_layout2;
734
+ const tableData = input.data[0];
735
+ const normalizeHeaders = (values)=>{
736
+ // Case: values is array of arrays
737
+ if (Array.isArray(values[0])) {
738
+ return values.map((row)=>row.map((cell)=>cleanText(cell)).filter(Boolean).join(' '));
739
+ }
740
+ // Case: values is 1d array
741
+ return values.map((cell)=>cleanText(cell));
742
+ };
743
+ var _tableData_cells_values;
744
+ const columns = (_tableData_cells_values = (_tableData_cells = tableData.cells) === null || _tableData_cells === void 0 ? void 0 : _tableData_cells.values) !== null && _tableData_cells_values !== void 0 ? _tableData_cells_values : [];
745
+ const rows = columns[0].map((_, rowIndex)=>columns.map((col)=>{
746
+ const cell = col[rowIndex];
747
+ return {
748
+ value: typeof cell === 'string' ? cleanText(cell) : cell
749
+ };
750
+ }));
751
+ const styles = {
752
+ root: {
753
+ ...((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_font = _input_layout.font) === null || _input_layout_font === void 0 ? void 0 : _input_layout_font.size) ? {
754
+ fontSize: input.layout.font.size
755
+ } : {}
756
+ }
757
+ };
758
+ var _tableData_header_values;
759
+ return {
760
+ headers: normalizeHeaders((_tableData_header_values = (_tableData_header = tableData.header) === null || _tableData_header === void 0 ? void 0 : _tableData_header.values) !== null && _tableData_header_values !== void 0 ? _tableData_header_values : []).map((value)=>({
761
+ value
762
+ })),
763
+ rows,
764
+ width: (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.width,
765
+ height: (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.height,
766
+ styles
674
767
  };
675
768
  };
676
769
  export const projectPolarToCartesian = (input)=>{
@@ -691,21 +784,28 @@ export const projectPolarToCartesian = (input)=>{
691
784
  }
692
785
  return projection;
693
786
  };
787
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
694
788
  function isPlainObject(obj) {
695
789
  return Object.prototype.toString.call(obj) === '[object Object]' && Object.getPrototypeOf(obj).hasOwnProperty('hasOwnProperty');
696
790
  }
791
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
697
792
  var arrayAttributes = [];
793
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
698
794
  var stack = [];
795
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
699
796
  var isArrayStack = [];
797
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
700
798
  var baseContainer, baseAttrName;
701
799
  /**
702
800
  * Interate iteratively through the trace object and find all the array attributes.
703
801
  * 1 trace record = 1 series of data
704
802
  * @param trace
705
- */ export function findArrayAttributes(trace) {
803
+ */ // eslint-disable-next-line @typescript-eslint/no-explicit-any
804
+ export function findArrayAttributes(trace) {
706
805
  // Init basecontainer and baseAttrName
707
806
  crawlIntoTrace(baseContainer, 0, '');
708
807
  }
808
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
709
809
  function crawlIntoTrace(container, i, astrPartial) {
710
810
  var item = container[stack[i]];
711
811
  var newAstrPartial = astrPartial + stack[i];
@@ -757,7 +857,9 @@ function getLineOptions(line) {
757
857
  }
758
858
  return Object.keys(lineOptions).length > 0 ? lineOptions : undefined;
759
859
  }
860
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
760
861
  const isStringArray = (arr)=>{
862
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
761
863
  return isArrayOfType(arr, (value)=>typeof value === 'string');
762
864
  };
763
865
  // TODO: Use binary search to find the appropriate bin for numeric value.
@@ -854,3 +956,18 @@ const precisionRound = (value, precision)=>{
854
956
  const factor = Math.pow(10, precision);
855
957
  return Math.round(value * factor) / factor;
856
958
  };
959
+ const getLegendProps = (data, layout)=>{
960
+ const legends = [];
961
+ if (data.length === 1) {
962
+ legends.push(data[0].name || '');
963
+ } else {
964
+ data.forEach((series, index)=>{
965
+ legends.push(series.name || `Series ${index + 1}`);
966
+ });
967
+ }
968
+ const hideLegends = data.every((series)=>series.showlegend === false);
969
+ return {
970
+ legends,
971
+ hideLegend: (layout === null || layout === void 0 ? void 0 : layout.showlegend) === false ? true : hideLegends
972
+ };
973
+ };