@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
|
@@ -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,34 +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 _series_mode
|
|
268
|
+
var _series_mode;
|
|
263
269
|
const lineColor = resolveColor(extractedLineColors, index1, legend, colorMap, isDarkTheme);
|
|
264
270
|
const lineOptions = !((_series_mode = series.mode) === null || _series_mode === void 0 ? void 0 : _series_mode.includes('text')) ? getLineOptions(series.line) : undefined;
|
|
265
|
-
const
|
|
266
|
-
|
|
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
|
|
277
|
+
color: (_rgb_copy_formatHex81 = rgb(lineColor).copy({
|
|
278
|
+
opacity
|
|
279
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex81 !== void 0 ? _rgb_copy_formatHex81 : color,
|
|
272
280
|
lineOptions: {
|
|
273
281
|
...lineOptions !== null && lineOptions !== void 0 ? lineOptions : {},
|
|
274
282
|
mode: series.mode
|
|
275
283
|
},
|
|
276
|
-
useSecondaryYScale: usesSecondaryYScale(series)
|
|
284
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout)
|
|
277
285
|
});
|
|
278
|
-
if (!usesSecondaryYScale(series) && typeof yVal === 'number') {
|
|
286
|
+
if (!usesSecondaryYScale(series, input.layout) && typeof yVal === 'number') {
|
|
279
287
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
280
288
|
yMinValue = Math.min(yMinValue, yVal);
|
|
281
289
|
}
|
|
@@ -323,11 +331,11 @@ const createColorScale = (layout, series)=>{
|
|
|
323
331
|
const scaleColors = scale.map((item)=>item[1]);
|
|
324
332
|
return d3ScaleLinear().domain(scaleDomain).range(scaleColors);
|
|
325
333
|
};
|
|
326
|
-
export const transformPlotlyJsonToGVBCProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
334
|
+
export const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
327
335
|
var _input_layout, _input_layout1, _gvbcData_;
|
|
328
336
|
const mapXToDataPoints = {};
|
|
329
337
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, 0, 0);
|
|
330
|
-
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
338
|
+
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
331
339
|
let colorScale = undefined;
|
|
332
340
|
input.data.forEach((series, index1)=>{
|
|
333
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;
|
|
@@ -352,13 +360,17 @@ export const transformPlotlyJsonToGVBCProps = (input, colorMap, colorwayType, is
|
|
|
352
360
|
const legend = legends[index1];
|
|
353
361
|
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
354
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;
|
|
355
365
|
mapXToDataPoints[x].series.push({
|
|
356
366
|
key: legend,
|
|
357
367
|
data: series.y[index2],
|
|
358
368
|
xAxisCalloutData: x,
|
|
359
|
-
color
|
|
369
|
+
color: (_rgb_copy_formatHex8 = rgb(color).copy({
|
|
370
|
+
opacity
|
|
371
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
|
|
360
372
|
legend,
|
|
361
|
-
useSecondaryYScale: usesSecondaryYScale(series)
|
|
373
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout)
|
|
362
374
|
});
|
|
363
375
|
}
|
|
364
376
|
});
|
|
@@ -382,10 +394,10 @@ export const transformPlotlyJsonToGVBCProps = (input, colorMap, colorwayType, is
|
|
|
382
394
|
roundCorners: true
|
|
383
395
|
};
|
|
384
396
|
};
|
|
385
|
-
export const transformPlotlyJsonToVBCProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
397
|
+
export const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
386
398
|
var _input_layout, _input_layout1, _vbcData_;
|
|
387
399
|
const vbcData = [];
|
|
388
|
-
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
400
|
+
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
389
401
|
let colorScale = undefined;
|
|
390
402
|
input.data.forEach((series, seriesIdx)=>{
|
|
391
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;
|
|
@@ -429,12 +441,16 @@ export const transformPlotlyJsonToVBCProps = (input, colorMap, colorwayType, isD
|
|
|
429
441
|
const legend = legends[seriesIdx];
|
|
430
442
|
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
431
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);
|
|
432
445
|
const yVal = calculateHistNorm(series.histnorm, y[index], total, isXString ? bin.length : getBinSize(bin));
|
|
446
|
+
var _rgb_copy_formatHex8;
|
|
433
447
|
vbcData.push({
|
|
434
448
|
x: isXString ? bin.join(', ') : getBinCenter(bin),
|
|
435
449
|
y: yVal,
|
|
436
450
|
legend,
|
|
437
|
-
color
|
|
451
|
+
color: (_rgb_copy_formatHex8 = rgb(color).copy({
|
|
452
|
+
opacity
|
|
453
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
|
|
438
454
|
...isXString ? {} : {
|
|
439
455
|
xAxisCalloutData: `[${bin.x0} - ${bin.x1})`
|
|
440
456
|
}
|
|
@@ -458,14 +474,32 @@ export const transformPlotlyJsonToVBCProps = (input, colorMap, colorwayType, isD
|
|
|
458
474
|
roundCorners: true
|
|
459
475
|
};
|
|
460
476
|
};
|
|
461
|
-
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);
|
|
462
496
|
const isAreaChart = chartType === 'area';
|
|
463
497
|
const isScatterChart = chartType === 'scatter';
|
|
464
498
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
|
|
465
499
|
let mode = 'tonexty';
|
|
466
|
-
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
500
|
+
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
467
501
|
const chartData = input.data.map((series, index)=>{
|
|
468
|
-
var _series_mode, _series_line, _series_marker, _series_line1, _input_layout_template_layout, _input_layout_template, _input_layout, _series_mode1
|
|
502
|
+
var _series_mode, _series_line, _series_marker, _series_line1, _input_layout_template_layout, _input_layout_template, _input_layout, _series_mode1;
|
|
469
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;
|
|
470
504
|
// extract colors for each series only once
|
|
471
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);
|
|
@@ -477,10 +511,10 @@ export const transformPlotlyJsonToScatterChartProps = (input, chartType, isScatt
|
|
|
477
511
|
const legend = legends[index];
|
|
478
512
|
// resolve color for each legend's lines from the extracted colors
|
|
479
513
|
const seriesColor = resolveColor(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
514
|
+
const seriesOpacity = getOpacity(series, index);
|
|
480
515
|
mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
|
|
481
516
|
const lineOptions = !((_series_mode1 = series.mode) === null || _series_mode1 === void 0 ? void 0 : _series_mode1.includes('text')) ? getLineOptions(series.line) : undefined;
|
|
482
|
-
const
|
|
483
|
-
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';
|
|
517
|
+
const legendShape = getLegendShape(series);
|
|
484
518
|
const validXYRanges = getValidXYRanges(series);
|
|
485
519
|
return validXYRanges.map(([rangeStart, rangeEnd], rangeIdx)=>{
|
|
486
520
|
var _series_marker;
|
|
@@ -488,6 +522,7 @@ export const transformPlotlyJsonToScatterChartProps = (input, chartType, isScatt
|
|
|
488
522
|
const rangeYValues = series.y.slice(rangeStart, rangeEnd);
|
|
489
523
|
const markerSizes = isArrayOrTypedArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.size) ? series.marker.size.slice(rangeStart, rangeEnd) : [];
|
|
490
524
|
const textValues = Array.isArray(series.text) ? series.text.slice(rangeStart, rangeEnd) : undefined;
|
|
525
|
+
var _rgb_copy_formatHex8;
|
|
491
526
|
return {
|
|
492
527
|
legend,
|
|
493
528
|
legendShape,
|
|
@@ -506,12 +541,14 @@ export const transformPlotlyJsonToScatterChartProps = (input, chartType, isScatt
|
|
|
506
541
|
} : {}
|
|
507
542
|
};
|
|
508
543
|
}),
|
|
509
|
-
color: seriesColor
|
|
544
|
+
color: (_rgb_copy_formatHex8 = rgb(seriesColor).copy({
|
|
545
|
+
opacity: seriesOpacity
|
|
546
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : seriesColor,
|
|
510
547
|
lineOptions: {
|
|
511
548
|
...lineOptions !== null && lineOptions !== void 0 ? lineOptions : {},
|
|
512
549
|
mode: series.mode
|
|
513
550
|
},
|
|
514
|
-
useSecondaryYScale: usesSecondaryYScale(series)
|
|
551
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout)
|
|
515
552
|
};
|
|
516
553
|
});
|
|
517
554
|
}).flat();
|
|
@@ -564,9 +601,9 @@ export const transformPlotlyJsonToScatterChartProps = (input, chartType, isScatt
|
|
|
564
601
|
};
|
|
565
602
|
}
|
|
566
603
|
};
|
|
567
|
-
export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
604
|
+
export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
568
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;
|
|
569
|
-
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
606
|
+
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
570
607
|
let colorScale = undefined;
|
|
571
608
|
const chartData = input.data.map((series, index)=>{
|
|
572
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;
|
|
@@ -583,11 +620,15 @@ export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, colorMap,
|
|
|
583
620
|
}
|
|
584
621
|
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
585
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;
|
|
586
625
|
return {
|
|
587
626
|
x: series.x[i],
|
|
588
627
|
y: yValue,
|
|
589
628
|
legend,
|
|
590
|
-
color
|
|
629
|
+
color: (_rgb_copy_formatHex8 = rgb(color).copy({
|
|
630
|
+
opacity
|
|
631
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
|
|
591
632
|
};
|
|
592
633
|
}).filter((point)=>point !== null);
|
|
593
634
|
}).reverse().flat()//reversing the order to invert the Y bars order as required by plotly.
|
|
@@ -621,7 +662,7 @@ export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, colorMap,
|
|
|
621
662
|
roundCorners: true
|
|
622
663
|
};
|
|
623
664
|
};
|
|
624
|
-
export const transformPlotlyJsonToHeatmapProps = (input)=>{
|
|
665
|
+
export const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
625
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;
|
|
626
667
|
const firstData = input.data[0];
|
|
627
668
|
const heatmapDataPoints = [];
|
|
@@ -754,7 +795,7 @@ export const transformPlotlyJsonToHeatmapProps = (input)=>{
|
|
|
754
795
|
wrapXAxisLables: true
|
|
755
796
|
};
|
|
756
797
|
};
|
|
757
|
-
export const transformPlotlyJsonToSankeyProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
798
|
+
export const transformPlotlyJsonToSankeyProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
758
799
|
var _input_layout_template_layout, _input_layout_template, _input_layout, _node_label, _input_layout1, _input_layout2;
|
|
759
800
|
const { link, node } = input.data[0];
|
|
760
801
|
var _link_value;
|
|
@@ -803,7 +844,7 @@ export const transformPlotlyJsonToSankeyProps = (input, colorMap, colorwayType,
|
|
|
803
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
|
|
804
845
|
};
|
|
805
846
|
};
|
|
806
|
-
export const transformPlotlyJsonToGaugeProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
847
|
+
export const transformPlotlyJsonToGaugeProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
807
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;
|
|
808
849
|
const firstData = input.data[0];
|
|
809
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;
|
|
@@ -899,7 +940,7 @@ const formatValue = (value, colIndex, cells)=>{
|
|
|
899
940
|
}
|
|
900
941
|
return `${prefix !== null && prefix !== void 0 ? prefix : ''}${formatted}${suffix !== null && suffix !== void 0 ? suffix : ''}`;
|
|
901
942
|
};
|
|
902
|
-
export const transformPlotlyJsonToChartTableProps = (input, colorMap, isDarkTheme)=>{
|
|
943
|
+
export const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
903
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;
|
|
904
945
|
const tableData = input.data[0];
|
|
905
946
|
const normalizeHeaders = (values, header)=>{
|
|
@@ -1120,11 +1161,6 @@ function getLineOptions(line) {
|
|
|
1120
1161
|
}
|
|
1121
1162
|
return Object.keys(lineOptions).length > 0 ? lineOptions : undefined;
|
|
1122
1163
|
}
|
|
1123
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1124
|
-
export const isStringArray = (arr)=>{
|
|
1125
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1126
|
-
return isArrayOfType(arr, (value)=>typeof value === 'string' || value === null);
|
|
1127
|
-
};
|
|
1128
1164
|
// TODO: Use binary search to find the appropriate bin for numeric value.
|
|
1129
1165
|
const findBinIndex = (bins, value, isString)=>{
|
|
1130
1166
|
if (typeof value === 'undefined' || value === null) {
|
|
@@ -1219,7 +1255,46 @@ const precisionRound = (value, precision)=>{
|
|
|
1219
1255
|
const factor = Math.pow(10, precision);
|
|
1220
1256
|
return Math.round(value * factor) / factor;
|
|
1221
1257
|
};
|
|
1222
|
-
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)=>{
|
|
1223
1298
|
const legends = [];
|
|
1224
1299
|
if (data.length === 1) {
|
|
1225
1300
|
legends.push(data[0].name || '');
|
|
@@ -1228,10 +1303,11 @@ const getLegendProps = (data, layout)=>{
|
|
|
1228
1303
|
legends.push(series.name || `Series ${index + 1}`);
|
|
1229
1304
|
});
|
|
1230
1305
|
}
|
|
1231
|
-
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;
|
|
1232
1308
|
return {
|
|
1233
1309
|
legends,
|
|
1234
|
-
hideLegend:
|
|
1310
|
+
hideLegend: isMultiPlot || hideLegendsInferred || hideLegendsData
|
|
1235
1311
|
};
|
|
1236
1312
|
};
|
|
1237
1313
|
export const getNumberAtIndexOrDefault = (data, index)=>{
|
|
@@ -1269,3 +1345,176 @@ export const getValidXYRanges = (series)=>{
|
|
|
1269
1345
|
}
|
|
1270
1346
|
return ranges;
|
|
1271
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
|
+
};
|