@fluentui/react-charts 0.0.0-nightly-20250819-0407.1 → 0.0.0-nightly-20250821-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 (135) hide show
  1. package/CHANGELOG.md +15 -15
  2. package/dist/index.d.ts +9 -1
  3. package/lib/components/AreaChart/AreaChart.js +4 -1
  4. package/lib/components/AreaChart/AreaChart.js.map +1 -1
  5. package/lib/components/AreaChart/useAreaChartStyles.styles.js +2 -1
  6. package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
  7. package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js +2 -1
  8. package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
  9. package/lib/components/CommonComponents/CartesianChart.js +48 -3
  10. package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
  11. package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
  12. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +13 -0
  13. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  14. package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +12 -0
  15. package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
  16. package/lib/components/DeclarativeChart/DeclarativeChart.js +175 -120
  17. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  18. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +6 -1
  19. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
  20. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +346 -52
  21. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  22. package/lib/components/GanttChart/useGanttChartStyles.styles.js +2 -1
  23. package/lib/components/GanttChart/useGanttChartStyles.styles.js.map +1 -1
  24. package/lib/components/GanttChart/useGanttChartStyles.styles.raw.js +2 -1
  25. package/lib/components/GanttChart/useGanttChartStyles.styles.raw.js.map +1 -1
  26. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +23 -4
  27. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  28. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +2 -1
  29. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  30. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +2 -1
  31. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
  32. package/lib/components/HeatMapChart/HeatMapChart.js +175 -114
  33. package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
  34. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js +2 -1
  35. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
  36. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +2 -1
  37. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
  38. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +26 -6
  39. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  40. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +2 -1
  41. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
  42. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +2 -1
  43. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
  44. package/lib/components/LineChart/useLineChartStyles.styles.js +2 -1
  45. package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  46. package/lib/components/LineChart/useLineChartStyles.styles.raw.js +2 -1
  47. package/lib/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
  48. package/lib/components/ScatterChart/ScatterChart.js +49 -30
  49. package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
  50. package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -1
  51. package/lib/components/ScatterChart/useScatterChartStyles.styles.js +21 -4
  52. package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  53. package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js +16 -3
  54. package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
  55. package/lib/components/VerticalBarChart/VerticalBarChart.js +27 -4
  56. package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  57. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +2 -1
  58. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  59. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +2 -1
  60. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
  61. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +61 -44
  62. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  63. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +2 -1
  64. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
  65. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +2 -1
  66. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
  67. package/lib/utilities/utilities.js +0 -29
  68. package/lib/utilities/utilities.js.map +1 -1
  69. package/lib-commonjs/components/AreaChart/AreaChart.js +4 -1
  70. package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
  71. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js +2 -1
  72. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
  73. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js +2 -1
  74. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
  75. package/lib-commonjs/components/CommonComponents/CartesianChart.js +48 -3
  76. package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
  77. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
  78. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +13 -0
  79. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  80. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +12 -0
  81. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
  82. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +171 -118
  83. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  84. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +9 -1
  85. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
  86. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +362 -58
  87. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  88. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js +2 -1
  89. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js.map +1 -1
  90. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.raw.js +2 -1
  91. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.raw.js.map +1 -1
  92. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +22 -3
  93. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  94. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +2 -1
  95. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  96. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +2 -1
  97. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
  98. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +174 -113
  99. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
  100. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js +2 -1
  101. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
  102. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +2 -1
  103. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
  104. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +25 -5
  105. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  106. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +2 -1
  107. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
  108. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +2 -1
  109. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
  110. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js +2 -1
  111. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  112. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js +2 -1
  113. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
  114. package/lib-commonjs/components/ScatterChart/ScatterChart.js +49 -30
  115. package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
  116. package/lib-commonjs/components/ScatterChart/ScatterChart.types.js.map +1 -1
  117. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js +30 -3
  118. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  119. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js +15 -2
  120. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
  121. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +26 -3
  122. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  123. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +2 -1
  124. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  125. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +2 -1
  126. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
  127. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +60 -43
  128. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  129. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +2 -1
  130. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
  131. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +2 -1
  132. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
  133. package/lib-commonjs/utilities/utilities.js +0 -32
  134. package/lib-commonjs/utilities/utilities.js.map +1 -1
  135. package/package.json +12 -12
@@ -1,10 +1,10 @@
1
1
  /* eslint-disable @typescript-eslint/naming-convention */ import * as React from 'react';
2
- import { decodeBase64Fields, isArrayOrTypedArray, isDateArray, isMonthArray, isNumberArray, isYearArray, mapFluentChart, sanitizeJson } from '@fluentui/chart-utilities';
2
+ import { decodeBase64Fields, isArrayOrTypedArray, isMonthArray, mapFluentChart, sanitizeJson } from '@fluentui/chart-utilities';
3
3
  import { tokens } from '@fluentui/react-theme';
4
4
  import { ThemeContext_unstable as V9ThemeContext } from '@fluentui/react-shared-contexts';
5
5
  import { webLightTheme } from '@fluentui/tokens';
6
6
  import * as d3Color from 'd3-color';
7
- import { correctYearMonth, transformPlotlyJsonToDonutProps, transformPlotlyJsonToVSBCProps, transformPlotlyJsonToScatterChartProps, transformPlotlyJsonToHorizontalBarWithAxisProps, transformPlotlyJsonToHeatmapProps, transformPlotlyJsonToSankeyProps, transformPlotlyJsonToGaugeProps, transformPlotlyJsonToGVBCProps, transformPlotlyJsonToVBCProps, transformPlotlyJsonToChartTableProps, projectPolarToCartesian, isStringArray } from './PlotlySchemaAdapter';
7
+ import { correctYearMonth, getGridProperties, transformPlotlyJsonToDonutProps, transformPlotlyJsonToVSBCProps, transformPlotlyJsonToAreaChartProps, transformPlotlyJsonToLineChartProps, transformPlotlyJsonToHorizontalBarWithAxisProps, transformPlotlyJsonToHeatmapProps, transformPlotlyJsonToSankeyProps, transformPlotlyJsonToGaugeProps, transformPlotlyJsonToGVBCProps, transformPlotlyJsonToVBCProps, transformPlotlyJsonToChartTableProps, transformPlotlyJsonToScatterChartProps, projectPolarToCartesian, getAllupLegendsProps } from './PlotlySchemaAdapter';
8
8
  import { DonutChart } from '../DonutChart/index';
9
9
  import { VerticalStackedBarChart } from '../VerticalStackedBarChart/index';
10
10
  import { LineChart } from '../LineChart/index';
@@ -18,6 +18,7 @@ import { VerticalBarChart } from '../VerticalBarChart/index';
18
18
  import { ScatterChart } from '../ScatterChart/index';
19
19
  import { withResponsiveContainer } from '../ResponsiveContainer/withResponsiveContainer';
20
20
  import { ChartTable } from '../ChartTable/index';
21
+ import { Legends } from '../Legends/index';
21
22
  const ResponsiveDonutChart = withResponsiveContainer(DonutChart);
22
23
  const ResponsiveVerticalStackedBarChart = withResponsiveContainer(VerticalStackedBarChart);
23
24
  const ResponsiveLineChart = withResponsiveContainer(LineChart);
@@ -30,10 +31,106 @@ const ResponsiveGroupedVerticalBarChart = withResponsiveContainer(GroupedVertica
30
31
  const ResponsiveVerticalBarChart = withResponsiveContainer(VerticalBarChart);
31
32
  const ResponsiveScatterChart = withResponsiveContainer(ScatterChart);
32
33
  const ResponsiveChartTable = withResponsiveContainer(ChartTable);
34
+ // Default x-axis key for grouping traces. Also applicable for PieData and SankeyData where x-axis is not defined.
35
+ const DEFAULT_XAXIS = 'x';
36
+ const FALLBACK_TYPE = 'fallback';
33
37
  const useColorMapping = ()=>{
34
38
  const colorMap = React.useRef(new Map());
35
39
  return colorMap;
36
40
  };
41
+ function renderChart(Renderer, // eslint-disable-next-line @typescript-eslint/no-explicit-any
42
+ transformer, // eslint-disable-next-line @typescript-eslint/no-explicit-any
43
+ transformerArgs, commonProps, cellRow, cellColumn) {
44
+ const chartProps = transformer(...transformerArgs);
45
+ return /*#__PURE__*/ React.createElement("div", {
46
+ key: `${cellRow}_${cellColumn}`,
47
+ style: {
48
+ gridRowStart: cellRow,
49
+ gridRowEnd: cellRow + 1,
50
+ gridColumnStart: cellColumn,
51
+ gridColumnEnd: cellColumn + 1
52
+ }
53
+ }, /*#__PURE__*/ React.createElement(Renderer, {
54
+ ...chartProps,
55
+ ...commonProps
56
+ }));
57
+ }
58
+ const LineAreaPreTransformOp = (plotlyInput)=>{
59
+ const xValues = plotlyInput.data[0].x;
60
+ const isXMonth = isMonthArray(xValues);
61
+ let renderData = plotlyInput.data;
62
+ if (isXMonth) {
63
+ renderData = plotlyInput.data.map((dataPoint)=>({
64
+ ...dataPoint,
65
+ x: correctYearMonth(dataPoint.x)
66
+ }));
67
+ }
68
+ return {
69
+ data: renderData,
70
+ layout: plotlyInput.layout
71
+ };
72
+ };
73
+ const chartMap = {
74
+ // PieData category charts
75
+ donut: {
76
+ transformer: transformPlotlyJsonToDonutProps,
77
+ renderer: ResponsiveDonutChart
78
+ },
79
+ // SankeyData category charts
80
+ sankey: {
81
+ transformer: transformPlotlyJsonToSankeyProps,
82
+ renderer: ResponsiveSankeyChart
83
+ },
84
+ // TableData category charts
85
+ table: {
86
+ transformer: transformPlotlyJsonToChartTableProps,
87
+ renderer: ResponsiveChartTable
88
+ },
89
+ // PlotData category charts
90
+ horizontalbar: {
91
+ transformer: transformPlotlyJsonToHorizontalBarWithAxisProps,
92
+ renderer: ResponsiveHorizontalBarChartWithAxis
93
+ },
94
+ groupedverticalbar: {
95
+ transformer: transformPlotlyJsonToGVBCProps,
96
+ renderer: ResponsiveGroupedVerticalBarChart
97
+ },
98
+ verticalstackedbar: {
99
+ transformer: transformPlotlyJsonToVSBCProps,
100
+ renderer: ResponsiveVerticalStackedBarChart
101
+ },
102
+ heatmap: {
103
+ transformer: transformPlotlyJsonToHeatmapProps,
104
+ renderer: ResponsiveHeatMapChart
105
+ },
106
+ gauge: {
107
+ transformer: transformPlotlyJsonToGaugeProps,
108
+ renderer: ResponsiveGaugeChart
109
+ },
110
+ verticalbar: {
111
+ transformer: transformPlotlyJsonToVBCProps,
112
+ renderer: ResponsiveVerticalBarChart
113
+ },
114
+ area: {
115
+ transformer: transformPlotlyJsonToAreaChartProps,
116
+ renderer: ResponsiveAreaChart,
117
+ preTransformOperation: LineAreaPreTransformOp
118
+ },
119
+ line: {
120
+ transformer: transformPlotlyJsonToLineChartProps,
121
+ renderer: ResponsiveLineChart,
122
+ preTransformOperation: LineAreaPreTransformOp
123
+ },
124
+ scatter: {
125
+ transformer: transformPlotlyJsonToScatterChartProps,
126
+ renderer: ResponsiveScatterChart,
127
+ preTransformOperation: LineAreaPreTransformOp
128
+ },
129
+ fallback: {
130
+ transformer: transformPlotlyJsonToVSBCProps,
131
+ renderer: ResponsiveVerticalStackedBarChart
132
+ }
133
+ };
37
134
  const useIsDarkTheme = ()=>{
38
135
  const parentV9Theme = React.useContext(V9ThemeContext);
39
136
  const v9Theme = parentV9Theme ? parentV9Theme : webLightTheme;
@@ -62,10 +159,15 @@ const useIsDarkTheme = ()=>{
62
159
  ...plotlyInput,
63
160
  data: chart.validTracesInfo.map((trace)=>plotlyInput.data[trace.index])
64
161
  };
162
+ const validTracesFilteredIndex = chart.validTracesInfo.map((trace, index)=>[
163
+ index,
164
+ trace.type
165
+ ]);
65
166
  let { selectedLegends } = plotlySchema;
66
167
  const colorMap = useColorMapping();
67
168
  const isDarkTheme = useIsDarkTheme();
68
169
  const chartRef = React.useRef(null);
170
+ const isMultiPlot = React.useRef(false);
69
171
  if (!isArrayOrTypedArray(selectedLegends)) {
70
172
  selectedLegends = [];
71
173
  }
@@ -99,66 +201,20 @@ const useIsDarkTheme = ()=>{
99
201
  legendProps: multiSelectLegendProps,
100
202
  componentRef: chartRef
101
203
  };
102
- const renderLineAreaScatter = (plotlyData, isAreaChart, isScatterChart)=>{
103
- var _plotlyData_;
104
- const isScatterMarkers = [
105
- 'text+markers',
106
- 'markers+text',
107
- 'lines+markers',
108
- 'markers+line',
109
- 'text+lines+markers'
110
- ].includes((_plotlyData_ = plotlyData[0]) === null || _plotlyData_ === void 0 ? void 0 : _plotlyData_.mode);
111
- const chartType = isAreaChart ? 'area' : isScatterChart ? 'scatter' : 'line';
112
- const chartProps = {
113
- ...transformPlotlyJsonToScatterChartProps({
114
- data: plotlyData,
115
- layout: plotlyInput.layout
116
- }, chartType, isScatterMarkers, colorMap, props.colorwayType, isDarkTheme),
117
- ...commonProps
118
- };
119
- if (isAreaChart) {
120
- return /*#__PURE__*/ React.createElement(ResponsiveAreaChart, chartProps);
121
- }
122
- if (isScatterChart) {
123
- return /*#__PURE__*/ React.createElement(ResponsiveScatterChart, chartProps);
124
- }
125
- return /*#__PURE__*/ React.createElement(ResponsiveLineChart, chartProps);
126
- };
127
- const checkAndRenderChart = (isAreaChart = false)=>{
128
- let fallbackVSBC = false;
129
- const xValues = plotlyInputWithValidData.data[0].x;
130
- const isXDate = isDateArray(xValues);
131
- const isXNumber = isNumberArray(xValues);
132
- const isXMonth = isMonthArray(xValues);
133
- const isYString = isStringArray(plotlyInputWithValidData.data[0].y);
134
- // Consider year as categorical variable not numeric continuous variable
135
- // Also year is not considered a date variable as it is represented as a point
136
- // in time and brings additional complexity of handling timezone and locale
137
- // formatting given the current design of the charting library
138
- const isXYear = isYearArray(xValues);
139
- const allModes = plotlyInputWithValidData.data.map((data)=>data.mode);
140
- const isScatterChart = allModes.every((mode)=>mode === 'markers');
141
- // If x is date or number and y is not string, render as Line/Area Chart
142
- // If x is month, correct the year and render as Line/Area Chart
143
- if ((isXDate || isXNumber) && !isXYear && !isYString || isScatterChart && !isYString) {
144
- return renderLineAreaScatter(plotlyInputWithValidData.data, isAreaChart, isScatterChart);
145
- } else if (isXMonth) {
146
- const updatedData = plotlyInputWithValidData.data.map((dataPoint)=>({
147
- ...dataPoint,
148
- x: correctYearMonth(dataPoint.x)
149
- }));
150
- return renderLineAreaScatter(updatedData, isAreaChart, isScatterChart);
151
- }
152
- // Unsupported schema, render as VerticalStackedBarChart
153
- fallbackVSBC = true;
154
- return /*#__PURE__*/ React.createElement(ResponsiveVerticalStackedBarChart, {
155
- ...transformPlotlyJsonToVSBCProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme, fallbackVSBC),
156
- ...commonProps
204
+ function createLegends(legendProps) {
205
+ // eslint-disable-next-line react/jsx-no-bind
206
+ return /*#__PURE__*/ React.createElement(Legends, {
207
+ ...legendProps,
208
+ selectedLegends: activeLegends,
209
+ onChange: onActiveLegendsChange
157
210
  });
158
- };
211
+ }
159
212
  // TODO
160
213
  const exportAsImage = React.useCallback((opts)=>{
161
214
  return new Promise((resolve, reject)=>{
215
+ if (isMultiPlot.current) {
216
+ return reject(Error('Exporting multi plot charts as image is not supported'));
217
+ }
162
218
  if (!chartRef.current || typeof chartRef.current.toImage !== 'function') {
163
219
  return reject(Error('Chart cannot be exported as image'));
164
220
  }
@@ -174,70 +230,69 @@ const useIsDarkTheme = ()=>{
174
230
  }), [
175
231
  exportAsImage
176
232
  ]);
177
- switch(chart.type){
178
- case 'donut':
179
- return /*#__PURE__*/ React.createElement(ResponsiveDonutChart, {
180
- ...transformPlotlyJsonToDonutProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme),
181
- ...commonProps
182
- });
183
- case 'horizontalbar':
184
- return /*#__PURE__*/ React.createElement(ResponsiveHorizontalBarChartWithAxis, {
185
- ...transformPlotlyJsonToHorizontalBarWithAxisProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme),
186
- ...commonProps
187
- });
188
- case 'groupedverticalbar':
189
- return /*#__PURE__*/ React.createElement(ResponsiveGroupedVerticalBarChart, {
190
- ...transformPlotlyJsonToGVBCProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme),
191
- ...commonProps
192
- });
193
- case 'verticalstackedbar':
194
- return /*#__PURE__*/ React.createElement(ResponsiveVerticalStackedBarChart, {
195
- ...transformPlotlyJsonToVSBCProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme),
196
- ...commonProps
197
- });
198
- case 'heatmap':
199
- return /*#__PURE__*/ React.createElement(ResponsiveHeatMapChart, {
200
- ...transformPlotlyJsonToHeatmapProps(plotlyInputWithValidData),
201
- ...commonProps,
202
- legendProps: {}
203
- });
204
- case 'sankey':
205
- return /*#__PURE__*/ React.createElement(ResponsiveSankeyChart, {
206
- ...transformPlotlyJsonToSankeyProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme),
207
- ...commonProps
208
- });
209
- case 'gauge':
210
- return /*#__PURE__*/ React.createElement(ResponsiveGaugeChart, {
211
- ...transformPlotlyJsonToGaugeProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme),
212
- ...commonProps
213
- });
214
- case 'verticalbar':
215
- return /*#__PURE__*/ React.createElement(ResponsiveVerticalBarChart, {
216
- ...transformPlotlyJsonToVBCProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme),
217
- ...commonProps
218
- });
219
- case 'table':
220
- return /*#__PURE__*/ React.createElement(ResponsiveChartTable, {
221
- ...transformPlotlyJsonToChartTableProps(plotlyInputWithValidData, colorMap, isDarkTheme),
222
- ...commonProps
223
- });
224
- // TODO: Add 'scatter' as a separate chart type
225
- case 'area':
226
- case 'line':
227
- case 'fallback':
228
- case 'scatterpolar':
229
- case 'scatter':
230
- if (chart.type === 'scatterpolar') {
231
- const cartesianProjection = projectPolarToCartesian(plotlyInputWithValidData);
232
- plotlyInputWithValidData.data = cartesianProjection.data;
233
+ if (chart.type === 'scatterpolar') {
234
+ const cartesianProjection = projectPolarToCartesian(plotlyInputWithValidData);
235
+ plotlyInputWithValidData.data = cartesianProjection.data;
236
+ validTracesFilteredIndex.forEach((trace, index)=>{
237
+ if (trace[1] === 'scatterpolar') {
238
+ validTracesFilteredIndex[index][1] = 'line'; // Change type to line for rendering
233
239
  }
234
- // Need recheck for area chart as we don't have ability to check for valid months in previous step
235
- const isAreaChart = plotlyInputWithValidData.data.some((series)=>series.fill === 'tonexty' || series.fill === 'tozeroy' || !!series.stackgroup);
236
- return checkAndRenderChart(isAreaChart);
237
- default:
238
- var _plotlyInputWithValidData_data_;
239
- throw new Error(`Unsupported chart type :${(_plotlyInputWithValidData_data_ = plotlyInputWithValidData.data[0]) === null || _plotlyInputWithValidData_data_ === void 0 ? void 0 : _plotlyInputWithValidData_data_.type}`);
240
+ });
240
241
  }
242
+ const groupedTraces = {};
243
+ plotlyInputWithValidData.data.forEach((trace, index)=>{
244
+ var _trace_xaxis;
245
+ const xAxisKey = (_trace_xaxis = trace.xaxis) !== null && _trace_xaxis !== void 0 ? _trace_xaxis : DEFAULT_XAXIS;
246
+ if (!groupedTraces[xAxisKey]) {
247
+ groupedTraces[xAxisKey] = [];
248
+ }
249
+ groupedTraces[xAxisKey].push(index);
250
+ });
251
+ isMultiPlot.current = Object.keys(groupedTraces).length > 1;
252
+ const gridProperties = getGridProperties(plotlyInputWithValidData.layout, isMultiPlot.current);
253
+ const allupLegendsProps = getAllupLegendsProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme);
254
+ // map through the grouped traces and render the appropriate chart
255
+ return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement("div", {
256
+ style: {
257
+ display: 'grid',
258
+ gridTemplateRows: gridProperties.templateRows,
259
+ gridTemplateColumns: gridProperties.templateColumns
260
+ }
261
+ }, Object.entries(groupedTraces).map(([xAxisKey, index])=>{
262
+ const plotlyInputForGroup = {
263
+ ...plotlyInputWithValidData,
264
+ data: index.map((idx)=>plotlyInputWithValidData.data[idx])
265
+ };
266
+ const filteredTracesInfo = validTracesFilteredIndex.filter((trace)=>index.includes(trace[0]));
267
+ let chartType = validTracesFilteredIndex.some((trace)=>trace[1] === FALLBACK_TYPE) || chart.type === FALLBACK_TYPE ? FALLBACK_TYPE : filteredTracesInfo[0][1];
268
+ if (validTracesFilteredIndex.some((trace)=>trace[1] === 'line') && validTracesFilteredIndex.some((trace)=>trace[1] === 'scatter')) {
269
+ chartType = 'line';
270
+ }
271
+ const chartEntry = chartMap[chartType];
272
+ if (chartEntry) {
273
+ const { transformer, renderer, preTransformCondition, preTransformOperation } = chartEntry;
274
+ if (preTransformCondition === undefined || preTransformCondition(plotlyInputForGroup)) {
275
+ const transformedInput = preTransformOperation ? preTransformOperation(plotlyInputForGroup) : plotlyInputForGroup;
276
+ const cellProperties = gridProperties.layout[xAxisKey];
277
+ var _cellProperties_row, _cellProperties_column;
278
+ return renderChart(renderer, transformer, [
279
+ transformedInput,
280
+ isMultiPlot.current,
281
+ colorMap,
282
+ props.colorwayType,
283
+ isDarkTheme
284
+ ], {
285
+ ...commonProps,
286
+ xAxisAnnotation: cellProperties === null || cellProperties === void 0 ? void 0 : cellProperties.xAnnotation,
287
+ yAxisAnnotation: cellProperties === null || cellProperties === void 0 ? void 0 : cellProperties.yAnnotation
288
+ }, (_cellProperties_row = cellProperties === null || cellProperties === void 0 ? void 0 : cellProperties.row) !== null && _cellProperties_row !== void 0 ? _cellProperties_row : 1, (_cellProperties_column = cellProperties === null || cellProperties === void 0 ? void 0 : cellProperties.column) !== null && _cellProperties_column !== void 0 ? _cellProperties_column : 1);
289
+ }
290
+ return /*#__PURE__*/ React.createElement(React.Fragment, null);
291
+ } else {
292
+ var _plotlyInputForGroup_data_;
293
+ throw new Error(`Unsupported chart type :${(_plotlyInputForGroup_data_ = plotlyInputForGroup.data[0]) === null || _plotlyInputForGroup_data_ === void 0 ? void 0 : _plotlyInputForGroup_data_.type}`);
294
+ }
295
+ })), isMultiPlot.current && createLegends(allupLegendsProps));
241
296
  });
242
297
  DeclarativeChart.displayName = 'DeclarativeChart';
243
298
  DeclarativeChart.defaultProps = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/DeclarativeChart/DeclarativeChart.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\nimport * as React from 'react';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport type { Data, PlotData, PlotlySchema, OutputChartType } from '@fluentui/chart-utilities';\nimport {\n decodeBase64Fields,\n isArrayOrTypedArray,\n isDateArray,\n isMonthArray,\n isNumberArray,\n isYearArray,\n mapFluentChart,\n sanitizeJson,\n} from '@fluentui/chart-utilities';\nimport { tokens } from '@fluentui/react-theme';\nimport { ThemeContext_unstable as V9ThemeContext } from '@fluentui/react-shared-contexts';\nimport { Theme, webLightTheme } from '@fluentui/tokens';\nimport * as d3Color from 'd3-color';\n\nimport {\n correctYearMonth,\n transformPlotlyJsonToDonutProps,\n transformPlotlyJsonToVSBCProps,\n transformPlotlyJsonToScatterChartProps,\n transformPlotlyJsonToHorizontalBarWithAxisProps,\n transformPlotlyJsonToHeatmapProps,\n transformPlotlyJsonToSankeyProps,\n transformPlotlyJsonToGaugeProps,\n transformPlotlyJsonToGVBCProps,\n transformPlotlyJsonToVBCProps,\n transformPlotlyJsonToChartTableProps,\n projectPolarToCartesian,\n isStringArray,\n} from './PlotlySchemaAdapter';\nimport type { ColorwayType } from './PlotlyColorAdapter';\nimport { DonutChart } from '../DonutChart/index';\nimport { VerticalStackedBarChart } from '../VerticalStackedBarChart/index';\nimport { LineChart, LineChartProps } from '../LineChart/index';\nimport { HorizontalBarChartWithAxis } from '../HorizontalBarChartWithAxis/index';\nimport { AreaChart, AreaChartProps } from '../AreaChart/index';\nimport { HeatMapChart } from '../HeatMapChart/index';\nimport { SankeyChart } from '../SankeyChart/SankeyChart';\nimport { GaugeChart } from '../GaugeChart/index';\nimport { GroupedVerticalBarChart } from '../GroupedVerticalBarChart/index';\nimport { VerticalBarChart } from '../VerticalBarChart/index';\nimport { Chart, ImageExportOptions } from '../../types/index';\nimport { ScatterChart, ScatterChartProps } from '../ScatterChart/index';\n\nimport { withResponsiveContainer } from '../ResponsiveContainer/withResponsiveContainer';\nimport { ChartTable } from '../ChartTable/index';\n\nconst ResponsiveDonutChart = withResponsiveContainer(DonutChart);\nconst ResponsiveVerticalStackedBarChart = withResponsiveContainer(VerticalStackedBarChart);\nconst ResponsiveLineChart = withResponsiveContainer(LineChart);\nconst ResponsiveHorizontalBarChartWithAxis = withResponsiveContainer(HorizontalBarChartWithAxis);\nconst ResponsiveAreaChart = withResponsiveContainer(AreaChart);\nconst ResponsiveHeatMapChart = withResponsiveContainer(HeatMapChart);\nconst ResponsiveSankeyChart = withResponsiveContainer(SankeyChart);\nconst ResponsiveGaugeChart = withResponsiveContainer(GaugeChart);\nconst ResponsiveGroupedVerticalBarChart = withResponsiveContainer(GroupedVerticalBarChart);\nconst ResponsiveVerticalBarChart = withResponsiveContainer(VerticalBarChart);\nconst ResponsiveScatterChart = withResponsiveContainer(ScatterChart);\nconst ResponsiveChartTable = withResponsiveContainer(ChartTable);\n\n/**\n * DeclarativeChart schema.\n * {@docCategory DeclarativeChart}\n */\nexport interface Schema {\n /**\n * Plotly schema represented as JSON object\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n plotlySchema: any;\n}\n\n/**\n * DeclarativeChart props.\n * {@docCategory DeclarativeChart}\n */\nexport interface DeclarativeChartProps extends React.RefAttributes<HTMLDivElement> {\n /**\n * The schema representing the chart data, layout and configuration\n */\n chartSchema: Schema;\n\n /**\n * Callback when an event occurs\n */\n onSchemaChange?: (eventData: Schema) => void;\n\n /**\n * Optional callback to access the IDeclarativeChart interface. Use this instead of ref for accessing\n * the public methods and properties of the component.\n */\n componentRef?: React.RefObject<IDeclarativeChart>;\n\n /**\n * Optional prop to specify the colorway type of the chart.\n * - 'default': Use Fluent UI color palette aligning with plotly colorway.\n * - 'builtin': Use Fluent UI colorway.\n * - 'others': Reserved for future colorways.\n * @default 'default'\n */\n colorwayType?: ColorwayType;\n}\n\n/**\n * {@docCategory DeclarativeChart}\n */\nexport interface IDeclarativeChart {\n exportAsImage: (opts?: ImageExportOptions) => Promise<string>;\n}\n\nconst useColorMapping = () => {\n const colorMap = React.useRef(new Map<string, string>());\n return colorMap;\n};\n\nconst useIsDarkTheme = (): boolean => {\n const parentV9Theme = React.useContext(V9ThemeContext) as Theme;\n const v9Theme: Theme = parentV9Theme ? parentV9Theme : webLightTheme;\n\n // Get background and foreground colors\n const backgroundColor = d3Color.hsl(v9Theme.colorNeutralBackground1);\n const foregroundColor = d3Color.hsl(v9Theme.colorNeutralForeground1);\n\n const isDarkTheme = backgroundColor.l < foregroundColor.l;\n\n return isDarkTheme;\n};\n\n/**\n * DeclarativeChart component.\n * {@docCategory DeclarativeChart}\n */\nexport const DeclarativeChart: React.FunctionComponent<DeclarativeChartProps> = React.forwardRef<\n HTMLDivElement,\n DeclarativeChartProps\n>((props, forwardedRef) => {\n const { plotlySchema } = sanitizeJson(props.chartSchema);\n const chart: OutputChartType = mapFluentChart(plotlySchema);\n if (!chart.isValid) {\n throw new Error(`Invalid chart schema: ${chart.errorMessage}`);\n }\n let plotlyInput = plotlySchema as PlotlySchema;\n try {\n plotlyInput = decodeBase64Fields(plotlyInput);\n } catch (error) {\n throw new Error(`Failed to decode plotly schema: ${error}`);\n }\n const plotlyInputWithValidData: PlotlySchema = {\n ...plotlyInput,\n data: chart.validTracesInfo!.map(trace => plotlyInput.data[trace.index]),\n };\n\n let { selectedLegends } = plotlySchema;\n const colorMap = useColorMapping();\n const isDarkTheme = useIsDarkTheme();\n const chartRef = React.useRef<Chart>(null);\n\n if (!isArrayOrTypedArray(selectedLegends)) {\n selectedLegends = [];\n }\n\n const [activeLegends, setActiveLegends] = React.useState<string[]>(selectedLegends);\n const onActiveLegendsChange = (keys: string[]) => {\n setActiveLegends(keys);\n if (props.onSchemaChange) {\n props.onSchemaChange({ plotlySchema: { plotlyInput, selectedLegends: keys } });\n }\n };\n\n React.useEffect(() => {\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const { plotlySchema } = sanitizeJson(props.chartSchema);\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const { selectedLegends } = plotlySchema;\n setActiveLegends(selectedLegends ?? []);\n }, [props.chartSchema]);\n\n const multiSelectLegendProps = {\n canSelectMultipleLegends: true,\n onChange: onActiveLegendsChange,\n selectedLegends: activeLegends,\n };\n\n const commonProps = {\n legendProps: multiSelectLegendProps,\n componentRef: chartRef,\n };\n\n const renderLineAreaScatter = (plotlyData: Data[], isAreaChart: boolean, isScatterChart: boolean): JSXElement => {\n const isScatterMarkers = [\n 'text+markers',\n 'markers+text',\n 'lines+markers',\n 'markers+line',\n 'text+lines+markers',\n ].includes((plotlyData[0] as PlotData)?.mode);\n const chartType = isAreaChart ? 'area' : isScatterChart ? 'scatter' : 'line';\n const chartProps: LineChartProps | AreaChartProps | ScatterChartProps = {\n ...transformPlotlyJsonToScatterChartProps(\n { data: plotlyData, layout: plotlyInput.layout },\n chartType,\n isScatterMarkers,\n colorMap,\n props.colorwayType,\n isDarkTheme,\n ),\n ...commonProps,\n };\n if (isAreaChart) {\n return <ResponsiveAreaChart {...chartProps} />;\n }\n if (isScatterChart) {\n return <ResponsiveScatterChart {...(chartProps as ScatterChartProps)} />;\n }\n return <ResponsiveLineChart {...chartProps} />;\n };\n\n const checkAndRenderChart = (isAreaChart: boolean = false) => {\n let fallbackVSBC = false;\n const xValues = (plotlyInputWithValidData.data[0] as PlotData).x;\n const isXDate = isDateArray(xValues);\n const isXNumber = isNumberArray(xValues);\n const isXMonth = isMonthArray(xValues);\n const isYString = isStringArray((plotlyInputWithValidData.data[0] as Partial<PlotData>).y);\n\n // Consider year as categorical variable not numeric continuous variable\n // Also year is not considered a date variable as it is represented as a point\n // in time and brings additional complexity of handling timezone and locale\n // formatting given the current design of the charting library\n const isXYear = isYearArray(xValues);\n\n const allModes = plotlyInputWithValidData.data.map((data: PlotData) => data.mode);\n const isScatterChart = allModes.every((mode: string) => mode === 'markers');\n // If x is date or number and y is not string, render as Line/Area Chart\n // If x is month, correct the year and render as Line/Area Chart\n if (((isXDate || isXNumber) && !isXYear && !isYString) || (isScatterChart && !isYString)) {\n return renderLineAreaScatter(plotlyInputWithValidData.data, isAreaChart, isScatterChart);\n } else if (isXMonth) {\n const updatedData = plotlyInputWithValidData.data.map((dataPoint: PlotData) => ({\n ...dataPoint,\n x: correctYearMonth(dataPoint.x),\n }));\n return renderLineAreaScatter(updatedData, isAreaChart, isScatterChart);\n }\n // Unsupported schema, render as VerticalStackedBarChart\n fallbackVSBC = true;\n return (\n <ResponsiveVerticalStackedBarChart\n {...transformPlotlyJsonToVSBCProps(\n plotlyInputWithValidData,\n colorMap,\n props.colorwayType,\n isDarkTheme,\n fallbackVSBC,\n )}\n {...commonProps}\n />\n );\n };\n\n // TODO\n const exportAsImage = React.useCallback((opts?: ImageExportOptions): Promise<string> => {\n return new Promise((resolve, reject) => {\n if (!chartRef.current || typeof chartRef.current.toImage !== 'function') {\n return reject(Error('Chart cannot be exported as image'));\n }\n\n chartRef.current\n .toImage({\n background: tokens.colorNeutralBackground1,\n scale: 5,\n ...opts,\n })\n .then(resolve)\n .catch(reject);\n });\n }, []);\n\n React.useImperativeHandle(\n props.componentRef,\n () => ({\n exportAsImage,\n }),\n [exportAsImage],\n );\n\n switch (chart.type) {\n case 'donut':\n return (\n <ResponsiveDonutChart\n {...transformPlotlyJsonToDonutProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme)}\n {...commonProps}\n />\n );\n case 'horizontalbar':\n return (\n <ResponsiveHorizontalBarChartWithAxis\n {...transformPlotlyJsonToHorizontalBarWithAxisProps(\n plotlyInputWithValidData,\n colorMap,\n props.colorwayType,\n isDarkTheme,\n )}\n {...commonProps}\n />\n );\n case 'groupedverticalbar':\n return (\n <ResponsiveGroupedVerticalBarChart\n {...transformPlotlyJsonToGVBCProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme)}\n {...commonProps}\n />\n );\n case 'verticalstackedbar':\n return (\n <ResponsiveVerticalStackedBarChart\n {...transformPlotlyJsonToVSBCProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme)}\n {...commonProps}\n />\n );\n case 'heatmap':\n return (\n <ResponsiveHeatMapChart\n {...transformPlotlyJsonToHeatmapProps(plotlyInputWithValidData)}\n {...commonProps}\n legendProps={{}}\n />\n );\n case 'sankey':\n return (\n <ResponsiveSankeyChart\n {...transformPlotlyJsonToSankeyProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme)}\n {...commonProps}\n />\n );\n case 'gauge':\n return (\n <ResponsiveGaugeChart\n {...transformPlotlyJsonToGaugeProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme)}\n {...commonProps}\n />\n );\n case 'verticalbar':\n return (\n <ResponsiveVerticalBarChart\n {...transformPlotlyJsonToVBCProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme)}\n {...commonProps}\n />\n );\n case 'table':\n return (\n <ResponsiveChartTable\n {...transformPlotlyJsonToChartTableProps(plotlyInputWithValidData, colorMap, isDarkTheme)}\n {...commonProps}\n />\n );\n // TODO: Add 'scatter' as a separate chart type\n case 'area':\n case 'line':\n case 'fallback':\n case 'scatterpolar':\n case 'scatter':\n if (chart.type === 'scatterpolar') {\n const cartesianProjection = projectPolarToCartesian(plotlyInputWithValidData);\n plotlyInputWithValidData.data = cartesianProjection.data;\n }\n // Need recheck for area chart as we don't have ability to check for valid months in previous step\n const isAreaChart = plotlyInputWithValidData.data.some(\n (series: PlotData) => series.fill === 'tonexty' || series.fill === 'tozeroy' || !!series.stackgroup,\n );\n return checkAndRenderChart(isAreaChart);\n default:\n throw new Error(`Unsupported chart type :${plotlyInputWithValidData.data[0]?.type}`);\n }\n});\nDeclarativeChart.displayName = 'DeclarativeChart';\nDeclarativeChart.defaultProps = {\n colorwayType: 'default',\n};\n"],"names":["React","decodeBase64Fields","isArrayOrTypedArray","isDateArray","isMonthArray","isNumberArray","isYearArray","mapFluentChart","sanitizeJson","tokens","ThemeContext_unstable","V9ThemeContext","webLightTheme","d3Color","correctYearMonth","transformPlotlyJsonToDonutProps","transformPlotlyJsonToVSBCProps","transformPlotlyJsonToScatterChartProps","transformPlotlyJsonToHorizontalBarWithAxisProps","transformPlotlyJsonToHeatmapProps","transformPlotlyJsonToSankeyProps","transformPlotlyJsonToGaugeProps","transformPlotlyJsonToGVBCProps","transformPlotlyJsonToVBCProps","transformPlotlyJsonToChartTableProps","projectPolarToCartesian","isStringArray","DonutChart","VerticalStackedBarChart","LineChart","HorizontalBarChartWithAxis","AreaChart","HeatMapChart","SankeyChart","GaugeChart","GroupedVerticalBarChart","VerticalBarChart","ScatterChart","withResponsiveContainer","ChartTable","ResponsiveDonutChart","ResponsiveVerticalStackedBarChart","ResponsiveLineChart","ResponsiveHorizontalBarChartWithAxis","ResponsiveAreaChart","ResponsiveHeatMapChart","ResponsiveSankeyChart","ResponsiveGaugeChart","ResponsiveGroupedVerticalBarChart","ResponsiveVerticalBarChart","ResponsiveScatterChart","ResponsiveChartTable","useColorMapping","colorMap","useRef","Map","useIsDarkTheme","parentV9Theme","useContext","v9Theme","backgroundColor","hsl","colorNeutralBackground1","foregroundColor","colorNeutralForeground1","isDarkTheme","l","DeclarativeChart","forwardRef","props","forwardedRef","plotlySchema","chartSchema","chart","isValid","Error","errorMessage","plotlyInput","error","plotlyInputWithValidData","data","validTracesInfo","map","trace","index","selectedLegends","chartRef","activeLegends","setActiveLegends","useState","onActiveLegendsChange","keys","onSchemaChange","useEffect","multiSelectLegendProps","canSelectMultipleLegends","onChange","commonProps","legendProps","componentRef","renderLineAreaScatter","plotlyData","isAreaChart","isScatterChart","isScatterMarkers","includes","mode","chartType","chartProps","layout","colorwayType","checkAndRenderChart","fallbackVSBC","xValues","x","isXDate","isXNumber","isXMonth","isYString","y","isXYear","allModes","every","updatedData","dataPoint","exportAsImage","useCallback","opts","Promise","resolve","reject","current","toImage","background","scale","then","catch","useImperativeHandle","type","cartesianProjection","some","series","fill","stackgroup","displayName","defaultProps"],"mappings":"AAAA,uDAAuD,GACvD,YAAYA,WAAW,QAAQ;AAG/B,SACEC,kBAAkB,EAClBC,mBAAmB,EACnBC,WAAW,EACXC,YAAY,EACZC,aAAa,EACbC,WAAW,EACXC,cAAc,EACdC,YAAY,QACP,4BAA4B;AACnC,SAASC,MAAM,QAAQ,wBAAwB;AAC/C,SAASC,yBAAyBC,cAAc,QAAQ,kCAAkC;AAC1F,SAAgBC,aAAa,QAAQ,mBAAmB;AACxD,YAAYC,aAAa,WAAW;AAEpC,SACEC,gBAAgB,EAChBC,+BAA+B,EAC/BC,8BAA8B,EAC9BC,sCAAsC,EACtCC,+CAA+C,EAC/CC,iCAAiC,EACjCC,gCAAgC,EAChCC,+BAA+B,EAC/BC,8BAA8B,EAC9BC,6BAA6B,EAC7BC,oCAAoC,EACpCC,uBAAuB,EACvBC,aAAa,QACR,wBAAwB;AAE/B,SAASC,UAAU,QAAQ,sBAAsB;AACjD,SAASC,uBAAuB,QAAQ,mCAAmC;AAC3E,SAASC,SAAS,QAAwB,qBAAqB;AAC/D,SAASC,0BAA0B,QAAQ,sCAAsC;AACjF,SAASC,SAAS,QAAwB,qBAAqB;AAC/D,SAASC,YAAY,QAAQ,wBAAwB;AACrD,SAASC,WAAW,QAAQ,6BAA6B;AACzD,SAASC,UAAU,QAAQ,sBAAsB;AACjD,SAASC,uBAAuB,QAAQ,mCAAmC;AAC3E,SAASC,gBAAgB,QAAQ,4BAA4B;AAE7D,SAASC,YAAY,QAA2B,wBAAwB;AAExE,SAASC,uB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,cAAc;AAChB"}
1
+ {"version":3,"sources":["../src/components/DeclarativeChart/DeclarativeChart.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\nimport * as React from 'react';\nimport type { PlotData, PlotlySchema, OutputChartType } from '@fluentui/chart-utilities';\nimport {\n decodeBase64Fields,\n isArrayOrTypedArray,\n isMonthArray,\n mapFluentChart,\n sanitizeJson,\n} from '@fluentui/chart-utilities';\nimport type { GridProperties } from './PlotlySchemaAdapter';\nimport { tokens } from '@fluentui/react-theme';\nimport { ThemeContext_unstable as V9ThemeContext } from '@fluentui/react-shared-contexts';\nimport { Theme, webLightTheme } from '@fluentui/tokens';\nimport * as d3Color from 'd3-color';\n\nimport {\n correctYearMonth,\n getGridProperties,\n transformPlotlyJsonToDonutProps,\n transformPlotlyJsonToVSBCProps,\n transformPlotlyJsonToAreaChartProps,\n transformPlotlyJsonToLineChartProps,\n transformPlotlyJsonToHorizontalBarWithAxisProps,\n transformPlotlyJsonToHeatmapProps,\n transformPlotlyJsonToSankeyProps,\n transformPlotlyJsonToGaugeProps,\n transformPlotlyJsonToGVBCProps,\n transformPlotlyJsonToVBCProps,\n transformPlotlyJsonToChartTableProps,\n transformPlotlyJsonToScatterChartProps,\n projectPolarToCartesian,\n getAllupLegendsProps,\n} from './PlotlySchemaAdapter';\nimport type { ColorwayType } from './PlotlyColorAdapter';\nimport { DonutChart } from '../DonutChart/index';\nimport { VerticalStackedBarChart } from '../VerticalStackedBarChart/index';\nimport { LineChart } from '../LineChart/index';\nimport { HorizontalBarChartWithAxis } from '../HorizontalBarChartWithAxis/index';\nimport { AreaChart } from '../AreaChart/index';\nimport { HeatMapChart } from '../HeatMapChart/index';\nimport { SankeyChart } from '../SankeyChart/SankeyChart';\nimport { GaugeChart } from '../GaugeChart/index';\nimport { GroupedVerticalBarChart } from '../GroupedVerticalBarChart/index';\nimport { VerticalBarChart } from '../VerticalBarChart/index';\nimport { Chart, ImageExportOptions } from '../../types/index';\nimport { ScatterChart } from '../ScatterChart/index';\n\nimport { withResponsiveContainer } from '../ResponsiveContainer/withResponsiveContainer';\nimport { ChartTable } from '../ChartTable/index';\nimport { LegendsProps, Legends } from '../Legends/index';\nimport { JSXElement } from '@fluentui/react-utilities/src/index';\n\nconst ResponsiveDonutChart = withResponsiveContainer(DonutChart);\nconst ResponsiveVerticalStackedBarChart = withResponsiveContainer(VerticalStackedBarChart);\nconst ResponsiveLineChart = withResponsiveContainer(LineChart);\nconst ResponsiveHorizontalBarChartWithAxis = withResponsiveContainer(HorizontalBarChartWithAxis);\nconst ResponsiveAreaChart = withResponsiveContainer(AreaChart);\nconst ResponsiveHeatMapChart = withResponsiveContainer(HeatMapChart);\nconst ResponsiveSankeyChart = withResponsiveContainer(SankeyChart);\nconst ResponsiveGaugeChart = withResponsiveContainer(GaugeChart);\nconst ResponsiveGroupedVerticalBarChart = withResponsiveContainer(GroupedVerticalBarChart);\nconst ResponsiveVerticalBarChart = withResponsiveContainer(VerticalBarChart);\nconst ResponsiveScatterChart = withResponsiveContainer(ScatterChart);\nconst ResponsiveChartTable = withResponsiveContainer(ChartTable);\n\n// Default x-axis key for grouping traces. Also applicable for PieData and SankeyData where x-axis is not defined.\nconst DEFAULT_XAXIS = 'x';\nconst FALLBACK_TYPE = 'fallback';\n\n/**\n * DeclarativeChart schema.\n * {@docCategory DeclarativeChart}\n */\nexport interface Schema {\n /**\n * Plotly schema represented as JSON object\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n plotlySchema: any;\n}\n\n/**\n * DeclarativeChart props.\n * {@docCategory DeclarativeChart}\n */\nexport interface DeclarativeChartProps extends React.RefAttributes<HTMLDivElement> {\n /**\n * The schema representing the chart data, layout and configuration\n */\n chartSchema: Schema;\n\n /**\n * Callback when an event occurs\n */\n onSchemaChange?: (eventData: Schema) => void;\n\n /**\n * Optional callback to access the IDeclarativeChart interface. Use this instead of ref for accessing\n * the public methods and properties of the component.\n */\n componentRef?: React.RefObject<IDeclarativeChart>;\n\n /**\n * Optional prop to specify the colorway type of the chart.\n * - 'default': Use Fluent UI color palette aligning with plotly colorway.\n * - 'builtin': Use Fluent UI colorway.\n * - 'others': Reserved for future colorways.\n * @default 'default'\n */\n colorwayType?: ColorwayType;\n}\n\n/**\n * {@docCategory DeclarativeChart}\n */\nexport interface IDeclarativeChart {\n exportAsImage: (opts?: ImageExportOptions) => Promise<string>;\n}\n\nconst useColorMapping = () => {\n const colorMap = React.useRef(new Map<string, string>());\n return colorMap;\n};\n\nfunction renderChart<TProps>(\n Renderer: React.ComponentType<TProps>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n transformer: (...args: any[]) => TProps,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n transformerArgs: any[],\n commonProps: Partial<TProps>,\n cellRow: number,\n cellColumn: number,\n): JSXElement {\n const chartProps = transformer(...transformerArgs);\n return (\n <div\n key={`${cellRow}_${cellColumn}`}\n style={{\n gridRowStart: cellRow,\n gridRowEnd: cellRow + 1,\n gridColumnStart: cellColumn,\n gridColumnEnd: cellColumn + 1,\n }}\n >\n <Renderer {...chartProps} {...commonProps} />\n </div>\n );\n}\n\ntype PreTransformHooks = {\n preTransformCondition?: (plotlySchema: PlotlySchema) => boolean;\n preTransformOperation?: (plotlySchema: PlotlySchema) => PlotlySchema;\n};\n\nconst LineAreaPreTransformOp = (plotlyInput: PlotlySchema) => {\n const xValues = (plotlyInput.data[0] as PlotData).x;\n const isXMonth = isMonthArray(xValues);\n let renderData = plotlyInput.data;\n if (isXMonth) {\n renderData = plotlyInput.data.map((dataPoint: PlotData) => ({\n ...dataPoint,\n x: correctYearMonth(dataPoint.x),\n }));\n }\n return { data: renderData, layout: plotlyInput.layout };\n};\n\ntype ChartTypeMap = {\n donut: {\n transformer: typeof transformPlotlyJsonToDonutProps;\n renderer: typeof ResponsiveDonutChart;\n } & PreTransformHooks;\n sankey: {\n transformer: typeof transformPlotlyJsonToSankeyProps;\n renderer: typeof ResponsiveSankeyChart;\n } & PreTransformHooks;\n table: {\n transformer: typeof transformPlotlyJsonToChartTableProps;\n renderer: typeof ResponsiveChartTable;\n } & PreTransformHooks;\n horizontalbar: {\n transformer: typeof transformPlotlyJsonToHorizontalBarWithAxisProps;\n renderer: typeof ResponsiveHorizontalBarChartWithAxis;\n } & PreTransformHooks;\n groupedverticalbar: {\n transformer: typeof transformPlotlyJsonToGVBCProps;\n renderer: typeof ResponsiveGroupedVerticalBarChart;\n } & PreTransformHooks;\n verticalstackedbar: {\n transformer: typeof transformPlotlyJsonToVSBCProps;\n renderer: typeof ResponsiveVerticalStackedBarChart;\n } & PreTransformHooks;\n heatmap: {\n transformer: typeof transformPlotlyJsonToHeatmapProps;\n renderer: typeof ResponsiveHeatMapChart;\n } & PreTransformHooks;\n gauge: {\n transformer: typeof transformPlotlyJsonToGaugeProps;\n renderer: typeof ResponsiveGaugeChart;\n } & PreTransformHooks;\n verticalbar: {\n transformer: typeof transformPlotlyJsonToVBCProps;\n renderer: typeof ResponsiveVerticalBarChart;\n } & PreTransformHooks;\n area: {\n transformer: typeof transformPlotlyJsonToAreaChartProps;\n renderer: typeof ResponsiveAreaChart;\n } & PreTransformHooks;\n line: {\n transformer: typeof transformPlotlyJsonToLineChartProps;\n renderer: typeof ResponsiveLineChart;\n } & PreTransformHooks;\n scatter: {\n transformer: typeof transformPlotlyJsonToScatterChartProps;\n renderer: typeof ResponsiveScatterChart;\n } & PreTransformHooks;\n fallback: {\n transformer: typeof transformPlotlyJsonToVSBCProps;\n renderer: typeof ResponsiveVerticalStackedBarChart;\n } & PreTransformHooks;\n};\n\nconst chartMap: ChartTypeMap = {\n // PieData category charts\n donut: {\n transformer: transformPlotlyJsonToDonutProps,\n renderer: ResponsiveDonutChart,\n },\n // SankeyData category charts\n sankey: {\n transformer: transformPlotlyJsonToSankeyProps,\n renderer: ResponsiveSankeyChart,\n },\n // TableData category charts\n table: {\n transformer: transformPlotlyJsonToChartTableProps,\n renderer: ResponsiveChartTable,\n },\n // PlotData category charts\n horizontalbar: {\n transformer: transformPlotlyJsonToHorizontalBarWithAxisProps,\n renderer: ResponsiveHorizontalBarChartWithAxis,\n },\n groupedverticalbar: {\n transformer: transformPlotlyJsonToGVBCProps,\n renderer: ResponsiveGroupedVerticalBarChart,\n },\n verticalstackedbar: {\n transformer: transformPlotlyJsonToVSBCProps,\n renderer: ResponsiveVerticalStackedBarChart,\n },\n heatmap: {\n transformer: transformPlotlyJsonToHeatmapProps,\n renderer: ResponsiveHeatMapChart,\n },\n gauge: {\n transformer: transformPlotlyJsonToGaugeProps,\n renderer: ResponsiveGaugeChart,\n },\n verticalbar: {\n transformer: transformPlotlyJsonToVBCProps,\n renderer: ResponsiveVerticalBarChart,\n },\n area: {\n transformer: transformPlotlyJsonToAreaChartProps,\n renderer: ResponsiveAreaChart,\n preTransformOperation: LineAreaPreTransformOp,\n },\n line: {\n transformer: transformPlotlyJsonToLineChartProps,\n renderer: ResponsiveLineChart,\n preTransformOperation: LineAreaPreTransformOp,\n },\n scatter: {\n transformer: transformPlotlyJsonToScatterChartProps,\n renderer: ResponsiveScatterChart,\n preTransformOperation: LineAreaPreTransformOp,\n },\n fallback: {\n transformer: transformPlotlyJsonToVSBCProps,\n renderer: ResponsiveVerticalStackedBarChart,\n },\n};\n\nconst useIsDarkTheme = (): boolean => {\n const parentV9Theme = React.useContext(V9ThemeContext) as Theme;\n const v9Theme: Theme = parentV9Theme ? parentV9Theme : webLightTheme;\n\n // Get background and foreground colors\n const backgroundColor = d3Color.hsl(v9Theme.colorNeutralBackground1);\n const foregroundColor = d3Color.hsl(v9Theme.colorNeutralForeground1);\n\n const isDarkTheme = backgroundColor.l < foregroundColor.l;\n\n return isDarkTheme;\n};\n\n/**\n * DeclarativeChart component.\n * {@docCategory DeclarativeChart}\n */\nexport const DeclarativeChart: React.FunctionComponent<DeclarativeChartProps> = React.forwardRef<\n HTMLDivElement,\n DeclarativeChartProps\n>((props, forwardedRef) => {\n const { plotlySchema } = sanitizeJson(props.chartSchema);\n const chart: OutputChartType = mapFluentChart(plotlySchema);\n if (!chart.isValid) {\n throw new Error(`Invalid chart schema: ${chart.errorMessage}`);\n }\n let plotlyInput = plotlySchema as PlotlySchema;\n try {\n plotlyInput = decodeBase64Fields(plotlyInput);\n } catch (error) {\n throw new Error(`Failed to decode plotly schema: ${error}`);\n }\n const plotlyInputWithValidData: PlotlySchema = {\n ...plotlyInput,\n data: chart.validTracesInfo!.map(trace => plotlyInput.data[trace.index]),\n };\n\n const validTracesFilteredIndex: [number, string][] = chart.validTracesInfo!.map((trace, index) => [\n index,\n trace.type,\n ]);\n\n let { selectedLegends } = plotlySchema;\n const colorMap = useColorMapping();\n const isDarkTheme = useIsDarkTheme();\n const chartRef = React.useRef<Chart>(null);\n const isMultiPlot = React.useRef(false);\n\n if (!isArrayOrTypedArray(selectedLegends)) {\n selectedLegends = [];\n }\n\n const [activeLegends, setActiveLegends] = React.useState<string[]>(selectedLegends);\n const onActiveLegendsChange = (keys: string[]) => {\n setActiveLegends(keys);\n if (props.onSchemaChange) {\n props.onSchemaChange({ plotlySchema: { plotlyInput, selectedLegends: keys } });\n }\n };\n\n React.useEffect(() => {\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const { plotlySchema } = sanitizeJson(props.chartSchema);\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const { selectedLegends } = plotlySchema;\n setActiveLegends(selectedLegends ?? []);\n }, [props.chartSchema]);\n\n const multiSelectLegendProps = {\n canSelectMultipleLegends: true,\n onChange: onActiveLegendsChange,\n selectedLegends: activeLegends,\n };\n\n const commonProps = {\n legendProps: multiSelectLegendProps,\n componentRef: chartRef,\n };\n\n function createLegends(legendProps: LegendsProps): JSXElement {\n // eslint-disable-next-line react/jsx-no-bind\n return <Legends {...legendProps} selectedLegends={activeLegends} onChange={onActiveLegendsChange} />;\n }\n\n // TODO\n const exportAsImage = React.useCallback((opts?: ImageExportOptions): Promise<string> => {\n return new Promise((resolve, reject) => {\n if (isMultiPlot.current) {\n return reject(Error('Exporting multi plot charts as image is not supported'));\n }\n if (!chartRef.current || typeof chartRef.current.toImage !== 'function') {\n return reject(Error('Chart cannot be exported as image'));\n }\n\n chartRef.current\n .toImage({\n background: tokens.colorNeutralBackground1,\n scale: 5,\n ...opts,\n })\n .then(resolve)\n .catch(reject);\n });\n }, []);\n\n React.useImperativeHandle(\n props.componentRef,\n () => ({\n exportAsImage,\n }),\n [exportAsImage],\n );\n\n if (chart.type === 'scatterpolar') {\n const cartesianProjection = projectPolarToCartesian(plotlyInputWithValidData);\n plotlyInputWithValidData.data = cartesianProjection.data;\n validTracesFilteredIndex.forEach((trace, index) => {\n if (trace[1] === 'scatterpolar') {\n validTracesFilteredIndex[index][1] = 'line'; // Change type to line for rendering\n }\n });\n }\n const groupedTraces: Record<string, number[]> = {};\n plotlyInputWithValidData.data.forEach((trace: Partial<PlotData>, index) => {\n const xAxisKey = trace.xaxis ?? DEFAULT_XAXIS;\n if (!groupedTraces[xAxisKey]) {\n groupedTraces[xAxisKey] = [];\n }\n groupedTraces[xAxisKey].push(index);\n });\n\n isMultiPlot.current = Object.keys(groupedTraces).length > 1;\n const gridProperties: GridProperties = getGridProperties(plotlyInputWithValidData.layout, isMultiPlot.current);\n\n const allupLegendsProps = getAllupLegendsProps(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme);\n\n type ChartType = keyof ChartTypeMap;\n // map through the grouped traces and render the appropriate chart\n return (\n <>\n <div\n style={{\n display: 'grid',\n gridTemplateRows: gridProperties.templateRows,\n gridTemplateColumns: gridProperties.templateColumns,\n }}\n >\n {Object.entries(groupedTraces).map(([xAxisKey, index]) => {\n const plotlyInputForGroup: PlotlySchema = {\n ...plotlyInputWithValidData,\n data: index.map(idx => plotlyInputWithValidData.data[idx]),\n };\n\n const filteredTracesInfo = validTracesFilteredIndex.filter(trace => index.includes(trace[0]));\n let chartType =\n validTracesFilteredIndex.some(trace => trace[1] === FALLBACK_TYPE) || chart.type === FALLBACK_TYPE\n ? FALLBACK_TYPE\n : filteredTracesInfo[0][1];\n\n if (\n validTracesFilteredIndex.some(trace => trace[1] === 'line') &&\n validTracesFilteredIndex.some(trace => trace[1] === 'scatter')\n ) {\n chartType = 'line';\n }\n\n const chartEntry = chartMap[chartType as ChartType];\n if (chartEntry) {\n const { transformer, renderer, preTransformCondition, preTransformOperation } = chartEntry;\n if (preTransformCondition === undefined || preTransformCondition(plotlyInputForGroup)) {\n const transformedInput = preTransformOperation\n ? preTransformOperation(plotlyInputForGroup)\n : plotlyInputForGroup;\n const cellProperties = gridProperties.layout[xAxisKey];\n\n return renderChart<ReturnType<typeof transformer>>(\n renderer,\n transformer,\n [transformedInput, isMultiPlot.current, colorMap, props.colorwayType, isDarkTheme],\n {\n ...commonProps,\n xAxisAnnotation: cellProperties?.xAnnotation,\n yAxisAnnotation: cellProperties?.yAnnotation,\n },\n cellProperties?.row ?? 1,\n cellProperties?.column ?? 1,\n );\n }\n return <></>;\n } else {\n throw new Error(`Unsupported chart type :${plotlyInputForGroup.data[0]?.type}`);\n }\n })}\n </div>\n {isMultiPlot.current && createLegends(allupLegendsProps)}\n </>\n );\n});\nDeclarativeChart.displayName = 'DeclarativeChart';\nDeclarativeChart.defaultProps = {\n colorwayType: 'default',\n};\n"],"names":["React","decodeBase64Fields","isArrayOrTypedArray","isMonthArray","mapFluentChart","sanitizeJson","tokens","ThemeContext_unstable","V9ThemeContext","webLightTheme","d3Color","correctYearMonth","getGridProperties","transformPlotlyJsonToDonutProps","transformPlotlyJsonToVSBCProps","transformPlotlyJsonToAreaChartProps","transformPlotlyJsonToLineChartProps","transformPlotlyJsonToHorizontalBarWithAxisProps","transformPlotlyJsonToHeatmapProps","transformPlotlyJsonToSankeyProps","transformPlotlyJsonToGaugeProps","transformPlotlyJsonToGVBCProps","transformPlotlyJsonToVBCProps","transformPlotlyJsonToChartTableProps","transformPlotlyJsonToScatterChartProps","projectPolarToCartesian","getAllupLegendsProps","DonutChart","VerticalStackedBarChart","LineChart","HorizontalBarChartWithAxis","AreaChart","HeatMapChart","SankeyChart","GaugeChart","GroupedVerticalBarChart","VerticalBarChart","ScatterChart","withResponsiveContainer","ChartTable","Legends","ResponsiveDonutChart","ResponsiveVerticalStackedBarChart","ResponsiveLineChart","ResponsiveHorizontalBarChartWithAxis","ResponsiveAreaChart","ResponsiveHeatMapChart","ResponsiveSankeyChart","ResponsiveGaugeChart","ResponsiveGroupedVerticalBarChart","ResponsiveVerticalBarChart","ResponsiveScatterChart","ResponsiveChartTable","DEFAULT_XAXIS","FALLBACK_TYPE","useColorMapping","colorMap","useRef","Map","renderChart","Renderer","transformer","transformerArgs","commonProps","cellRow","cellColumn","chartProps","div","key","style","gridRowStart","gridRowEnd","gridColumnStart","gridColumnEnd","LineAreaPreTransformOp","plotlyInput","xValues","data","x","isXMonth","renderData","map","dataPoint","layout","chartMap","donut","renderer","sankey","table","horizontalbar","groupedverticalbar","verticalstackedbar","heatmap","gauge","verticalbar","area","preTransformOperation","line","scatter","fallback","useIsDarkTheme","parentV9Theme","useContext","v9Theme","backgroundColor","hsl","colorNeutralBackground1","foregroundColor","colorNeutralForeground1","isDarkTheme","l","DeclarativeChart","forwardRef","props","forwardedRef","plotlySchema","chartSchema","chart","isValid","Error","errorMessage","error","plotlyInputWithValidData","validTracesInfo","trace","index","validTracesFilteredIndex","type","selectedLegends","chartRef","isMultiPlot","activeLegends","setActiveLegends","useState","onActiveLegendsChange","keys","onSchemaChange","useEffect","multiSelectLegendProps","canSelectMultipleLegends","onChange","legendProps","componentRef","createLegends","exportAsImage","useCallback","opts","Promise","resolve","reject","current","toImage","background","scale","then","catch","useImperativeHandle","cartesianProjection","forEach","groupedTraces","xAxisKey","xaxis","push","Object","length","gridProperties","allupLegendsProps","colorwayType","display","gridTemplateRows","templateRows","gridTemplateColumns","templateColumns","entries","plotlyInputForGroup","idx","filteredTracesInfo","filter","includes","chartType","some","chartEntry","preTransformCondition","undefined","transformedInput","cellProperties","xAxisAnnotation","xAnnotation","yAxisAnnotation","yAnnotation","row","column","displayName","defaultProps"],"mappings":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IE,YAAY;YACd,MAAM,EAAExH,WAAW,EAAEyB,QAAQ,EAAEgG,qBAAqB,EAAEtF,qBAAqB,EAAE,GAAGqF;YAChF,IAAIC,0BAA0BC,aAAaD,sBAAsBR,sBAAsB;gBACrF,MAAMU,mBAAmBxF,wBACrBA,sBAAsB8E,uBACtBA;gBACJ,MAAMW,iBAAiBpB,eAAelF,MAAM,CAAC6E,SAAS;oBAWpDyB,qBACAA;gBAVF,OAAO9H,YACL2B,UACAzB,aACA;oBAAC2H;oBAAkBtD,YAAYoB,OAAO;oBAAE9F;oBAAUyD,MAAMsD,YAAY;oBAAE1D;iBAAY,EAClF;oBACE,GAAG9C,WAAW;oBACd2H,eAAe,EAAED,2BAAAA,qCAAAA,eAAgBE,WAAW;oBAC5CC,eAAe,EAAEH,2BAAAA,qCAAAA,eAAgBI,WAAW;gBAC9C,GACAJ,CAAAA,sBAAAA,2BAAAA,qCAAAA,eAAgBK,GAAG,cAAnBL,iCAAAA,sBAAuB,GACvBA,CAAAA,yBAAAA,2BAAAA,qCAAAA,eAAgBM,MAAM,cAAtBN,oCAAAA,yBAA0B;YAE9B;YACA,qBAAO;QACT,OAAO;gBACsCX;YAA3C,MAAM,IAAIvD,MAAM,CAAC,wBAAwB,GAAEuD,6BAAAA,oBAAoBjG,IAAI,CAAC,EAAE,cAA3BiG,iDAAAA,2BAA6B/C,IAAI,EAAE;QAChF;IACF,KAEDG,YAAYoB,OAAO,IAAIP,cAAcuB;AAG5C,GAAG;AACHvD,iBAAiBiF,WAAW,GAAG;AAC/BjF,iBAAiBkF,YAAY,GAAG;IAC9B1B,cAAc;AAChB"}
@@ -84,7 +84,7 @@ export const extractColor = (colorway, colorwayType, colors, colorMap, isDarkThe
84
84
  };
85
85
  export const resolveColor = (extractedColors, index, legend, colorMap, isDarkTheme)=>{
86
86
  let color = '';
87
- if (extractedColors && isArrayOrTypedArray(extractedColors) && extractedColors[index]) {
87
+ if (extractedColors && isArrayOrTypedArray(extractedColors) && extractedColors.length > 0) {
88
88
  color = extractedColors[index % extractedColors.length];
89
89
  } else if (typeof extractedColors === 'string') {
90
90
  color = extractedColors;
@@ -93,3 +93,8 @@ export const resolveColor = (extractedColors, index, legend, colorMap, isDarkThe
93
93
  }
94
94
  return color;
95
95
  };
96
+ export const getOpacity = (series, index)=>{
97
+ var _series_marker, _series_marker1, _series_marker2, _series_marker3, _series_marker4;
98
+ var _series_opacity;
99
+ return ((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.opacity) ? isArrayOrTypedArray((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.opacity) ? ((_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : _series_marker2.opacity)[index % ((_series_marker3 = series.marker) === null || _series_marker3 === void 0 ? void 0 : _series_marker3.opacity).length] : (_series_marker4 = series.marker) === null || _series_marker4 === void 0 ? void 0 : _series_marker4.opacity : (_series_opacity = series.opacity) !== null && _series_opacity !== void 0 ? _series_opacity : 1;
100
+ };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/DeclarativeChart/PlotlyColorAdapter.ts"],"sourcesContent":["import * as React from 'react';\nimport { color as d3Color } from 'd3-color';\nimport type { PieColors, Color } from '@fluentui/chart-utilities';\nimport { isArrayOrTypedArray } from '@fluentui/chart-utilities';\nimport { areArraysEqual } from '../../utilities/utilities';\nimport { DataVizPalette, getColorFromToken, getNextColor } from '../../utilities/colors';\n\ntype PlotlyColorway = 'plotly' | 'others';\n\n// The color sequences in plotly express are defined here:\n// https://plotly.com/python/discrete-color/#:~:text=Join%20now.-,Color%20Sequences%20in%20Plotly%20Express,-By%20default%2C%20Plotly\nexport type ColorwayType = 'default' | 'builtin' | 'others' | undefined;\n\nconst DEFAULT_PLOTLY_COLORWAY = [\n '#636efa', //1\n '#ef553b', //2\n '#00cc96', //3\n '#ab63fa', //4\n '#ffa15a', //5\n '#19d3f3', //6\n '#ff6692', //7\n '#b6e880', //8\n '#ff97ff', //9\n '#fecb52', //10\n];\n\nconst PLOTLY_FLUENTVIZ_COLORWAY_MAPPING = [\n DataVizPalette.color1, //1\n DataVizPalette.warning, //2\n DataVizPalette.color8, //3\n DataVizPalette.color4, //4\n DataVizPalette.color7, //5\n DataVizPalette.color6, //6\n DataVizPalette.color2, //7\n DataVizPalette.color5, //8\n DataVizPalette.color9, //9\n DataVizPalette.color10, //10\n];\n\nfunction getPlotlyColorway(colorway: string[] | undefined): PlotlyColorway {\n const isPlotlyColorway =\n isArrayOrTypedArray(colorway) &&\n areArraysEqual(\n colorway?.map(c => c.toLowerCase()),\n DEFAULT_PLOTLY_COLORWAY,\n );\n\n return isPlotlyColorway ? 'plotly' : 'others';\n}\n\nfunction tryMapFluentDataViz(hexColor: string, templateColorway: PlotlyColorway, isDarkTheme?: boolean): string {\n if (templateColorway !== 'plotly') {\n return hexColor;\n }\n const index = DEFAULT_PLOTLY_COLORWAY.indexOf(hexColor.toLowerCase());\n if (index !== -1) {\n return getColorFromToken(PLOTLY_FLUENTVIZ_COLORWAY_MAPPING[index], isDarkTheme);\n }\n return hexColor;\n}\n\nexport const getColor = (\n legendLabel: string,\n colorMap: React.MutableRefObject<Map<string, string>>,\n isDarkTheme?: boolean,\n): string => {\n if (!colorMap.current.has(legendLabel)) {\n let nextColor: string;\n if (colorMap.current.size < PLOTLY_FLUENTVIZ_COLORWAY_MAPPING.length) {\n // Get first 10 colors from plotly-fluentviz colorway mapping\n nextColor = getColorFromToken(PLOTLY_FLUENTVIZ_COLORWAY_MAPPING[colorMap.current.size], isDarkTheme);\n } else {\n nextColor = getNextColor(colorMap.current.size, 0, isDarkTheme);\n }\n colorMap.current.set(legendLabel, nextColor);\n return nextColor;\n }\n\n return colorMap.current.get(legendLabel) as string;\n};\n\nexport const getSchemaColors = (\n colorway: string[] | undefined,\n colors: PieColors | Color | Color[] | string | null | undefined,\n colorMap: React.MutableRefObject<Map<string, string>>,\n isDarkTheme?: boolean,\n): string[] | string | undefined => {\n const hexColors: string[] = [];\n if (!colors) {\n return undefined;\n }\n const templateColorway = getPlotlyColorway(colorway);\n if (isArrayOrTypedArray(colors)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (colors as any[]).forEach((element, index) => {\n const colorString = element?.toString().trim();\n const nextFluentColor = getColor(`Label_${index}`, colorMap, isDarkTheme);\n if (colorString) {\n const parsedColor = d3Color(colorString);\n hexColors.push(\n parsedColor ? tryMapFluentDataViz(parsedColor.formatHex(), templateColorway, isDarkTheme) : nextFluentColor,\n );\n } else {\n hexColors.push(nextFluentColor);\n }\n });\n } else if (typeof colors === 'string') {\n const parsedColor = d3Color(colors);\n return parsedColor\n ? tryMapFluentDataViz(parsedColor.formatHex(), templateColorway, isDarkTheme)\n : getColor('Label_0', colorMap, isDarkTheme);\n }\n return hexColors;\n};\n\nexport const extractColor = (\n colorway: string[] | undefined,\n colorwayType: ColorwayType,\n colors: PieColors | Color | Color[] | string | null | undefined,\n colorMap: React.MutableRefObject<Map<string, string>>,\n isDarkTheme?: boolean,\n): string | string[] | undefined => {\n return colorwayType === 'default' && colors ? getSchemaColors(colorway, colors, colorMap, isDarkTheme) : undefined;\n};\n\nexport const resolveColor = (\n extractedColors: string[] | string | null | undefined,\n index: number,\n legend: string,\n colorMap: React.MutableRefObject<Map<string, string>>,\n isDarkTheme?: boolean,\n): string => {\n let color = '';\n if (extractedColors && isArrayOrTypedArray(extractedColors) && extractedColors[index]) {\n color = extractedColors[index % extractedColors.length];\n } else if (typeof extractedColors === 'string') {\n color = extractedColors;\n } else {\n color = getColor(legend, colorMap, isDarkTheme);\n }\n return color;\n};\n"],"names":["React","color","d3Color","isArrayOrTypedArray","areArraysEqual","DataVizPalette","getColorFromToken","getNextColor","DEFAULT_PLOTLY_COLORWAY","PLOTLY_FLUENTVIZ_COLORWAY_MAPPING","color1","warning","color8","color4","color7","color6","color2","color5","color9","color10","getPlotlyColorway","colorway","isPlotlyColorway","map","c","toLowerCase","tryMapFluentDataViz","hexColor","templateColorway","isDarkTheme","index","indexOf","getColor","legendLabel","colorMap","current","has","nextColor","size","length","set","get","getSchemaColors","colors","hexColors","undefined","forEach","element","colorString","toString","trim","nextFluentColor","parsedColor","push","formatHex","extractColor","colorwayType","resolveColor","extractedColors","legend"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,SAASC,OAAO,QAAQ,WAAW;AAE5C,SAASC,mBAAmB,QAAQ,4BAA4B;AAChE,SAASC,cAAc,QAAQ,4BAA4B;AAC3D,SAASC,cAAc,EAAEC,iBAAiB,EAAEC,YAAY,QAAQ,yBAAyB;AAQzF,MAAMC,0BAA0B;IAC9B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,MAAMC,oCAAoC;IACxCJ,eAAeK,MAAM;IACrBL,eAAeM,OAAO;IACtBN,eAAeO,MAAM;IACrBP,eAAeQ,MAAM;IACrBR,eAAeS,MAAM;IACrBT,eAAeU,MAAM;IACrBV,eAAeW,MAAM;IACrBX,eAAeY,MAAM;IACrBZ,eAAea,MAAM;IACrBb,eAAec,OAAO;CACvB;AAED,SAASC,kBAAkBC,QAA8B;IACvD,MAAMC,mBACJnB,oBAAoBkB,aACpBjB,eACEiB,qBAAAA,+BAAAA,SAAUE,GAAG,CAACC,CAAAA,IAAKA,EAAEC,WAAW,KAChCjB;IAGJ,OAAOc,mBAAmB,WAAW;AACvC;AAEA,SAASI,oBAAoBC,QAAgB,EAAEC,gBAAgC,EAAEC,WAAqB;IACpG,IAAID,qBAAqB,UAAU;QACjC,OAAOD;IACT;IACA,MAAMG,QAAQtB,wBAAwBuB,OAAO,CAACJ,SAASF,WAAW;IAClE,IAAIK,UAAU,CAAC,GAAG;QAChB,OAAOxB,kBAAkBG,iCAAiC,CAACqB,MAAM,EAAED;IACrE;IACA,OAAOF;AACT;AAEA,OAAO,MAAMK,WAAW,CACtBC,aACAC,UACAL;IAEA,IAAI,CAACK,SAASC,OAAO,CAACC,GAAG,CAACH,cAAc;QACtC,IAAII;QACJ,IAAIH,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UL,eAAegB;AAC3G,EAAE;AAEF,OAAO,MAAMY,eAAe,CAC1BC,iBACA5B,OACA6B,QACAzB,UACAL;IAEA,IAAI5B,QAAQ;IACZ,IAAIyD,mBAAmBvD,oBAAoBuD,oBAAoBA,eAAe,CAAC5B,MAAM,EAAE;QACrF7B,QAAQyD,eAAe,CAAC5B,QAAQ4B,gBAAgBnB,MAAM,CAAC;IACzD,OAAO,IAAI,OAAOmB,oBAAoB,UAAU;QAC9CzD,QAAQyD;IACV,OAAO;QACLzD,QAAQ+B,SAAS2B,QAAQzB,UAAUL;IACrC;IACA,OAAO5B;AACT,EAAE"}
1
+ {"version":3,"sources":["../src/components/DeclarativeChart/PlotlyColorAdapter.ts"],"sourcesContent":["import * as React from 'react';\nimport { color as d3Color } from 'd3-color';\nimport type { PieColors, Color, PlotData } from '@fluentui/chart-utilities';\nimport { isArrayOrTypedArray } from '@fluentui/chart-utilities';\nimport { areArraysEqual } from '../../utilities/utilities';\nimport { DataVizPalette, getColorFromToken, getNextColor } from '../../utilities/colors';\n\ntype PlotlyColorway = 'plotly' | 'others';\n\n// The color sequences in plotly express are defined here:\n// https://plotly.com/python/discrete-color/#:~:text=Join%20now.-,Color%20Sequences%20in%20Plotly%20Express,-By%20default%2C%20Plotly\nexport type ColorwayType = 'default' | 'builtin' | 'others' | undefined;\n\nconst DEFAULT_PLOTLY_COLORWAY = [\n '#636efa', //1\n '#ef553b', //2\n '#00cc96', //3\n '#ab63fa', //4\n '#ffa15a', //5\n '#19d3f3', //6\n '#ff6692', //7\n '#b6e880', //8\n '#ff97ff', //9\n '#fecb52', //10\n];\n\nconst PLOTLY_FLUENTVIZ_COLORWAY_MAPPING = [\n DataVizPalette.color1, //1\n DataVizPalette.warning, //2\n DataVizPalette.color8, //3\n DataVizPalette.color4, //4\n DataVizPalette.color7, //5\n DataVizPalette.color6, //6\n DataVizPalette.color2, //7\n DataVizPalette.color5, //8\n DataVizPalette.color9, //9\n DataVizPalette.color10, //10\n];\n\nfunction getPlotlyColorway(colorway: string[] | undefined): PlotlyColorway {\n const isPlotlyColorway =\n isArrayOrTypedArray(colorway) &&\n areArraysEqual(\n colorway?.map(c => c.toLowerCase()),\n DEFAULT_PLOTLY_COLORWAY,\n );\n\n return isPlotlyColorway ? 'plotly' : 'others';\n}\n\nfunction tryMapFluentDataViz(hexColor: string, templateColorway: PlotlyColorway, isDarkTheme?: boolean): string {\n if (templateColorway !== 'plotly') {\n return hexColor;\n }\n const index = DEFAULT_PLOTLY_COLORWAY.indexOf(hexColor.toLowerCase());\n if (index !== -1) {\n return getColorFromToken(PLOTLY_FLUENTVIZ_COLORWAY_MAPPING[index], isDarkTheme);\n }\n return hexColor;\n}\n\nexport const getColor = (\n legendLabel: string,\n colorMap: React.MutableRefObject<Map<string, string>>,\n isDarkTheme?: boolean,\n): string => {\n if (!colorMap.current.has(legendLabel)) {\n let nextColor: string;\n if (colorMap.current.size < PLOTLY_FLUENTVIZ_COLORWAY_MAPPING.length) {\n // Get first 10 colors from plotly-fluentviz colorway mapping\n nextColor = getColorFromToken(PLOTLY_FLUENTVIZ_COLORWAY_MAPPING[colorMap.current.size], isDarkTheme);\n } else {\n nextColor = getNextColor(colorMap.current.size, 0, isDarkTheme);\n }\n colorMap.current.set(legendLabel, nextColor);\n return nextColor;\n }\n\n return colorMap.current.get(legendLabel) as string;\n};\n\nexport const getSchemaColors = (\n colorway: string[] | undefined,\n colors: PieColors | Color | Color[] | string | null | undefined,\n colorMap: React.MutableRefObject<Map<string, string>>,\n isDarkTheme?: boolean,\n): string[] | string | undefined => {\n const hexColors: string[] = [];\n if (!colors) {\n return undefined;\n }\n const templateColorway = getPlotlyColorway(colorway);\n if (isArrayOrTypedArray(colors)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (colors as any[]).forEach((element, index) => {\n const colorString = element?.toString().trim();\n const nextFluentColor = getColor(`Label_${index}`, colorMap, isDarkTheme);\n if (colorString) {\n const parsedColor = d3Color(colorString);\n hexColors.push(\n parsedColor ? tryMapFluentDataViz(parsedColor.formatHex(), templateColorway, isDarkTheme) : nextFluentColor,\n );\n } else {\n hexColors.push(nextFluentColor);\n }\n });\n } else if (typeof colors === 'string') {\n const parsedColor = d3Color(colors);\n return parsedColor\n ? tryMapFluentDataViz(parsedColor.formatHex(), templateColorway, isDarkTheme)\n : getColor('Label_0', colorMap, isDarkTheme);\n }\n return hexColors;\n};\n\nexport const extractColor = (\n colorway: string[] | undefined,\n colorwayType: ColorwayType,\n colors: PieColors | Color | Color[] | string | null | undefined,\n colorMap: React.MutableRefObject<Map<string, string>>,\n isDarkTheme?: boolean,\n): string | string[] | undefined => {\n return colorwayType === 'default' && colors ? getSchemaColors(colorway, colors, colorMap, isDarkTheme) : undefined;\n};\n\nexport const resolveColor = (\n extractedColors: string[] | string | null | undefined,\n index: number,\n legend: string,\n colorMap: React.MutableRefObject<Map<string, string>>,\n isDarkTheme?: boolean,\n): string => {\n let color = '';\n if (extractedColors && isArrayOrTypedArray(extractedColors) && extractedColors.length > 0) {\n color = extractedColors[index % extractedColors.length];\n } else if (typeof extractedColors === 'string') {\n color = extractedColors;\n } else {\n color = getColor(legend, colorMap, isDarkTheme);\n }\n return color;\n};\n\nexport const getOpacity = (series: Partial<PlotData>, index: number): number => {\n return series.marker?.opacity\n ? isArrayOrTypedArray(series.marker?.opacity)\n ? (series.marker?.opacity as number[])[index % (series.marker?.opacity as number[]).length]\n : (series.marker?.opacity as number)\n : series.opacity ?? 1;\n};\n"],"names":["React","color","d3Color","isArrayOrTypedArray","areArraysEqual","DataVizPalette","getColorFromToken","getNextColor","DEFAULT_PLOTLY_COLORWAY","PLOTLY_FLUENTVIZ_COLORWAY_MAPPING","color1","warning","color8","color4","color7","color6","color2","color5","color9","color10","getPlotlyColorway","colorway","isPlotlyColorway","map","c","toLowerCase","tryMapFluentDataViz","hexColor","templateColorway","isDarkTheme","index","indexOf","getColor","legendLabel","colorMap","current","has","nextColor","size","length","set","get","getSchemaColors","colors","hexColors","undefined","forEach","element","colorString","toString","trim","nextFluentColor","parsedColor","push","formatHex","extractColor","colorwayType","resolveColor","extractedColors","legend","getOpacity","series","marker","opacity"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,SAASC,OAAO,QAAQ,WAAW;AAE5C,SAASC,mBAAmB,QAAQ,4BAA4B;AAChE,SAASC,cAAc,QAAQ,4BAA4B;AAC3D,SAASC,cAAc,EAAEC,iBAAiB,EAAEC,YAAY,QAAQ,yBAAyB;AAQzF,MAAMC,0BAA0B;IAC9B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,MAAMC,oCAAoC;IACxCJ,eAAeK,MAAM;IACrBL,eAAeM,OAAO;IACtBN,eAAeO,MAAM;IACrBP,eAAeQ,MAAM;IACrBR,eAAeS,MAAM;IACrBT,eAAeU,MAAM;IACrBV,eAAeW,MAAM;IACrBX,eAAeY,MAAM;IACrBZ,eAAea,MAAM;IACrBb,eAAec,OAAO;CACvB;AAED,SAASC,kBAAkBC,QAA8B;IACvD,MAAMC,mBACJnB,oBAAoBkB,aACpBjB,eACEiB,qBAAAA,+BAAAA,SAAUE,GAAG,CAACC,CAAAA,IAAKA,EAAEC,WAAW,KAChCjB;IAGJ,OAAOc,mBAAmB,WAAW;AACvC;AAEA,SAASI,oBAAoBC,QAAgB,EAAEC,gBAAgC,EAAEC,WAAqB;IACpG,IAAID,qBAAqB,UAAU;QACjC,OAAOD;IACT;IACA,MAAMG,QAAQtB,wBAAwBuB,OAAO,CAACJ,SAASF,WAAW;IAClE,IAAIK,UAAU,CAAC,GAAG;QAChB,OAAOxB,kBAAkBG,iCAAiC,CAACqB,MAAM,EAAED;IACrE;IACA,OAAOF;AACT;AAEA,OAAO,MAAMK,WAAW,CACtBC,aACAC,UACAL;IAEA,IAAI,CAACK,SAASC,OAAO,CAACC,GAAG,CAACH,cAAc;QACtC,IAAII;QACJ,IAAIH,SAASC,OAAO,CAACG,IAAI,GAAG7B,kCAAkC8B,MAAM,EAAE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