@fluentui/react-charts 0.0.0-nightly-20250821-0406.1 → 0.0.0-nightly-20250825-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 +48 -15
- package/dist/index.d.ts +5 -1
- package/lib/components/CommonComponents/CartesianChart.js +8 -7
- package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +32 -16
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +239 -191
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.js +6 -1
- 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 +21 -4
- package/lib/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
- package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js +16 -3
- package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.js +8 -7
- package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +31 -15
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +247 -190
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.js +6 -1
- package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -1
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js +32 -4
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js +16 -3
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
- package/package.json +12 -12
|
@@ -4,10 +4,12 @@ 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 } from '@fluentui/chart-utilities';
|
|
7
|
+
import { isArrayOrTypedArray, isDate, isDateArray, isNumberArray, isStringArray, isYearArray, isInvalidValue, formatToLocaleString } 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)';
|
|
11
13
|
const dashOptions = {
|
|
12
14
|
dot: {
|
|
13
15
|
strokeDasharray: '1, 5',
|
|
@@ -56,6 +58,47 @@ function getTitles(layout) {
|
|
|
56
58
|
};
|
|
57
59
|
return titles;
|
|
58
60
|
}
|
|
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
|
+
};
|
|
59
102
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
103
|
export const correctYearMonth = (xValues)=>{
|
|
61
104
|
const presentYear = new Date().getFullYear();
|
|
@@ -200,7 +243,7 @@ export const transformPlotlyJsonToDonutProps = (input, isMultiPlot, colorMap, co
|
|
|
200
243
|
chartTitle,
|
|
201
244
|
chartData: Object.values(mapLegendToDataPoint)
|
|
202
245
|
},
|
|
203
|
-
hideLegend: ((_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : _input_layout5.showlegend) === false
|
|
246
|
+
hideLegend: isMultiPlot || ((_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : _input_layout5.showlegend) === false,
|
|
204
247
|
width: (_input_layout6 = input.layout) === null || _input_layout6 === void 0 ? void 0 : _input_layout6.width,
|
|
205
248
|
height,
|
|
206
249
|
innerRadius,
|
|
@@ -219,6 +262,7 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
|
|
|
219
262
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
|
|
220
263
|
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
221
264
|
let colorScale = undefined;
|
|
265
|
+
const yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
222
266
|
let yMinValue = 0;
|
|
223
267
|
input.data.forEach((series, index1)=>{
|
|
224
268
|
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;
|
|
@@ -252,6 +296,7 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
|
|
|
252
296
|
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
297
|
const opacity = getOpacity(series, index2);
|
|
254
298
|
const yVal = rangeYValues[index2];
|
|
299
|
+
const yAxisCalloutData = getFormattedCalloutYData(yVal, yAxisTickFormat);
|
|
255
300
|
if (series.type === 'bar') {
|
|
256
301
|
var _rgb_copy_formatHex8;
|
|
257
302
|
mapXToDataPoints[x].chartData.push({
|
|
@@ -259,7 +304,8 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
|
|
|
259
304
|
data: yVal,
|
|
260
305
|
color: (_rgb_copy_formatHex8 = rgb(color).copy({
|
|
261
306
|
opacity
|
|
262
|
-
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
|
|
307
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
|
|
308
|
+
yAxisCalloutData
|
|
263
309
|
});
|
|
264
310
|
if (typeof yVal === 'number') {
|
|
265
311
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
@@ -281,7 +327,8 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
|
|
|
281
327
|
...lineOptions !== null && lineOptions !== void 0 ? lineOptions : {},
|
|
282
328
|
mode: series.mode
|
|
283
329
|
},
|
|
284
|
-
useSecondaryYScale: usesSecondaryYScale(series, input.layout)
|
|
330
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout),
|
|
331
|
+
yAxisCalloutData
|
|
285
332
|
});
|
|
286
333
|
if (!usesSecondaryYScale(series, input.layout) && typeof yVal === 'number') {
|
|
287
334
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
@@ -292,7 +339,6 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
|
|
|
292
339
|
});
|
|
293
340
|
});
|
|
294
341
|
});
|
|
295
|
-
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
296
342
|
const vsbcData = Object.values(mapXToDataPoints);
|
|
297
343
|
var _input_layout_height;
|
|
298
344
|
return {
|
|
@@ -302,9 +348,6 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
|
|
|
302
348
|
barWidth: 'auto',
|
|
303
349
|
yMaxValue,
|
|
304
350
|
yMinValue,
|
|
305
|
-
chartTitle,
|
|
306
|
-
xAxisTitle,
|
|
307
|
-
yAxisTitle,
|
|
308
351
|
mode: 'plotly',
|
|
309
352
|
...secondaryYAxisValues,
|
|
310
353
|
wrapXAxisLables: typeof ((_vsbcData_ = vsbcData[0]) === null || _vsbcData_ === void 0 ? void 0 : _vsbcData_.xAxisPoint) === 'string',
|
|
@@ -315,6 +358,9 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
|
|
|
315
358
|
showYAxisLables: true,
|
|
316
359
|
noOfCharsToTruncate: 20,
|
|
317
360
|
showYAxisLablesTooltip: true,
|
|
361
|
+
...getTitles(input.layout),
|
|
362
|
+
...getXAxisTickFormat(input.data[0], input.layout),
|
|
363
|
+
...yAxisTickFormat,
|
|
318
364
|
...getAxisCategoryOrderProps(input.data, input.layout)
|
|
319
365
|
};
|
|
320
366
|
};
|
|
@@ -338,6 +384,7 @@ export const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, col
|
|
|
338
384
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, 0, 0);
|
|
339
385
|
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
340
386
|
let colorScale = undefined;
|
|
387
|
+
const yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
341
388
|
input.data.forEach((series, index1)=>{
|
|
342
389
|
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;
|
|
343
390
|
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') {
|
|
@@ -362,21 +409,22 @@ export const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, col
|
|
|
362
409
|
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
363
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, index2, legend, colorMap, isDarkTheme);
|
|
364
411
|
const opacity = getOpacity(series, index2);
|
|
412
|
+
const yVal = series.y[index2];
|
|
365
413
|
var _rgb_copy_formatHex8;
|
|
366
414
|
mapXToDataPoints[x].series.push({
|
|
367
415
|
key: legend,
|
|
368
|
-
data:
|
|
416
|
+
data: yVal,
|
|
369
417
|
xAxisCalloutData: x,
|
|
370
418
|
color: (_rgb_copy_formatHex8 = rgb(color).copy({
|
|
371
419
|
opacity
|
|
372
420
|
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
|
|
373
421
|
legend,
|
|
374
|
-
useSecondaryYScale: usesSecondaryYScale(series, input.layout)
|
|
422
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout),
|
|
423
|
+
yAxisCalloutData: getFormattedCalloutYData(yVal, yAxisTickFormat)
|
|
375
424
|
});
|
|
376
425
|
}
|
|
377
426
|
});
|
|
378
427
|
});
|
|
379
|
-
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
380
428
|
const gvbcData = Object.values(mapXToDataPoints);
|
|
381
429
|
var _input_layout_height;
|
|
382
430
|
return {
|
|
@@ -384,15 +432,16 @@ export const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, col
|
|
|
384
432
|
width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
|
|
385
433
|
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,
|
|
386
434
|
barWidth: 'auto',
|
|
387
|
-
chartTitle,
|
|
388
|
-
xAxisTitle,
|
|
389
|
-
yAxisTitle,
|
|
390
435
|
mode: 'plotly',
|
|
391
436
|
...secondaryYAxisValues,
|
|
392
437
|
hideTickOverlap: true,
|
|
393
438
|
wrapXAxisLables: typeof ((_gvbcData_ = gvbcData[0]) === null || _gvbcData_ === void 0 ? void 0 : _gvbcData_.name) === 'string',
|
|
394
439
|
hideLegend,
|
|
395
440
|
roundCorners: true,
|
|
441
|
+
...getTitles(input.layout),
|
|
442
|
+
...getYMinMaxValues(input.data[0], input.layout),
|
|
443
|
+
...getXAxisTickFormat(input.data[0], input.layout),
|
|
444
|
+
...yAxisTickFormat,
|
|
396
445
|
...getAxisCategoryOrderProps(input.data, input.layout)
|
|
397
446
|
};
|
|
398
447
|
};
|
|
@@ -459,21 +508,19 @@ export const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colo
|
|
|
459
508
|
});
|
|
460
509
|
});
|
|
461
510
|
});
|
|
462
|
-
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
463
511
|
var _input_layout_height;
|
|
464
512
|
return {
|
|
465
513
|
data: vbcData,
|
|
466
514
|
width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
|
|
467
515
|
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,
|
|
468
|
-
chartTitle,
|
|
469
|
-
xAxisTitle,
|
|
470
|
-
yAxisTitle,
|
|
471
516
|
mode: 'histogram',
|
|
472
517
|
hideTickOverlap: true,
|
|
473
518
|
wrapXAxisLables: typeof ((_vbcData_ = vbcData[0]) === null || _vbcData_ === void 0 ? void 0 : _vbcData_.x) === 'string',
|
|
474
519
|
maxBarWidth: 50,
|
|
475
520
|
hideLegend,
|
|
476
521
|
roundCorners: true,
|
|
522
|
+
...getTitles(input.layout),
|
|
523
|
+
...getYMinMaxValues(input.data[0], input.layout),
|
|
477
524
|
...getAxisCategoryOrderProps(input.data, input.layout)
|
|
478
525
|
};
|
|
479
526
|
};
|
|
@@ -487,7 +534,7 @@ export const transformPlotlyJsonToScatterChartProps = (input, isMultiPlot, color
|
|
|
487
534
|
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'scatter', colorMap, colorwayType, isDarkTheme);
|
|
488
535
|
};
|
|
489
536
|
const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme)=>{
|
|
490
|
-
var _input_data_;
|
|
537
|
+
var _input_data_, _input_layout, _input_layout1;
|
|
491
538
|
const isScatterMarkers = [
|
|
492
539
|
'markers',
|
|
493
540
|
'text+markers',
|
|
@@ -501,6 +548,7 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
|
|
|
501
548
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
|
|
502
549
|
let mode = 'tonexty';
|
|
503
550
|
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
551
|
+
const yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
504
552
|
const chartData = input.data.map((series, index)=>{
|
|
505
553
|
var _series_mode, _series_line, _series_marker, _series_line1, _input_layout_template_layout, _input_layout_template, _input_layout, _series_mode1;
|
|
506
554
|
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;
|
|
@@ -541,7 +589,8 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
|
|
|
541
589
|
} : {},
|
|
542
590
|
...textValues ? {
|
|
543
591
|
text: textValues[i]
|
|
544
|
-
} : {}
|
|
592
|
+
} : {},
|
|
593
|
+
yAxisCalloutData: getFormattedCalloutYData(rangeYValues[i], yAxisTickFormat)
|
|
545
594
|
};
|
|
546
595
|
}),
|
|
547
596
|
color: (_rgb_copy_formatHex8 = rgb(seriesColor).copy({
|
|
@@ -555,52 +604,45 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
|
|
|
555
604
|
};
|
|
556
605
|
});
|
|
557
606
|
}).flat();
|
|
558
|
-
const
|
|
559
|
-
|
|
607
|
+
const yMinMax = getYMinMaxValues(input.data[0], input.layout);
|
|
608
|
+
if (yMinMax.yMinValue === undefined && yMinMax.yMaxValue === undefined) {
|
|
609
|
+
const yMinMaxValues = findNumericMinMaxOfY(chartData);
|
|
610
|
+
yMinMax.yMinValue = yMinMaxValues.startValue;
|
|
611
|
+
yMinMax.yMaxValue = yMinMaxValues.endValue;
|
|
612
|
+
}
|
|
560
613
|
const numDataPoints = chartData.reduce((total, lineChartPoints)=>total + lineChartPoints.data.length, 0);
|
|
561
614
|
const chartProps = {
|
|
562
|
-
chartTitle,
|
|
563
615
|
lineChartData: chartData
|
|
564
616
|
};
|
|
565
617
|
const scatterChartProps = {
|
|
566
|
-
chartTitle,
|
|
567
618
|
scatterChartData: chartData
|
|
568
619
|
};
|
|
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
|
+
};
|
|
569
634
|
if (isAreaChart) {
|
|
570
|
-
var _input_layout, _input_layout1;
|
|
571
|
-
var _input_layout_height;
|
|
572
635
|
return {
|
|
573
636
|
data: chartProps,
|
|
574
|
-
supportNegativeData: true,
|
|
575
|
-
xAxisTitle,
|
|
576
|
-
yAxisTitle,
|
|
577
|
-
...secondaryYAxisValues,
|
|
578
637
|
mode,
|
|
579
|
-
|
|
580
|
-
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,
|
|
581
|
-
hideTickOverlap: true,
|
|
582
|
-
useUTC: false,
|
|
583
|
-
hideLegend,
|
|
584
|
-
optimizeLargeData: numDataPoints > 1000
|
|
638
|
+
...commonProps
|
|
585
639
|
};
|
|
586
640
|
} else {
|
|
587
|
-
var _input_layout2, _input_layout3;
|
|
588
|
-
var _input_layout_height1;
|
|
589
641
|
return {
|
|
590
642
|
data: isScatterChart ? scatterChartProps : chartProps,
|
|
591
|
-
supportNegativeData: true,
|
|
592
|
-
xAxisTitle,
|
|
593
|
-
yAxisTitle,
|
|
594
|
-
...secondaryYAxisValues,
|
|
595
643
|
roundedTicks: true,
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
width: (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.width,
|
|
599
|
-
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,
|
|
600
|
-
hideTickOverlap: true,
|
|
601
|
-
useUTC: false,
|
|
602
|
-
hideLegend,
|
|
603
|
-
optimizeLargeData: numDataPoints > 1000
|
|
644
|
+
...commonProps,
|
|
645
|
+
...yMinMax
|
|
604
646
|
};
|
|
605
647
|
}
|
|
606
648
|
};
|
|
@@ -646,12 +688,8 @@ export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPl
|
|
|
646
688
|
const scalingFactor = 0.01;
|
|
647
689
|
const gapFactor = 1 / (1 + scalingFactor * numberOfRows);
|
|
648
690
|
const barHeight = availableHeight / (numberOfRows * (1 + gapFactor));
|
|
649
|
-
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
650
691
|
return {
|
|
651
692
|
data: chartData,
|
|
652
|
-
chartTitle,
|
|
653
|
-
xAxisTitle,
|
|
654
|
-
yAxisTitle,
|
|
655
693
|
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) || '',
|
|
656
694
|
barHeight,
|
|
657
695
|
showYAxisLables: true,
|
|
@@ -662,6 +700,7 @@ export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPl
|
|
|
662
700
|
showYAxisLablesTooltip: true,
|
|
663
701
|
hideLegend,
|
|
664
702
|
roundCorners: true,
|
|
703
|
+
...getTitles(input.layout),
|
|
665
704
|
...getAxisCategoryOrderProps(input.data, input.layout)
|
|
666
705
|
};
|
|
667
706
|
};
|
|
@@ -776,7 +815,6 @@ export const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap,
|
|
|
776
815
|
}
|
|
777
816
|
const domainValuesForColorScale = Array.isArray(colorscale) ? colorscale.map((arr)=>arr[0] * (zMax - zMin) + zMin) : defaultDomain;
|
|
778
817
|
const rangeValuesForColorScale = Array.isArray(colorscale) ? colorscale.map((arr)=>arr[1]) : defaultRange;
|
|
779
|
-
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
780
818
|
var _input_layout_height;
|
|
781
819
|
return {
|
|
782
820
|
data: [
|
|
@@ -786,9 +824,6 @@ export const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap,
|
|
|
786
824
|
rangeValuesForColorScale,
|
|
787
825
|
hideLegend: true,
|
|
788
826
|
showYAxisLables: true,
|
|
789
|
-
chartTitle,
|
|
790
|
-
xAxisTitle,
|
|
791
|
-
yAxisTitle,
|
|
792
827
|
sortOrder: 'none',
|
|
793
828
|
width: (_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : _input_layout5.width,
|
|
794
829
|
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,
|
|
@@ -796,6 +831,7 @@ export const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap,
|
|
|
796
831
|
noOfCharsToTruncate: 20,
|
|
797
832
|
showYAxisLablesTooltip: true,
|
|
798
833
|
wrapXAxisLables: true,
|
|
834
|
+
...getTitles(input.layout),
|
|
799
835
|
...getAxisCategoryOrderProps([
|
|
800
836
|
firstData
|
|
801
837
|
], input.layout)
|
|
@@ -1271,25 +1307,44 @@ const getLegendShape = (series)=>{
|
|
|
1271
1307
|
}
|
|
1272
1308
|
return 'default';
|
|
1273
1309
|
};
|
|
1274
|
-
export const getAllupLegendsProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
1310
|
+
export const getAllupLegendsProps = (input, colorMap, colorwayType, traceInfo, isDarkTheme)=>{
|
|
1275
1311
|
const allupLegends = [];
|
|
1276
1312
|
// reduce on showlegend boolean propperty. reduce should return true if at least one series has showlegend true
|
|
1277
1313
|
const toShowLegend = input.data.reduce((acc, series)=>{
|
|
1278
|
-
return acc || series.showlegend === true;
|
|
1314
|
+
return acc || series.showlegend === true || series.showlegend === undefined;
|
|
1279
1315
|
}, false);
|
|
1280
1316
|
if (toShowLegend) {
|
|
1281
1317
|
input.data.forEach((series, index)=>{
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
color
|
|
1291
|
-
|
|
1318
|
+
if (traceInfo[index].type === 'donut') {
|
|
1319
|
+
var _input_layout, _input_layout_template_layout, _input_layout_template, _input_layout1, _input_layout2, _pieSeries_marker, _pieSeries_labels;
|
|
1320
|
+
const pieSeries = series;
|
|
1321
|
+
var _input_layout_piecolorway, _input_layout_piecolorway1;
|
|
1322
|
+
const colors = extractColor((_input_layout_piecolorway = (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.piecolorway) !== null && _input_layout_piecolorway !== void 0 ? _input_layout_piecolorway : (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_template = _input_layout1.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, (_input_layout_piecolorway1 = (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.piecolorway) !== null && _input_layout_piecolorway1 !== void 0 ? _input_layout_piecolorway1 : pieSeries === null || pieSeries === void 0 ? void 0 : (_pieSeries_marker = pieSeries.marker) === null || _pieSeries_marker === void 0 ? void 0 : _pieSeries_marker.colors, colorMap, isDarkTheme);
|
|
1323
|
+
(_pieSeries_labels = pieSeries.labels) === null || _pieSeries_labels === void 0 ? void 0 : _pieSeries_labels.forEach((label, labelIndex)=>{
|
|
1324
|
+
const legend = `${label}`;
|
|
1325
|
+
// resolve color for each legend from the extracted colors
|
|
1326
|
+
const color = resolveColor(colors, labelIndex, legend, colorMap, isDarkTheme);
|
|
1327
|
+
if (legend !== '' && allupLegends.some((group)=>group.title === legend) === false) {
|
|
1328
|
+
allupLegends.push({
|
|
1329
|
+
title: legend,
|
|
1330
|
+
color
|
|
1331
|
+
});
|
|
1332
|
+
}
|
|
1292
1333
|
});
|
|
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
|
+
}
|
|
1293
1348
|
}
|
|
1294
1349
|
});
|
|
1295
1350
|
}
|
|
@@ -1355,28 +1410,21 @@ const getIndexFromKey = (key, pattern)=>{
|
|
|
1355
1410
|
const normalizedKey = key.replace(pattern, '') === '' ? '1' : key.replace(pattern, '');
|
|
1356
1411
|
return parseInt(normalizedKey, 10) - 1;
|
|
1357
1412
|
};
|
|
1358
|
-
export const
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1413
|
+
export const isNonPlotType = (chartType)=>{
|
|
1414
|
+
return [
|
|
1415
|
+
'donut',
|
|
1416
|
+
'sankey',
|
|
1417
|
+
'pie'
|
|
1418
|
+
].includes(chartType);
|
|
1419
|
+
};
|
|
1420
|
+
export const getGridProperties = (schema, isMultiPlot, validTracesInfo)=>{
|
|
1421
|
+
const domainX = [];
|
|
1422
|
+
const domainY = [];
|
|
1423
|
+
let cartesianDomains = 0;
|
|
1362
1424
|
const annotations = {};
|
|
1363
1425
|
let templateRows = '1fr';
|
|
1364
1426
|
let templateColumns = '1fr';
|
|
1365
1427
|
const gridLayout = {};
|
|
1366
|
-
if (layout === undefined || layout === null || Object.keys(layout).length === 0) {
|
|
1367
|
-
return {
|
|
1368
|
-
templateRows,
|
|
1369
|
-
templateColumns,
|
|
1370
|
-
layout: gridLayout
|
|
1371
|
-
};
|
|
1372
|
-
}
|
|
1373
|
-
if (!layout.xaxis || !layout.yaxis) {
|
|
1374
|
-
return {
|
|
1375
|
-
templateRows,
|
|
1376
|
-
templateColumns,
|
|
1377
|
-
layout: gridLayout
|
|
1378
|
-
};
|
|
1379
|
-
}
|
|
1380
1428
|
if (!isMultiPlot) {
|
|
1381
1429
|
return {
|
|
1382
1430
|
templateRows,
|
|
@@ -1384,144 +1432,144 @@ export const getGridProperties = (layout, isMultiPlot)=>{
|
|
|
1384
1432
|
layout: gridLayout
|
|
1385
1433
|
};
|
|
1386
1434
|
}
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
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 : [];
|
|
1399
|
-
} else if (key.startsWith('yaxis')) {
|
|
1400
|
-
var _layout_key2, _layout_key3;
|
|
1401
|
-
const index = getIndexFromKey(key, 'yaxis');
|
|
1402
|
-
var _layout_key_anchor1;
|
|
1403
|
-
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';
|
|
1404
|
-
const anchorIndex = getIndexFromKey(anchor, 'x');
|
|
1405
|
-
if (index !== anchorIndex) {
|
|
1406
|
-
var _layout_yaxis2;
|
|
1407
|
-
if (index === 1 && anchorIndex === 0 || ((_layout_yaxis2 = layout.yaxis2) === null || _layout_yaxis2 === void 0 ? void 0 : _layout_yaxis2.side) === 'right') {
|
|
1408
|
-
// Special case for secondary y axis where yaxis2 can anchor to x1
|
|
1409
|
-
return {
|
|
1410
|
-
templateRows,
|
|
1411
|
-
templateColumns
|
|
1412
|
-
};
|
|
1435
|
+
const layout = schema === null || schema === void 0 ? void 0 : schema.layout;
|
|
1436
|
+
if (layout !== undefined && layout !== null && Object.keys(layout).length > 0) {
|
|
1437
|
+
Object.keys(layout !== null && layout !== void 0 ? layout : {}).forEach((key)=>{
|
|
1438
|
+
if (key.startsWith('xaxis')) {
|
|
1439
|
+
var _layout_key;
|
|
1440
|
+
const index = getIndexFromKey(key, 'xaxis');
|
|
1441
|
+
var _layout_key_anchor;
|
|
1442
|
+
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';
|
|
1443
|
+
const anchorIndex = getIndexFromKey(anchor, 'y');
|
|
1444
|
+
if (index !== anchorIndex) {
|
|
1445
|
+
throw new Error(`Invalid layout: xaxis ${index + 1} anchor should be y${anchorIndex + 1}`);
|
|
1413
1446
|
}
|
|
1414
|
-
|
|
1447
|
+
const xAxisLayout = layout[key];
|
|
1448
|
+
const domainXInfo = {
|
|
1449
|
+
start: (xAxisLayout === null || xAxisLayout === void 0 ? void 0 : xAxisLayout.domain) ? xAxisLayout.domain[0] : 0,
|
|
1450
|
+
end: (xAxisLayout === null || xAxisLayout === void 0 ? void 0 : xAxisLayout.domain) ? xAxisLayout.domain[1] : 1
|
|
1451
|
+
};
|
|
1452
|
+
domainX.push(domainXInfo);
|
|
1453
|
+
} else if (key.startsWith('yaxis')) {
|
|
1454
|
+
var _layout_key1;
|
|
1455
|
+
const index = getIndexFromKey(key, 'yaxis');
|
|
1456
|
+
var _layout_key_anchor1;
|
|
1457
|
+
const anchor = (_layout_key_anchor1 = (_layout_key1 = layout[key]) === null || _layout_key1 === void 0 ? void 0 : _layout_key1.anchor) !== null && _layout_key_anchor1 !== void 0 ? _layout_key_anchor1 : 'x';
|
|
1458
|
+
const anchorIndex = getIndexFromKey(anchor, 'x');
|
|
1459
|
+
if (index !== anchorIndex) {
|
|
1460
|
+
var _layout_yaxis2;
|
|
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}`);
|
|
1469
|
+
}
|
|
1470
|
+
const yAxisLayout = layout[key];
|
|
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);
|
|
1415
1476
|
}
|
|
1416
|
-
|
|
1417
|
-
|
|
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);
|
|
1418
1494
|
}
|
|
1419
1495
|
});
|
|
1420
|
-
(
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1496
|
+
if (layout !== undefined && layout !== null && Object.keys(layout).length > 0) {
|
|
1497
|
+
var _layout_annotations;
|
|
1498
|
+
(_layout_annotations = layout.annotations) === null || _layout_annotations === void 0 ? void 0 : _layout_annotations.forEach((annotation)=>{
|
|
1499
|
+
const xMatches = domainX.flatMap((interval, idx)=>(annotation === null || annotation === void 0 ? void 0 : annotation.x) >= interval.start && (annotation === null || annotation === void 0 ? void 0 : annotation.x) <= interval.end ? [
|
|
1500
|
+
idx
|
|
1501
|
+
] : []);
|
|
1502
|
+
const yMatch = domainY.findIndex((interval, yIndex)=>xMatches.includes(yIndex) && (annotation === null || annotation === void 0 ? void 0 : annotation.y) >= interval.start && (annotation === null || annotation === void 0 ? void 0 : annotation.y) <= interval.end);
|
|
1503
|
+
if (yMatch !== -1) {
|
|
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
|
+
}
|
|
1433
1512
|
}
|
|
1434
|
-
}
|
|
1435
|
-
}
|
|
1436
|
-
if (
|
|
1513
|
+
});
|
|
1514
|
+
}
|
|
1515
|
+
if (domainX.length > 0) {
|
|
1437
1516
|
const uniqueXIntervals = new Map();
|
|
1438
|
-
|
|
1439
|
-
const key = `${interval
|
|
1517
|
+
domainX.forEach((interval)=>{
|
|
1518
|
+
const key = `${interval.start}-${interval.end}`;
|
|
1440
1519
|
if (!uniqueXIntervals.has(key)) {
|
|
1441
1520
|
uniqueXIntervals.set(key, interval);
|
|
1442
1521
|
}
|
|
1443
1522
|
});
|
|
1444
|
-
const
|
|
1445
|
-
templateColumns =
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
return;
|
|
1451
|
-
}
|
|
1452
|
-
const cellName = `x${index === 0 ? '' : index + 1}`;
|
|
1523
|
+
const sortedXStart = Array.from(uniqueXIntervals.values()).map((interval)=>interval.start).sort();
|
|
1524
|
+
templateColumns = `repeat(${sortedXStart.length}, 1fr)`;
|
|
1525
|
+
domainX.forEach((interval, index)=>{
|
|
1526
|
+
const cellName = index >= cartesianDomains ? `${NON_PLOT_KEY_PREFIX}${index - cartesianDomains + 1}` : `x${index === 0 ? '' : index + 1}`;
|
|
1527
|
+
const columnIndex = sortedXStart.findIndex((start)=>start === interval.start);
|
|
1528
|
+
const columnNumber = columnIndex + 1; // Column numbers are 1-based
|
|
1453
1529
|
const annotationProps = annotations[index];
|
|
1454
1530
|
const xAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.xAnnotation;
|
|
1455
|
-
if (interval[0] < lastIntervalEnd) {
|
|
1456
|
-
columnNumber = 1;
|
|
1457
|
-
}
|
|
1458
|
-
lastIntervalEnd = interval[1];
|
|
1459
1531
|
const row = {
|
|
1460
1532
|
row: -1,
|
|
1461
1533
|
column: columnNumber,
|
|
1462
|
-
xAnnotation
|
|
1534
|
+
xAnnotation,
|
|
1535
|
+
xDomain: interval,
|
|
1536
|
+
yDomain: {
|
|
1537
|
+
start: 0,
|
|
1538
|
+
end: 1
|
|
1539
|
+
}
|
|
1463
1540
|
};
|
|
1464
1541
|
gridLayout[cellName] = row;
|
|
1465
|
-
columnNumber += 1;
|
|
1466
1542
|
});
|
|
1467
1543
|
}
|
|
1468
|
-
|
|
1469
|
-
var _cell_column;
|
|
1470
|
-
return (_cell_column = cell.column) !== null && _cell_column !== void 0 ? _cell_column : 0;
|
|
1471
|
-
}));
|
|
1472
|
-
const columnFill = {};
|
|
1473
|
-
for(let i = 1; i <= numColumns; i++){
|
|
1474
|
-
columnFill[i] = {
|
|
1475
|
-
row: 1,
|
|
1476
|
-
fillDomain: 0
|
|
1477
|
-
};
|
|
1478
|
-
}
|
|
1479
|
-
if (gridY.length > 0) {
|
|
1544
|
+
if (domainY.length > 0) {
|
|
1480
1545
|
const uniqueYIntervals = new Map();
|
|
1481
|
-
|
|
1482
|
-
const key = `${interval
|
|
1546
|
+
domainY.forEach((interval)=>{
|
|
1547
|
+
const key = `${interval.start}-${interval.end}`;
|
|
1483
1548
|
if (!uniqueYIntervals.has(key)) {
|
|
1484
1549
|
uniqueYIntervals.set(key, interval);
|
|
1485
1550
|
}
|
|
1486
1551
|
});
|
|
1487
|
-
const
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
const
|
|
1552
|
+
const sortedYStart = Array.from(uniqueYIntervals.values()).map((interval)=>interval.start).sort();
|
|
1553
|
+
const numberOfRows = sortedYStart.length;
|
|
1554
|
+
templateRows = `repeat(${numberOfRows}, 1fr)`;
|
|
1555
|
+
domainY.forEach((interval, index)=>{
|
|
1556
|
+
const cellName = index >= cartesianDomains ? `${NON_PLOT_KEY_PREFIX}${index - cartesianDomains + 1}` : `x${index === 0 ? '' : index + 1}`;
|
|
1557
|
+
const rowIndex = sortedYStart.findIndex((start)=>start === interval.start);
|
|
1558
|
+
const rowNumber = numberOfRows - rowIndex; // Rows are 1-based and we need to reverse the order for CSS grid
|
|
1494
1559
|
const annotationProps = annotations[index];
|
|
1495
1560
|
const yAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.yAnnotation;
|
|
1496
1561
|
const cell = gridLayout[cellName];
|
|
1497
1562
|
if (cell !== undefined) {
|
|
1498
|
-
cell.row =
|
|
1563
|
+
cell.row = rowNumber;
|
|
1499
1564
|
cell.yAnnotation = yAnnotation;
|
|
1565
|
+
cell.yDomain = interval;
|
|
1500
1566
|
}
|
|
1501
|
-
columnFill[cell.column].fillDomain = interval[1];
|
|
1502
|
-
columnFill[cell.column].row += 1;
|
|
1503
1567
|
});
|
|
1504
1568
|
}
|
|
1505
|
-
// reverse the order of rows in grid layout from bottom-top to top-bottom as required by CSS grid
|
|
1506
|
-
const reversedGridLayout = {};
|
|
1507
|
-
// find the maximum row number
|
|
1508
|
-
const maxRowNumber = Math.max(...Object.values(gridLayout).map((cell)=>{
|
|
1509
|
-
var _cell_row;
|
|
1510
|
-
return (_cell_row = cell.row) !== null && _cell_row !== void 0 ? _cell_row : 0;
|
|
1511
|
-
}));
|
|
1512
|
-
// iterate over the gridLayout and reverse the row numbers
|
|
1513
|
-
Object.keys(gridLayout).forEach((key)=>{
|
|
1514
|
-
const cell = gridLayout[key];
|
|
1515
|
-
if (cell.row !== undefined) {
|
|
1516
|
-
// reverse the row number
|
|
1517
|
-
cell.row = maxRowNumber - cell.row + 1;
|
|
1518
|
-
}
|
|
1519
|
-
reversedGridLayout[key] = cell;
|
|
1520
|
-
});
|
|
1521
1569
|
return {
|
|
1522
1570
|
templateRows,
|
|
1523
1571
|
templateColumns,
|
|
1524
|
-
layout:
|
|
1572
|
+
layout: gridLayout
|
|
1525
1573
|
};
|
|
1526
1574
|
};
|
|
1527
1575
|
/**
|