@fluentui/react-charts 0.0.0-nightly-20250818-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 +65 -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 -112
- 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 +315 -55
- 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/LineChart.js +30 -9
- package/lib/components/LineChart/LineChart.js.map +1 -1
- package/lib/components/LineChart/LineChart.types.js.map +1 -1
- package/lib/components/LineChart/useLineChartStyles.styles.js +10 -3
- package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -1
- package/lib/components/LineChart/useLineChartStyles.styles.raw.js +14 -2
- package/lib/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.js +54 -37
- 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/types/DataPoint.js.map +1 -1
- package/lib/utilities/utilities.js +4 -1
- 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 -110
- 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 +331 -61
- 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/LineChart.js +30 -9
- package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.types.js.map +1 -1
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js +12 -3
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js +14 -2
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.js +54 -37
- 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/types/DataPoint.js.map +1 -1
- package/lib-commonjs/utilities/utilities.js +1 -0
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +12 -12
|
@@ -4,9 +4,10 @@ import { scaleLinear as d3ScaleLinear } from 'd3-scale';
|
|
|
4
4
|
import { format as d3Format } from 'd3-format';
|
|
5
5
|
import { DataVizPalette, getColorFromToken } from '../../utilities/colors';
|
|
6
6
|
import { findNumericMinMaxOfY, formatScientificLimitWidth, MIN_DONUT_RADIUS } from '../../utilities/utilities';
|
|
7
|
-
import {
|
|
7
|
+
import { isArrayOrTypedArray, isDate, isDateArray, isNumberArray, isStringArray, isYearArray, isInvalidValue } from '@fluentui/chart-utilities';
|
|
8
8
|
import { curveCardinal as d3CurveCardinal } from 'd3-shape';
|
|
9
|
-
import { extractColor, resolveColor } from './PlotlyColorAdapter';
|
|
9
|
+
import { getOpacity, extractColor, resolveColor } from './PlotlyColorAdapter';
|
|
10
|
+
import { rgb } from 'd3-color';
|
|
10
11
|
const dashOptions = {
|
|
11
12
|
dot: {
|
|
12
13
|
strokeDasharray: '1, 5',
|
|
@@ -91,8 +92,9 @@ export const correctYearMonth = (xValues)=>{
|
|
|
91
92
|
});
|
|
92
93
|
return xValues;
|
|
93
94
|
};
|
|
94
|
-
const usesSecondaryYScale = (series)=>{
|
|
95
|
-
|
|
95
|
+
const usesSecondaryYScale = (series, layout)=>{
|
|
96
|
+
var _layout_yaxis2, _layout_yaxis21;
|
|
97
|
+
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');
|
|
96
98
|
};
|
|
97
99
|
const getSecondaryYAxisValues = (data, layout, maxAllowedMinY, minAllowedMaxY)=>{
|
|
98
100
|
var _layout_yaxis2, _layout_yaxis21, _layout_yaxis2_title, _layout_yaxis22;
|
|
@@ -100,7 +102,7 @@ const getSecondaryYAxisValues = (data, layout, maxAllowedMinY, minAllowedMaxY)=>
|
|
|
100
102
|
let yMinValue;
|
|
101
103
|
let yMaxValue;
|
|
102
104
|
data.forEach((series)=>{
|
|
103
|
-
if (usesSecondaryYScale(series)) {
|
|
105
|
+
if (usesSecondaryYScale(series, layout)) {
|
|
104
106
|
containsSecondaryYAxis = true;
|
|
105
107
|
const yValues = series.y;
|
|
106
108
|
if (yValues) {
|
|
@@ -153,7 +155,7 @@ export const resolveXAxisPoint = (x, isXYearCategory, isXString, isXDate, isXNum
|
|
|
153
155
|
}
|
|
154
156
|
return x;
|
|
155
157
|
};
|
|
156
|
-
export const transformPlotlyJsonToDonutProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
158
|
+
export const transformPlotlyJsonToDonutProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
157
159
|
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;
|
|
158
160
|
const firstData = input.data[0];
|
|
159
161
|
var _input_layout_piecolorway, _input_layout_piecolorway1;
|
|
@@ -210,12 +212,12 @@ export const transformPlotlyJsonToDonutProps = (input, colorMap, colorwayType, i
|
|
|
210
212
|
roundCorners: true
|
|
211
213
|
};
|
|
212
214
|
};
|
|
213
|
-
export const transformPlotlyJsonToVSBCProps = (input, colorMap, colorwayType, isDarkTheme, fallbackVSBC)=>{
|
|
215
|
+
export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme, fallbackVSBC)=>{
|
|
214
216
|
var _input_layout, _input_layout1, _vsbcData_;
|
|
215
217
|
const mapXToDataPoints = {};
|
|
216
218
|
let yMaxValue = 0;
|
|
217
219
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
|
|
218
|
-
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
220
|
+
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
219
221
|
let colorScale = undefined;
|
|
220
222
|
let yMinValue = 0;
|
|
221
223
|
input.data.forEach((series, index1)=>{
|
|
@@ -248,33 +250,40 @@ export const transformPlotlyJsonToVSBCProps = (input, colorMap, colorwayType, is
|
|
|
248
250
|
const legend = legends[index1];
|
|
249
251
|
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
250
252
|
const color = colorScale ? colorScale(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) : resolveColor(extractedBarColors, index2, legend, colorMap, isDarkTheme);
|
|
253
|
+
const opacity = getOpacity(series, index2);
|
|
251
254
|
const yVal = rangeYValues[index2];
|
|
252
255
|
if (series.type === 'bar') {
|
|
256
|
+
var _rgb_copy_formatHex8;
|
|
253
257
|
mapXToDataPoints[x].chartData.push({
|
|
254
258
|
legend,
|
|
255
259
|
data: yVal,
|
|
256
|
-
color
|
|
260
|
+
color: (_rgb_copy_formatHex8 = rgb(color).copy({
|
|
261
|
+
opacity
|
|
262
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
|
|
257
263
|
});
|
|
258
264
|
if (typeof yVal === 'number') {
|
|
259
265
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
260
266
|
}
|
|
261
267
|
} else if (series.type === 'scatter' || !!fallbackVSBC) {
|
|
262
|
-
var
|
|
268
|
+
var _series_mode;
|
|
263
269
|
const lineColor = resolveColor(extractedLineColors, index1, legend, colorMap, isDarkTheme);
|
|
264
|
-
const lineOptions = getLineOptions(series.line);
|
|
265
|
-
const
|
|
266
|
-
|
|
270
|
+
const lineOptions = !((_series_mode = series.mode) === null || _series_mode === void 0 ? void 0 : _series_mode.includes('text')) ? getLineOptions(series.line) : undefined;
|
|
271
|
+
const legendShape = getLegendShape(series);
|
|
272
|
+
var _rgb_copy_formatHex81;
|
|
267
273
|
mapXToDataPoints[x].lineData.push({
|
|
268
274
|
legend: legend + (validXYRanges.length > 1 ? `.${rangeIdx + 1}` : ''),
|
|
269
275
|
legendShape,
|
|
270
276
|
y: yVal,
|
|
271
|
-
color: lineColor
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
277
|
+
color: (_rgb_copy_formatHex81 = rgb(lineColor).copy({
|
|
278
|
+
opacity
|
|
279
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex81 !== void 0 ? _rgb_copy_formatHex81 : color,
|
|
280
|
+
lineOptions: {
|
|
281
|
+
...lineOptions !== null && lineOptions !== void 0 ? lineOptions : {},
|
|
282
|
+
mode: series.mode
|
|
283
|
+
},
|
|
284
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout)
|
|
276
285
|
});
|
|
277
|
-
if (!usesSecondaryYScale(series) && typeof yVal === 'number') {
|
|
286
|
+
if (!usesSecondaryYScale(series, input.layout) && typeof yVal === 'number') {
|
|
278
287
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
279
288
|
yMinValue = Math.min(yMinValue, yVal);
|
|
280
289
|
}
|
|
@@ -322,11 +331,11 @@ const createColorScale = (layout, series)=>{
|
|
|
322
331
|
const scaleColors = scale.map((item)=>item[1]);
|
|
323
332
|
return d3ScaleLinear().domain(scaleDomain).range(scaleColors);
|
|
324
333
|
};
|
|
325
|
-
export const transformPlotlyJsonToGVBCProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
334
|
+
export const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
326
335
|
var _input_layout, _input_layout1, _gvbcData_;
|
|
327
336
|
const mapXToDataPoints = {};
|
|
328
337
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, 0, 0);
|
|
329
|
-
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
338
|
+
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
330
339
|
let colorScale = undefined;
|
|
331
340
|
input.data.forEach((series, index1)=>{
|
|
332
341
|
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;
|
|
@@ -351,13 +360,17 @@ export const transformPlotlyJsonToGVBCProps = (input, colorMap, colorwayType, is
|
|
|
351
360
|
const legend = legends[index1];
|
|
352
361
|
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
353
362
|
const color = colorScale ? colorScale(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) : resolveColor(extractedColors, index1, legend, colorMap, isDarkTheme);
|
|
363
|
+
const opacity = getOpacity(series, index2);
|
|
364
|
+
var _rgb_copy_formatHex8;
|
|
354
365
|
mapXToDataPoints[x].series.push({
|
|
355
366
|
key: legend,
|
|
356
367
|
data: series.y[index2],
|
|
357
368
|
xAxisCalloutData: x,
|
|
358
|
-
color
|
|
369
|
+
color: (_rgb_copy_formatHex8 = rgb(color).copy({
|
|
370
|
+
opacity
|
|
371
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
|
|
359
372
|
legend,
|
|
360
|
-
useSecondaryYScale: usesSecondaryYScale(series)
|
|
373
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout)
|
|
361
374
|
});
|
|
362
375
|
}
|
|
363
376
|
});
|
|
@@ -381,10 +394,10 @@ export const transformPlotlyJsonToGVBCProps = (input, colorMap, colorwayType, is
|
|
|
381
394
|
roundCorners: true
|
|
382
395
|
};
|
|
383
396
|
};
|
|
384
|
-
export const transformPlotlyJsonToVBCProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
397
|
+
export const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
385
398
|
var _input_layout, _input_layout1, _vbcData_;
|
|
386
399
|
const vbcData = [];
|
|
387
|
-
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
400
|
+
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
388
401
|
let colorScale = undefined;
|
|
389
402
|
input.data.forEach((series, seriesIdx)=>{
|
|
390
403
|
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;
|
|
@@ -428,12 +441,16 @@ export const transformPlotlyJsonToVBCProps = (input, colorMap, colorwayType, isD
|
|
|
428
441
|
const legend = legends[seriesIdx];
|
|
429
442
|
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
430
443
|
const color = colorScale ? colorScale(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) : resolveColor(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
444
|
+
const opacity = getOpacity(series, index);
|
|
431
445
|
const yVal = calculateHistNorm(series.histnorm, y[index], total, isXString ? bin.length : getBinSize(bin));
|
|
446
|
+
var _rgb_copy_formatHex8;
|
|
432
447
|
vbcData.push({
|
|
433
448
|
x: isXString ? bin.join(', ') : getBinCenter(bin),
|
|
434
449
|
y: yVal,
|
|
435
450
|
legend,
|
|
436
|
-
color
|
|
451
|
+
color: (_rgb_copy_formatHex8 = rgb(color).copy({
|
|
452
|
+
opacity
|
|
453
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
|
|
437
454
|
...isXString ? {} : {
|
|
438
455
|
xAxisCalloutData: `[${bin.x0} - ${bin.x1})`
|
|
439
456
|
}
|
|
@@ -457,12 +474,32 @@ export const transformPlotlyJsonToVBCProps = (input, colorMap, colorwayType, isD
|
|
|
457
474
|
roundCorners: true
|
|
458
475
|
};
|
|
459
476
|
};
|
|
460
|
-
export const
|
|
477
|
+
export const transformPlotlyJsonToAreaChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
478
|
+
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'area', colorMap, colorwayType, isDarkTheme);
|
|
479
|
+
};
|
|
480
|
+
export const transformPlotlyJsonToLineChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
481
|
+
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'line', colorMap, colorwayType, isDarkTheme);
|
|
482
|
+
};
|
|
483
|
+
export const transformPlotlyJsonToScatterChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
484
|
+
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'scatter', colorMap, colorwayType, isDarkTheme);
|
|
485
|
+
};
|
|
486
|
+
const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme)=>{
|
|
487
|
+
var _input_data_;
|
|
488
|
+
const isScatterMarkers = [
|
|
489
|
+
'markers',
|
|
490
|
+
'text+markers',
|
|
491
|
+
'markers+text',
|
|
492
|
+
'lines+markers',
|
|
493
|
+
'markers+line',
|
|
494
|
+
'text+lines+markers'
|
|
495
|
+
].includes((_input_data_ = input.data[0]) === null || _input_data_ === void 0 ? void 0 : _input_data_.mode);
|
|
496
|
+
const isAreaChart = chartType === 'area';
|
|
497
|
+
const isScatterChart = chartType === 'scatter';
|
|
461
498
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
|
|
462
499
|
let mode = 'tonexty';
|
|
463
|
-
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
500
|
+
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
464
501
|
const chartData = input.data.map((series, index)=>{
|
|
465
|
-
var _series_mode, _series_line, _series_marker, _series_line1, _input_layout_template_layout, _input_layout_template, _input_layout,
|
|
502
|
+
var _series_mode, _series_line, _series_marker, _series_line1, _input_layout_template_layout, _input_layout_template, _input_layout, _series_mode1;
|
|
466
503
|
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;
|
|
467
504
|
// extract colors for each series only once
|
|
468
505
|
const extractedColors = extractColor((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, colors, colorMap, isDarkTheme);
|
|
@@ -470,21 +507,22 @@ export const transformPlotlyJsonToScatterChartProps = (input, isAreaChart, isSca
|
|
|
470
507
|
const isXString = isStringArray(xValues);
|
|
471
508
|
const isXDate = isDateArray(xValues);
|
|
472
509
|
const isXNumber = isNumberArray(xValues);
|
|
473
|
-
|
|
474
|
-
const isXYearCategory = false;
|
|
510
|
+
const isXYearCategory = isYearArray(series.x); // Consider year as categorical not numeric continuous axis
|
|
475
511
|
const legend = legends[index];
|
|
476
512
|
// resolve color for each legend's lines from the extracted colors
|
|
477
513
|
const seriesColor = resolveColor(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
514
|
+
const seriesOpacity = getOpacity(series, index);
|
|
478
515
|
mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
|
|
479
|
-
const lineOptions = getLineOptions(series.line);
|
|
480
|
-
const
|
|
481
|
-
const legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot' ? 'dottedLine' : 'default';
|
|
516
|
+
const lineOptions = !((_series_mode1 = series.mode) === null || _series_mode1 === void 0 ? void 0 : _series_mode1.includes('text')) ? getLineOptions(series.line) : undefined;
|
|
517
|
+
const legendShape = getLegendShape(series);
|
|
482
518
|
const validXYRanges = getValidXYRanges(series);
|
|
483
519
|
return validXYRanges.map(([rangeStart, rangeEnd], rangeIdx)=>{
|
|
484
520
|
var _series_marker;
|
|
485
521
|
const rangeXValues = xValues.slice(rangeStart, rangeEnd);
|
|
486
522
|
const rangeYValues = series.y.slice(rangeStart, rangeEnd);
|
|
487
523
|
const markerSizes = isArrayOrTypedArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.size) ? series.marker.size.slice(rangeStart, rangeEnd) : [];
|
|
524
|
+
const textValues = Array.isArray(series.text) ? series.text.slice(rangeStart, rangeEnd) : undefined;
|
|
525
|
+
var _rgb_copy_formatHex8;
|
|
488
526
|
return {
|
|
489
527
|
legend,
|
|
490
528
|
legendShape,
|
|
@@ -497,14 +535,20 @@ export const transformPlotlyJsonToScatterChartProps = (input, isAreaChart, isSca
|
|
|
497
535
|
markerSize: markerSizes[i]
|
|
498
536
|
} : typeof ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.size) === 'number' ? {
|
|
499
537
|
markerSize: series.marker.size
|
|
538
|
+
} : {},
|
|
539
|
+
...textValues ? {
|
|
540
|
+
text: textValues[i]
|
|
500
541
|
} : {}
|
|
501
542
|
};
|
|
502
543
|
}),
|
|
503
|
-
color: seriesColor
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
544
|
+
color: (_rgb_copy_formatHex8 = rgb(seriesColor).copy({
|
|
545
|
+
opacity: seriesOpacity
|
|
546
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : seriesColor,
|
|
547
|
+
lineOptions: {
|
|
548
|
+
...lineOptions !== null && lineOptions !== void 0 ? lineOptions : {},
|
|
549
|
+
mode: series.mode
|
|
550
|
+
},
|
|
551
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout)
|
|
508
552
|
};
|
|
509
553
|
});
|
|
510
554
|
}).flat();
|
|
@@ -515,6 +559,10 @@ export const transformPlotlyJsonToScatterChartProps = (input, isAreaChart, isSca
|
|
|
515
559
|
chartTitle,
|
|
516
560
|
lineChartData: chartData
|
|
517
561
|
};
|
|
562
|
+
const scatterChartProps = {
|
|
563
|
+
chartTitle,
|
|
564
|
+
scatterChartData: chartData
|
|
565
|
+
};
|
|
518
566
|
if (isAreaChart) {
|
|
519
567
|
var _input_layout, _input_layout1;
|
|
520
568
|
var _input_layout_height;
|
|
@@ -536,7 +584,7 @@ export const transformPlotlyJsonToScatterChartProps = (input, isAreaChart, isSca
|
|
|
536
584
|
var _input_layout2, _input_layout3;
|
|
537
585
|
var _input_layout_height1;
|
|
538
586
|
return {
|
|
539
|
-
data: chartProps,
|
|
587
|
+
data: isScatterChart ? scatterChartProps : chartProps,
|
|
540
588
|
supportNegativeData: true,
|
|
541
589
|
xAxisTitle,
|
|
542
590
|
yAxisTitle,
|
|
@@ -553,9 +601,9 @@ export const transformPlotlyJsonToScatterChartProps = (input, isAreaChart, isSca
|
|
|
553
601
|
};
|
|
554
602
|
}
|
|
555
603
|
};
|
|
556
|
-
export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
604
|
+
export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
557
605
|
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;
|
|
558
|
-
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
606
|
+
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
559
607
|
let colorScale = undefined;
|
|
560
608
|
const chartData = input.data.map((series, index)=>{
|
|
561
609
|
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;
|
|
@@ -572,11 +620,15 @@ export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, colorMap,
|
|
|
572
620
|
}
|
|
573
621
|
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
574
622
|
const color = colorScale ? colorScale(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) : resolveColor(extractedColors, i, legend, colorMap, isDarkTheme);
|
|
623
|
+
const opacity = getOpacity(series, i);
|
|
624
|
+
var _rgb_copy_formatHex8;
|
|
575
625
|
return {
|
|
576
626
|
x: series.x[i],
|
|
577
627
|
y: yValue,
|
|
578
628
|
legend,
|
|
579
|
-
color
|
|
629
|
+
color: (_rgb_copy_formatHex8 = rgb(color).copy({
|
|
630
|
+
opacity
|
|
631
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
|
|
580
632
|
};
|
|
581
633
|
}).filter((point)=>point !== null);
|
|
582
634
|
}).reverse().flat()//reversing the order to invert the Y bars order as required by plotly.
|
|
@@ -610,7 +662,7 @@ export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, colorMap,
|
|
|
610
662
|
roundCorners: true
|
|
611
663
|
};
|
|
612
664
|
};
|
|
613
|
-
export const transformPlotlyJsonToHeatmapProps = (input)=>{
|
|
665
|
+
export const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
614
666
|
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;
|
|
615
667
|
const firstData = input.data[0];
|
|
616
668
|
const heatmapDataPoints = [];
|
|
@@ -743,7 +795,7 @@ export const transformPlotlyJsonToHeatmapProps = (input)=>{
|
|
|
743
795
|
wrapXAxisLables: true
|
|
744
796
|
};
|
|
745
797
|
};
|
|
746
|
-
export const transformPlotlyJsonToSankeyProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
798
|
+
export const transformPlotlyJsonToSankeyProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
747
799
|
var _input_layout_template_layout, _input_layout_template, _input_layout, _node_label, _input_layout1, _input_layout2;
|
|
748
800
|
const { link, node } = input.data[0];
|
|
749
801
|
var _link_value;
|
|
@@ -792,7 +844,7 @@ export const transformPlotlyJsonToSankeyProps = (input, colorMap, colorwayType,
|
|
|
792
844
|
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
|
|
793
845
|
};
|
|
794
846
|
};
|
|
795
|
-
export const transformPlotlyJsonToGaugeProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
847
|
+
export const transformPlotlyJsonToGaugeProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
796
848
|
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;
|
|
797
849
|
const firstData = input.data[0];
|
|
798
850
|
const stepsColors = ((_firstData_gauge = firstData.gauge) === null || _firstData_gauge === void 0 ? void 0 : _firstData_gauge.steps) ? firstData.gauge.steps.map((step)=>step.color) : undefined;
|
|
@@ -888,7 +940,7 @@ const formatValue = (value, colIndex, cells)=>{
|
|
|
888
940
|
}
|
|
889
941
|
return `${prefix !== null && prefix !== void 0 ? prefix : ''}${formatted}${suffix !== null && suffix !== void 0 ? suffix : ''}`;
|
|
890
942
|
};
|
|
891
|
-
export const transformPlotlyJsonToChartTableProps = (input, colorMap, isDarkTheme)=>{
|
|
943
|
+
export const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
892
944
|
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;
|
|
893
945
|
const tableData = input.data[0];
|
|
894
946
|
const normalizeHeaders = (values, header)=>{
|
|
@@ -1109,11 +1161,6 @@ function getLineOptions(line) {
|
|
|
1109
1161
|
}
|
|
1110
1162
|
return Object.keys(lineOptions).length > 0 ? lineOptions : undefined;
|
|
1111
1163
|
}
|
|
1112
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1113
|
-
export const isStringArray = (arr)=>{
|
|
1114
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1115
|
-
return isArrayOfType(arr, (value)=>typeof value === 'string' || value === null);
|
|
1116
|
-
};
|
|
1117
1164
|
// TODO: Use binary search to find the appropriate bin for numeric value.
|
|
1118
1165
|
const findBinIndex = (bins, value, isString)=>{
|
|
1119
1166
|
if (typeof value === 'undefined' || value === null) {
|
|
@@ -1208,7 +1255,46 @@ const precisionRound = (value, precision)=>{
|
|
|
1208
1255
|
const factor = Math.pow(10, precision);
|
|
1209
1256
|
return Math.round(value * factor) / factor;
|
|
1210
1257
|
};
|
|
1211
|
-
const
|
|
1258
|
+
const getLegendShape = (series)=>{
|
|
1259
|
+
var _series_line, _series_mode;
|
|
1260
|
+
const dashType = ((_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.dash) || 'solid';
|
|
1261
|
+
if (dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot') {
|
|
1262
|
+
return 'dottedLine';
|
|
1263
|
+
} else if ((_series_mode = series.mode) === null || _series_mode === void 0 ? void 0 : _series_mode.includes('markers')) {
|
|
1264
|
+
return 'circle';
|
|
1265
|
+
}
|
|
1266
|
+
return 'default';
|
|
1267
|
+
};
|
|
1268
|
+
export const getAllupLegendsProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
1269
|
+
const allupLegends = [];
|
|
1270
|
+
// reduce on showlegend boolean propperty. reduce should return true if at least one series has showlegend true
|
|
1271
|
+
const toShowLegend = input.data.reduce((acc, series)=>{
|
|
1272
|
+
return acc || series.showlegend === true;
|
|
1273
|
+
}, false);
|
|
1274
|
+
if (toShowLegend) {
|
|
1275
|
+
input.data.forEach((series, index)=>{
|
|
1276
|
+
var _series_line, _series_marker, _input_layout_template_layout, _input_layout_template, _input_layout;
|
|
1277
|
+
const name = series.legendgroup;
|
|
1278
|
+
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);
|
|
1279
|
+
const legendShape = getLegendShape(series);
|
|
1280
|
+
const resolvedColor = 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);
|
|
1281
|
+
if (name !== undefined && allupLegends.some((group)=>group.title === name) === false) {
|
|
1282
|
+
allupLegends.push({
|
|
1283
|
+
title: name,
|
|
1284
|
+
color: resolvedColor,
|
|
1285
|
+
shape: legendShape
|
|
1286
|
+
});
|
|
1287
|
+
}
|
|
1288
|
+
});
|
|
1289
|
+
}
|
|
1290
|
+
return {
|
|
1291
|
+
legends: allupLegends,
|
|
1292
|
+
centerLegends: true,
|
|
1293
|
+
enabledWrapLines: true,
|
|
1294
|
+
canSelectMultipleLegends: true
|
|
1295
|
+
};
|
|
1296
|
+
};
|
|
1297
|
+
const getLegendProps = (data, layout, isMultiPlot)=>{
|
|
1212
1298
|
const legends = [];
|
|
1213
1299
|
if (data.length === 1) {
|
|
1214
1300
|
legends.push(data[0].name || '');
|
|
@@ -1217,10 +1303,11 @@ const getLegendProps = (data, layout)=>{
|
|
|
1217
1303
|
legends.push(series.name || `Series ${index + 1}`);
|
|
1218
1304
|
});
|
|
1219
1305
|
}
|
|
1220
|
-
const
|
|
1306
|
+
const hideLegendsData = data.every((series)=>series.showlegend === false);
|
|
1307
|
+
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;
|
|
1221
1308
|
return {
|
|
1222
1309
|
legends,
|
|
1223
|
-
hideLegend:
|
|
1310
|
+
hideLegend: isMultiPlot || hideLegendsInferred || hideLegendsData
|
|
1224
1311
|
};
|
|
1225
1312
|
};
|
|
1226
1313
|
export const getNumberAtIndexOrDefault = (data, index)=>{
|
|
@@ -1258,3 +1345,176 @@ export const getValidXYRanges = (series)=>{
|
|
|
1258
1345
|
}
|
|
1259
1346
|
return ranges;
|
|
1260
1347
|
};
|
|
1348
|
+
const getIndexFromKey = (key, pattern)=>{
|
|
1349
|
+
const normalizedKey = key.replace(pattern, '') === '' ? '1' : key.replace(pattern, '');
|
|
1350
|
+
return parseInt(normalizedKey, 10) - 1;
|
|
1351
|
+
};
|
|
1352
|
+
export const getGridProperties = (layout, isMultiPlot)=>{
|
|
1353
|
+
var _layout_annotations;
|
|
1354
|
+
const gridX = [];
|
|
1355
|
+
const gridY = [];
|
|
1356
|
+
const annotations = {};
|
|
1357
|
+
let templateRows = '1fr';
|
|
1358
|
+
let templateColumns = '1fr';
|
|
1359
|
+
const gridLayout = {};
|
|
1360
|
+
if (layout === undefined || layout === null || Object.keys(layout).length === 0) {
|
|
1361
|
+
return {
|
|
1362
|
+
templateRows,
|
|
1363
|
+
templateColumns,
|
|
1364
|
+
layout: gridLayout
|
|
1365
|
+
};
|
|
1366
|
+
}
|
|
1367
|
+
if (!layout.xaxis || !layout.yaxis) {
|
|
1368
|
+
return {
|
|
1369
|
+
templateRows,
|
|
1370
|
+
templateColumns,
|
|
1371
|
+
layout: gridLayout
|
|
1372
|
+
};
|
|
1373
|
+
}
|
|
1374
|
+
if (!isMultiPlot) {
|
|
1375
|
+
return {
|
|
1376
|
+
templateRows,
|
|
1377
|
+
templateColumns,
|
|
1378
|
+
layout: gridLayout
|
|
1379
|
+
};
|
|
1380
|
+
}
|
|
1381
|
+
Object.keys(layout).forEach((key)=>{
|
|
1382
|
+
if (key.startsWith('xaxis')) {
|
|
1383
|
+
var _layout_key, _layout_key1;
|
|
1384
|
+
const index = getIndexFromKey(key, 'xaxis');
|
|
1385
|
+
var _layout_key_anchor;
|
|
1386
|
+
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';
|
|
1387
|
+
const anchorIndex = getIndexFromKey(anchor, 'y');
|
|
1388
|
+
if (index !== anchorIndex) {
|
|
1389
|
+
throw new Error(`Invalid layout: xaxis ${index + 1} anchor should be y${anchorIndex + 1}`);
|
|
1390
|
+
}
|
|
1391
|
+
var _layout_key_domain;
|
|
1392
|
+
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 : [];
|
|
1393
|
+
} else if (key.startsWith('yaxis')) {
|
|
1394
|
+
var _layout_key2, _layout_key3;
|
|
1395
|
+
const index = getIndexFromKey(key, 'yaxis');
|
|
1396
|
+
var _layout_key_anchor1;
|
|
1397
|
+
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';
|
|
1398
|
+
const anchorIndex = getIndexFromKey(anchor, 'x');
|
|
1399
|
+
if (index !== anchorIndex) {
|
|
1400
|
+
var _layout_yaxis2;
|
|
1401
|
+
if (index === 1 && anchorIndex === 0 || ((_layout_yaxis2 = layout.yaxis2) === null || _layout_yaxis2 === void 0 ? void 0 : _layout_yaxis2.side) === 'right') {
|
|
1402
|
+
// Special case for secondary y axis where yaxis2 can anchor to x1
|
|
1403
|
+
return {
|
|
1404
|
+
templateRows,
|
|
1405
|
+
templateColumns
|
|
1406
|
+
};
|
|
1407
|
+
}
|
|
1408
|
+
throw new Error(`Invalid layout: yaxis ${index + 1} anchor should be x${anchorIndex + 1}`);
|
|
1409
|
+
}
|
|
1410
|
+
var _layout_key_domain1;
|
|
1411
|
+
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 : [];
|
|
1412
|
+
}
|
|
1413
|
+
});
|
|
1414
|
+
(_layout_annotations = layout.annotations) === null || _layout_annotations === void 0 ? void 0 : _layout_annotations.forEach((annotation)=>{
|
|
1415
|
+
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] ? [
|
|
1416
|
+
idx
|
|
1417
|
+
] : []);
|
|
1418
|
+
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]);
|
|
1419
|
+
if (yMatch !== -1) {
|
|
1420
|
+
if (annotations[yMatch] === undefined) {
|
|
1421
|
+
annotations[yMatch] = {};
|
|
1422
|
+
}
|
|
1423
|
+
if ((annotation === null || annotation === void 0 ? void 0 : annotation.textangle) === 90) {
|
|
1424
|
+
annotations[yMatch].yAnnotation = annotation.text;
|
|
1425
|
+
} else {
|
|
1426
|
+
annotations[yMatch].xAnnotation = annotation.text;
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
});
|
|
1430
|
+
if (gridX.length > 0) {
|
|
1431
|
+
const uniqueXIntervals = new Map();
|
|
1432
|
+
gridX.forEach((interval)=>{
|
|
1433
|
+
const key = `${interval[0]}-${interval[1]}`;
|
|
1434
|
+
if (!uniqueXIntervals.has(key)) {
|
|
1435
|
+
uniqueXIntervals.set(key, interval);
|
|
1436
|
+
}
|
|
1437
|
+
});
|
|
1438
|
+
const minXInterval = Math.min(...Array.from(uniqueXIntervals.values()).map((interval)=>interval[1] - interval[0]));
|
|
1439
|
+
templateColumns = Array.from(uniqueXIntervals.values()).map((interval)=>`${(interval[1] - interval[0]) / minXInterval}fr`).join(' ');
|
|
1440
|
+
let columnNumber = 1;
|
|
1441
|
+
let lastIntervalEnd = 0;
|
|
1442
|
+
gridX.forEach((interval, index)=>{
|
|
1443
|
+
if (interval.length === 0) {
|
|
1444
|
+
return;
|
|
1445
|
+
}
|
|
1446
|
+
const cellName = `x${index === 0 ? '' : index + 1}`;
|
|
1447
|
+
const annotationProps = annotations[index];
|
|
1448
|
+
const xAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.xAnnotation;
|
|
1449
|
+
if (interval[0] < lastIntervalEnd) {
|
|
1450
|
+
columnNumber = 1;
|
|
1451
|
+
}
|
|
1452
|
+
lastIntervalEnd = interval[1];
|
|
1453
|
+
const row = {
|
|
1454
|
+
row: -1,
|
|
1455
|
+
column: columnNumber,
|
|
1456
|
+
xAnnotation
|
|
1457
|
+
};
|
|
1458
|
+
gridLayout[cellName] = row;
|
|
1459
|
+
columnNumber += 1;
|
|
1460
|
+
});
|
|
1461
|
+
}
|
|
1462
|
+
const numColumns = Math.max(...Object.values(gridLayout).map((cell)=>{
|
|
1463
|
+
var _cell_column;
|
|
1464
|
+
return (_cell_column = cell.column) !== null && _cell_column !== void 0 ? _cell_column : 0;
|
|
1465
|
+
}));
|
|
1466
|
+
const columnFill = {};
|
|
1467
|
+
for(let i = 1; i <= numColumns; i++){
|
|
1468
|
+
columnFill[i] = {
|
|
1469
|
+
row: 1,
|
|
1470
|
+
fillDomain: 0
|
|
1471
|
+
};
|
|
1472
|
+
}
|
|
1473
|
+
if (gridY.length > 0) {
|
|
1474
|
+
const uniqueYIntervals = new Map();
|
|
1475
|
+
gridY.forEach((interval)=>{
|
|
1476
|
+
const key = `${interval[0]}-${interval[1]}`;
|
|
1477
|
+
if (!uniqueYIntervals.has(key)) {
|
|
1478
|
+
uniqueYIntervals.set(key, interval);
|
|
1479
|
+
}
|
|
1480
|
+
});
|
|
1481
|
+
const minYInterval = Math.min(...Array.from(uniqueYIntervals.values()).map((interval)=>interval[1] - interval[0]));
|
|
1482
|
+
templateRows = Array.from(uniqueYIntervals.values()).map((interval)=>`${(interval[1] - interval[0]) / minYInterval}fr`).join(' ');
|
|
1483
|
+
gridY.forEach((interval, index)=>{
|
|
1484
|
+
if (interval.length === 0) {
|
|
1485
|
+
return;
|
|
1486
|
+
}
|
|
1487
|
+
const cellName = `x${index === 0 ? '' : index + 1}`;
|
|
1488
|
+
const annotationProps = annotations[index];
|
|
1489
|
+
const yAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.yAnnotation;
|
|
1490
|
+
const cell = gridLayout[cellName];
|
|
1491
|
+
if (cell !== undefined) {
|
|
1492
|
+
cell.row = columnFill[cell.column].row;
|
|
1493
|
+
cell.yAnnotation = yAnnotation;
|
|
1494
|
+
}
|
|
1495
|
+
columnFill[cell.column].fillDomain = interval[1];
|
|
1496
|
+
columnFill[cell.column].row += 1;
|
|
1497
|
+
});
|
|
1498
|
+
}
|
|
1499
|
+
// reverse the order of rows in grid layout from bottom-top to top-bottom as required by CSS grid
|
|
1500
|
+
const reversedGridLayout = {};
|
|
1501
|
+
// find the maximum row number
|
|
1502
|
+
const maxRowNumber = Math.max(...Object.values(gridLayout).map((cell)=>{
|
|
1503
|
+
var _cell_row;
|
|
1504
|
+
return (_cell_row = cell.row) !== null && _cell_row !== void 0 ? _cell_row : 0;
|
|
1505
|
+
}));
|
|
1506
|
+
// iterate over the gridLayout and reverse the row numbers
|
|
1507
|
+
Object.keys(gridLayout).forEach((key)=>{
|
|
1508
|
+
const cell = gridLayout[key];
|
|
1509
|
+
if (cell.row !== undefined) {
|
|
1510
|
+
// reverse the row number
|
|
1511
|
+
cell.row = maxRowNumber - cell.row + 1;
|
|
1512
|
+
}
|
|
1513
|
+
reversedGridLayout[key] = cell;
|
|
1514
|
+
});
|
|
1515
|
+
return {
|
|
1516
|
+
templateRows,
|
|
1517
|
+
templateColumns,
|
|
1518
|
+
layout: reversedGridLayout
|
|
1519
|
+
};
|
|
1520
|
+
};
|