@fluentui/react-charts 9.2.0 → 9.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -3
- package/dist/index.d.ts +84 -5
- package/lib/ChartTable.js +1 -0
- package/lib/ChartTable.js.map +1 -0
- package/lib/components/AreaChart/AreaChart.js.map +1 -1
- package/lib/components/ChartTable/ChartTable.js +57 -0
- package/lib/components/ChartTable/ChartTable.js.map +1 -0
- package/lib/components/ChartTable/ChartTable.types.js +1 -0
- package/lib/components/ChartTable/ChartTable.types.js.map +1 -0
- package/lib/components/ChartTable/index.js +3 -0
- package/lib/components/ChartTable/index.js.map +1 -0
- package/lib/components/ChartTable/useChartTableStyles.styles.js +93 -0
- package/lib/components/ChartTable/useChartTableStyles.styles.js.map +1 -0
- package/lib/components/ChartTable/useChartTableStyles.styles.raw.js +55 -0
- package/lib/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -0
- package/lib/components/CommonComponents/CartesianChart.js +110 -81
- package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/CommonComponents/ChartPopover.types.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +20 -10
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +95 -0
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +204 -87
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.types.js.map +1 -1
- package/lib/components/DonutChart/Pie/Pie.js.map +1 -1
- package/lib/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib/components/GanttChart/GanttChart.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +161 -141
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
- package/lib/components/HorizontalBarChart/HorizontalBarChart.types.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib/components/Legends/Legends.js.map +1 -1
- package/lib/components/Legends/OverflowMenu.js.map +1 -1
- package/lib/components/LineChart/LineChart.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.js +12 -11
- package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +57 -51
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/types/DataPoint.js.map +1 -1
- package/lib/utilities/FocusableTooltipText.js.map +1 -1
- package/lib/utilities/utilities.js +26 -37
- package/lib/utilities/utilities.js.map +1 -1
- package/lib/utilities/vbc-utils.js +24 -0
- package/lib/utilities/vbc-utils.js.map +1 -1
- package/lib-commonjs/ChartTable.js +6 -0
- package/lib-commonjs/ChartTable.js.map +1 -0
- package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
- package/lib-commonjs/components/ChartTable/ChartTable.js +68 -0
- package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -0
- package/lib-commonjs/components/ChartTable/ChartTable.types.js +6 -0
- package/lib-commonjs/components/ChartTable/ChartTable.types.js.map +1 -0
- package/lib-commonjs/components/ChartTable/index.js +8 -0
- package/lib-commonjs/components/ChartTable/index.js.map +1 -0
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js +196 -0
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js.map +1 -0
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js +69 -0
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -0
- package/lib-commonjs/components/CommonComponents/CartesianChart.js +109 -80
- package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/ChartPopover.types.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +19 -9
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +120 -0
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +204 -87
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Pie/Pie.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib-commonjs/components/GanttChart/GanttChart.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +159 -139
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.types.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib-commonjs/components/Legends/Legends.js.map +1 -1
- package/lib-commonjs/components/Legends/OverflowMenu.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +11 -10
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +56 -50
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib-commonjs/index.js +1 -0
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/types/DataPoint.js.map +1 -1
- package/lib-commonjs/utilities/FocusableTooltipText.js.map +1 -1
- package/lib-commonjs/utilities/utilities.js +29 -37
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/lib-commonjs/utilities/vbc-utils.js +27 -0
- package/lib-commonjs/utilities/vbc-utils.js.map +1 -1
- package/package.json +9 -9
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* eslint-disable one-var */ /* eslint-disable vars-on-top */ /* eslint-disable no-var */
|
|
1
|
+
/* eslint-disable one-var */ /* eslint-disable vars-on-top */ /* eslint-disable no-var */ "use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
@@ -9,18 +9,21 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
+
_getGaugeAxisColor: function() {
|
|
13
|
+
return _getGaugeAxisColor;
|
|
14
|
+
},
|
|
12
15
|
correctYearMonth: function() {
|
|
13
16
|
return correctYearMonth;
|
|
14
17
|
},
|
|
15
18
|
findArrayAttributes: function() {
|
|
16
19
|
return findArrayAttributes;
|
|
17
20
|
},
|
|
18
|
-
getColor: function() {
|
|
19
|
-
return getColor;
|
|
20
|
-
},
|
|
21
21
|
projectPolarToCartesian: function() {
|
|
22
22
|
return projectPolarToCartesian;
|
|
23
23
|
},
|
|
24
|
+
transformPlotlyJsonToChartTableProps: function() {
|
|
25
|
+
return transformPlotlyJsonToChartTableProps;
|
|
26
|
+
},
|
|
24
27
|
transformPlotlyJsonToDonutProps: function() {
|
|
25
28
|
return transformPlotlyJsonToDonutProps;
|
|
26
29
|
},
|
|
@@ -57,6 +60,7 @@ const _colors = require("../../utilities/colors");
|
|
|
57
60
|
const _utilities = require("../../utilities/utilities");
|
|
58
61
|
const _chartutilities = require("@fluentui/chart-utilities");
|
|
59
62
|
const _d3shape = require("d3-shape");
|
|
63
|
+
const _PlotlyColorAdapter = require("./PlotlyColorAdapter");
|
|
60
64
|
const dashOptions = {
|
|
61
65
|
dot: {
|
|
62
66
|
strokeDasharray: '1, 5',
|
|
@@ -95,9 +99,6 @@ const dashOptions = {
|
|
|
95
99
|
lineBorderWidth: '4'
|
|
96
100
|
}
|
|
97
101
|
};
|
|
98
|
-
const getLegend = (series, index)=>{
|
|
99
|
-
return series.name || `Series ${index + 1}`;
|
|
100
|
-
};
|
|
101
102
|
function getTitles(layout) {
|
|
102
103
|
var _layout_title, _layout_xaxis, _layout_xaxis1, _layout_xaxis_title, _layout_xaxis2, _layout_yaxis, _layout_yaxis1, _layout_yaxis_title, _layout_yaxis2;
|
|
103
104
|
var _layout_title_text, _layout_xaxis_title_text, _layout_yaxis_title_text;
|
|
@@ -133,14 +134,6 @@ const correctYearMonth = (xValues)=>{
|
|
|
133
134
|
});
|
|
134
135
|
return xValues;
|
|
135
136
|
};
|
|
136
|
-
const getColor = (legendLabel, colorMap, isDarkTheme)=>{
|
|
137
|
-
if (!colorMap.current.has(legendLabel)) {
|
|
138
|
-
const nextColor = (0, _colors.getNextColor)(colorMap.current.size + 1, 0, isDarkTheme);
|
|
139
|
-
colorMap.current.set(legendLabel, nextColor);
|
|
140
|
-
return nextColor;
|
|
141
|
-
}
|
|
142
|
-
return colorMap.current.get(legendLabel);
|
|
143
|
-
};
|
|
144
137
|
const usesSecondaryYScale = (series)=>{
|
|
145
138
|
return series.yaxis === 'y2';
|
|
146
139
|
};
|
|
@@ -180,13 +173,20 @@ const getSecondaryYAxisValues = (data, layout, maxAllowedMinY, minAllowedMaxY)=>
|
|
|
180
173
|
}
|
|
181
174
|
};
|
|
182
175
|
};
|
|
183
|
-
const
|
|
184
|
-
|
|
176
|
+
const _getGaugeAxisColor = (colorway, colorwayType, color, colorMap, isDarkTheme)=>{
|
|
177
|
+
const extractedColors = (0, _PlotlyColorAdapter.extractColor)(colorway, colorwayType, color, colorMap, isDarkTheme);
|
|
178
|
+
return (0, _PlotlyColorAdapter.resolveColor)(extractedColors, 0, '', colorMap, isDarkTheme);
|
|
179
|
+
};
|
|
180
|
+
const transformPlotlyJsonToDonutProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
181
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout, _firstData_marker, _firstData_labels, _input_layout1, _input_layout2, _input_layout3, _input_layout4;
|
|
185
182
|
const firstData = input.data[0];
|
|
183
|
+
// extract colors for each series only once
|
|
184
|
+
const colors = (0, _PlotlyColorAdapter.extractColor)((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, firstData === null || firstData === void 0 ? void 0 : (_firstData_marker = firstData.marker) === null || _firstData_marker === void 0 ? void 0 : _firstData_marker.colors, colorMap, isDarkTheme);
|
|
186
185
|
const mapLegendToDataPoint = {};
|
|
187
186
|
(_firstData_labels = firstData.labels) === null || _firstData_labels === void 0 ? void 0 : _firstData_labels.forEach((label, index)=>{
|
|
188
187
|
var _firstData_values;
|
|
189
|
-
|
|
188
|
+
// resolve color for each legend from the extracted colors
|
|
189
|
+
const color = (0, _PlotlyColorAdapter.resolveColor)(colors, index, label, colorMap, isDarkTheme);
|
|
190
190
|
//ToDo how to handle string data?
|
|
191
191
|
const value = typeof ((_firstData_values = firstData.values) === null || _firstData_values === void 0 ? void 0 : _firstData_values[index]) === 'number' ? firstData.values[index] : 1;
|
|
192
192
|
if (!mapLegendToDataPoint[label]) {
|
|
@@ -200,9 +200,9 @@ const transformPlotlyJsonToDonutProps = (input, colorMap, isDarkTheme)=>{
|
|
|
200
200
|
}
|
|
201
201
|
});
|
|
202
202
|
var _input_layout_width;
|
|
203
|
-
const width = (_input_layout_width = (
|
|
203
|
+
const width = (_input_layout_width = (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.width) !== null && _input_layout_width !== void 0 ? _input_layout_width : 440;
|
|
204
204
|
var _input_layout_height;
|
|
205
|
-
const height = (_input_layout_height = (
|
|
205
|
+
const height = (_input_layout_height = (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 220;
|
|
206
206
|
const hideLabels = firstData.textinfo ? ![
|
|
207
207
|
'value',
|
|
208
208
|
'percent',
|
|
@@ -217,26 +217,32 @@ const transformPlotlyJsonToDonutProps = (input, colorMap, isDarkTheme)=>{
|
|
|
217
217
|
chartTitle,
|
|
218
218
|
chartData: Object.values(mapLegendToDataPoint)
|
|
219
219
|
},
|
|
220
|
-
hideLegend: ((
|
|
221
|
-
width: (
|
|
220
|
+
hideLegend: ((_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : _input_layout3.showlegend) === false ? true : false,
|
|
221
|
+
width: (_input_layout4 = input.layout) === null || _input_layout4 === void 0 ? void 0 : _input_layout4.width,
|
|
222
222
|
height,
|
|
223
223
|
innerRadius,
|
|
224
224
|
hideLabels,
|
|
225
225
|
showLabelsInPercent: firstData.textinfo ? [
|
|
226
226
|
'percent',
|
|
227
227
|
'label+percent'
|
|
228
|
-
].includes(firstData.textinfo) : true
|
|
228
|
+
].includes(firstData.textinfo) : true,
|
|
229
|
+
roundCorners: true
|
|
229
230
|
};
|
|
230
231
|
};
|
|
231
|
-
const transformPlotlyJsonToVSBCProps = (input, colorMap, isDarkTheme, fallbackVSBC)=>{
|
|
232
|
-
var _input_layout, _input_layout1;
|
|
232
|
+
const transformPlotlyJsonToVSBCProps = (input, colorMap, colorwayType, isDarkTheme, fallbackVSBC)=>{
|
|
233
|
+
var _input_layout, _input_layout1, _vsbcData_;
|
|
233
234
|
const mapXToDataPoints = {};
|
|
234
235
|
let yMaxValue = 0;
|
|
235
236
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
|
|
237
|
+
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
236
238
|
let yMinValue = 0;
|
|
237
239
|
input.data.forEach((series, index1)=>{
|
|
238
|
-
var _series_x;
|
|
240
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _input_layout_template_layout1, _input_layout_template1, _input_layout1, _series_line, _series_x;
|
|
239
241
|
const isXYearCategory = (0, _chartutilities.isYearArray)(series.x); // Consider year as categorical not numeric continuous axis
|
|
242
|
+
// extract bar colors for each series only once
|
|
243
|
+
const extractedBarColors = (0, _PlotlyColorAdapter.extractColor)((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color, colorMap, isDarkTheme);
|
|
244
|
+
// extract line colors for each series only once
|
|
245
|
+
const extractedLineColors = (0, _PlotlyColorAdapter.extractColor)((_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_template1 = _input_layout1.template) === null || _input_layout_template1 === void 0 ? void 0 : (_input_layout_template_layout1 = _input_layout_template1.layout) === null || _input_layout_template_layout1 === void 0 ? void 0 : _input_layout_template_layout1.colorway, colorwayType, (_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.color, colorMap, isDarkTheme);
|
|
240
246
|
(_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x.forEach((x, index2)=>{
|
|
241
247
|
var _series_y;
|
|
242
248
|
if (!mapXToDataPoints[x]) {
|
|
@@ -246,11 +252,12 @@ const transformPlotlyJsonToVSBCProps = (input, colorMap, isDarkTheme, fallbackVS
|
|
|
246
252
|
lineData: []
|
|
247
253
|
};
|
|
248
254
|
}
|
|
249
|
-
const legend =
|
|
255
|
+
const legend = legends[index1];
|
|
256
|
+
// resolve color for each legend's bars from the extracted colors
|
|
257
|
+
const color = (0, _PlotlyColorAdapter.resolveColor)(extractedBarColors, index1, legend, colorMap, isDarkTheme);
|
|
250
258
|
var _series_y_index2;
|
|
251
259
|
const yVal = (_series_y_index2 = (_series_y = series.y) === null || _series_y === void 0 ? void 0 : _series_y[index2]) !== null && _series_y_index2 !== void 0 ? _series_y_index2 : 0;
|
|
252
260
|
if (series.type === 'bar') {
|
|
253
|
-
const color = getColor(legend, colorMap, isDarkTheme);
|
|
254
261
|
mapXToDataPoints[x].chartData.push({
|
|
255
262
|
legend,
|
|
256
263
|
data: yVal,
|
|
@@ -258,12 +265,16 @@ const transformPlotlyJsonToVSBCProps = (input, colorMap, isDarkTheme, fallbackVS
|
|
|
258
265
|
});
|
|
259
266
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
260
267
|
} else if (series.type === 'scatter' || !!fallbackVSBC) {
|
|
261
|
-
|
|
268
|
+
var _series_line;
|
|
269
|
+
const lineColor = (0, _PlotlyColorAdapter.resolveColor)(extractedLineColors, index1, legend, colorMap, isDarkTheme);
|
|
262
270
|
const lineOptions = getLineOptions(series.line);
|
|
271
|
+
const dashType = ((_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.dash) || 'solid';
|
|
272
|
+
const legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot' ? 'dottedLine' : 'default';
|
|
263
273
|
mapXToDataPoints[x].lineData.push({
|
|
264
274
|
legend,
|
|
275
|
+
legendShape,
|
|
265
276
|
y: yVal,
|
|
266
|
-
color,
|
|
277
|
+
color: lineColor,
|
|
267
278
|
...lineOptions ? {
|
|
268
279
|
lineOptions
|
|
269
280
|
} : {},
|
|
@@ -278,9 +289,10 @@ const transformPlotlyJsonToVSBCProps = (input, colorMap, isDarkTheme, fallbackVS
|
|
|
278
289
|
});
|
|
279
290
|
});
|
|
280
291
|
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
292
|
+
const vsbcData = Object.values(mapXToDataPoints);
|
|
281
293
|
var _input_layout_height;
|
|
282
294
|
return {
|
|
283
|
-
data:
|
|
295
|
+
data: vsbcData,
|
|
284
296
|
width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
|
|
285
297
|
height: (_input_layout_height = (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
|
|
286
298
|
barWidth: 'auto',
|
|
@@ -291,16 +303,22 @@ const transformPlotlyJsonToVSBCProps = (input, colorMap, isDarkTheme, fallbackVS
|
|
|
291
303
|
yAxisTitle,
|
|
292
304
|
mode: 'plotly',
|
|
293
305
|
...secondaryYAxisValues,
|
|
306
|
+
wrapXAxisLables: typeof ((_vsbcData_ = vsbcData[0]) === null || _vsbcData_ === void 0 ? void 0 : _vsbcData_.xAxisPoint) === 'string',
|
|
294
307
|
hideTickOverlap: true,
|
|
295
|
-
barGapMax: 2
|
|
308
|
+
barGapMax: 2,
|
|
309
|
+
hideLegend,
|
|
310
|
+
roundCorners: true
|
|
296
311
|
};
|
|
297
312
|
};
|
|
298
|
-
const transformPlotlyJsonToGVBCProps = (input, colorMap, isDarkTheme)=>{
|
|
299
|
-
var _input_layout, _input_layout1;
|
|
313
|
+
const transformPlotlyJsonToGVBCProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
314
|
+
var _input_layout, _input_layout1, _gvbcData_;
|
|
300
315
|
const mapXToDataPoints = {};
|
|
301
316
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, 0, 0);
|
|
317
|
+
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
302
318
|
input.data.forEach((series, index1)=>{
|
|
303
|
-
var _series_x;
|
|
319
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _series_x;
|
|
320
|
+
// extract colors for each series only once
|
|
321
|
+
const extractedColors = (0, _PlotlyColorAdapter.extractColor)((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color, colorMap, isDarkTheme);
|
|
304
322
|
(_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x.forEach((x, index2)=>{
|
|
305
323
|
if (!mapXToDataPoints[x]) {
|
|
306
324
|
mapXToDataPoints[x] = {
|
|
@@ -310,8 +328,9 @@ const transformPlotlyJsonToGVBCProps = (input, colorMap, isDarkTheme)=>{
|
|
|
310
328
|
}
|
|
311
329
|
if (series.type === 'bar') {
|
|
312
330
|
var _series_y;
|
|
313
|
-
const legend =
|
|
314
|
-
|
|
331
|
+
const legend = legends[index1];
|
|
332
|
+
// resolve color for each legend's bars from the extracted colors
|
|
333
|
+
const color = (0, _PlotlyColorAdapter.resolveColor)(extractedColors, index1, legend, colorMap, isDarkTheme);
|
|
315
334
|
var _series_y_index2;
|
|
316
335
|
mapXToDataPoints[x].series.push({
|
|
317
336
|
key: legend,
|
|
@@ -325,9 +344,10 @@ const transformPlotlyJsonToGVBCProps = (input, colorMap, isDarkTheme)=>{
|
|
|
325
344
|
});
|
|
326
345
|
});
|
|
327
346
|
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
347
|
+
const gvbcData = Object.values(mapXToDataPoints);
|
|
328
348
|
var _input_layout_height;
|
|
329
349
|
return {
|
|
330
|
-
data:
|
|
350
|
+
data: gvbcData,
|
|
331
351
|
width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
|
|
332
352
|
height: (_input_layout_height = (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
|
|
333
353
|
barWidth: 'auto',
|
|
@@ -336,17 +356,23 @@ const transformPlotlyJsonToGVBCProps = (input, colorMap, isDarkTheme)=>{
|
|
|
336
356
|
yAxisTitle,
|
|
337
357
|
mode: 'plotly',
|
|
338
358
|
...secondaryYAxisValues,
|
|
339
|
-
hideTickOverlap: true
|
|
359
|
+
hideTickOverlap: true,
|
|
360
|
+
wrapXAxisLables: typeof ((_gvbcData_ = gvbcData[0]) === null || _gvbcData_ === void 0 ? void 0 : _gvbcData_.name) === 'string',
|
|
361
|
+
hideLegend,
|
|
362
|
+
roundCorners: true
|
|
340
363
|
};
|
|
341
364
|
};
|
|
342
|
-
const transformPlotlyJsonToVBCProps = (input, colorMap, isDarkTheme)=>{
|
|
343
|
-
var _input_layout, _input_layout1;
|
|
365
|
+
const transformPlotlyJsonToVBCProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
366
|
+
var _input_layout, _input_layout1, _vbcData_;
|
|
344
367
|
const vbcData = [];
|
|
368
|
+
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
345
369
|
input.data.forEach((series, seriesIdx)=>{
|
|
346
|
-
var _series_xbins, _series_xbins1, _series_xbins2;
|
|
370
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _series_xbins, _series_xbins1, _series_xbins2;
|
|
347
371
|
if (!series.x) {
|
|
348
372
|
return;
|
|
349
373
|
}
|
|
374
|
+
// extract colors for each series only once
|
|
375
|
+
const extractedColors = (0, _PlotlyColorAdapter.extractColor)((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color, colorMap, isDarkTheme);
|
|
350
376
|
const isXString = isStringArray(series.x);
|
|
351
377
|
// TODO: In case of a single bin, add an empty bin of the same size to prevent the
|
|
352
378
|
// default bar width from being used and ensure the bar spans the full intended range.
|
|
@@ -367,8 +393,9 @@ const transformPlotlyJsonToVBCProps = (input, colorMap, isDarkTheme)=>{
|
|
|
367
393
|
return yVal;
|
|
368
394
|
});
|
|
369
395
|
xBins.forEach((bin, index)=>{
|
|
370
|
-
const legend =
|
|
371
|
-
|
|
396
|
+
const legend = legends[seriesIdx];
|
|
397
|
+
// resolve color for each legend's bars from the extracted colors
|
|
398
|
+
const color = (0, _PlotlyColorAdapter.resolveColor)(extractedColors, seriesIdx, legend, colorMap, isDarkTheme);
|
|
372
399
|
const yVal = calculateHistNorm(series.histnorm, y[index], total, isXString ? bin.length : getBinSize(bin));
|
|
373
400
|
vbcData.push({
|
|
374
401
|
x: isXString ? bin.join(', ') : getBinCenter(bin),
|
|
@@ -392,23 +419,34 @@ const transformPlotlyJsonToVBCProps = (input, colorMap, isDarkTheme)=>{
|
|
|
392
419
|
yAxisTitle,
|
|
393
420
|
mode: 'histogram',
|
|
394
421
|
hideTickOverlap: true,
|
|
395
|
-
|
|
422
|
+
wrapXAxisLables: typeof ((_vbcData_ = vbcData[0]) === null || _vbcData_ === void 0 ? void 0 : _vbcData_.x) === 'string',
|
|
423
|
+
maxBarWidth: 50,
|
|
424
|
+
hideLegend,
|
|
425
|
+
roundCorners: true
|
|
396
426
|
};
|
|
397
427
|
};
|
|
398
|
-
const transformPlotlyJsonToScatterChartProps = (input, isAreaChart, colorMap, isDarkTheme)=>{
|
|
428
|
+
const transformPlotlyJsonToScatterChartProps = (input, isAreaChart, isScatterMarkers, colorMap, colorwayType, isDarkTheme)=>{
|
|
399
429
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
|
|
400
430
|
let mode = 'tonexty';
|
|
431
|
+
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
401
432
|
const chartData = input.data.map((series, index)=>{
|
|
433
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _series_line, _series_line1;
|
|
434
|
+
// extract colors for each series only once
|
|
435
|
+
const extractedColors = (0, _PlotlyColorAdapter.extractColor)((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, isScatterMarkers ? (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color : (_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.color, colorMap, isDarkTheme);
|
|
402
436
|
const xValues = series.x;
|
|
403
437
|
const isString = typeof xValues[0] === 'string';
|
|
404
438
|
const isXDate = (0, _chartutilities.isDateArray)(xValues);
|
|
405
439
|
const isXNumber = (0, _chartutilities.isNumberArray)(xValues);
|
|
406
|
-
const legend =
|
|
407
|
-
|
|
440
|
+
const legend = legends[index];
|
|
441
|
+
// resolve color for each legend's lines from the extracted colors
|
|
442
|
+
const seriesColor = (0, _PlotlyColorAdapter.resolveColor)(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
408
443
|
mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
|
|
409
444
|
const lineOptions = getLineOptions(series.line);
|
|
445
|
+
const dashType = ((_series_line1 = series.line) === null || _series_line1 === void 0 ? void 0 : _series_line1.dash) || 'solid';
|
|
446
|
+
const legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot' ? 'dottedLine' : 'default';
|
|
410
447
|
return {
|
|
411
448
|
legend,
|
|
449
|
+
legendShape,
|
|
412
450
|
data: xValues.map((x, i)=>{
|
|
413
451
|
var _series_marker, _series_marker1;
|
|
414
452
|
return {
|
|
@@ -421,7 +459,7 @@ const transformPlotlyJsonToScatterChartProps = (input, isAreaChart, colorMap, is
|
|
|
421
459
|
} : {}
|
|
422
460
|
};
|
|
423
461
|
}),
|
|
424
|
-
color:
|
|
462
|
+
color: seriesColor,
|
|
425
463
|
...lineOptions ? {
|
|
426
464
|
lineOptions
|
|
427
465
|
} : {},
|
|
@@ -447,7 +485,8 @@ const transformPlotlyJsonToScatterChartProps = (input, isAreaChart, colorMap, is
|
|
|
447
485
|
width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
|
|
448
486
|
height: (_input_layout_height = (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
|
|
449
487
|
hideTickOverlap: true,
|
|
450
|
-
useUTC: false
|
|
488
|
+
useUTC: false,
|
|
489
|
+
hideLegend
|
|
451
490
|
};
|
|
452
491
|
} else {
|
|
453
492
|
var _input_layout2, _input_layout3;
|
|
@@ -464,21 +503,26 @@ const transformPlotlyJsonToScatterChartProps = (input, isAreaChart, colorMap, is
|
|
|
464
503
|
width: (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.width,
|
|
465
504
|
height: (_input_layout_height1 = (_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : _input_layout3.height) !== null && _input_layout_height1 !== void 0 ? _input_layout_height1 : 350,
|
|
466
505
|
hideTickOverlap: true,
|
|
467
|
-
useUTC: false
|
|
506
|
+
useUTC: false,
|
|
507
|
+
hideLegend
|
|
468
508
|
};
|
|
469
509
|
}
|
|
470
510
|
};
|
|
471
|
-
const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, colorMap, isDarkTheme)=>{
|
|
511
|
+
const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
472
512
|
var _input_layout, _input_layout_margin, _input_layout1, _input_layout_margin1, _input_layout2, _input_layout_yaxis2, _input_layout3, _input_layout_yaxis21, _input_layout4, _input_layout_yaxis2_title, _input_layout_yaxis22, _input_layout5, _input_layout6;
|
|
513
|
+
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
473
514
|
const chartData = input.data.map((series, index)=>{
|
|
515
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker;
|
|
516
|
+
// extract colors for each series only once
|
|
517
|
+
const extractedColors = (0, _PlotlyColorAdapter.extractColor)((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color, colorMap, isDarkTheme);
|
|
518
|
+
const legend = legends[index];
|
|
519
|
+
// resolve color for each legend's bars from the extracted colors
|
|
520
|
+
const color = (0, _PlotlyColorAdapter.resolveColor)(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
474
521
|
return series.y.map((yValue, i)=>{
|
|
475
|
-
var _series_name;
|
|
476
|
-
const legendName = (_series_name = series.name) !== null && _series_name !== void 0 ? _series_name : yValue;
|
|
477
|
-
const color = getColor(legendName, colorMap, isDarkTheme);
|
|
478
522
|
return {
|
|
479
523
|
x: series.x[i],
|
|
480
524
|
y: yValue,
|
|
481
|
-
legend
|
|
525
|
+
legend,
|
|
482
526
|
color
|
|
483
527
|
};
|
|
484
528
|
});
|
|
@@ -508,7 +552,9 @@ const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, colorMap, isDark
|
|
|
508
552
|
width: (_input_layout6 = input.layout) === null || _input_layout6 === void 0 ? void 0 : _input_layout6.width,
|
|
509
553
|
hideTickOverlap: true,
|
|
510
554
|
noOfCharsToTruncate: 20,
|
|
511
|
-
showYAxisLablesTooltip: true
|
|
555
|
+
showYAxisLablesTooltip: true,
|
|
556
|
+
hideLegend,
|
|
557
|
+
roundCorners: true
|
|
512
558
|
};
|
|
513
559
|
};
|
|
514
560
|
const transformPlotlyJsonToHeatmapProps = (input)=>{
|
|
@@ -614,29 +660,31 @@ const transformPlotlyJsonToHeatmapProps = (input)=>{
|
|
|
614
660
|
height: (_input_layout_height = (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
|
|
615
661
|
hideTickOverlap: true,
|
|
616
662
|
noOfCharsToTruncate: 20,
|
|
617
|
-
showYAxisLablesTooltip: true
|
|
663
|
+
showYAxisLablesTooltip: true,
|
|
664
|
+
wrapXAxisLables: true
|
|
618
665
|
};
|
|
619
666
|
};
|
|
620
|
-
const transformPlotlyJsonToSankeyProps = (input, colorMap, isDarkTheme)=>{
|
|
621
|
-
var
|
|
667
|
+
const transformPlotlyJsonToSankeyProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
668
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout, _node_label, _input_layout1, _input_layout2;
|
|
622
669
|
const { link, node } = input.data[0];
|
|
623
670
|
var _link_value;
|
|
624
671
|
const validLinks = ((_link_value = link === null || link === void 0 ? void 0 : link.value) !== null && _link_value !== void 0 ? _link_value : []).map((val, index)=>({
|
|
625
672
|
value: val,
|
|
626
673
|
source: link === null || link === void 0 ? void 0 : link.source[index],
|
|
627
674
|
target: link === null || link === void 0 ? void 0 : link.target[index]
|
|
628
|
-
})) //
|
|
629
|
-
// Filter out negative nodes, unequal nodes and self-references (circular links)
|
|
675
|
+
})) // Filter out negative nodes, unequal nodes and self-references (circular links)
|
|
630
676
|
.filter((x)=>x.source >= 0 && x.target >= 0 && x.source !== x.target);
|
|
677
|
+
const extractedNodeColors = (0, _PlotlyColorAdapter.extractColor)((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, node === null || node === void 0 ? void 0 : node.color, colorMap, isDarkTheme);
|
|
631
678
|
const sankeyChartData = {
|
|
632
679
|
nodes: (_node_label = node.label) === null || _node_label === void 0 ? void 0 : _node_label.map((label, index)=>{
|
|
633
|
-
const color =
|
|
680
|
+
const color = (0, _PlotlyColorAdapter.resolveColor)(extractedNodeColors, index, label, colorMap, isDarkTheme);
|
|
634
681
|
return {
|
|
635
682
|
nodeId: index,
|
|
636
683
|
name: label,
|
|
637
684
|
color
|
|
638
685
|
};
|
|
639
686
|
}),
|
|
687
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
640
688
|
links: validLinks.map((validLink, index)=>{
|
|
641
689
|
return {
|
|
642
690
|
...validLink
|
|
@@ -655,18 +703,20 @@ const transformPlotlyJsonToSankeyProps = (input, colorMap, isDarkTheme)=>{
|
|
|
655
703
|
chartTitle,
|
|
656
704
|
SankeyChartData: sankeyChartData
|
|
657
705
|
},
|
|
658
|
-
width: (
|
|
659
|
-
height: (_input_layout_height = (
|
|
706
|
+
width: (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.width,
|
|
707
|
+
height: (_input_layout_height = (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 468
|
|
660
708
|
};
|
|
661
709
|
};
|
|
662
|
-
const transformPlotlyJsonToGaugeProps = (input, colorMap, isDarkTheme)=>{
|
|
663
|
-
var _firstData_gauge_steps,
|
|
710
|
+
const transformPlotlyJsonToGaugeProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
711
|
+
var _firstData_gauge, _input_layout_template_layout, _input_layout_template, _input_layout, _firstData_gauge_steps, _firstData_gauge1, _firstData_gauge_axis_range, _firstData_gauge_axis, _firstData_gauge2, _input_layout_template_layout1, _input_layout_template1, _input_layout1, _firstData_gauge_axis1, _firstData_gauge3, _firstData_gauge_axis_range1, _firstData_gauge_axis2, _firstData_gauge4, _firstData_delta, _firstData_gauge_axis_range2, _firstData_gauge_axis3, _firstData_gauge5, _firstData_gauge_axis_range3, _firstData_gauge_axis4, _firstData_gauge6, _firstData_gauge_axis_range4, _firstData_gauge_axis5, _firstData_gauge7, _firstData_gauge_axis_range5, _firstData_gauge_axis6, _firstData_gauge8, _input_layout2, _input_layout3, _firstData_gauge_steps1, _firstData_gauge9;
|
|
664
712
|
const firstData = input.data[0];
|
|
713
|
+
const stepsColors = ((_firstData_gauge = firstData.gauge) === null || _firstData_gauge === void 0 ? void 0 : _firstData_gauge.steps) ? firstData.gauge.steps.map((step)=>step.color) : undefined;
|
|
714
|
+
const extractedColors = (0, _PlotlyColorAdapter.extractColor)((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, stepsColors, colorMap, isDarkTheme);
|
|
665
715
|
var _firstData_gauge_axis_range_, _firstData_value, _firstData_gauge_axis_range_1, _firstData_value1;
|
|
666
|
-
const segments = ((
|
|
716
|
+
const segments = ((_firstData_gauge1 = firstData.gauge) === null || _firstData_gauge1 === void 0 ? void 0 : (_firstData_gauge_steps = _firstData_gauge1.steps) === null || _firstData_gauge_steps === void 0 ? void 0 : _firstData_gauge_steps.length) ? firstData.gauge.steps.map((step, index)=>{
|
|
667
717
|
var _step_range, _step_range1;
|
|
668
718
|
const legend = step.name || `Segment ${index + 1}`;
|
|
669
|
-
const color =
|
|
719
|
+
const color = (0, _PlotlyColorAdapter.resolveColor)(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
670
720
|
return {
|
|
671
721
|
legend,
|
|
672
722
|
size: ((_step_range = step.range) === null || _step_range === void 0 ? void 0 : _step_range[1]) - ((_step_range1 = step.range) === null || _step_range1 === void 0 ? void 0 : _step_range1[0]),
|
|
@@ -675,34 +725,36 @@ const transformPlotlyJsonToGaugeProps = (input, colorMap, isDarkTheme)=>{
|
|
|
675
725
|
}) : [
|
|
676
726
|
{
|
|
677
727
|
legend: 'Current',
|
|
678
|
-
size: (_firstData_value = firstData.value) !== null && _firstData_value !== void 0 ? _firstData_value : 0 - ((_firstData_gauge_axis_range_ = (
|
|
679
|
-
color:
|
|
728
|
+
size: (_firstData_value = firstData.value) !== null && _firstData_value !== void 0 ? _firstData_value : 0 - ((_firstData_gauge_axis_range_ = (_firstData_gauge2 = firstData.gauge) === null || _firstData_gauge2 === void 0 ? void 0 : (_firstData_gauge_axis = _firstData_gauge2.axis) === null || _firstData_gauge_axis === void 0 ? void 0 : (_firstData_gauge_axis_range = _firstData_gauge_axis.range) === null || _firstData_gauge_axis_range === void 0 ? void 0 : _firstData_gauge_axis_range[0]) !== null && _firstData_gauge_axis_range_ !== void 0 ? _firstData_gauge_axis_range_ : 0),
|
|
729
|
+
color: _getGaugeAxisColor((_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_template1 = _input_layout1.template) === null || _input_layout_template1 === void 0 ? void 0 : (_input_layout_template_layout1 = _input_layout_template1.layout) === null || _input_layout_template_layout1 === void 0 ? void 0 : _input_layout_template_layout1.colorway, colorwayType, (_firstData_gauge3 = firstData.gauge) === null || _firstData_gauge3 === void 0 ? void 0 : (_firstData_gauge_axis1 = _firstData_gauge3.axis) === null || _firstData_gauge_axis1 === void 0 ? void 0 : _firstData_gauge_axis1.color, colorMap, isDarkTheme)
|
|
680
730
|
},
|
|
681
731
|
{
|
|
682
732
|
legend: 'Target',
|
|
683
|
-
size: ((_firstData_gauge_axis_range_1 = (
|
|
733
|
+
size: ((_firstData_gauge_axis_range_1 = (_firstData_gauge4 = firstData.gauge) === null || _firstData_gauge4 === void 0 ? void 0 : (_firstData_gauge_axis2 = _firstData_gauge4.axis) === null || _firstData_gauge_axis2 === void 0 ? void 0 : (_firstData_gauge_axis_range1 = _firstData_gauge_axis2.range) === null || _firstData_gauge_axis_range1 === void 0 ? void 0 : _firstData_gauge_axis_range1[1]) !== null && _firstData_gauge_axis_range_1 !== void 0 ? _firstData_gauge_axis_range_1 : 100) - ((_firstData_value1 = firstData.value) !== null && _firstData_value1 !== void 0 ? _firstData_value1 : 0),
|
|
684
734
|
color: _colors.DataVizPalette.disabled
|
|
685
735
|
}
|
|
686
736
|
];
|
|
687
737
|
let sublabel;
|
|
688
|
-
|
|
738
|
+
let sublabelColor;
|
|
689
739
|
if ((_firstData_delta = firstData.delta) === null || _firstData_delta === void 0 ? void 0 : _firstData_delta.reference) {
|
|
690
740
|
const diff = firstData.value - firstData.delta.reference;
|
|
691
741
|
if (diff >= 0) {
|
|
742
|
+
var _input_layout_template_layout2, _input_layout_template2, _input_layout4, _firstData_delta_increasing, _firstData_delta1;
|
|
692
743
|
sublabel = `\u25B2 ${diff}`;
|
|
693
|
-
|
|
694
|
-
|
|
744
|
+
const extractedIncreasingDeltaColors = (0, _PlotlyColorAdapter.extractColor)((_input_layout4 = input.layout) === null || _input_layout4 === void 0 ? void 0 : (_input_layout_template2 = _input_layout4.template) === null || _input_layout_template2 === void 0 ? void 0 : (_input_layout_template_layout2 = _input_layout_template2.layout) === null || _input_layout_template_layout2 === void 0 ? void 0 : _input_layout_template_layout2.colorway, colorwayType, (_firstData_delta1 = firstData.delta) === null || _firstData_delta1 === void 0 ? void 0 : (_firstData_delta_increasing = _firstData_delta1.increasing) === null || _firstData_delta_increasing === void 0 ? void 0 : _firstData_delta_increasing.color, colorMap, isDarkTheme);
|
|
745
|
+
const color = (0, _PlotlyColorAdapter.resolveColor)(extractedIncreasingDeltaColors, 0, '', colorMap, isDarkTheme);
|
|
746
|
+
sublabelColor = color;
|
|
695
747
|
} else {
|
|
748
|
+
var _input_layout_template_layout3, _input_layout_template3, _input_layout5, _firstData_delta_decreasing, _firstData_delta2;
|
|
696
749
|
sublabel = `\u25BC ${Math.abs(diff)}`;
|
|
697
|
-
|
|
698
|
-
|
|
750
|
+
const extractedDecreasingDeltaColors = (0, _PlotlyColorAdapter.extractColor)((_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : (_input_layout_template3 = _input_layout5.template) === null || _input_layout_template3 === void 0 ? void 0 : (_input_layout_template_layout3 = _input_layout_template3.layout) === null || _input_layout_template_layout3 === void 0 ? void 0 : _input_layout_template_layout3.colorway, colorwayType, (_firstData_delta2 = firstData.delta) === null || _firstData_delta2 === void 0 ? void 0 : (_firstData_delta_decreasing = _firstData_delta2.decreasing) === null || _firstData_delta_decreasing === void 0 ? void 0 : _firstData_delta_decreasing.color, colorMap, isDarkTheme);
|
|
751
|
+
const color = (0, _PlotlyColorAdapter.resolveColor)(extractedDecreasingDeltaColors, 0, '', colorMap, isDarkTheme);
|
|
752
|
+
sublabelColor = color;
|
|
699
753
|
}
|
|
700
754
|
}
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
// },
|
|
705
|
-
// };
|
|
755
|
+
const styles = {
|
|
756
|
+
sublabel: sublabelColor
|
|
757
|
+
};
|
|
706
758
|
const { chartTitle } = getTitles(input.layout);
|
|
707
759
|
var _firstData_value2, _input_layout_height;
|
|
708
760
|
return {
|
|
@@ -711,18 +763,60 @@ const transformPlotlyJsonToGaugeProps = (input, colorMap, isDarkTheme)=>{
|
|
|
711
763
|
chartTitle,
|
|
712
764
|
sublabel,
|
|
713
765
|
// range values can be null
|
|
714
|
-
minValue: typeof ((
|
|
715
|
-
maxValue: typeof ((
|
|
766
|
+
minValue: typeof ((_firstData_gauge5 = firstData.gauge) === null || _firstData_gauge5 === void 0 ? void 0 : (_firstData_gauge_axis3 = _firstData_gauge5.axis) === null || _firstData_gauge_axis3 === void 0 ? void 0 : (_firstData_gauge_axis_range2 = _firstData_gauge_axis3.range) === null || _firstData_gauge_axis_range2 === void 0 ? void 0 : _firstData_gauge_axis_range2[0]) === 'number' ? (_firstData_gauge6 = firstData.gauge) === null || _firstData_gauge6 === void 0 ? void 0 : (_firstData_gauge_axis4 = _firstData_gauge6.axis) === null || _firstData_gauge_axis4 === void 0 ? void 0 : (_firstData_gauge_axis_range3 = _firstData_gauge_axis4.range) === null || _firstData_gauge_axis_range3 === void 0 ? void 0 : _firstData_gauge_axis_range3[0] : undefined,
|
|
767
|
+
maxValue: typeof ((_firstData_gauge7 = firstData.gauge) === null || _firstData_gauge7 === void 0 ? void 0 : (_firstData_gauge_axis5 = _firstData_gauge7.axis) === null || _firstData_gauge_axis5 === void 0 ? void 0 : (_firstData_gauge_axis_range4 = _firstData_gauge_axis5.range) === null || _firstData_gauge_axis_range4 === void 0 ? void 0 : _firstData_gauge_axis_range4[1]) === 'number' ? (_firstData_gauge8 = firstData.gauge) === null || _firstData_gauge8 === void 0 ? void 0 : (_firstData_gauge_axis6 = _firstData_gauge8.axis) === null || _firstData_gauge_axis6 === void 0 ? void 0 : (_firstData_gauge_axis_range5 = _firstData_gauge_axis6.range) === null || _firstData_gauge_axis_range5 === void 0 ? void 0 : _firstData_gauge_axis_range5[1] : undefined,
|
|
716
768
|
chartValueFormat: ()=>{
|
|
717
769
|
var _firstData_value;
|
|
718
770
|
var _firstData_value_toString;
|
|
719
771
|
return (_firstData_value_toString = (_firstData_value = firstData.value) === null || _firstData_value === void 0 ? void 0 : _firstData_value.toString()) !== null && _firstData_value_toString !== void 0 ? _firstData_value_toString : '';
|
|
720
772
|
},
|
|
721
|
-
width: (
|
|
722
|
-
height: (_input_layout_height = (
|
|
773
|
+
width: (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.width,
|
|
774
|
+
height: (_input_layout_height = (_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : _input_layout3.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 220,
|
|
723
775
|
// TODO
|
|
724
776
|
// styles,
|
|
725
|
-
variant: ((
|
|
777
|
+
variant: ((_firstData_gauge9 = firstData.gauge) === null || _firstData_gauge9 === void 0 ? void 0 : (_firstData_gauge_steps1 = _firstData_gauge9.steps) === null || _firstData_gauge_steps1 === void 0 ? void 0 : _firstData_gauge_steps1.length) ? 'multiple-segments' : 'single-segment',
|
|
778
|
+
styles,
|
|
779
|
+
roundCorners: true
|
|
780
|
+
};
|
|
781
|
+
};
|
|
782
|
+
const cleanText = (text)=>{
|
|
783
|
+
return text.replace(/<[^&]*?>/g, '').replace(/<[^>]*>/g, '').replace(/<br>|\\u003cbr\\u003e|<br>/gi, '').replace(/\$[^$]*\$/g, '$').trim();
|
|
784
|
+
};
|
|
785
|
+
const transformPlotlyJsonToChartTableProps = (input, colorMap, isDarkTheme)=>{
|
|
786
|
+
var _tableData_cells, _input_layout_font, _input_layout, _tableData_header, _input_layout1, _input_layout2;
|
|
787
|
+
const tableData = input.data[0];
|
|
788
|
+
const normalizeHeaders = (values)=>{
|
|
789
|
+
// Case: values is array of arrays
|
|
790
|
+
if (Array.isArray(values[0])) {
|
|
791
|
+
return values.map((row)=>row.map((cell)=>cleanText(cell)).filter(Boolean).join(' '));
|
|
792
|
+
}
|
|
793
|
+
// Case: values is 1d array
|
|
794
|
+
return values.map((cell)=>cleanText(cell));
|
|
795
|
+
};
|
|
796
|
+
var _tableData_cells_values;
|
|
797
|
+
const columns = (_tableData_cells_values = (_tableData_cells = tableData.cells) === null || _tableData_cells === void 0 ? void 0 : _tableData_cells.values) !== null && _tableData_cells_values !== void 0 ? _tableData_cells_values : [];
|
|
798
|
+
const rows = columns[0].map((_, rowIndex)=>columns.map((col)=>{
|
|
799
|
+
const cell = col[rowIndex];
|
|
800
|
+
return {
|
|
801
|
+
value: typeof cell === 'string' ? cleanText(cell) : cell
|
|
802
|
+
};
|
|
803
|
+
}));
|
|
804
|
+
const styles = {
|
|
805
|
+
root: {
|
|
806
|
+
...((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_font = _input_layout.font) === null || _input_layout_font === void 0 ? void 0 : _input_layout_font.size) ? {
|
|
807
|
+
fontSize: input.layout.font.size
|
|
808
|
+
} : {}
|
|
809
|
+
}
|
|
810
|
+
};
|
|
811
|
+
var _tableData_header_values;
|
|
812
|
+
return {
|
|
813
|
+
headers: normalizeHeaders((_tableData_header_values = (_tableData_header = tableData.header) === null || _tableData_header === void 0 ? void 0 : _tableData_header.values) !== null && _tableData_header_values !== void 0 ? _tableData_header_values : []).map((value)=>({
|
|
814
|
+
value
|
|
815
|
+
})),
|
|
816
|
+
rows,
|
|
817
|
+
width: (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.width,
|
|
818
|
+
height: (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.height,
|
|
819
|
+
styles
|
|
726
820
|
};
|
|
727
821
|
};
|
|
728
822
|
const projectPolarToCartesian = (input)=>{
|
|
@@ -743,17 +837,23 @@ const projectPolarToCartesian = (input)=>{
|
|
|
743
837
|
}
|
|
744
838
|
return projection;
|
|
745
839
|
};
|
|
840
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
746
841
|
function isPlainObject(obj) {
|
|
747
842
|
return Object.prototype.toString.call(obj) === '[object Object]' && Object.getPrototypeOf(obj).hasOwnProperty('hasOwnProperty');
|
|
748
843
|
}
|
|
844
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
749
845
|
var arrayAttributes = [];
|
|
846
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
750
847
|
var stack = [];
|
|
848
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
751
849
|
var isArrayStack = [];
|
|
850
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
752
851
|
var baseContainer, baseAttrName;
|
|
753
852
|
function findArrayAttributes(trace) {
|
|
754
853
|
// Init basecontainer and baseAttrName
|
|
755
854
|
crawlIntoTrace(baseContainer, 0, '');
|
|
756
855
|
}
|
|
856
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
757
857
|
function crawlIntoTrace(container, i, astrPartial) {
|
|
758
858
|
var item = container[stack[i]];
|
|
759
859
|
var newAstrPartial = astrPartial + stack[i];
|
|
@@ -805,7 +905,9 @@ function getLineOptions(line) {
|
|
|
805
905
|
}
|
|
806
906
|
return Object.keys(lineOptions).length > 0 ? lineOptions : undefined;
|
|
807
907
|
}
|
|
908
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
808
909
|
const isStringArray = (arr)=>{
|
|
910
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
809
911
|
return (0, _chartutilities.isArrayOfType)(arr, (value)=>typeof value === 'string');
|
|
810
912
|
};
|
|
811
913
|
// TODO: Use binary search to find the appropriate bin for numeric value.
|
|
@@ -902,3 +1004,18 @@ const precisionRound = (value, precision)=>{
|
|
|
902
1004
|
const factor = Math.pow(10, precision);
|
|
903
1005
|
return Math.round(value * factor) / factor;
|
|
904
1006
|
};
|
|
1007
|
+
const getLegendProps = (data, layout)=>{
|
|
1008
|
+
const legends = [];
|
|
1009
|
+
if (data.length === 1) {
|
|
1010
|
+
legends.push(data[0].name || '');
|
|
1011
|
+
} else {
|
|
1012
|
+
data.forEach((series, index)=>{
|
|
1013
|
+
legends.push(series.name || `Series ${index + 1}`);
|
|
1014
|
+
});
|
|
1015
|
+
}
|
|
1016
|
+
const hideLegends = data.every((series)=>series.showlegend === false);
|
|
1017
|
+
return {
|
|
1018
|
+
legends,
|
|
1019
|
+
hideLegend: (layout === null || layout === void 0 ? void 0 : layout.showlegend) === false ? true : hideLegends
|
|
1020
|
+
};
|
|
1021
|
+
};
|