@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
@@ -29,6 +29,7 @@ const _index8 = require("../VerticalBarChart/index");
29
29
  const _index9 = require("../ScatterChart/index");
30
30
  const _withResponsiveContainer = require("../ResponsiveContainer/withResponsiveContainer");
31
31
  const _index10 = require("../ChartTable/index");
32
+ const _index11 = require("../Legends/index");
32
33
  const ResponsiveDonutChart = (0, _withResponsiveContainer.withResponsiveContainer)(_index.DonutChart);
33
34
  const ResponsiveVerticalStackedBarChart = (0, _withResponsiveContainer.withResponsiveContainer)(_index1.VerticalStackedBarChart);
34
35
  const ResponsiveLineChart = (0, _withResponsiveContainer.withResponsiveContainer)(_index2.LineChart);
@@ -41,10 +42,104 @@ const ResponsiveGroupedVerticalBarChart = (0, _withResponsiveContainer.withRespo
41
42
  const ResponsiveVerticalBarChart = (0, _withResponsiveContainer.withResponsiveContainer)(_index8.VerticalBarChart);
42
43
  const ResponsiveScatterChart = (0, _withResponsiveContainer.withResponsiveContainer)(_index9.ScatterChart);
43
44
  const ResponsiveChartTable = (0, _withResponsiveContainer.withResponsiveContainer)(_index10.ChartTable);
45
+ // Default x-axis key for grouping traces. Also applicable for PieData and SankeyData where x-axis is not defined.
46
+ const DEFAULT_XAXIS = 'x';
47
+ const FALLBACK_TYPE = 'fallback';
44
48
  const useColorMapping = ()=>{
45
49
  const colorMap = _react.useRef(new Map());
46
50
  return colorMap;
47
51
  };
52
+ function renderChart(Renderer, transformer, transformerArgs, commonProps, cellRow, cellColumn) {
53
+ const chartProps = transformer(...transformerArgs);
54
+ return /*#__PURE__*/ _react.createElement("div", {
55
+ key: `${cellRow}_${cellColumn}`,
56
+ style: {
57
+ gridRowStart: cellRow,
58
+ gridRowEnd: cellRow + 1,
59
+ gridColumnStart: cellColumn,
60
+ gridColumnEnd: cellColumn + 1
61
+ }
62
+ }, /*#__PURE__*/ _react.createElement(Renderer, {
63
+ ...chartProps,
64
+ ...commonProps
65
+ }));
66
+ }
67
+ const LineAreaPreTransformOp = (plotlyInput)=>{
68
+ const xValues = plotlyInput.data[0].x;
69
+ const isXMonth = (0, _chartutilities.isMonthArray)(xValues);
70
+ let renderData = plotlyInput.data;
71
+ if (isXMonth) {
72
+ renderData = plotlyInput.data.map((dataPoint)=>({
73
+ ...dataPoint,
74
+ x: (0, _PlotlySchemaAdapter.correctYearMonth)(dataPoint.x)
75
+ }));
76
+ }
77
+ return {
78
+ data: renderData,
79
+ layout: plotlyInput.layout
80
+ };
81
+ };
82
+ const chartMap = {
83
+ // PieData category charts
84
+ donut: {
85
+ transformer: _PlotlySchemaAdapter.transformPlotlyJsonToDonutProps,
86
+ renderer: ResponsiveDonutChart
87
+ },
88
+ // SankeyData category charts
89
+ sankey: {
90
+ transformer: _PlotlySchemaAdapter.transformPlotlyJsonToSankeyProps,
91
+ renderer: ResponsiveSankeyChart
92
+ },
93
+ // TableData category charts
94
+ table: {
95
+ transformer: _PlotlySchemaAdapter.transformPlotlyJsonToChartTableProps,
96
+ renderer: ResponsiveChartTable
97
+ },
98
+ // PlotData category charts
99
+ horizontalbar: {
100
+ transformer: _PlotlySchemaAdapter.transformPlotlyJsonToHorizontalBarWithAxisProps,
101
+ renderer: ResponsiveHorizontalBarChartWithAxis
102
+ },
103
+ groupedverticalbar: {
104
+ transformer: _PlotlySchemaAdapter.transformPlotlyJsonToGVBCProps,
105
+ renderer: ResponsiveGroupedVerticalBarChart
106
+ },
107
+ verticalstackedbar: {
108
+ transformer: _PlotlySchemaAdapter.transformPlotlyJsonToVSBCProps,
109
+ renderer: ResponsiveVerticalStackedBarChart
110
+ },
111
+ heatmap: {
112
+ transformer: _PlotlySchemaAdapter.transformPlotlyJsonToHeatmapProps,
113
+ renderer: ResponsiveHeatMapChart
114
+ },
115
+ gauge: {
116
+ transformer: _PlotlySchemaAdapter.transformPlotlyJsonToGaugeProps,
117
+ renderer: ResponsiveGaugeChart
118
+ },
119
+ verticalbar: {
120
+ transformer: _PlotlySchemaAdapter.transformPlotlyJsonToVBCProps,
121
+ renderer: ResponsiveVerticalBarChart
122
+ },
123
+ area: {
124
+ transformer: _PlotlySchemaAdapter.transformPlotlyJsonToAreaChartProps,
125
+ renderer: ResponsiveAreaChart,
126
+ preTransformOperation: LineAreaPreTransformOp
127
+ },
128
+ line: {
129
+ transformer: _PlotlySchemaAdapter.transformPlotlyJsonToLineChartProps,
130
+ renderer: ResponsiveLineChart,
131
+ preTransformOperation: LineAreaPreTransformOp
132
+ },
133
+ scatter: {
134
+ transformer: _PlotlySchemaAdapter.transformPlotlyJsonToScatterChartProps,
135
+ renderer: ResponsiveScatterChart,
136
+ preTransformOperation: LineAreaPreTransformOp
137
+ },
138
+ fallback: {
139
+ transformer: _PlotlySchemaAdapter.transformPlotlyJsonToVSBCProps,
140
+ renderer: ResponsiveVerticalStackedBarChart
141
+ }
142
+ };
48
143
  const useIsDarkTheme = ()=>{
49
144
  const parentV9Theme = _react.useContext(_reactsharedcontexts.ThemeContext_unstable);
50
145
  const v9Theme = parentV9Theme ? parentV9Theme : _tokens.webLightTheme;
@@ -70,10 +165,15 @@ const DeclarativeChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>
70
165
  ...plotlyInput,
71
166
  data: chart.validTracesInfo.map((trace)=>plotlyInput.data[trace.index])
72
167
  };
168
+ const validTracesFilteredIndex = chart.validTracesInfo.map((trace, index)=>[
169
+ index,
170
+ trace.type
171
+ ]);
73
172
  let { selectedLegends } = plotlySchema;
74
173
  const colorMap = useColorMapping();
75
174
  const isDarkTheme = useIsDarkTheme();
76
175
  const chartRef = _react.useRef(null);
176
+ const isMultiPlot = _react.useRef(false);
77
177
  if (!(0, _chartutilities.isArrayOrTypedArray)(selectedLegends)) {
78
178
  selectedLegends = [];
79
179
  }
@@ -107,66 +207,20 @@ const DeclarativeChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>
107
207
  legendProps: multiSelectLegendProps,
108
208
  componentRef: chartRef
109
209
  };
110
- const renderLineAreaScatter = (plotlyData, isAreaChart, isScatterChart)=>{
111
- var _plotlyData_;
112
- const isScatterMarkers = [
113
- 'text+markers',
114
- 'markers+text',
115
- 'lines+markers',
116
- 'markers+line',
117
- 'text+lines+markers'
118
- ].includes((_plotlyData_ = plotlyData[0]) === null || _plotlyData_ === void 0 ? void 0 : _plotlyData_.mode);
119
- const chartType = isAreaChart ? 'area' : isScatterChart ? 'scatter' : 'line';
120
- const chartProps = {
121
- ...(0, _PlotlySchemaAdapter.transformPlotlyJsonToScatterChartProps)({
122
- data: plotlyData,
123
- layout: plotlyInput.layout
124
- }, chartType, isScatterMarkers, colorMap, props.colorwayType, isDarkTheme),
125
- ...commonProps
126
- };
127
- if (isAreaChart) {
128
- return /*#__PURE__*/ _react.createElement(ResponsiveAreaChart, chartProps);
129
- }
130
- if (isScatterChart) {
131
- return /*#__PURE__*/ _react.createElement(ResponsiveScatterChart, chartProps);
132
- }
133
- return /*#__PURE__*/ _react.createElement(ResponsiveLineChart, chartProps);
134
- };
135
- const checkAndRenderChart = (isAreaChart = false)=>{
136
- let fallbackVSBC = false;
137
- const xValues = plotlyInputWithValidData.data[0].x;
138
- const isXDate = (0, _chartutilities.isDateArray)(xValues);
139
- const isXNumber = (0, _chartutilities.isNumberArray)(xValues);
140
- const isXMonth = (0, _chartutilities.isMonthArray)(xValues);
141
- const isYString = (0, _PlotlySchemaAdapter.isStringArray)(plotlyInputWithValidData.data[0].y);
142
- // Consider year as categorical variable not numeric continuous variable
143
- // Also year is not considered a date variable as it is represented as a point
144
- // in time and brings additional complexity of handling timezone and locale
145
- // formatting given the current design of the charting library
146
- const isXYear = (0, _chartutilities.isYearArray)(xValues);
147
- const allModes = plotlyInputWithValidData.data.map((data)=>data.mode);
148
- const isScatterChart = allModes.every((mode)=>mode === 'markers');
149
- // If x is date or number and y is not string, render as Line/Area Chart
150
- // If x is month, correct the year and render as Line/Area Chart
151
- if ((isXDate || isXNumber) && !isXYear && !isYString || isScatterChart && !isYString) {
152
- return renderLineAreaScatter(plotlyInputWithValidData.data, isAreaChart, isScatterChart);
153
- } else if (isXMonth) {
154
- const updatedData = plotlyInputWithValidData.data.map((dataPoint)=>({
155
- ...dataPoint,
156
- x: (0, _PlotlySchemaAdapter.correctYearMonth)(dataPoint.x)
157
- }));
158
- return renderLineAreaScatter(updatedData, isAreaChart, isScatterChart);
159
- }
160
- // Unsupported schema, render as VerticalStackedBarChart
161
- fallbackVSBC = true;
162
- return /*#__PURE__*/ _react.createElement(ResponsiveVerticalStackedBarChart, {
163
- ...(0, _PlotlySchemaAdapter.transformPlotlyJsonToVSBCProps)(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme, fallbackVSBC),
164
- ...commonProps
210
+ function createLegends(legendProps) {
211
+ // eslint-disable-next-line react/jsx-no-bind
212
+ return /*#__PURE__*/ _react.createElement(_index11.Legends, {
213
+ ...legendProps,
214
+ selectedLegends: activeLegends,
215
+ onChange: onActiveLegendsChange
165
216
  });
166
- };
217
+ }
167
218
  // TODO
168
219
  const exportAsImage = _react.useCallback((opts)=>{
169
220
  return new Promise((resolve, reject)=>{
221
+ if (isMultiPlot.current) {
222
+ return reject(Error('Exporting multi plot charts as image is not supported'));
223
+ }
170
224
  if (!chartRef.current || typeof chartRef.current.toImage !== 'function') {
171
225
  return reject(Error('Chart cannot be exported as image'));
172
226
  }
@@ -182,70 +236,69 @@ const DeclarativeChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>
182
236
  }), [
183
237
  exportAsImage
184
238
  ]);
185
- switch(chart.type){
186
- case 'donut':
187
- return /*#__PURE__*/ _react.createElement(ResponsiveDonutChart, {
188
- ...(0, _PlotlySchemaAdapter.transformPlotlyJsonToDonutProps)(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme),
189
- ...commonProps
190
- });
191
- case 'horizontalbar':
192
- return /*#__PURE__*/ _react.createElement(ResponsiveHorizontalBarChartWithAxis, {
193
- ...(0, _PlotlySchemaAdapter.transformPlotlyJsonToHorizontalBarWithAxisProps)(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme),
194
- ...commonProps
195
- });
196
- case 'groupedverticalbar':
197
- return /*#__PURE__*/ _react.createElement(ResponsiveGroupedVerticalBarChart, {
198
- ...(0, _PlotlySchemaAdapter.transformPlotlyJsonToGVBCProps)(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme),
199
- ...commonProps
200
- });
201
- case 'verticalstackedbar':
202
- return /*#__PURE__*/ _react.createElement(ResponsiveVerticalStackedBarChart, {
203
- ...(0, _PlotlySchemaAdapter.transformPlotlyJsonToVSBCProps)(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme),
204
- ...commonProps
205
- });
206
- case 'heatmap':
207
- return /*#__PURE__*/ _react.createElement(ResponsiveHeatMapChart, {
208
- ...(0, _PlotlySchemaAdapter.transformPlotlyJsonToHeatmapProps)(plotlyInputWithValidData),
209
- ...commonProps,
210
- legendProps: {}
211
- });
212
- case 'sankey':
213
- return /*#__PURE__*/ _react.createElement(ResponsiveSankeyChart, {
214
- ...(0, _PlotlySchemaAdapter.transformPlotlyJsonToSankeyProps)(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme),
215
- ...commonProps
216
- });
217
- case 'gauge':
218
- return /*#__PURE__*/ _react.createElement(ResponsiveGaugeChart, {
219
- ...(0, _PlotlySchemaAdapter.transformPlotlyJsonToGaugeProps)(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme),
220
- ...commonProps
221
- });
222
- case 'verticalbar':
223
- return /*#__PURE__*/ _react.createElement(ResponsiveVerticalBarChart, {
224
- ...(0, _PlotlySchemaAdapter.transformPlotlyJsonToVBCProps)(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme),
225
- ...commonProps
226
- });
227
- case 'table':
228
- return /*#__PURE__*/ _react.createElement(ResponsiveChartTable, {
229
- ...(0, _PlotlySchemaAdapter.transformPlotlyJsonToChartTableProps)(plotlyInputWithValidData, colorMap, isDarkTheme),
230
- ...commonProps
231
- });
232
- // TODO: Add 'scatter' as a separate chart type
233
- case 'area':
234
- case 'line':
235
- case 'fallback':
236
- case 'scatterpolar':
237
- case 'scatter':
238
- if (chart.type === 'scatterpolar') {
239
- const cartesianProjection = (0, _PlotlySchemaAdapter.projectPolarToCartesian)(plotlyInputWithValidData);
240
- plotlyInputWithValidData.data = cartesianProjection.data;
239
+ if (chart.type === 'scatterpolar') {
240
+ const cartesianProjection = (0, _PlotlySchemaAdapter.projectPolarToCartesian)(plotlyInputWithValidData);
241
+ plotlyInputWithValidData.data = cartesianProjection.data;
242
+ validTracesFilteredIndex.forEach((trace, index)=>{
243
+ if (trace[1] === 'scatterpolar') {
244
+ validTracesFilteredIndex[index][1] = 'line'; // Change type to line for rendering
241
245
  }
242
- // Need recheck for area chart as we don't have ability to check for valid months in previous step
243
- const isAreaChart = plotlyInputWithValidData.data.some((series)=>series.fill === 'tonexty' || series.fill === 'tozeroy' || !!series.stackgroup);
244
- return checkAndRenderChart(isAreaChart);
245
- default:
246
- var _plotlyInputWithValidData_data_;
247
- throw new Error(`Unsupported chart type :${(_plotlyInputWithValidData_data_ = plotlyInputWithValidData.data[0]) === null || _plotlyInputWithValidData_data_ === void 0 ? void 0 : _plotlyInputWithValidData_data_.type}`);
246
+ });
248
247
  }
248
+ const groupedTraces = {};
249
+ plotlyInputWithValidData.data.forEach((trace, index)=>{
250
+ var _trace_xaxis;
251
+ const xAxisKey = (_trace_xaxis = trace.xaxis) !== null && _trace_xaxis !== void 0 ? _trace_xaxis : DEFAULT_XAXIS;
252
+ if (!groupedTraces[xAxisKey]) {
253
+ groupedTraces[xAxisKey] = [];
254
+ }
255
+ groupedTraces[xAxisKey].push(index);
256
+ });
257
+ isMultiPlot.current = Object.keys(groupedTraces).length > 1;
258
+ const gridProperties = (0, _PlotlySchemaAdapter.getGridProperties)(plotlyInputWithValidData.layout, isMultiPlot.current);
259
+ const allupLegendsProps = (0, _PlotlySchemaAdapter.getAllupLegendsProps)(plotlyInputWithValidData, colorMap, props.colorwayType, isDarkTheme);
260
+ // map through the grouped traces and render the appropriate chart
261
+ return /*#__PURE__*/ _react.createElement(_react.Fragment, null, /*#__PURE__*/ _react.createElement("div", {
262
+ style: {
263
+ display: 'grid',
264
+ gridTemplateRows: gridProperties.templateRows,
265
+ gridTemplateColumns: gridProperties.templateColumns
266
+ }
267
+ }, Object.entries(groupedTraces).map(([xAxisKey, index])=>{
268
+ const plotlyInputForGroup = {
269
+ ...plotlyInputWithValidData,
270
+ data: index.map((idx)=>plotlyInputWithValidData.data[idx])
271
+ };
272
+ const filteredTracesInfo = validTracesFilteredIndex.filter((trace)=>index.includes(trace[0]));
273
+ let chartType = validTracesFilteredIndex.some((trace)=>trace[1] === FALLBACK_TYPE) || chart.type === FALLBACK_TYPE ? FALLBACK_TYPE : filteredTracesInfo[0][1];
274
+ if (validTracesFilteredIndex.some((trace)=>trace[1] === 'line') && validTracesFilteredIndex.some((trace)=>trace[1] === 'scatter')) {
275
+ chartType = 'line';
276
+ }
277
+ const chartEntry = chartMap[chartType];
278
+ if (chartEntry) {
279
+ const { transformer, renderer, preTransformCondition, preTransformOperation } = chartEntry;
280
+ if (preTransformCondition === undefined || preTransformCondition(plotlyInputForGroup)) {
281
+ const transformedInput = preTransformOperation ? preTransformOperation(plotlyInputForGroup) : plotlyInputForGroup;
282
+ const cellProperties = gridProperties.layout[xAxisKey];
283
+ var _cellProperties_row, _cellProperties_column;
284
+ return renderChart(renderer, transformer, [
285
+ transformedInput,
286
+ isMultiPlot.current,
287
+ colorMap,
288
+ props.colorwayType,
289
+ isDarkTheme
290
+ ], {
291
+ ...commonProps,
292
+ xAxisAnnotation: cellProperties === null || cellProperties === void 0 ? void 0 : cellProperties.xAnnotation,
293
+ yAxisAnnotation: cellProperties === null || cellProperties === void 0 ? void 0 : cellProperties.yAnnotation
294
+ }, (_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);
295
+ }
296
+ return /*#__PURE__*/ _react.createElement(_react.Fragment, null);
297
+ } else {
298
+ var _plotlyInputForGroup_data_;
299
+ throw new Error(`Unsupported chart type :${(_plotlyInputForGroup_data_ = plotlyInputForGroup.data[0]) === null || _plotlyInputForGroup_data_ === void 0 ? void 0 : _plotlyInputForGroup_data_.type}`);
300
+ }
301
+ })), isMultiPlot.current && createLegends(allupLegendsProps));
249
302
  });
250
303
  DeclarativeChart.displayName = 'DeclarativeChart';
251
304
  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;;;;;;;eAuICmE;;;;iEAvIU,QAAQ;gCAYxB,4BAA4B;4BACZ,wBAAwB;qCACS,kCAAkC;wBACrD,mBAAmB;mEAC/B,WAAW;qCAgB7B,wBAAwB;uBAEJ,sBAAsB;wBACT,mCAAmC;wBACjC,qBAAqB;wBACpB,sCAAsC;wBACvC,qBAAqB;wBAClC,wBAAwB;6BACzB,6BAA6B;wBAC9B,sBAAsB;wBACT,mCAAmC;wBAC1C,4BAA4B;wBAEb,wBAAwB;yCAEhC,iDAAiD;yBAC9D,sBAAsB;AAEjD,MAAM3B,2BAAuBF,gDAAAA,EAAwBX,iBAAAA;AACrD,MAAMc,wCAAoCH,gDAAAA,EAAwBV,+BAAAA;AAClE,MAAMc,0BAAsBJ,gDAAAA,EAAwBT,iBAAAA;AACpD,MAAMc,2CAAuCL,gDAAAA,EAAwBR,kCAAAA;AACrE,MAAMc,0BAAsBN,gDAAAA,EAAwBP,iBAAAA;AACpD,MAAMc,6BAAyBP,gDAAAA,EAAwBN,oBAAAA;AACvD,MAAMc,4BAAwBR,gDAAAA,EAAwBL,wBAAAA;AACtD,MAAMc,2BAAuBT,gDAAAA,EAAwBJ,kBAAAA;AACrD,MAAMc,wCAAoCV,gDAAAA,EAAwBH,+BAAAA;AAClE,MAAMc,iCAA6BX,gDAAAA,EAAwBF,wBAAAA;AAC3D,MAAMc,6BAAyBZ,gDAAAA,EAAwBD,oBAAAA;AACvD,MAAMc,2BAAuBb,gDAAAA,EAAwBC,mBAAAA;AAoDrD,MAAMa,kBAAkB;IACtB,MAAMC,WAAWrD,OAAMsD,MAAM,CAAC,IAAIC;IAClC,OAAOF;AACT;AAEA,MAAMG,iBAAiB;IACrB,MAAMC,gBAAgBzD,OAAM0D,UAAU,CAAC/C,0CAAAA;IACvC,MAAMgD,UAAiBF,gBAAgBA,gBAAgB7C,qBAAA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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":"AAAA,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
15
15
  getColor: function() {
16
16
  return getColor;
17
17
  },
18
+ getOpacity: function() {
19
+ return getOpacity;
20
+ },
18
21
  getSchemaColors: function() {
19
22
  return getSchemaColors;
20
23
  },
@@ -109,7 +112,7 @@ const extractColor = (colorway, colorwayType, colors, colorMap, isDarkTheme)=>{
109
112
  };
110
113
  const resolveColor = (extractedColors, index, legend, colorMap, isDarkTheme)=>{
111
114
  let color = '';
112
- if (extractedColors && (0, _chartutilities.isArrayOrTypedArray)(extractedColors) && extractedColors[index]) {
115
+ if (extractedColors && (0, _chartutilities.isArrayOrTypedArray)(extractedColors) && extractedColors.length > 0) {
113
116
  color = extractedColors[index % extractedColors.length];
114
117
  } else if (typeof extractedColors === 'string') {
115
118
  color = extractedColors;
@@ -118,3 +121,8 @@ const resolveColor = (extractedColors, index, legend, colorMap, isDarkTheme)=>{
118
121
  }
119
122
  return color;
120
123
  };
124
+ const getOpacity = (series, index)=>{
125
+ var _series_marker, _series_marker1, _series_marker2, _series_marker3, _series_marker4;
126
+ var _series_opacity;
127
+ return ((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.opacity) ? (0, _chartutilities.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;
128
+ };
@@ -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":";;;;;;;;;;;gBAmHauD;eAAAA;;YAtDAvB;;;mBAoBAU;;;gBA4CAe;;;;;iEA7HU,QAAQ;yBACE,WAAW;gCAER,4BAA4B;2BACjC,4BAA4B;wBACK,yBAAyB;AAQzF,MAAMjD,0BAA0B;IAC9B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,MAAMC,oCAAoC;IACxCJ,sBAAAA,CAAeK,MAAM;IACrBL,sBAAAA,CAAeM,OAAO;IACtBN,sBAAAA,CAAeO,MAAM;IACrBP,sBAAAA,CAAeQ,MAAM;IACrBR,sBAAAA,CAAeS,MAAM;IACrBT,sBAAAA,CAAeU,MAAM;IACrBV,sBAAAA,CAAeW,MAAM;IACrBX,sBAAAA,CAAeY,MAAM;IACrBZ,sBAAAA,CAAea,MAAM;IACrBb,sBAAAA,CAAec,OAAO;CACvB;AAED,SAASC,kBAAkBC,QAA8B;IACvD,MAAMC,uBACJnB,mCAAAA,EAAoBkB,iBACpBjB,yBAAAA,EACEiB,aAAAA,QAAAA,aAAAA,KAAAA,IAAAA,KAAAA,IAAAA,SAAU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,EAAEF,OAAO,EAAEI,UAAUL;YAC7D,IAAImB,aAAa;gBACf,MAAMI,kBAAclD,cAAAA,EAAQ8C;gBAC5BJ,UAAUS,IAAI,CACZD,cAAc1B,oBAAoB0B,YAAYE,SAAS,IAAI1B,kBAAkBC,eAAesB;YAEhG,OAAO;gBACLP,UAAUS,IAAI,CAACF;YACjB;QACF;IACF,OAAO,IAAI,OAAOR,WAAW,UAAU;QACrC,MAAMS,kBAAclD,cAAAA,EAAQyC;QAC5B,OAAOS,cACH1B,oBAAoB0B,YAAYE,SAAS,IAAI1B,kBAAkBC,eAC/DG,SAAS,WAAWE,UAAUL;IACpC;IACA,OAAOe;AACT,EAAE;AAEK,qBAAqB,CAC1BvB,UACAmC,cACAb,QACAT,UACAL;IAEA,OAAO2B,iBAAiB,aAAab,SAASD,gBAAgBrB,UAAUsB,QAAQT,UAAUL,eAAegB;AAC3G,EAAE;AAEK,MAAMY,eAAe,CAC1BC,iBACA5B,OACA6B,QACAzB,UACAL;IAEA,IAAI5B,QAAQ;IACZ,IAAIyD,uBAAmBvD,mCAAAA,EAAoBuD,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":";;;;;;;;;;;gBAmHauD;;;YAtDAvB;;;cAkFA4B;eAAAA;;IA9DAlB,eAAAA;;;gBA4CAe;;;;;iEA7HU,QAAQ;yBACE,WAAW;gCAER,4BAA4B;2BACjC,4BAA4B;wBACK,yBAAyB;AAQzF,MAAMjD,0BAA0B;IAC9B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,MAAMC,oCAAoC;IACxCJ,sBAAAA,CAAeK,MAAM;IACrBL,sBAAAA,CAAeM,OAAO;IACtBN,sBAAAA,CAAeO,MAAM;IACrBP,sBAAAA,CAAeQ,MAAM;IACrBR,sBAAAA,CAAeS,MAAM;IACrBT,sBAAAA,CAAeU,MAAM;IACrBV,sBAAAA,CAAeW,MAAM;IACrBX,sBAAAA,CAAeY,MAAM;IACrBZ,sBAAAA,CAAea,MAAM;IACrBb,sBAAAA,CAAec,OAAO;CACvB;AAED,SAASC,kBAAkBC,QAA8B;IACvD,MAAMC,uBAC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