@fluentui/react-charts 0.0.0-nightly-20250825-0406.1 → 0.0.0-nightly-20250826-2140.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 -48
- package/dist/index.d.ts +1 -9
- package/lib/components/AreaChart/AreaChart.js +1 -4
- package/lib/components/AreaChart/AreaChart.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.js +9 -13
- package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +16 -32
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +1 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +199 -293
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.js +1 -6
- package/lib/components/DonutChart/DonutChart.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.types.js.map +1 -1
- package/lib/components/DonutChart/useDonutChartStyles.styles.js +4 -21
- package/lib/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
- package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js +3 -16
- package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +4 -23
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib/components/HeatMapChart/HeatMapChart.js +114 -175
- package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +6 -26
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.js +30 -49
- 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 +3 -19
- package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js +2 -14
- package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.js +4 -27
- package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +44 -61
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib/utilities/utilities.js +29 -0
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-commonjs/components/AreaChart/AreaChart.js +1 -4
- package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.js +9 -13
- package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +15 -31
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +198 -301
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.js +1 -6
- package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -1
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js +4 -32
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js +3 -16
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +3 -22
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +113 -174
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +5 -25
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.js +30 -49
- 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 +2 -28
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js +1 -13
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +3 -26
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +43 -60
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib-commonjs/utilities/utilities.js +32 -0
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +12 -12
|
@@ -4,12 +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 { isArrayOrTypedArray, isDate, isDateArray, isNumberArray, isStringArray, isYearArray, isInvalidValue
|
|
7
|
+
import { isArrayOrTypedArray, isDate, isDateArray, isNumberArray, isStringArray, isYearArray, isInvalidValue } from '@fluentui/chart-utilities';
|
|
8
8
|
import { curveCardinal as d3CurveCardinal } from 'd3-shape';
|
|
9
9
|
import { getOpacity, extractColor, resolveColor } from './PlotlyColorAdapter';
|
|
10
10
|
import { rgb } from 'd3-color';
|
|
11
|
-
export const NON_PLOT_KEY_PREFIX = 'nonplot_';
|
|
12
|
-
export const SINGLE_REPEAT = 'repeat(1, 1fr)';
|
|
13
11
|
const dashOptions = {
|
|
14
12
|
dot: {
|
|
15
13
|
strokeDasharray: '1, 5',
|
|
@@ -58,47 +56,6 @@ function getTitles(layout) {
|
|
|
58
56
|
};
|
|
59
57
|
return titles;
|
|
60
58
|
}
|
|
61
|
-
const getXAxisTickFormat = (series, layout)=>{
|
|
62
|
-
const xAxis = getXAxisProperties(series, layout);
|
|
63
|
-
if (xAxis === null || xAxis === void 0 ? void 0 : xAxis.tickformat) {
|
|
64
|
-
return {
|
|
65
|
-
tickFormat: xAxis === null || xAxis === void 0 ? void 0 : xAxis.tickformat
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
return {};
|
|
69
|
-
};
|
|
70
|
-
const getYAxisTickFormat = (series, layout)=>{
|
|
71
|
-
const yAxis = getYAxisProperties(series, layout);
|
|
72
|
-
if (yAxis === null || yAxis === void 0 ? void 0 : yAxis.tickformat) {
|
|
73
|
-
return {
|
|
74
|
-
yAxisTickFormat: d3Format(yAxis === null || yAxis === void 0 ? void 0 : yAxis.tickformat)
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
return {};
|
|
78
|
-
};
|
|
79
|
-
const getYMinMaxValues = (series, layout)=>{
|
|
80
|
-
var _getYAxisProperties;
|
|
81
|
-
const range = (_getYAxisProperties = getYAxisProperties(series, layout)) === null || _getYAxisProperties === void 0 ? void 0 : _getYAxisProperties.range;
|
|
82
|
-
if (range && range.length === 2) {
|
|
83
|
-
return {
|
|
84
|
-
yMinValue: range[0],
|
|
85
|
-
yMaxValue: range[1]
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
return {};
|
|
89
|
-
};
|
|
90
|
-
const getYAxisProperties = (series, layout)=>{
|
|
91
|
-
return layout === null || layout === void 0 ? void 0 : layout.yaxis;
|
|
92
|
-
};
|
|
93
|
-
const getXAxisProperties = (series, layout)=>{
|
|
94
|
-
return layout === null || layout === void 0 ? void 0 : layout.xaxis;
|
|
95
|
-
};
|
|
96
|
-
const getFormattedCalloutYData = (yVal, yAxisFormat)=>{
|
|
97
|
-
if (typeof (yAxisFormat === null || yAxisFormat === void 0 ? void 0 : yAxisFormat.yAxisTickFormat) === 'function' && typeof yVal === 'number') {
|
|
98
|
-
return yAxisFormat.yAxisTickFormat(yVal);
|
|
99
|
-
}
|
|
100
|
-
return formatToLocaleString(yVal);
|
|
101
|
-
};
|
|
102
59
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
103
60
|
export const correctYearMonth = (xValues)=>{
|
|
104
61
|
const presentYear = new Date().getFullYear();
|
|
@@ -243,7 +200,7 @@ export const transformPlotlyJsonToDonutProps = (input, isMultiPlot, colorMap, co
|
|
|
243
200
|
chartTitle,
|
|
244
201
|
chartData: Object.values(mapLegendToDataPoint)
|
|
245
202
|
},
|
|
246
|
-
hideLegend:
|
|
203
|
+
hideLegend: ((_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : _input_layout5.showlegend) === false ? true : false,
|
|
247
204
|
width: (_input_layout6 = input.layout) === null || _input_layout6 === void 0 ? void 0 : _input_layout6.width,
|
|
248
205
|
height,
|
|
249
206
|
innerRadius,
|
|
@@ -262,7 +219,6 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
|
|
|
262
219
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
|
|
263
220
|
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
264
221
|
let colorScale = undefined;
|
|
265
|
-
const yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
266
222
|
let yMinValue = 0;
|
|
267
223
|
input.data.forEach((series, index1)=>{
|
|
268
224
|
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, _input_layout_template_layout1, _input_layout_template1, _input_layout2, _series_line;
|
|
@@ -296,7 +252,6 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
|
|
|
296
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);
|
|
297
253
|
const opacity = getOpacity(series, index2);
|
|
298
254
|
const yVal = rangeYValues[index2];
|
|
299
|
-
const yAxisCalloutData = getFormattedCalloutYData(yVal, yAxisTickFormat);
|
|
300
255
|
if (series.type === 'bar') {
|
|
301
256
|
var _rgb_copy_formatHex8;
|
|
302
257
|
mapXToDataPoints[x].chartData.push({
|
|
@@ -304,8 +259,7 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
|
|
|
304
259
|
data: yVal,
|
|
305
260
|
color: (_rgb_copy_formatHex8 = rgb(color).copy({
|
|
306
261
|
opacity
|
|
307
|
-
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
|
|
308
|
-
yAxisCalloutData
|
|
262
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
|
|
309
263
|
});
|
|
310
264
|
if (typeof yVal === 'number') {
|
|
311
265
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
@@ -327,8 +281,7 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
|
|
|
327
281
|
...lineOptions !== null && lineOptions !== void 0 ? lineOptions : {},
|
|
328
282
|
mode: series.mode
|
|
329
283
|
},
|
|
330
|
-
useSecondaryYScale: usesSecondaryYScale(series, input.layout)
|
|
331
|
-
yAxisCalloutData
|
|
284
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout)
|
|
332
285
|
});
|
|
333
286
|
if (!usesSecondaryYScale(series, input.layout) && typeof yVal === 'number') {
|
|
334
287
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
@@ -339,6 +292,7 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
|
|
|
339
292
|
});
|
|
340
293
|
});
|
|
341
294
|
});
|
|
295
|
+
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
342
296
|
const vsbcData = Object.values(mapXToDataPoints);
|
|
343
297
|
var _input_layout_height;
|
|
344
298
|
return {
|
|
@@ -348,6 +302,9 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
|
|
|
348
302
|
barWidth: 'auto',
|
|
349
303
|
yMaxValue,
|
|
350
304
|
yMinValue,
|
|
305
|
+
chartTitle,
|
|
306
|
+
xAxisTitle,
|
|
307
|
+
yAxisTitle,
|
|
351
308
|
mode: 'plotly',
|
|
352
309
|
...secondaryYAxisValues,
|
|
353
310
|
wrapXAxisLables: typeof ((_vsbcData_ = vsbcData[0]) === null || _vsbcData_ === void 0 ? void 0 : _vsbcData_.xAxisPoint) === 'string',
|
|
@@ -357,11 +314,7 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
|
|
|
357
314
|
roundCorners: true,
|
|
358
315
|
showYAxisLables: true,
|
|
359
316
|
noOfCharsToTruncate: 20,
|
|
360
|
-
showYAxisLablesTooltip: true
|
|
361
|
-
...getTitles(input.layout),
|
|
362
|
-
...getXAxisTickFormat(input.data[0], input.layout),
|
|
363
|
-
...yAxisTickFormat,
|
|
364
|
-
...getAxisCategoryOrderProps(input.data, input.layout)
|
|
317
|
+
showYAxisLablesTooltip: true
|
|
365
318
|
};
|
|
366
319
|
};
|
|
367
320
|
const createColorScale = (layout, series)=>{
|
|
@@ -384,7 +337,6 @@ export const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, col
|
|
|
384
337
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, 0, 0);
|
|
385
338
|
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
386
339
|
let colorScale = undefined;
|
|
387
|
-
const yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
388
340
|
input.data.forEach((series, index1)=>{
|
|
389
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;
|
|
390
342
|
if (((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_coloraxis = _input_layout.coloraxis) === null || _input_layout_coloraxis === void 0 ? void 0 : (_input_layout_coloraxis_colorscale = _input_layout_coloraxis.colorscale) === null || _input_layout_coloraxis_colorscale === void 0 ? void 0 : _input_layout_coloraxis_colorscale.length) && isArrayOrTypedArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) && ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length > 0 && typeof ((_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[0]) === 'number') {
|
|
@@ -407,24 +359,23 @@ export const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, col
|
|
|
407
359
|
var _series_marker, _series_marker1, _series_marker_color, _series_marker2;
|
|
408
360
|
const legend = legends[index1];
|
|
409
361
|
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
410
|
-
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,
|
|
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);
|
|
411
363
|
const opacity = getOpacity(series, index2);
|
|
412
|
-
const yVal = series.y[index2];
|
|
413
364
|
var _rgb_copy_formatHex8;
|
|
414
365
|
mapXToDataPoints[x].series.push({
|
|
415
366
|
key: legend,
|
|
416
|
-
data:
|
|
367
|
+
data: series.y[index2],
|
|
417
368
|
xAxisCalloutData: x,
|
|
418
369
|
color: (_rgb_copy_formatHex8 = rgb(color).copy({
|
|
419
370
|
opacity
|
|
420
371
|
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
|
|
421
372
|
legend,
|
|
422
|
-
useSecondaryYScale: usesSecondaryYScale(series, input.layout)
|
|
423
|
-
yAxisCalloutData: getFormattedCalloutYData(yVal, yAxisTickFormat)
|
|
373
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout)
|
|
424
374
|
});
|
|
425
375
|
}
|
|
426
376
|
});
|
|
427
377
|
});
|
|
378
|
+
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
428
379
|
const gvbcData = Object.values(mapXToDataPoints);
|
|
429
380
|
var _input_layout_height;
|
|
430
381
|
return {
|
|
@@ -432,17 +383,15 @@ export const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, col
|
|
|
432
383
|
width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
|
|
433
384
|
height: (_input_layout_height = (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
|
|
434
385
|
barWidth: 'auto',
|
|
386
|
+
chartTitle,
|
|
387
|
+
xAxisTitle,
|
|
388
|
+
yAxisTitle,
|
|
435
389
|
mode: 'plotly',
|
|
436
390
|
...secondaryYAxisValues,
|
|
437
391
|
hideTickOverlap: true,
|
|
438
392
|
wrapXAxisLables: typeof ((_gvbcData_ = gvbcData[0]) === null || _gvbcData_ === void 0 ? void 0 : _gvbcData_.name) === 'string',
|
|
439
393
|
hideLegend,
|
|
440
|
-
roundCorners: true
|
|
441
|
-
...getTitles(input.layout),
|
|
442
|
-
...getYMinMaxValues(input.data[0], input.layout),
|
|
443
|
-
...getXAxisTickFormat(input.data[0], input.layout),
|
|
444
|
-
...yAxisTickFormat,
|
|
445
|
-
...getAxisCategoryOrderProps(input.data, input.layout)
|
|
394
|
+
roundCorners: true
|
|
446
395
|
};
|
|
447
396
|
};
|
|
448
397
|
export const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
@@ -508,20 +457,21 @@ export const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colo
|
|
|
508
457
|
});
|
|
509
458
|
});
|
|
510
459
|
});
|
|
460
|
+
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
511
461
|
var _input_layout_height;
|
|
512
462
|
return {
|
|
513
463
|
data: vbcData,
|
|
514
464
|
width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
|
|
515
465
|
height: (_input_layout_height = (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
|
|
466
|
+
chartTitle,
|
|
467
|
+
xAxisTitle,
|
|
468
|
+
yAxisTitle,
|
|
516
469
|
mode: 'histogram',
|
|
517
470
|
hideTickOverlap: true,
|
|
518
471
|
wrapXAxisLables: typeof ((_vbcData_ = vbcData[0]) === null || _vbcData_ === void 0 ? void 0 : _vbcData_.x) === 'string',
|
|
519
472
|
maxBarWidth: 50,
|
|
520
473
|
hideLegend,
|
|
521
|
-
roundCorners: true
|
|
522
|
-
...getTitles(input.layout),
|
|
523
|
-
...getYMinMaxValues(input.data[0], input.layout),
|
|
524
|
-
...getAxisCategoryOrderProps(input.data, input.layout)
|
|
474
|
+
roundCorners: true
|
|
525
475
|
};
|
|
526
476
|
};
|
|
527
477
|
export const transformPlotlyJsonToAreaChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
@@ -534,9 +484,8 @@ export const transformPlotlyJsonToScatterChartProps = (input, isMultiPlot, color
|
|
|
534
484
|
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'scatter', colorMap, colorwayType, isDarkTheme);
|
|
535
485
|
};
|
|
536
486
|
const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme)=>{
|
|
537
|
-
var _input_data_
|
|
487
|
+
var _input_data_;
|
|
538
488
|
const isScatterMarkers = [
|
|
539
|
-
'markers',
|
|
540
489
|
'text+markers',
|
|
541
490
|
'markers+text',
|
|
542
491
|
'lines+markers',
|
|
@@ -548,7 +497,6 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
|
|
|
548
497
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
|
|
549
498
|
let mode = 'tonexty';
|
|
550
499
|
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
551
|
-
const yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
552
500
|
const chartData = input.data.map((series, index)=>{
|
|
553
501
|
var _series_mode, _series_line, _series_marker, _series_line1, _input_layout_template_layout, _input_layout_template, _input_layout, _series_mode1;
|
|
554
502
|
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;
|
|
@@ -589,8 +537,7 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
|
|
|
589
537
|
} : {},
|
|
590
538
|
...textValues ? {
|
|
591
539
|
text: textValues[i]
|
|
592
|
-
} : {}
|
|
593
|
-
yAxisCalloutData: getFormattedCalloutYData(rangeYValues[i], yAxisTickFormat)
|
|
540
|
+
} : {}
|
|
594
541
|
};
|
|
595
542
|
}),
|
|
596
543
|
color: (_rgb_copy_formatHex8 = rgb(seriesColor).copy({
|
|
@@ -604,45 +551,52 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
|
|
|
604
551
|
};
|
|
605
552
|
});
|
|
606
553
|
}).flat();
|
|
607
|
-
const
|
|
608
|
-
|
|
609
|
-
const yMinMaxValues = findNumericMinMaxOfY(chartData);
|
|
610
|
-
yMinMax.yMinValue = yMinMaxValues.startValue;
|
|
611
|
-
yMinMax.yMaxValue = yMinMaxValues.endValue;
|
|
612
|
-
}
|
|
554
|
+
const yMinMaxValues = findNumericMinMaxOfY(chartData);
|
|
555
|
+
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
613
556
|
const numDataPoints = chartData.reduce((total, lineChartPoints)=>total + lineChartPoints.data.length, 0);
|
|
614
557
|
const chartProps = {
|
|
558
|
+
chartTitle,
|
|
615
559
|
lineChartData: chartData
|
|
616
560
|
};
|
|
617
561
|
const scatterChartProps = {
|
|
562
|
+
chartTitle,
|
|
618
563
|
scatterChartData: chartData
|
|
619
564
|
};
|
|
620
|
-
var _input_layout_height;
|
|
621
|
-
const commonProps = {
|
|
622
|
-
supportNegativeData: true,
|
|
623
|
-
...secondaryYAxisValues,
|
|
624
|
-
width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
|
|
625
|
-
height: (_input_layout_height = (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
|
|
626
|
-
hideTickOverlap: true,
|
|
627
|
-
hideLegend,
|
|
628
|
-
useUTC: false,
|
|
629
|
-
optimizeLargeData: numDataPoints > 1000,
|
|
630
|
-
...getTitles(input.layout),
|
|
631
|
-
...getXAxisTickFormat(input.data[0], input.layout),
|
|
632
|
-
...yAxisTickFormat
|
|
633
|
-
};
|
|
634
565
|
if (isAreaChart) {
|
|
566
|
+
var _input_layout, _input_layout1;
|
|
567
|
+
var _input_layout_height;
|
|
635
568
|
return {
|
|
636
569
|
data: chartProps,
|
|
570
|
+
supportNegativeData: true,
|
|
571
|
+
xAxisTitle,
|
|
572
|
+
yAxisTitle,
|
|
573
|
+
...secondaryYAxisValues,
|
|
637
574
|
mode,
|
|
638
|
-
|
|
575
|
+
width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
|
|
576
|
+
height: (_input_layout_height = (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
|
|
577
|
+
hideTickOverlap: true,
|
|
578
|
+
useUTC: false,
|
|
579
|
+
hideLegend,
|
|
580
|
+
optimizeLargeData: numDataPoints > 1000
|
|
639
581
|
};
|
|
640
582
|
} else {
|
|
583
|
+
var _input_layout2, _input_layout3;
|
|
584
|
+
var _input_layout_height1;
|
|
641
585
|
return {
|
|
642
586
|
data: isScatterChart ? scatterChartProps : chartProps,
|
|
587
|
+
supportNegativeData: true,
|
|
588
|
+
xAxisTitle,
|
|
589
|
+
yAxisTitle,
|
|
590
|
+
...secondaryYAxisValues,
|
|
643
591
|
roundedTicks: true,
|
|
644
|
-
|
|
645
|
-
|
|
592
|
+
yMinValue: yMinMaxValues.startValue,
|
|
593
|
+
yMaxValue: yMinMaxValues.endValue,
|
|
594
|
+
width: (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.width,
|
|
595
|
+
height: (_input_layout_height1 = (_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : _input_layout3.height) !== null && _input_layout_height1 !== void 0 ? _input_layout_height1 : 350,
|
|
596
|
+
hideTickOverlap: true,
|
|
597
|
+
useUTC: false,
|
|
598
|
+
hideLegend,
|
|
599
|
+
optimizeLargeData: numDataPoints > 1000
|
|
646
600
|
};
|
|
647
601
|
}
|
|
648
602
|
};
|
|
@@ -676,7 +630,8 @@ export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPl
|
|
|
676
630
|
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
|
|
677
631
|
};
|
|
678
632
|
}).filter((point)=>point !== null);
|
|
679
|
-
}).flat()
|
|
633
|
+
}).reverse().flat()//reversing the order to invert the Y bars order as required by plotly.
|
|
634
|
+
.reverse();
|
|
680
635
|
var _input_layout_height;
|
|
681
636
|
const chartHeight = (_input_layout_height = (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 450;
|
|
682
637
|
var _input_layout_margin_l;
|
|
@@ -688,8 +643,12 @@ export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPl
|
|
|
688
643
|
const scalingFactor = 0.01;
|
|
689
644
|
const gapFactor = 1 / (1 + scalingFactor * numberOfRows);
|
|
690
645
|
const barHeight = availableHeight / (numberOfRows * (1 + gapFactor));
|
|
646
|
+
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
691
647
|
return {
|
|
692
648
|
data: chartData,
|
|
649
|
+
chartTitle,
|
|
650
|
+
xAxisTitle,
|
|
651
|
+
yAxisTitle,
|
|
693
652
|
secondaryYAxistitle: typeof ((_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : (_input_layout_yaxis2 = _input_layout3.yaxis2) === null || _input_layout_yaxis2 === void 0 ? void 0 : _input_layout_yaxis2.title) === 'string' ? (_input_layout4 = input.layout) === null || _input_layout4 === void 0 ? void 0 : (_input_layout_yaxis21 = _input_layout4.yaxis2) === null || _input_layout_yaxis21 === void 0 ? void 0 : _input_layout_yaxis21.title : ((_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : (_input_layout_yaxis22 = _input_layout5.yaxis2) === null || _input_layout_yaxis22 === void 0 ? void 0 : (_input_layout_yaxis2_title = _input_layout_yaxis22.title) === null || _input_layout_yaxis2_title === void 0 ? void 0 : _input_layout_yaxis2_title.text) || '',
|
|
694
653
|
barHeight,
|
|
695
654
|
showYAxisLables: true,
|
|
@@ -699,9 +658,7 @@ export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPl
|
|
|
699
658
|
noOfCharsToTruncate: 20,
|
|
700
659
|
showYAxisLablesTooltip: true,
|
|
701
660
|
hideLegend,
|
|
702
|
-
roundCorners: true
|
|
703
|
-
...getTitles(input.layout),
|
|
704
|
-
...getAxisCategoryOrderProps(input.data, input.layout)
|
|
661
|
+
roundCorners: true
|
|
705
662
|
};
|
|
706
663
|
};
|
|
707
664
|
export const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
@@ -815,6 +772,7 @@ export const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap,
|
|
|
815
772
|
}
|
|
816
773
|
const domainValuesForColorScale = Array.isArray(colorscale) ? colorscale.map((arr)=>arr[0] * (zMax - zMin) + zMin) : defaultDomain;
|
|
817
774
|
const rangeValuesForColorScale = Array.isArray(colorscale) ? colorscale.map((arr)=>arr[1]) : defaultRange;
|
|
775
|
+
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
818
776
|
var _input_layout_height;
|
|
819
777
|
return {
|
|
820
778
|
data: [
|
|
@@ -824,17 +782,16 @@ export const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap,
|
|
|
824
782
|
rangeValuesForColorScale,
|
|
825
783
|
hideLegend: true,
|
|
826
784
|
showYAxisLables: true,
|
|
785
|
+
chartTitle,
|
|
786
|
+
xAxisTitle,
|
|
787
|
+
yAxisTitle,
|
|
827
788
|
sortOrder: 'none',
|
|
828
789
|
width: (_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : _input_layout5.width,
|
|
829
790
|
height: (_input_layout_height = (_input_layout6 = input.layout) === null || _input_layout6 === void 0 ? void 0 : _input_layout6.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
|
|
830
791
|
hideTickOverlap: true,
|
|
831
792
|
noOfCharsToTruncate: 20,
|
|
832
793
|
showYAxisLablesTooltip: true,
|
|
833
|
-
wrapXAxisLables: true
|
|
834
|
-
...getTitles(input.layout),
|
|
835
|
-
...getAxisCategoryOrderProps([
|
|
836
|
-
firstData
|
|
837
|
-
], input.layout)
|
|
794
|
+
wrapXAxisLables: true
|
|
838
795
|
};
|
|
839
796
|
};
|
|
840
797
|
export const transformPlotlyJsonToSankeyProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
@@ -1307,44 +1264,25 @@ const getLegendShape = (series)=>{
|
|
|
1307
1264
|
}
|
|
1308
1265
|
return 'default';
|
|
1309
1266
|
};
|
|
1310
|
-
export const getAllupLegendsProps = (input, colorMap, colorwayType,
|
|
1267
|
+
export const getAllupLegendsProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
1311
1268
|
const allupLegends = [];
|
|
1312
1269
|
// reduce on showlegend boolean propperty. reduce should return true if at least one series has showlegend true
|
|
1313
1270
|
const toShowLegend = input.data.reduce((acc, series)=>{
|
|
1314
|
-
return acc || series.showlegend === true
|
|
1271
|
+
return acc || series.showlegend === true;
|
|
1315
1272
|
}, false);
|
|
1316
1273
|
if (toShowLegend) {
|
|
1317
1274
|
input.data.forEach((series, index)=>{
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
allupLegends.push({
|
|
1329
|
-
title: legend,
|
|
1330
|
-
color
|
|
1331
|
-
});
|
|
1332
|
-
}
|
|
1275
|
+
var _series_line, _series_marker, _input_layout_template_layout, _input_layout_template, _input_layout;
|
|
1276
|
+
const name = series.legendgroup;
|
|
1277
|
+
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);
|
|
1278
|
+
const legendShape = getLegendShape(series);
|
|
1279
|
+
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);
|
|
1280
|
+
if (name !== undefined && allupLegends.some((group)=>group.title === name) === false) {
|
|
1281
|
+
allupLegends.push({
|
|
1282
|
+
title: name,
|
|
1283
|
+
color: resolvedColor,
|
|
1284
|
+
shape: legendShape
|
|
1333
1285
|
});
|
|
1334
|
-
} else if (isNonPlotType(traceInfo[index].type) === false) {
|
|
1335
|
-
var _plotSeries_line, _plotSeries_marker, _input_layout_template_layout1, _input_layout_template1, _input_layout3;
|
|
1336
|
-
const plotSeries = series;
|
|
1337
|
-
const name = plotSeries.legendgroup;
|
|
1338
|
-
const color = ((_plotSeries_line = plotSeries.line) === null || _plotSeries_line === void 0 ? void 0 : _plotSeries_line.color) || ((_plotSeries_marker = plotSeries.marker) === null || _plotSeries_marker === void 0 ? void 0 : _plotSeries_marker.color);
|
|
1339
|
-
const legendShape = getLegendShape(plotSeries);
|
|
1340
|
-
const resolvedColor = extractColor((_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : (_input_layout_template1 = _input_layout3.template) === null || _input_layout_template1 === void 0 ? void 0 : (_input_layout_template_layout1 = _input_layout_template1.layout) === null || _input_layout_template_layout1 === void 0 ? void 0 : _input_layout_template_layout1.colorway, colorwayType, color, colorMap, isDarkTheme);
|
|
1341
|
-
if (name !== undefined && name !== '' && allupLegends.some((group)=>group.title === name) === false) {
|
|
1342
|
-
allupLegends.push({
|
|
1343
|
-
title: name,
|
|
1344
|
-
color: resolvedColor,
|
|
1345
|
-
shape: legendShape
|
|
1346
|
-
});
|
|
1347
|
-
}
|
|
1348
1286
|
}
|
|
1349
1287
|
});
|
|
1350
1288
|
}
|
|
@@ -1410,21 +1348,28 @@ const getIndexFromKey = (key, pattern)=>{
|
|
|
1410
1348
|
const normalizedKey = key.replace(pattern, '') === '' ? '1' : key.replace(pattern, '');
|
|
1411
1349
|
return parseInt(normalizedKey, 10) - 1;
|
|
1412
1350
|
};
|
|
1413
|
-
export const
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
'pie'
|
|
1418
|
-
].includes(chartType);
|
|
1419
|
-
};
|
|
1420
|
-
export const getGridProperties = (schema, isMultiPlot, validTracesInfo)=>{
|
|
1421
|
-
const domainX = [];
|
|
1422
|
-
const domainY = [];
|
|
1423
|
-
let cartesianDomains = 0;
|
|
1351
|
+
export const getGridProperties = (layout, isMultiPlot)=>{
|
|
1352
|
+
var _layout_annotations;
|
|
1353
|
+
const gridX = [];
|
|
1354
|
+
const gridY = [];
|
|
1424
1355
|
const annotations = {};
|
|
1425
1356
|
let templateRows = '1fr';
|
|
1426
1357
|
let templateColumns = '1fr';
|
|
1427
1358
|
const gridLayout = {};
|
|
1359
|
+
if (layout === undefined || layout === null || Object.keys(layout).length === 0) {
|
|
1360
|
+
return {
|
|
1361
|
+
templateRows,
|
|
1362
|
+
templateColumns,
|
|
1363
|
+
layout: gridLayout
|
|
1364
|
+
};
|
|
1365
|
+
}
|
|
1366
|
+
if (!layout.xaxis || !layout.yaxis) {
|
|
1367
|
+
return {
|
|
1368
|
+
templateRows,
|
|
1369
|
+
templateColumns,
|
|
1370
|
+
layout: gridLayout
|
|
1371
|
+
};
|
|
1372
|
+
}
|
|
1428
1373
|
if (!isMultiPlot) {
|
|
1429
1374
|
return {
|
|
1430
1375
|
templateRows,
|
|
@@ -1432,182 +1377,143 @@ export const getGridProperties = (schema, isMultiPlot, validTracesInfo)=>{
|
|
|
1432
1377
|
layout: gridLayout
|
|
1433
1378
|
};
|
|
1434
1379
|
}
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
var
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
if (index === 1 && anchorIndex === 0 || ((_layout_yaxis2 = layout.yaxis2) === null || _layout_yaxis2 === void 0 ? void 0 : _layout_yaxis2.side) === 'right') {
|
|
1462
|
-
// Special case for secondary y axis where yaxis2 can anchor to x1
|
|
1463
|
-
return {
|
|
1464
|
-
templateRows,
|
|
1465
|
-
templateColumns
|
|
1466
|
-
};
|
|
1467
|
-
}
|
|
1468
|
-
throw new Error(`Invalid layout: yaxis ${index + 1} anchor should be x${anchorIndex + 1}`);
|
|
1380
|
+
Object.keys(layout).forEach((key)=>{
|
|
1381
|
+
if (key.startsWith('xaxis')) {
|
|
1382
|
+
var _layout_key, _layout_key1;
|
|
1383
|
+
const index = getIndexFromKey(key, 'xaxis');
|
|
1384
|
+
var _layout_key_anchor;
|
|
1385
|
+
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';
|
|
1386
|
+
const anchorIndex = getIndexFromKey(anchor, 'y');
|
|
1387
|
+
if (index !== anchorIndex) {
|
|
1388
|
+
throw new Error(`Invalid layout: xaxis ${index + 1} anchor should be y${anchorIndex + 1}`);
|
|
1389
|
+
}
|
|
1390
|
+
var _layout_key_domain;
|
|
1391
|
+
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 : [];
|
|
1392
|
+
} else if (key.startsWith('yaxis')) {
|
|
1393
|
+
var _layout_key2, _layout_key3;
|
|
1394
|
+
const index = getIndexFromKey(key, 'yaxis');
|
|
1395
|
+
var _layout_key_anchor1;
|
|
1396
|
+
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';
|
|
1397
|
+
const anchorIndex = getIndexFromKey(anchor, 'x');
|
|
1398
|
+
if (index !== anchorIndex) {
|
|
1399
|
+
var _layout_yaxis2;
|
|
1400
|
+
if (index === 1 && anchorIndex === 0 || ((_layout_yaxis2 = layout.yaxis2) === null || _layout_yaxis2 === void 0 ? void 0 : _layout_yaxis2.side) === 'right') {
|
|
1401
|
+
// Special case for secondary y axis where yaxis2 can anchor to x1
|
|
1402
|
+
return {
|
|
1403
|
+
templateRows,
|
|
1404
|
+
templateColumns
|
|
1405
|
+
};
|
|
1469
1406
|
}
|
|
1470
|
-
|
|
1471
|
-
const domainYInfo = {
|
|
1472
|
-
start: (yAxisLayout === null || yAxisLayout === void 0 ? void 0 : yAxisLayout.domain) ? yAxisLayout.domain[0] : 0,
|
|
1473
|
-
end: (yAxisLayout === null || yAxisLayout === void 0 ? void 0 : yAxisLayout.domain) ? yAxisLayout.domain[1] : 1
|
|
1474
|
-
};
|
|
1475
|
-
domainY.push(domainYInfo);
|
|
1407
|
+
throw new Error(`Invalid layout: yaxis ${index + 1} anchor should be x${anchorIndex + 1}`);
|
|
1476
1408
|
}
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
cartesianDomains = domainX.length; // Assuming that the number of x and y axes is the same
|
|
1480
|
-
validTracesInfo.forEach((trace, index)=>{
|
|
1481
|
-
if (isNonPlotType(trace.type)) {
|
|
1482
|
-
var _schema_data, _series_domain, _series_domain1, _series_domain2, _series_domain3;
|
|
1483
|
-
const series = schema === null || schema === void 0 ? void 0 : (_schema_data = schema.data) === null || _schema_data === void 0 ? void 0 : _schema_data[index];
|
|
1484
|
-
const domainXInfo = {
|
|
1485
|
-
start: ((_series_domain = series.domain) === null || _series_domain === void 0 ? void 0 : _series_domain.x) ? series.domain.x[0] : 0,
|
|
1486
|
-
end: ((_series_domain1 = series.domain) === null || _series_domain1 === void 0 ? void 0 : _series_domain1.x) ? series.domain.x[1] : 1
|
|
1487
|
-
};
|
|
1488
|
-
const domainYInfo = {
|
|
1489
|
-
start: ((_series_domain2 = series.domain) === null || _series_domain2 === void 0 ? void 0 : _series_domain2.y) ? series.domain.y[0] : 0,
|
|
1490
|
-
end: ((_series_domain3 = series.domain) === null || _series_domain3 === void 0 ? void 0 : _series_domain3.y) ? series.domain.y[1] : 1
|
|
1491
|
-
};
|
|
1492
|
-
domainX.push(domainXInfo);
|
|
1493
|
-
domainY.push(domainYInfo);
|
|
1409
|
+
var _layout_key_domain1;
|
|
1410
|
+
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 : [];
|
|
1494
1411
|
}
|
|
1495
1412
|
});
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
if (annotations[yMatch] === undefined) {
|
|
1505
|
-
annotations[yMatch] = {};
|
|
1506
|
-
}
|
|
1507
|
-
if ((annotation === null || annotation === void 0 ? void 0 : annotation.textangle) === 90) {
|
|
1508
|
-
annotations[yMatch].yAnnotation = annotation.text;
|
|
1509
|
-
} else {
|
|
1510
|
-
annotations[yMatch].xAnnotation = annotation.text;
|
|
1511
|
-
}
|
|
1413
|
+
(_layout_annotations = layout.annotations) === null || _layout_annotations === void 0 ? void 0 : _layout_annotations.forEach((annotation)=>{
|
|
1414
|
+
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] ? [
|
|
1415
|
+
idx
|
|
1416
|
+
] : []);
|
|
1417
|
+
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]);
|
|
1418
|
+
if (yMatch !== -1) {
|
|
1419
|
+
if (annotations[yMatch] === undefined) {
|
|
1420
|
+
annotations[yMatch] = {};
|
|
1512
1421
|
}
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1422
|
+
if ((annotation === null || annotation === void 0 ? void 0 : annotation.textangle) === 90) {
|
|
1423
|
+
annotations[yMatch].yAnnotation = annotation.text;
|
|
1424
|
+
} else {
|
|
1425
|
+
annotations[yMatch].xAnnotation = annotation.text;
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
});
|
|
1429
|
+
if (gridX.length > 0) {
|
|
1516
1430
|
const uniqueXIntervals = new Map();
|
|
1517
|
-
|
|
1518
|
-
const key = `${interval
|
|
1431
|
+
gridX.forEach((interval)=>{
|
|
1432
|
+
const key = `${interval[0]}-${interval[1]}`;
|
|
1519
1433
|
if (!uniqueXIntervals.has(key)) {
|
|
1520
1434
|
uniqueXIntervals.set(key, interval);
|
|
1521
1435
|
}
|
|
1522
1436
|
});
|
|
1523
|
-
const
|
|
1524
|
-
templateColumns =
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1437
|
+
const minXInterval = Math.min(...Array.from(uniqueXIntervals.values()).map((interval)=>interval[1] - interval[0]));
|
|
1438
|
+
templateColumns = Array.from(uniqueXIntervals.values()).map((interval)=>`${(interval[1] - interval[0]) / minXInterval}fr`).join(' ');
|
|
1439
|
+
let columnNumber = 1;
|
|
1440
|
+
let lastIntervalEnd = 0;
|
|
1441
|
+
gridX.forEach((interval, index)=>{
|
|
1442
|
+
if (interval.length === 0) {
|
|
1443
|
+
return;
|
|
1444
|
+
}
|
|
1445
|
+
const cellName = `x${index === 0 ? '' : index + 1}`;
|
|
1529
1446
|
const annotationProps = annotations[index];
|
|
1530
1447
|
const xAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.xAnnotation;
|
|
1448
|
+
if (interval[0] < lastIntervalEnd) {
|
|
1449
|
+
columnNumber = 1;
|
|
1450
|
+
}
|
|
1451
|
+
lastIntervalEnd = interval[1];
|
|
1531
1452
|
const row = {
|
|
1532
1453
|
row: -1,
|
|
1533
1454
|
column: columnNumber,
|
|
1534
|
-
xAnnotation
|
|
1535
|
-
xDomain: interval,
|
|
1536
|
-
yDomain: {
|
|
1537
|
-
start: 0,
|
|
1538
|
-
end: 1
|
|
1539
|
-
}
|
|
1455
|
+
xAnnotation
|
|
1540
1456
|
};
|
|
1541
1457
|
gridLayout[cellName] = row;
|
|
1458
|
+
columnNumber += 1;
|
|
1542
1459
|
});
|
|
1543
1460
|
}
|
|
1544
|
-
|
|
1461
|
+
const numColumns = Math.max(...Object.values(gridLayout).map((cell)=>{
|
|
1462
|
+
var _cell_column;
|
|
1463
|
+
return (_cell_column = cell.column) !== null && _cell_column !== void 0 ? _cell_column : 0;
|
|
1464
|
+
}));
|
|
1465
|
+
const columnFill = {};
|
|
1466
|
+
for(let i = 1; i <= numColumns; i++){
|
|
1467
|
+
columnFill[i] = {
|
|
1468
|
+
row: 1,
|
|
1469
|
+
fillDomain: 0
|
|
1470
|
+
};
|
|
1471
|
+
}
|
|
1472
|
+
if (gridY.length > 0) {
|
|
1545
1473
|
const uniqueYIntervals = new Map();
|
|
1546
|
-
|
|
1547
|
-
const key = `${interval
|
|
1474
|
+
gridY.forEach((interval)=>{
|
|
1475
|
+
const key = `${interval[0]}-${interval[1]}`;
|
|
1548
1476
|
if (!uniqueYIntervals.has(key)) {
|
|
1549
1477
|
uniqueYIntervals.set(key, interval);
|
|
1550
1478
|
}
|
|
1551
1479
|
});
|
|
1552
|
-
const
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
const
|
|
1480
|
+
const minYInterval = Math.min(...Array.from(uniqueYIntervals.values()).map((interval)=>interval[1] - interval[0]));
|
|
1481
|
+
templateRows = Array.from(uniqueYIntervals.values()).map((interval)=>`${(interval[1] - interval[0]) / minYInterval}fr`).join(' ');
|
|
1482
|
+
gridY.forEach((interval, index)=>{
|
|
1483
|
+
if (interval.length === 0) {
|
|
1484
|
+
return;
|
|
1485
|
+
}
|
|
1486
|
+
const cellName = `x${index === 0 ? '' : index + 1}`;
|
|
1559
1487
|
const annotationProps = annotations[index];
|
|
1560
1488
|
const yAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.yAnnotation;
|
|
1561
1489
|
const cell = gridLayout[cellName];
|
|
1562
1490
|
if (cell !== undefined) {
|
|
1563
|
-
cell.row =
|
|
1491
|
+
cell.row = columnFill[cell.column].row;
|
|
1564
1492
|
cell.yAnnotation = yAnnotation;
|
|
1565
|
-
cell.yDomain = interval;
|
|
1566
1493
|
}
|
|
1494
|
+
columnFill[cell.column].fillDomain = interval[1];
|
|
1495
|
+
columnFill[cell.column].row += 1;
|
|
1567
1496
|
});
|
|
1568
1497
|
}
|
|
1498
|
+
// reverse the order of rows in grid layout from bottom-top to top-bottom as required by CSS grid
|
|
1499
|
+
const reversedGridLayout = {};
|
|
1500
|
+
// find the maximum row number
|
|
1501
|
+
const maxRowNumber = Math.max(...Object.values(gridLayout).map((cell)=>{
|
|
1502
|
+
var _cell_row;
|
|
1503
|
+
return (_cell_row = cell.row) !== null && _cell_row !== void 0 ? _cell_row : 0;
|
|
1504
|
+
}));
|
|
1505
|
+
// iterate over the gridLayout and reverse the row numbers
|
|
1506
|
+
Object.keys(gridLayout).forEach((key)=>{
|
|
1507
|
+
const cell = gridLayout[key];
|
|
1508
|
+
if (cell.row !== undefined) {
|
|
1509
|
+
// reverse the row number
|
|
1510
|
+
cell.row = maxRowNumber - cell.row + 1;
|
|
1511
|
+
}
|
|
1512
|
+
reversedGridLayout[key] = cell;
|
|
1513
|
+
});
|
|
1569
1514
|
return {
|
|
1570
1515
|
templateRows,
|
|
1571
1516
|
templateColumns,
|
|
1572
|
-
layout:
|
|
1573
|
-
};
|
|
1574
|
-
};
|
|
1575
|
-
/**
|
|
1576
|
-
* @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/category_order_defaults.js#L50}
|
|
1577
|
-
*/ const getAxisCategoryOrderProps = (data, layout)=>{
|
|
1578
|
-
const result = {};
|
|
1579
|
-
const axesById = {
|
|
1580
|
-
x: layout === null || layout === void 0 ? void 0 : layout.xaxis,
|
|
1581
|
-
y: layout === null || layout === void 0 ? void 0 : layout.yaxis
|
|
1517
|
+
layout: reversedGridLayout
|
|
1582
1518
|
};
|
|
1583
|
-
Object.keys(axesById).forEach((axId)=>{
|
|
1584
|
-
const ax = axesById[axId];
|
|
1585
|
-
const axLetter = axId[0];
|
|
1586
|
-
const propName = `${axLetter}AxisCategoryOrder`;
|
|
1587
|
-
const values = [];
|
|
1588
|
-
data.forEach((series)=>{
|
|
1589
|
-
var _series_axLetter;
|
|
1590
|
-
(_series_axLetter = series[axLetter]) === null || _series_axLetter === void 0 ? void 0 : _series_axLetter.forEach((val)=>{
|
|
1591
|
-
if (!isInvalidValue(val)) {
|
|
1592
|
-
values.push(val);
|
|
1593
|
-
}
|
|
1594
|
-
});
|
|
1595
|
-
});
|
|
1596
|
-
const isAxisTypeCategory = (ax === null || ax === void 0 ? void 0 : ax.type) === 'category' || isStringArray(values) && !isNumberArray(values) && !isDateArray(values);
|
|
1597
|
-
if (!isAxisTypeCategory) {
|
|
1598
|
-
return;
|
|
1599
|
-
}
|
|
1600
|
-
const isValidArray = isArrayOrTypedArray(ax === null || ax === void 0 ? void 0 : ax.categoryarray) && ax.categoryarray.length > 0;
|
|
1601
|
-
if (isValidArray && (!(ax === null || ax === void 0 ? void 0 : ax.categoryorder) || ax.categoryorder === 'array')) {
|
|
1602
|
-
result[propName] = ax.categoryarray;
|
|
1603
|
-
return;
|
|
1604
|
-
}
|
|
1605
|
-
if (!(ax === null || ax === void 0 ? void 0 : ax.categoryorder) || ax.categoryorder === 'trace' || ax.categoryorder === 'array') {
|
|
1606
|
-
const categoriesInTraceOrder = Array.from(new Set(values));
|
|
1607
|
-
result[propName] = categoriesInTraceOrder;
|
|
1608
|
-
return;
|
|
1609
|
-
}
|
|
1610
|
-
result[propName] = ax.categoryorder;
|
|
1611
|
-
});
|
|
1612
|
-
return result;
|
|
1613
1519
|
};
|