@fluentui/react-charts 0.0.0-nightly-20250819-0407.1 → 0.0.0-nightly-20250820-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.
- package/CHANGELOG.md +15 -15
- package/dist/index.d.ts +9 -1
- package/lib/components/AreaChart/AreaChart.js +4 -1
- package/lib/components/AreaChart/AreaChart.js.map +1 -1
- package/lib/components/AreaChart/useAreaChartStyles.styles.js +2 -1
- package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
- package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js +2 -1
- package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.js +48 -3
- package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +13 -0
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +12 -0
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +175 -120
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +6 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +293 -44
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/GanttChart/useGanttChartStyles.styles.js +2 -1
- package/lib/components/GanttChart/useGanttChartStyles.styles.js.map +1 -1
- package/lib/components/GanttChart/useGanttChartStyles.styles.raw.js +2 -1
- package/lib/components/GanttChart/useGanttChartStyles.styles.raw.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +2 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +2 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js +2 -1
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +2 -1
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +2 -1
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +2 -1
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
- package/lib/components/LineChart/useLineChartStyles.styles.js +2 -1
- package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -1
- package/lib/components/LineChart/useLineChartStyles.styles.raw.js +2 -1
- package/lib/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.js +47 -30
- package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -1
- package/lib/components/ScatterChart/useScatterChartStyles.styles.js +21 -4
- package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js +16 -3
- package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +2 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +2 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +2 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +2 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
- package/lib/utilities/utilities.js +0 -29
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-commonjs/components/AreaChart/AreaChart.js +4 -1
- package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js +2 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.js +48 -3
- 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/useCartesianChartStyles.styles.js +13 -0
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +12 -0
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +171 -118
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +9 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +309 -50
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js +2 -1
- package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +2 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js +2 -1
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +2 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js +2 -1
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.js +47 -30
- package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.types.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js +30 -3
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js +15 -2
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +2 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +2 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/utilities/utilities.js +0 -32
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +12 -12
|
@@ -18,21 +18,27 @@ _export(exports, {
|
|
|
18
18
|
findArrayAttributes: function() {
|
|
19
19
|
return findArrayAttributes;
|
|
20
20
|
},
|
|
21
|
+
getAllupLegendsProps: function() {
|
|
22
|
+
return getAllupLegendsProps;
|
|
23
|
+
},
|
|
24
|
+
getGridProperties: function() {
|
|
25
|
+
return getGridProperties;
|
|
26
|
+
},
|
|
21
27
|
getNumberAtIndexOrDefault: function() {
|
|
22
28
|
return getNumberAtIndexOrDefault;
|
|
23
29
|
},
|
|
24
30
|
getValidXYRanges: function() {
|
|
25
31
|
return getValidXYRanges;
|
|
26
32
|
},
|
|
27
|
-
isStringArray: function() {
|
|
28
|
-
return isStringArray;
|
|
29
|
-
},
|
|
30
33
|
projectPolarToCartesian: function() {
|
|
31
34
|
return projectPolarToCartesian;
|
|
32
35
|
},
|
|
33
36
|
resolveXAxisPoint: function() {
|
|
34
37
|
return resolveXAxisPoint;
|
|
35
38
|
},
|
|
39
|
+
transformPlotlyJsonToAreaChartProps: function() {
|
|
40
|
+
return transformPlotlyJsonToAreaChartProps;
|
|
41
|
+
},
|
|
36
42
|
transformPlotlyJsonToChartTableProps: function() {
|
|
37
43
|
return transformPlotlyJsonToChartTableProps;
|
|
38
44
|
},
|
|
@@ -51,6 +57,9 @@ _export(exports, {
|
|
|
51
57
|
transformPlotlyJsonToHorizontalBarWithAxisProps: function() {
|
|
52
58
|
return transformPlotlyJsonToHorizontalBarWithAxisProps;
|
|
53
59
|
},
|
|
60
|
+
transformPlotlyJsonToLineChartProps: function() {
|
|
61
|
+
return transformPlotlyJsonToLineChartProps;
|
|
62
|
+
},
|
|
54
63
|
transformPlotlyJsonToSankeyProps: function() {
|
|
55
64
|
return transformPlotlyJsonToSankeyProps;
|
|
56
65
|
},
|
|
@@ -74,6 +83,7 @@ const _utilities = require("../../utilities/utilities");
|
|
|
74
83
|
const _chartutilities = require("@fluentui/chart-utilities");
|
|
75
84
|
const _d3shape = require("d3-shape");
|
|
76
85
|
const _PlotlyColorAdapter = require("./PlotlyColorAdapter");
|
|
86
|
+
const _d3color = require("d3-color");
|
|
77
87
|
const dashOptions = {
|
|
78
88
|
dot: {
|
|
79
89
|
strokeDasharray: '1, 5',
|
|
@@ -157,8 +167,9 @@ const correctYearMonth = (xValues)=>{
|
|
|
157
167
|
});
|
|
158
168
|
return xValues;
|
|
159
169
|
};
|
|
160
|
-
const usesSecondaryYScale = (series)=>{
|
|
161
|
-
|
|
170
|
+
const usesSecondaryYScale = (series, layout)=>{
|
|
171
|
+
var _layout_yaxis2, _layout_yaxis21;
|
|
172
|
+
return series.yaxis === 'y2' && ((layout === null || layout === void 0 ? void 0 : (_layout_yaxis2 = layout.yaxis2) === null || _layout_yaxis2 === void 0 ? void 0 : _layout_yaxis2.anchor) === 'x' || (layout === null || layout === void 0 ? void 0 : (_layout_yaxis21 = layout.yaxis2) === null || _layout_yaxis21 === void 0 ? void 0 : _layout_yaxis21.side) === 'right');
|
|
162
173
|
};
|
|
163
174
|
const getSecondaryYAxisValues = (data, layout, maxAllowedMinY, minAllowedMaxY)=>{
|
|
164
175
|
var _layout_yaxis2, _layout_yaxis21, _layout_yaxis2_title, _layout_yaxis22;
|
|
@@ -166,7 +177,7 @@ const getSecondaryYAxisValues = (data, layout, maxAllowedMinY, minAllowedMaxY)=>
|
|
|
166
177
|
let yMinValue;
|
|
167
178
|
let yMaxValue;
|
|
168
179
|
data.forEach((series)=>{
|
|
169
|
-
if (usesSecondaryYScale(series)) {
|
|
180
|
+
if (usesSecondaryYScale(series, layout)) {
|
|
170
181
|
containsSecondaryYAxis = true;
|
|
171
182
|
const yValues = series.y;
|
|
172
183
|
if (yValues) {
|
|
@@ -219,7 +230,7 @@ const resolveXAxisPoint = (x, isXYearCategory, isXString, isXDate, isXNumber)=>{
|
|
|
219
230
|
}
|
|
220
231
|
return x;
|
|
221
232
|
};
|
|
222
|
-
const transformPlotlyJsonToDonutProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
233
|
+
const transformPlotlyJsonToDonutProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
223
234
|
var _input_layout, _input_layout_template_layout, _input_layout_template, _input_layout1, _input_layout2, _firstData_marker, _firstData_labels, _input_layout3, _input_layout4, _input_layout5, _input_layout6;
|
|
224
235
|
const firstData = input.data[0];
|
|
225
236
|
var _input_layout_piecolorway, _input_layout_piecolorway1;
|
|
@@ -276,12 +287,12 @@ const transformPlotlyJsonToDonutProps = (input, colorMap, colorwayType, isDarkTh
|
|
|
276
287
|
roundCorners: true
|
|
277
288
|
};
|
|
278
289
|
};
|
|
279
|
-
const transformPlotlyJsonToVSBCProps = (input, colorMap, colorwayType, isDarkTheme, fallbackVSBC)=>{
|
|
290
|
+
const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme, fallbackVSBC)=>{
|
|
280
291
|
var _input_layout, _input_layout1, _vsbcData_;
|
|
281
292
|
const mapXToDataPoints = {};
|
|
282
293
|
let yMaxValue = 0;
|
|
283
294
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
|
|
284
|
-
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
295
|
+
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
285
296
|
let colorScale = undefined;
|
|
286
297
|
let yMinValue = 0;
|
|
287
298
|
input.data.forEach((series, index1)=>{
|
|
@@ -296,7 +307,7 @@ const transformPlotlyJsonToVSBCProps = (input, colorMap, colorwayType, isDarkThe
|
|
|
296
307
|
const extractedLineColors = (0, _PlotlyColorAdapter.extractColor)((_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : (_input_layout_template1 = _input_layout2.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);
|
|
297
308
|
const xValues = series.x;
|
|
298
309
|
const isXDate = (0, _chartutilities.isDateArray)(xValues);
|
|
299
|
-
const isXString = isStringArray(xValues);
|
|
310
|
+
const isXString = (0, _chartutilities.isStringArray)(xValues);
|
|
300
311
|
const isXNumber = (0, _chartutilities.isNumberArray)(xValues);
|
|
301
312
|
const validXYRanges = getValidXYRanges(series);
|
|
302
313
|
validXYRanges.forEach(([rangeStart, rangeEnd], rangeIdx)=>{
|
|
@@ -314,34 +325,40 @@ const transformPlotlyJsonToVSBCProps = (input, colorMap, colorwayType, isDarkThe
|
|
|
314
325
|
const legend = legends[index1];
|
|
315
326
|
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
316
327
|
const color = colorScale ? colorScale((0, _chartutilities.isArrayOrTypedArray)((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) ? (_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[index2 % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : (0, _PlotlyColorAdapter.resolveColor)(extractedBarColors, index2, legend, colorMap, isDarkTheme);
|
|
328
|
+
const opacity = (0, _PlotlyColorAdapter.getOpacity)(series, index2);
|
|
317
329
|
const yVal = rangeYValues[index2];
|
|
318
330
|
if (series.type === 'bar') {
|
|
331
|
+
var _rgb_copy_formatHex8;
|
|
319
332
|
mapXToDataPoints[x].chartData.push({
|
|
320
333
|
legend,
|
|
321
334
|
data: yVal,
|
|
322
|
-
color
|
|
335
|
+
color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(color).copy({
|
|
336
|
+
opacity
|
|
337
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
|
|
323
338
|
});
|
|
324
339
|
if (typeof yVal === 'number') {
|
|
325
340
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
326
341
|
}
|
|
327
342
|
} else if (series.type === 'scatter' || !!fallbackVSBC) {
|
|
328
|
-
var _series_mode
|
|
343
|
+
var _series_mode;
|
|
329
344
|
const lineColor = (0, _PlotlyColorAdapter.resolveColor)(extractedLineColors, index1, legend, colorMap, isDarkTheme);
|
|
330
345
|
const lineOptions = !((_series_mode = series.mode) === null || _series_mode === void 0 ? void 0 : _series_mode.includes('text')) ? getLineOptions(series.line) : undefined;
|
|
331
|
-
const
|
|
332
|
-
|
|
346
|
+
const legendShape = getLegendShape(series);
|
|
347
|
+
var _rgb_copy_formatHex81;
|
|
333
348
|
mapXToDataPoints[x].lineData.push({
|
|
334
349
|
legend: legend + (validXYRanges.length > 1 ? `.${rangeIdx + 1}` : ''),
|
|
335
350
|
legendShape,
|
|
336
351
|
y: yVal,
|
|
337
|
-
color: lineColor
|
|
352
|
+
color: (_rgb_copy_formatHex81 = (0, _d3color.rgb)(lineColor).copy({
|
|
353
|
+
opacity
|
|
354
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex81 !== void 0 ? _rgb_copy_formatHex81 : color,
|
|
338
355
|
lineOptions: {
|
|
339
356
|
...lineOptions !== null && lineOptions !== void 0 ? lineOptions : {},
|
|
340
357
|
mode: series.mode
|
|
341
358
|
},
|
|
342
|
-
useSecondaryYScale: usesSecondaryYScale(series)
|
|
359
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout)
|
|
343
360
|
});
|
|
344
|
-
if (!usesSecondaryYScale(series) && typeof yVal === 'number') {
|
|
361
|
+
if (!usesSecondaryYScale(series, input.layout) && typeof yVal === 'number') {
|
|
345
362
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
346
363
|
yMinValue = Math.min(yMinValue, yVal);
|
|
347
364
|
}
|
|
@@ -389,11 +406,11 @@ const createColorScale = (layout, series)=>{
|
|
|
389
406
|
const scaleColors = scale.map((item)=>item[1]);
|
|
390
407
|
return (0, _d3scale.scaleLinear)().domain(scaleDomain).range(scaleColors);
|
|
391
408
|
};
|
|
392
|
-
const transformPlotlyJsonToGVBCProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
409
|
+
const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
393
410
|
var _input_layout, _input_layout1, _gvbcData_;
|
|
394
411
|
const mapXToDataPoints = {};
|
|
395
412
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, 0, 0);
|
|
396
|
-
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
413
|
+
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
397
414
|
let colorScale = undefined;
|
|
398
415
|
input.data.forEach((series, index1)=>{
|
|
399
416
|
var _input_layout_coloraxis_colorscale, _input_layout_coloraxis, _input_layout, _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout1, _series_marker3, _series_x;
|
|
@@ -418,13 +435,17 @@ const transformPlotlyJsonToGVBCProps = (input, colorMap, colorwayType, isDarkThe
|
|
|
418
435
|
const legend = legends[index1];
|
|
419
436
|
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
420
437
|
const color = colorScale ? colorScale((0, _chartutilities.isArrayOrTypedArray)((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) ? (_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[index2 % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : (0, _PlotlyColorAdapter.resolveColor)(extractedColors, index1, legend, colorMap, isDarkTheme);
|
|
438
|
+
const opacity = (0, _PlotlyColorAdapter.getOpacity)(series, index2);
|
|
439
|
+
var _rgb_copy_formatHex8;
|
|
421
440
|
mapXToDataPoints[x].series.push({
|
|
422
441
|
key: legend,
|
|
423
442
|
data: series.y[index2],
|
|
424
443
|
xAxisCalloutData: x,
|
|
425
|
-
color,
|
|
444
|
+
color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(color).copy({
|
|
445
|
+
opacity
|
|
446
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
|
|
426
447
|
legend,
|
|
427
|
-
useSecondaryYScale: usesSecondaryYScale(series)
|
|
448
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout)
|
|
428
449
|
});
|
|
429
450
|
}
|
|
430
451
|
});
|
|
@@ -448,10 +469,10 @@ const transformPlotlyJsonToGVBCProps = (input, colorMap, colorwayType, isDarkThe
|
|
|
448
469
|
roundCorners: true
|
|
449
470
|
};
|
|
450
471
|
};
|
|
451
|
-
const transformPlotlyJsonToVBCProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
472
|
+
const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
452
473
|
var _input_layout, _input_layout1, _vbcData_;
|
|
453
474
|
const vbcData = [];
|
|
454
|
-
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
475
|
+
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
455
476
|
let colorScale = undefined;
|
|
456
477
|
input.data.forEach((series, seriesIdx)=>{
|
|
457
478
|
var _input_layout_coloraxis_colorscale, _input_layout_coloraxis, _input_layout, _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout1, _series_marker3, _series_xbins, _series_xbins1, _series_xbins2;
|
|
@@ -473,7 +494,7 @@ const transformPlotlyJsonToVBCProps = (input, colorMap, colorwayType, isDarkThem
|
|
|
473
494
|
xValues.push(xVal);
|
|
474
495
|
yValues.push(yVal);
|
|
475
496
|
});
|
|
476
|
-
const isXString = isStringArray(xValues);
|
|
497
|
+
const isXString = (0, _chartutilities.isStringArray)(xValues);
|
|
477
498
|
// TODO: In case of a single bin, add an empty bin of the same size to prevent the
|
|
478
499
|
// default bar width from being used and ensure the bar spans the full intended range.
|
|
479
500
|
const xBins = createBins(xValues, (_series_xbins = series.xbins) === null || _series_xbins === void 0 ? void 0 : _series_xbins.start, (_series_xbins1 = series.xbins) === null || _series_xbins1 === void 0 ? void 0 : _series_xbins1.end, (_series_xbins2 = series.xbins) === null || _series_xbins2 === void 0 ? void 0 : _series_xbins2.size);
|
|
@@ -495,12 +516,16 @@ const transformPlotlyJsonToVBCProps = (input, colorMap, colorwayType, isDarkThem
|
|
|
495
516
|
const legend = legends[seriesIdx];
|
|
496
517
|
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
497
518
|
const color = colorScale ? colorScale((0, _chartutilities.isArrayOrTypedArray)((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) ? (_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[index % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : (0, _PlotlyColorAdapter.resolveColor)(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
519
|
+
const opacity = (0, _PlotlyColorAdapter.getOpacity)(series, index);
|
|
498
520
|
const yVal = calculateHistNorm(series.histnorm, y[index], total, isXString ? bin.length : getBinSize(bin));
|
|
521
|
+
var _rgb_copy_formatHex8;
|
|
499
522
|
vbcData.push({
|
|
500
523
|
x: isXString ? bin.join(', ') : getBinCenter(bin),
|
|
501
524
|
y: yVal,
|
|
502
525
|
legend,
|
|
503
|
-
color,
|
|
526
|
+
color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(color).copy({
|
|
527
|
+
opacity
|
|
528
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
|
|
504
529
|
...isXString ? {} : {
|
|
505
530
|
xAxisCalloutData: `[${bin.x0} - ${bin.x1})`
|
|
506
531
|
}
|
|
@@ -524,29 +549,47 @@ const transformPlotlyJsonToVBCProps = (input, colorMap, colorwayType, isDarkThem
|
|
|
524
549
|
roundCorners: true
|
|
525
550
|
};
|
|
526
551
|
};
|
|
527
|
-
const
|
|
552
|
+
const transformPlotlyJsonToAreaChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
553
|
+
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'area', colorMap, colorwayType, isDarkTheme);
|
|
554
|
+
};
|
|
555
|
+
const transformPlotlyJsonToLineChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
556
|
+
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'line', colorMap, colorwayType, isDarkTheme);
|
|
557
|
+
};
|
|
558
|
+
const transformPlotlyJsonToScatterChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
559
|
+
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'scatter', colorMap, colorwayType, isDarkTheme);
|
|
560
|
+
};
|
|
561
|
+
const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme)=>{
|
|
562
|
+
var _input_data_;
|
|
563
|
+
const isScatterMarkers = [
|
|
564
|
+
'markers',
|
|
565
|
+
'text+markers',
|
|
566
|
+
'markers+text',
|
|
567
|
+
'lines+markers',
|
|
568
|
+
'markers+line',
|
|
569
|
+
'text+lines+markers'
|
|
570
|
+
].includes((_input_data_ = input.data[0]) === null || _input_data_ === void 0 ? void 0 : _input_data_.mode);
|
|
528
571
|
const isAreaChart = chartType === 'area';
|
|
529
572
|
const isScatterChart = chartType === 'scatter';
|
|
530
573
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
|
|
531
574
|
let mode = 'tonexty';
|
|
532
|
-
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
575
|
+
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
533
576
|
const chartData = input.data.map((series, index)=>{
|
|
534
|
-
var _series_mode, _series_line, _series_marker, _series_line1, _input_layout_template_layout, _input_layout_template, _input_layout, _series_mode1
|
|
577
|
+
var _series_mode, _series_line, _series_marker, _series_line1, _input_layout_template_layout, _input_layout_template, _input_layout, _series_mode1;
|
|
535
578
|
const colors = isScatterMarkers ? (series === null || series === void 0 ? void 0 : (_series_mode = series.mode) === null || _series_mode === void 0 ? void 0 : _series_mode.includes('line')) ? (_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.color : (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color : (_series_line1 = series.line) === null || _series_line1 === void 0 ? void 0 : _series_line1.color;
|
|
536
579
|
// extract colors for each series only once
|
|
537
580
|
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, colors, colorMap, isDarkTheme);
|
|
538
581
|
const xValues = series.x;
|
|
539
|
-
const isXString = isStringArray(xValues);
|
|
582
|
+
const isXString = (0, _chartutilities.isStringArray)(xValues);
|
|
540
583
|
const isXDate = (0, _chartutilities.isDateArray)(xValues);
|
|
541
584
|
const isXNumber = (0, _chartutilities.isNumberArray)(xValues);
|
|
542
585
|
const isXYearCategory = (0, _chartutilities.isYearArray)(series.x); // Consider year as categorical not numeric continuous axis
|
|
543
586
|
const legend = legends[index];
|
|
544
587
|
// resolve color for each legend's lines from the extracted colors
|
|
545
588
|
const seriesColor = (0, _PlotlyColorAdapter.resolveColor)(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
589
|
+
const seriesOpacity = (0, _PlotlyColorAdapter.getOpacity)(series, index);
|
|
546
590
|
mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
|
|
547
591
|
const lineOptions = !((_series_mode1 = series.mode) === null || _series_mode1 === void 0 ? void 0 : _series_mode1.includes('text')) ? getLineOptions(series.line) : undefined;
|
|
548
|
-
const
|
|
549
|
-
const legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot' ? 'dottedLine' : ((_series_mode2 = series.mode) === null || _series_mode2 === void 0 ? void 0 : _series_mode2.includes('markers')) ? 'circle' : 'default';
|
|
592
|
+
const legendShape = getLegendShape(series);
|
|
550
593
|
const validXYRanges = getValidXYRanges(series);
|
|
551
594
|
return validXYRanges.map(([rangeStart, rangeEnd], rangeIdx)=>{
|
|
552
595
|
var _series_marker;
|
|
@@ -554,6 +597,7 @@ const transformPlotlyJsonToScatterChartProps = (input, chartType, isScatterMarke
|
|
|
554
597
|
const rangeYValues = series.y.slice(rangeStart, rangeEnd);
|
|
555
598
|
const markerSizes = (0, _chartutilities.isArrayOrTypedArray)((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.size) ? series.marker.size.slice(rangeStart, rangeEnd) : [];
|
|
556
599
|
const textValues = Array.isArray(series.text) ? series.text.slice(rangeStart, rangeEnd) : undefined;
|
|
600
|
+
var _rgb_copy_formatHex8;
|
|
557
601
|
return {
|
|
558
602
|
legend,
|
|
559
603
|
legendShape,
|
|
@@ -572,12 +616,14 @@ const transformPlotlyJsonToScatterChartProps = (input, chartType, isScatterMarke
|
|
|
572
616
|
} : {}
|
|
573
617
|
};
|
|
574
618
|
}),
|
|
575
|
-
color: seriesColor
|
|
619
|
+
color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(seriesColor).copy({
|
|
620
|
+
opacity: seriesOpacity
|
|
621
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : seriesColor,
|
|
576
622
|
lineOptions: {
|
|
577
623
|
...lineOptions !== null && lineOptions !== void 0 ? lineOptions : {},
|
|
578
624
|
mode: series.mode
|
|
579
625
|
},
|
|
580
|
-
useSecondaryYScale: usesSecondaryYScale(series)
|
|
626
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout)
|
|
581
627
|
};
|
|
582
628
|
});
|
|
583
629
|
}).flat();
|
|
@@ -630,9 +676,9 @@ const transformPlotlyJsonToScatterChartProps = (input, chartType, isScatterMarke
|
|
|
630
676
|
};
|
|
631
677
|
}
|
|
632
678
|
};
|
|
633
|
-
const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
679
|
+
const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
634
680
|
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;
|
|
635
|
-
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
681
|
+
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
636
682
|
let colorScale = undefined;
|
|
637
683
|
const chartData = input.data.map((series, index)=>{
|
|
638
684
|
var _input_layout_coloraxis_colorscale, _input_layout_coloraxis, _input_layout, _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout1, _series_marker3;
|
|
@@ -649,11 +695,15 @@ const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, colorMap, colorw
|
|
|
649
695
|
}
|
|
650
696
|
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
651
697
|
const color = colorScale ? colorScale((0, _chartutilities.isArrayOrTypedArray)((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) ? (_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[i % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : (0, _PlotlyColorAdapter.resolveColor)(extractedColors, i, legend, colorMap, isDarkTheme);
|
|
698
|
+
const opacity = (0, _PlotlyColorAdapter.getOpacity)(series, i);
|
|
699
|
+
var _rgb_copy_formatHex8;
|
|
652
700
|
return {
|
|
653
701
|
x: series.x[i],
|
|
654
702
|
y: yValue,
|
|
655
703
|
legend,
|
|
656
|
-
color
|
|
704
|
+
color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(color).copy({
|
|
705
|
+
opacity
|
|
706
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
|
|
657
707
|
};
|
|
658
708
|
}).filter((point)=>point !== null);
|
|
659
709
|
}).reverse().flat() //reversing the order to invert the Y bars order as required by plotly.
|
|
@@ -687,7 +737,7 @@ const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, colorMap, colorw
|
|
|
687
737
|
roundCorners: true
|
|
688
738
|
};
|
|
689
739
|
};
|
|
690
|
-
const transformPlotlyJsonToHeatmapProps = (input)=>{
|
|
740
|
+
const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
691
741
|
var _input_layout, _input_layout_coloraxis, _input_layout1, _input_layout_template_layout, _input_layout_template, _input_layout2, _input_layout_template_data_histogram2d_, _input_layout_template_data_histogram2d, _input_layout_template_data, _input_layout_template1, _input_layout3, _input_layout_template_data_heatmap_, _input_layout_template_data_heatmap, _input_layout_template_data1, _input_layout_template2, _input_layout4, _input_layout5, _input_layout6;
|
|
692
742
|
const firstData = input.data[0];
|
|
693
743
|
const heatmapDataPoints = [];
|
|
@@ -708,8 +758,8 @@ const transformPlotlyJsonToHeatmapProps = (input)=>{
|
|
|
708
758
|
yValues.push(firstData.y[index]);
|
|
709
759
|
zValues.push(zVal);
|
|
710
760
|
});
|
|
711
|
-
const isXString = isStringArray(xValues);
|
|
712
|
-
const isYString = isStringArray(yValues);
|
|
761
|
+
const isXString = (0, _chartutilities.isStringArray)(xValues);
|
|
762
|
+
const isYString = (0, _chartutilities.isStringArray)(yValues);
|
|
713
763
|
const xBins = createBins(xValues, (_firstData_xbins = firstData.xbins) === null || _firstData_xbins === void 0 ? void 0 : _firstData_xbins.start, (_firstData_xbins1 = firstData.xbins) === null || _firstData_xbins1 === void 0 ? void 0 : _firstData_xbins1.end, (_firstData_xbins2 = firstData.xbins) === null || _firstData_xbins2 === void 0 ? void 0 : _firstData_xbins2.size);
|
|
714
764
|
const yBins = createBins(yValues, (_firstData_ybins = firstData.ybins) === null || _firstData_ybins === void 0 ? void 0 : _firstData_ybins.start, (_firstData_ybins1 = firstData.ybins) === null || _firstData_ybins1 === void 0 ? void 0 : _firstData_ybins1.end, (_firstData_ybins2 = firstData.ybins) === null || _firstData_ybins2 === void 0 ? void 0 : _firstData_ybins2.size);
|
|
715
765
|
const zBins = yBins.map(()=>xBins.map(()=>[]));
|
|
@@ -819,7 +869,7 @@ const transformPlotlyJsonToHeatmapProps = (input)=>{
|
|
|
819
869
|
wrapXAxisLables: true
|
|
820
870
|
};
|
|
821
871
|
};
|
|
822
|
-
const transformPlotlyJsonToSankeyProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
872
|
+
const transformPlotlyJsonToSankeyProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
823
873
|
var _input_layout_template_layout, _input_layout_template, _input_layout, _node_label, _input_layout1, _input_layout2;
|
|
824
874
|
const { link, node } = input.data[0];
|
|
825
875
|
var _link_value;
|
|
@@ -868,7 +918,7 @@ const transformPlotlyJsonToSankeyProps = (input, colorMap, colorwayType, isDarkT
|
|
|
868
918
|
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
|
|
869
919
|
};
|
|
870
920
|
};
|
|
871
|
-
const transformPlotlyJsonToGaugeProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
921
|
+
const transformPlotlyJsonToGaugeProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
872
922
|
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;
|
|
873
923
|
const firstData = input.data[0];
|
|
874
924
|
const stepsColors = ((_firstData_gauge = firstData.gauge) === null || _firstData_gauge === void 0 ? void 0 : _firstData_gauge.steps) ? firstData.gauge.steps.map((step)=>step.color) : undefined;
|
|
@@ -964,7 +1014,7 @@ const formatValue = (value, colIndex, cells)=>{
|
|
|
964
1014
|
}
|
|
965
1015
|
return `${prefix !== null && prefix !== void 0 ? prefix : ''}${formatted}${suffix !== null && suffix !== void 0 ? suffix : ''}`;
|
|
966
1016
|
};
|
|
967
|
-
const transformPlotlyJsonToChartTableProps = (input, colorMap, isDarkTheme)=>{
|
|
1017
|
+
const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
968
1018
|
var _tableData_cells, _input_layout_template_data, _input_layout_template, _input_layout, _input_layout_font, _input_layout1, _tableData_header, _tableData_header1, _input_layout_template_data1, _input_layout_template1, _input_layout2, _input_layout3, _input_layout4;
|
|
969
1019
|
const tableData = input.data[0];
|
|
970
1020
|
const normalizeHeaders = (values, header)=>{
|
|
@@ -1180,10 +1230,6 @@ function getLineOptions(line) {
|
|
|
1180
1230
|
}
|
|
1181
1231
|
return Object.keys(lineOptions).length > 0 ? lineOptions : undefined;
|
|
1182
1232
|
}
|
|
1183
|
-
const isStringArray = (arr)=>{
|
|
1184
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1185
|
-
return (0, _chartutilities.isArrayOfType)(arr, (value)=>typeof value === 'string' || value === null);
|
|
1186
|
-
};
|
|
1187
1233
|
// TODO: Use binary search to find the appropriate bin for numeric value.
|
|
1188
1234
|
const findBinIndex = (bins, value, isString)=>{
|
|
1189
1235
|
if (typeof value === 'undefined' || value === null) {
|
|
@@ -1202,7 +1248,7 @@ const createBins = (data, binStart, binEnd, binSize)=>{
|
|
|
1202
1248
|
if (!data || data.length === 0) {
|
|
1203
1249
|
return [];
|
|
1204
1250
|
}
|
|
1205
|
-
if (isStringArray(data)) {
|
|
1251
|
+
if ((0, _chartutilities.isStringArray)(data)) {
|
|
1206
1252
|
const categories = Array.from(new Set(data));
|
|
1207
1253
|
const start = typeof binStart === 'number' ? Math.ceil(binStart) : 0;
|
|
1208
1254
|
const stop = typeof binEnd === 'number' ? Math.floor(binEnd) + 1 : categories.length;
|
|
@@ -1278,7 +1324,46 @@ const precisionRound = (value, precision)=>{
|
|
|
1278
1324
|
const factor = Math.pow(10, precision);
|
|
1279
1325
|
return Math.round(value * factor) / factor;
|
|
1280
1326
|
};
|
|
1281
|
-
const
|
|
1327
|
+
const getLegendShape = (series)=>{
|
|
1328
|
+
var _series_line, _series_mode;
|
|
1329
|
+
const dashType = ((_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.dash) || 'solid';
|
|
1330
|
+
if (dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot') {
|
|
1331
|
+
return 'dottedLine';
|
|
1332
|
+
} else if ((_series_mode = series.mode) === null || _series_mode === void 0 ? void 0 : _series_mode.includes('markers')) {
|
|
1333
|
+
return 'circle';
|
|
1334
|
+
}
|
|
1335
|
+
return 'default';
|
|
1336
|
+
};
|
|
1337
|
+
const getAllupLegendsProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
1338
|
+
const allupLegends = [];
|
|
1339
|
+
// reduce on showlegend boolean propperty. reduce should return true if at least one series has showlegend true
|
|
1340
|
+
const toShowLegend = input.data.reduce((acc, series)=>{
|
|
1341
|
+
return acc || series.showlegend === true;
|
|
1342
|
+
}, false);
|
|
1343
|
+
if (toShowLegend) {
|
|
1344
|
+
input.data.forEach((series, index)=>{
|
|
1345
|
+
var _series_line, _series_marker, _input_layout_template_layout, _input_layout_template, _input_layout;
|
|
1346
|
+
const name = series.legendgroup;
|
|
1347
|
+
const color = ((_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.color) || ((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color);
|
|
1348
|
+
const legendShape = getLegendShape(series);
|
|
1349
|
+
const resolvedColor = (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, color, colorMap, isDarkTheme);
|
|
1350
|
+
if (name !== undefined && allupLegends.some((group)=>group.title === name) === false) {
|
|
1351
|
+
allupLegends.push({
|
|
1352
|
+
title: name,
|
|
1353
|
+
color: resolvedColor,
|
|
1354
|
+
shape: legendShape
|
|
1355
|
+
});
|
|
1356
|
+
}
|
|
1357
|
+
});
|
|
1358
|
+
}
|
|
1359
|
+
return {
|
|
1360
|
+
legends: allupLegends,
|
|
1361
|
+
centerLegends: true,
|
|
1362
|
+
enabledWrapLines: true,
|
|
1363
|
+
canSelectMultipleLegends: true
|
|
1364
|
+
};
|
|
1365
|
+
};
|
|
1366
|
+
const getLegendProps = (data, layout, isMultiPlot)=>{
|
|
1282
1367
|
const legends = [];
|
|
1283
1368
|
if (data.length === 1) {
|
|
1284
1369
|
legends.push(data[0].name || '');
|
|
@@ -1287,10 +1372,11 @@ const getLegendProps = (data, layout)=>{
|
|
|
1287
1372
|
legends.push(series.name || `Series ${index + 1}`);
|
|
1288
1373
|
});
|
|
1289
1374
|
}
|
|
1290
|
-
const
|
|
1375
|
+
const hideLegendsData = data.every((series)=>series.showlegend === false);
|
|
1376
|
+
const hideLegendsInferred = (layout === null || layout === void 0 ? void 0 : layout.showlegend) === false || (layout === null || layout === void 0 ? void 0 : layout.showlegend) !== true && legends.length < 2;
|
|
1291
1377
|
return {
|
|
1292
1378
|
legends,
|
|
1293
|
-
hideLegend:
|
|
1379
|
+
hideLegend: isMultiPlot || hideLegendsInferred || hideLegendsData
|
|
1294
1380
|
};
|
|
1295
1381
|
};
|
|
1296
1382
|
const getNumberAtIndexOrDefault = (data, index)=>{
|
|
@@ -1328,3 +1414,176 @@ const getValidXYRanges = (series)=>{
|
|
|
1328
1414
|
}
|
|
1329
1415
|
return ranges;
|
|
1330
1416
|
};
|
|
1417
|
+
const getIndexFromKey = (key, pattern)=>{
|
|
1418
|
+
const normalizedKey = key.replace(pattern, '') === '' ? '1' : key.replace(pattern, '');
|
|
1419
|
+
return parseInt(normalizedKey, 10) - 1;
|
|
1420
|
+
};
|
|
1421
|
+
const getGridProperties = (layout, isMultiPlot)=>{
|
|
1422
|
+
var _layout_annotations;
|
|
1423
|
+
const gridX = [];
|
|
1424
|
+
const gridY = [];
|
|
1425
|
+
const annotations = {};
|
|
1426
|
+
let templateRows = '1fr';
|
|
1427
|
+
let templateColumns = '1fr';
|
|
1428
|
+
const gridLayout = {};
|
|
1429
|
+
if (layout === undefined || layout === null || Object.keys(layout).length === 0) {
|
|
1430
|
+
return {
|
|
1431
|
+
templateRows,
|
|
1432
|
+
templateColumns,
|
|
1433
|
+
layout: gridLayout
|
|
1434
|
+
};
|
|
1435
|
+
}
|
|
1436
|
+
if (!layout.xaxis || !layout.yaxis) {
|
|
1437
|
+
return {
|
|
1438
|
+
templateRows,
|
|
1439
|
+
templateColumns,
|
|
1440
|
+
layout: gridLayout
|
|
1441
|
+
};
|
|
1442
|
+
}
|
|
1443
|
+
if (!isMultiPlot) {
|
|
1444
|
+
return {
|
|
1445
|
+
templateRows,
|
|
1446
|
+
templateColumns,
|
|
1447
|
+
layout: gridLayout
|
|
1448
|
+
};
|
|
1449
|
+
}
|
|
1450
|
+
Object.keys(layout).forEach((key)=>{
|
|
1451
|
+
if (key.startsWith('xaxis')) {
|
|
1452
|
+
var _layout_key, _layout_key1;
|
|
1453
|
+
const index = getIndexFromKey(key, 'xaxis');
|
|
1454
|
+
var _layout_key_anchor;
|
|
1455
|
+
const anchor = (_layout_key_anchor = (_layout_key = layout[key]) === null || _layout_key === void 0 ? void 0 : _layout_key.anchor) !== null && _layout_key_anchor !== void 0 ? _layout_key_anchor : 'y';
|
|
1456
|
+
const anchorIndex = getIndexFromKey(anchor, 'y');
|
|
1457
|
+
if (index !== anchorIndex) {
|
|
1458
|
+
throw new Error(`Invalid layout: xaxis ${index + 1} anchor should be y${anchorIndex + 1}`);
|
|
1459
|
+
}
|
|
1460
|
+
var _layout_key_domain;
|
|
1461
|
+
gridX[index] = (_layout_key_domain = (_layout_key1 = layout[key]) === null || _layout_key1 === void 0 ? void 0 : _layout_key1.domain) !== null && _layout_key_domain !== void 0 ? _layout_key_domain : [];
|
|
1462
|
+
} else if (key.startsWith('yaxis')) {
|
|
1463
|
+
var _layout_key2, _layout_key3;
|
|
1464
|
+
const index = getIndexFromKey(key, 'yaxis');
|
|
1465
|
+
var _layout_key_anchor1;
|
|
1466
|
+
const anchor = (_layout_key_anchor1 = (_layout_key2 = layout[key]) === null || _layout_key2 === void 0 ? void 0 : _layout_key2.anchor) !== null && _layout_key_anchor1 !== void 0 ? _layout_key_anchor1 : 'x';
|
|
1467
|
+
const anchorIndex = getIndexFromKey(anchor, 'x');
|
|
1468
|
+
if (index !== anchorIndex) {
|
|
1469
|
+
var _layout_yaxis2;
|
|
1470
|
+
if (index === 1 && anchorIndex === 0 || ((_layout_yaxis2 = layout.yaxis2) === null || _layout_yaxis2 === void 0 ? void 0 : _layout_yaxis2.side) === 'right') {
|
|
1471
|
+
// Special case for secondary y axis where yaxis2 can anchor to x1
|
|
1472
|
+
return {
|
|
1473
|
+
templateRows,
|
|
1474
|
+
templateColumns
|
|
1475
|
+
};
|
|
1476
|
+
}
|
|
1477
|
+
throw new Error(`Invalid layout: yaxis ${index + 1} anchor should be x${anchorIndex + 1}`);
|
|
1478
|
+
}
|
|
1479
|
+
var _layout_key_domain1;
|
|
1480
|
+
gridY[index] = (_layout_key_domain1 = (_layout_key3 = layout[key]) === null || _layout_key3 === void 0 ? void 0 : _layout_key3.domain) !== null && _layout_key_domain1 !== void 0 ? _layout_key_domain1 : [];
|
|
1481
|
+
}
|
|
1482
|
+
});
|
|
1483
|
+
(_layout_annotations = layout.annotations) === null || _layout_annotations === void 0 ? void 0 : _layout_annotations.forEach((annotation)=>{
|
|
1484
|
+
const xMatches = gridX.flatMap((interval, idx)=>(annotation === null || annotation === void 0 ? void 0 : annotation.x) >= interval[0] && (annotation === null || annotation === void 0 ? void 0 : annotation.x) <= interval[1] ? [
|
|
1485
|
+
idx
|
|
1486
|
+
] : []);
|
|
1487
|
+
const yMatch = gridY.findIndex((interval, yIndex)=>xMatches.includes(yIndex) && (annotation === null || annotation === void 0 ? void 0 : annotation.y) >= interval[0] && (annotation === null || annotation === void 0 ? void 0 : annotation.y) <= interval[1]);
|
|
1488
|
+
if (yMatch !== -1) {
|
|
1489
|
+
if (annotations[yMatch] === undefined) {
|
|
1490
|
+
annotations[yMatch] = {};
|
|
1491
|
+
}
|
|
1492
|
+
if ((annotation === null || annotation === void 0 ? void 0 : annotation.textangle) === 90) {
|
|
1493
|
+
annotations[yMatch].yAnnotation = annotation.text;
|
|
1494
|
+
} else {
|
|
1495
|
+
annotations[yMatch].xAnnotation = annotation.text;
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1498
|
+
});
|
|
1499
|
+
if (gridX.length > 0) {
|
|
1500
|
+
const uniqueXIntervals = new Map();
|
|
1501
|
+
gridX.forEach((interval)=>{
|
|
1502
|
+
const key = `${interval[0]}-${interval[1]}`;
|
|
1503
|
+
if (!uniqueXIntervals.has(key)) {
|
|
1504
|
+
uniqueXIntervals.set(key, interval);
|
|
1505
|
+
}
|
|
1506
|
+
});
|
|
1507
|
+
const minXInterval = Math.min(...Array.from(uniqueXIntervals.values()).map((interval)=>interval[1] - interval[0]));
|
|
1508
|
+
templateColumns = Array.from(uniqueXIntervals.values()).map((interval)=>`${(interval[1] - interval[0]) / minXInterval}fr`).join(' ');
|
|
1509
|
+
let columnNumber = 1;
|
|
1510
|
+
let lastIntervalEnd = 0;
|
|
1511
|
+
gridX.forEach((interval, index)=>{
|
|
1512
|
+
if (interval.length === 0) {
|
|
1513
|
+
return;
|
|
1514
|
+
}
|
|
1515
|
+
const cellName = `x${index === 0 ? '' : index + 1}`;
|
|
1516
|
+
const annotationProps = annotations[index];
|
|
1517
|
+
const xAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.xAnnotation;
|
|
1518
|
+
if (interval[0] < lastIntervalEnd) {
|
|
1519
|
+
columnNumber = 1;
|
|
1520
|
+
}
|
|
1521
|
+
lastIntervalEnd = interval[1];
|
|
1522
|
+
const row = {
|
|
1523
|
+
row: -1,
|
|
1524
|
+
column: columnNumber,
|
|
1525
|
+
xAnnotation
|
|
1526
|
+
};
|
|
1527
|
+
gridLayout[cellName] = row;
|
|
1528
|
+
columnNumber += 1;
|
|
1529
|
+
});
|
|
1530
|
+
}
|
|
1531
|
+
const numColumns = Math.max(...Object.values(gridLayout).map((cell)=>{
|
|
1532
|
+
var _cell_column;
|
|
1533
|
+
return (_cell_column = cell.column) !== null && _cell_column !== void 0 ? _cell_column : 0;
|
|
1534
|
+
}));
|
|
1535
|
+
const columnFill = {};
|
|
1536
|
+
for(let i = 1; i <= numColumns; i++){
|
|
1537
|
+
columnFill[i] = {
|
|
1538
|
+
row: 1,
|
|
1539
|
+
fillDomain: 0
|
|
1540
|
+
};
|
|
1541
|
+
}
|
|
1542
|
+
if (gridY.length > 0) {
|
|
1543
|
+
const uniqueYIntervals = new Map();
|
|
1544
|
+
gridY.forEach((interval)=>{
|
|
1545
|
+
const key = `${interval[0]}-${interval[1]}`;
|
|
1546
|
+
if (!uniqueYIntervals.has(key)) {
|
|
1547
|
+
uniqueYIntervals.set(key, interval);
|
|
1548
|
+
}
|
|
1549
|
+
});
|
|
1550
|
+
const minYInterval = Math.min(...Array.from(uniqueYIntervals.values()).map((interval)=>interval[1] - interval[0]));
|
|
1551
|
+
templateRows = Array.from(uniqueYIntervals.values()).map((interval)=>`${(interval[1] - interval[0]) / minYInterval}fr`).join(' ');
|
|
1552
|
+
gridY.forEach((interval, index)=>{
|
|
1553
|
+
if (interval.length === 0) {
|
|
1554
|
+
return;
|
|
1555
|
+
}
|
|
1556
|
+
const cellName = `x${index === 0 ? '' : index + 1}`;
|
|
1557
|
+
const annotationProps = annotations[index];
|
|
1558
|
+
const yAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.yAnnotation;
|
|
1559
|
+
const cell = gridLayout[cellName];
|
|
1560
|
+
if (cell !== undefined) {
|
|
1561
|
+
cell.row = columnFill[cell.column].row;
|
|
1562
|
+
cell.yAnnotation = yAnnotation;
|
|
1563
|
+
}
|
|
1564
|
+
columnFill[cell.column].fillDomain = interval[1];
|
|
1565
|
+
columnFill[cell.column].row += 1;
|
|
1566
|
+
});
|
|
1567
|
+
}
|
|
1568
|
+
// reverse the order of rows in grid layout from bottom-top to top-bottom as required by CSS grid
|
|
1569
|
+
const reversedGridLayout = {};
|
|
1570
|
+
// find the maximum row number
|
|
1571
|
+
const maxRowNumber = Math.max(...Object.values(gridLayout).map((cell)=>{
|
|
1572
|
+
var _cell_row;
|
|
1573
|
+
return (_cell_row = cell.row) !== null && _cell_row !== void 0 ? _cell_row : 0;
|
|
1574
|
+
}));
|
|
1575
|
+
// iterate over the gridLayout and reverse the row numbers
|
|
1576
|
+
Object.keys(gridLayout).forEach((key)=>{
|
|
1577
|
+
const cell = gridLayout[key];
|
|
1578
|
+
if (cell.row !== undefined) {
|
|
1579
|
+
// reverse the row number
|
|
1580
|
+
cell.row = maxRowNumber - cell.row + 1;
|
|
1581
|
+
}
|
|
1582
|
+
reversedGridLayout[key] = cell;
|
|
1583
|
+
});
|
|
1584
|
+
return {
|
|
1585
|
+
templateRows,
|
|
1586
|
+
templateColumns,
|
|
1587
|
+
layout: reversedGridLayout
|
|
1588
|
+
};
|
|
1589
|
+
};
|