@fluentui/react-charting 5.24.4 → 5.24.5
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.json +40 -1
- package/CHANGELOG.md +15 -2
- package/config/tests.js +0 -12
- package/dist/react-charting.d.ts +4 -0
- package/dist/react-charting.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/etc/react-charting.api.md +1 -0
- package/lib/components/CommonComponents/CartesianChart.base.js +12 -11
- package/lib/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.styles.js +41 -37
- package/lib/components/CommonComponents/CartesianChart.styles.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +38 -16
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +13 -3
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +215 -139
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.base.js +1 -0
- package/lib/components/DonutChart/DonutChart.base.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.styles.js +18 -0
- package/lib/components/DonutChart/DonutChart.styles.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.types.d.ts +4 -0
- package/lib/components/DonutChart/DonutChart.types.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +3 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.base.js +3 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +3 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
- package/lib/utilities/SVGTooltipText.js +3 -3
- package/lib/utilities/SVGTooltipText.js.map +1 -1
- package/lib-amd/components/CommonComponents/CartesianChart.base.js +12 -11
- package/lib-amd/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-amd/components/CommonComponents/CartesianChart.styles.js +41 -37
- package/lib-amd/components/CommonComponents/CartesianChart.styles.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/DeclarativeChart.js +37 -15
- package/lib-amd/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +13 -3
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +216 -139
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-amd/components/DonutChart/DonutChart.base.js +1 -0
- package/lib-amd/components/DonutChart/DonutChart.base.js.map +1 -1
- package/lib-amd/components/DonutChart/DonutChart.styles.js +17 -1
- package/lib-amd/components/DonutChart/DonutChart.styles.js.map +1 -1
- package/lib-amd/components/DonutChart/DonutChart.types.d.ts +4 -0
- package/lib-amd/components/DonutChart/DonutChart.types.js.map +1 -1
- package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +3 -1
- package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
- package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js +3 -1
- package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +3 -1
- package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
- package/lib-amd/utilities/SVGTooltipText.js +3 -3
- package/lib-amd/utilities/SVGTooltipText.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js +12 -11
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.styles.js +41 -37
- package/lib-commonjs/components/CommonComponents/CartesianChart.styles.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +37 -15
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +13 -3
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +216 -139
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.base.js +1 -0
- package/lib-commonjs/components/DonutChart/DonutChart.base.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.styles.js +18 -0
- package/lib-commonjs/components/DonutChart/DonutChart.styles.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.types.d.ts +4 -0
- package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +3 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js +3 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +3 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
- package/lib-commonjs/utilities/SVGTooltipText.js +3 -3
- package/lib-commonjs/utilities/SVGTooltipText.js.map +1 -1
- package/package.json +2 -2
- package/src/components/DonutChart/DonutChart.types.ts +5 -0
|
@@ -5,10 +5,12 @@ import { format as d3Format } from 'd3-format';
|
|
|
5
5
|
import { DataVizPalette, getColorFromToken } from '../../utilities/colors';
|
|
6
6
|
import { GaugeChartVariant } from '../GaugeChart/index';
|
|
7
7
|
import { findNumericMinMaxOfY, formatScientificLimitWidth, MIN_DONUT_RADIUS } from '../../utilities/utilities';
|
|
8
|
-
import { isArrayOrTypedArray, isDate, isDateArray, isNumberArray, isStringArray, isYearArray, isInvalidValue, } from '@fluentui/chart-utilities';
|
|
8
|
+
import { isArrayOrTypedArray, isDate, isDateArray, isNumberArray, isStringArray, isYearArray, isInvalidValue, formatToLocaleString, } from '@fluentui/chart-utilities';
|
|
9
9
|
import { curveCardinal as d3CurveCardinal } from 'd3-shape';
|
|
10
10
|
import { getOpacity, extractColor, resolveColor } from './PlotlyColorAdapter';
|
|
11
11
|
import { rgb } from 'd3-color';
|
|
12
|
+
export var NON_PLOT_KEY_PREFIX = 'nonplot_';
|
|
13
|
+
export var SINGLE_REPEAT = 'repeat(1, 1fr)';
|
|
12
14
|
var dashOptions = {
|
|
13
15
|
dot: {
|
|
14
16
|
strokeDasharray: '1, 5',
|
|
@@ -56,6 +58,47 @@ function getTitles(layout) {
|
|
|
56
58
|
};
|
|
57
59
|
return titles;
|
|
58
60
|
}
|
|
61
|
+
var getXAxisTickFormat = function (series, layout) {
|
|
62
|
+
var 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
|
+
var getYAxisTickFormat = function (series, layout) {
|
|
71
|
+
var 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
|
+
var getYMinMaxValues = function (series, layout) {
|
|
80
|
+
var _a;
|
|
81
|
+
var range = (_a = getYAxisProperties(series, layout)) === null || _a === void 0 ? void 0 : _a.range;
|
|
82
|
+
if (range && range.length === 2) {
|
|
83
|
+
return {
|
|
84
|
+
yMinValue: range[0],
|
|
85
|
+
yMaxValue: range[1],
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return {};
|
|
89
|
+
};
|
|
90
|
+
var getYAxisProperties = function (series, layout) {
|
|
91
|
+
return layout === null || layout === void 0 ? void 0 : layout.yaxis;
|
|
92
|
+
};
|
|
93
|
+
var getXAxisProperties = function (series, layout) {
|
|
94
|
+
return layout === null || layout === void 0 ? void 0 : layout.xaxis;
|
|
95
|
+
};
|
|
96
|
+
var getFormattedCalloutYData = function (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 var correctYearMonth = function (xValues) {
|
|
61
104
|
var presentYear = new Date().getFullYear();
|
|
@@ -203,7 +246,7 @@ export var transformPlotlyJsonToDonutProps = function (input, isMultiPlot, color
|
|
|
203
246
|
chartTitle: chartTitle,
|
|
204
247
|
chartData: Object.values(mapLegendToDataPoint),
|
|
205
248
|
},
|
|
206
|
-
hideLegend: ((_p = input.layout) === null || _p === void 0 ? void 0 : _p.showlegend) === false
|
|
249
|
+
hideLegend: isMultiPlot || ((_p = input.layout) === null || _p === void 0 ? void 0 : _p.showlegend) === false,
|
|
207
250
|
width: (_q = input.layout) === null || _q === void 0 ? void 0 : _q.width,
|
|
208
251
|
height: height,
|
|
209
252
|
innerRadius: innerRadius,
|
|
@@ -220,6 +263,7 @@ export var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorM
|
|
|
220
263
|
var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
|
|
221
264
|
var _d = getLegendProps(input.data, input.layout, isMultiPlot), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
222
265
|
var colorScale = undefined;
|
|
266
|
+
var yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
223
267
|
input.data.forEach(function (series, index1) {
|
|
224
268
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
225
269
|
if (((_c = (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.coloraxis) === null || _b === void 0 ? void 0 : _b.colorscale) === null || _c === void 0 ? void 0 : _c.length) &&
|
|
@@ -260,11 +304,13 @@ export var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorM
|
|
|
260
304
|
: resolveColor(extractedBarColors, index2, legend, colorMap, isDarkTheme);
|
|
261
305
|
var opacity = getOpacity(series, index2);
|
|
262
306
|
var yVal = rangeYValues[index2];
|
|
307
|
+
var yAxisCalloutData = getFormattedCalloutYData(yVal, yAxisTickFormat);
|
|
263
308
|
if (series.type === 'bar') {
|
|
264
309
|
mapXToDataPoints[x].chartData.push({
|
|
265
310
|
legend: legend,
|
|
266
311
|
data: yVal,
|
|
267
312
|
color: (_e = rgb(color).copy({ opacity: opacity }).formatHex8()) !== null && _e !== void 0 ? _e : color,
|
|
313
|
+
yAxisCalloutData: yAxisCalloutData,
|
|
268
314
|
});
|
|
269
315
|
if (typeof yVal === 'number') {
|
|
270
316
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
@@ -281,6 +327,7 @@ export var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorM
|
|
|
281
327
|
color: (_f = rgb(lineColor).copy({ opacity: opacity }).formatHex8()) !== null && _f !== void 0 ? _f : color,
|
|
282
328
|
lineOptions: __assign(__assign({}, (lineOptions !== null && lineOptions !== void 0 ? lineOptions : {})), { mode: series.mode }),
|
|
283
329
|
useSecondaryYScale: usesSecondaryYScale(series, input.layout),
|
|
330
|
+
yAxisCalloutData: yAxisCalloutData,
|
|
284
331
|
});
|
|
285
332
|
if (!usesSecondaryYScale(series, input.layout) && typeof yVal === 'number') {
|
|
286
333
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
@@ -290,8 +337,7 @@ export var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorM
|
|
|
290
337
|
});
|
|
291
338
|
});
|
|
292
339
|
});
|
|
293
|
-
|
|
294
|
-
return __assign(__assign(__assign({ data: Object.values(mapXToDataPoints), width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, barWidth: 'auto', yMaxValue: yMaxValue, yMinValue: yMinValue, chartTitle: chartTitle, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle, mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true, supportNegativeData: true, barGapMax: 2, showYAxisLables: true, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true }), getAxisCategoryOrderProps(input.data, input.layout));
|
|
340
|
+
return __assign(__assign(__assign(__assign(__assign(__assign({ data: Object.values(mapXToDataPoints), width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, barWidth: 'auto', yMaxValue: yMaxValue, yMinValue: yMinValue, mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true, supportNegativeData: true, barGapMax: 2, showYAxisLables: true, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true }), getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getXAxisTickFormat(input.data[0], input.layout)), yAxisTickFormat);
|
|
295
341
|
};
|
|
296
342
|
var createColorScale = function (layout, series) {
|
|
297
343
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -315,6 +361,7 @@ export var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorM
|
|
|
315
361
|
var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, 0, 0);
|
|
316
362
|
var _d = getLegendProps(input.data, input.layout, isMultiPlot), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
317
363
|
var colorScale = undefined;
|
|
364
|
+
var yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
318
365
|
input.data.forEach(function (series, index1) {
|
|
319
366
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
320
367
|
if (((_c = (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.coloraxis) === null || _b === void 0 ? void 0 : _b.colorscale) === null || _c === void 0 ? void 0 : _c.length) &&
|
|
@@ -342,19 +389,20 @@ export var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorM
|
|
|
342
389
|
: 0)
|
|
343
390
|
: resolveColor(extractedColors, xIndex, legend, colorMap, isDarkTheme);
|
|
344
391
|
var opacity = getOpacity(series, xIndex);
|
|
392
|
+
var yVal = series.y[xIndex];
|
|
345
393
|
mapXToDataPoints[x].series.push({
|
|
346
394
|
key: legend,
|
|
347
|
-
data:
|
|
395
|
+
data: yVal,
|
|
348
396
|
xAxisCalloutData: x,
|
|
349
397
|
color: (_f = rgb(color).copy({ opacity: opacity }).formatHex8()) !== null && _f !== void 0 ? _f : color,
|
|
350
398
|
legend: legend,
|
|
351
399
|
useSecondaryYScale: usesSecondaryYScale(series, input.layout),
|
|
400
|
+
yAxisCalloutData: getFormattedCalloutYData(yVal, yAxisTickFormat),
|
|
352
401
|
});
|
|
353
402
|
}
|
|
354
403
|
});
|
|
355
404
|
});
|
|
356
|
-
|
|
357
|
-
return __assign(__assign(__assign({ data: Object.values(mapXToDataPoints), width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, barwidth: 'auto', chartTitle: chartTitle, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle, mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true }), getAxisCategoryOrderProps(input.data, input.layout));
|
|
405
|
+
return __assign(__assign(__assign(__assign(__assign(__assign(__assign({ data: Object.values(mapXToDataPoints), width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, barwidth: 'auto', mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true }), getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getYMinMaxValues(input.data[0], input.layout)), getXAxisTickFormat(input.data[0], input.layout)), yAxisTickFormat);
|
|
358
406
|
};
|
|
359
407
|
export var transformPlotlyJsonToVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
360
408
|
var _a, _b, _c;
|
|
@@ -417,8 +465,7 @@ export var transformPlotlyJsonToVBCProps = function (input, isMultiPlot, colorMa
|
|
|
417
465
|
: { xAxisCalloutData: "[".concat(bin.x0, " - ").concat(bin.x1, ")") })));
|
|
418
466
|
});
|
|
419
467
|
});
|
|
420
|
-
|
|
421
|
-
return __assign({ data: vbcData, width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, supportNegativeData: true, chartTitle: chartTitle, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle, mode: 'histogram', hideTickOverlap: true, maxBarWidth: 50, hideLegend: hideLegend, roundCorners: true }, getAxisCategoryOrderProps(input.data, input.layout));
|
|
468
|
+
return __assign(__assign(__assign({ data: vbcData, width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, supportNegativeData: true, mode: 'histogram', hideTickOverlap: true, maxBarWidth: 50, hideLegend: hideLegend, roundCorners: true }, getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getYMinMaxValues(input.data[0], input.layout));
|
|
422
469
|
};
|
|
423
470
|
export var transformPlotlyJsonToAreaChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
424
471
|
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'area', colorMap, colorwayType, isDarkTheme);
|
|
@@ -430,7 +477,7 @@ export var transformPlotlyJsonToScatterChartProps = function (input, isMultiPlot
|
|
|
430
477
|
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'scatter', colorMap, colorwayType, isDarkTheme);
|
|
431
478
|
};
|
|
432
479
|
var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme) {
|
|
433
|
-
var _a, _b, _c, _d
|
|
480
|
+
var _a, _b, _c, _d;
|
|
434
481
|
var isScatterMarkers = [
|
|
435
482
|
'markers',
|
|
436
483
|
'text+markers',
|
|
@@ -443,7 +490,8 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
|
|
|
443
490
|
var isScatterChart = chartType === 'scatter';
|
|
444
491
|
var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
|
|
445
492
|
var mode = 'tonexty';
|
|
446
|
-
var
|
|
493
|
+
var _e = getLegendProps(input.data, input.layout, isMultiPlot), legends = _e.legends, hideLegend = _e.hideLegend;
|
|
494
|
+
var yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
447
495
|
var chartData = input.data
|
|
448
496
|
.map(function (series, index) {
|
|
449
497
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
@@ -481,11 +529,11 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
|
|
|
481
529
|
legendShape: legendShape,
|
|
482
530
|
data: rangeXValues.map(function (x, i) {
|
|
483
531
|
var _a, _b;
|
|
484
|
-
return (__assign(__assign({ x: resolveXAxisPoint(x, isXYearCategory, isXString, isXDate, isXNumber), y: rangeYValues[i] }, (Array.isArray((_a = series.marker) === null || _a === void 0 ? void 0 : _a.size)
|
|
532
|
+
return (__assign(__assign(__assign({ x: resolveXAxisPoint(x, isXYearCategory, isXString, isXDate, isXNumber), y: rangeYValues[i] }, (Array.isArray((_a = series.marker) === null || _a === void 0 ? void 0 : _a.size)
|
|
485
533
|
? { markerSize: markerSizes[i] }
|
|
486
534
|
: typeof ((_b = series.marker) === null || _b === void 0 ? void 0 : _b.size) === 'number'
|
|
487
535
|
? { markerSize: series.marker.size }
|
|
488
|
-
: {})), (textValues ? { text: textValues[i] } : {})));
|
|
536
|
+
: {})), (textValues ? { text: textValues[i] } : {})), { yAxisCalloutData: getFormattedCalloutYData(rangeYValues[i], yAxisTickFormat) }));
|
|
489
537
|
}),
|
|
490
538
|
color: (_c = rgb(seriesColor).copy({ opacity: seriesOpacity }).formatHex8()) !== null && _c !== void 0 ? _c : seriesColor,
|
|
491
539
|
lineOptions: __assign(__assign({}, (lineOptions !== null && lineOptions !== void 0 ? lineOptions : {})), { mode: series.mode }),
|
|
@@ -494,22 +542,25 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
|
|
|
494
542
|
});
|
|
495
543
|
})
|
|
496
544
|
.flat();
|
|
497
|
-
var
|
|
498
|
-
|
|
545
|
+
var yMinMax = getYMinMaxValues(input.data[0], input.layout);
|
|
546
|
+
if (yMinMax.yMinValue === undefined && yMinMax.yMaxValue === undefined) {
|
|
547
|
+
var yMinMaxValues = findNumericMinMaxOfY(chartData);
|
|
548
|
+
yMinMax.yMinValue = yMinMaxValues.startValue;
|
|
549
|
+
yMinMax.yMaxValue = yMinMaxValues.endValue;
|
|
550
|
+
}
|
|
499
551
|
var numDataPoints = chartData.reduce(function (total, lineChartPoints) { return total + lineChartPoints.data.length; }, 0);
|
|
500
552
|
var chartProps = {
|
|
501
|
-
chartTitle: chartTitle,
|
|
502
553
|
lineChartData: chartData,
|
|
503
554
|
};
|
|
504
555
|
var scatterChartProps = {
|
|
505
|
-
chartTitle: chartTitle,
|
|
506
556
|
scatterChartData: chartData,
|
|
507
557
|
};
|
|
558
|
+
var commonProps = __assign(__assign(__assign(__assign(__assign({ supportNegativeData: true }, secondaryYAxisValues), { width: (_b = input.layout) === null || _b === void 0 ? void 0 : _b.width, height: (_d = (_c = input.layout) === null || _c === void 0 ? void 0 : _c.height) !== null && _d !== void 0 ? _d : 350, hideTickOverlap: true, hideLegend: hideLegend, useUTC: false, optimizeLargeData: numDataPoints > 1000 }), getTitles(input.layout)), getXAxisTickFormat(input.data[0], input.layout)), yAxisTickFormat);
|
|
508
559
|
if (isAreaChart) {
|
|
509
|
-
return __assign(
|
|
560
|
+
return __assign({ data: chartProps, mode: mode }, commonProps);
|
|
510
561
|
}
|
|
511
562
|
else {
|
|
512
|
-
return __assign(__assign({ data: isScatterChart ? scatterChartProps : chartProps,
|
|
563
|
+
return __assign(__assign({ data: isScatterChart ? scatterChartProps : chartProps, roundedTicks: true, enableReflow: false }, commonProps), yMinMax);
|
|
513
564
|
}
|
|
514
565
|
};
|
|
515
566
|
export var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -559,10 +610,9 @@ export var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, is
|
|
|
559
610
|
var scalingFactor = 0.01;
|
|
560
611
|
var gapFactor = 1 / (1 + scalingFactor * numberOfRows);
|
|
561
612
|
var barHeight = availableHeight / (numberOfRows * (1 + gapFactor));
|
|
562
|
-
|
|
563
|
-
return __assign({ data: chartData, chartTitle: chartTitle, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle, secondaryYAxistitle: typeof ((_k = (_j = input.layout) === null || _j === void 0 ? void 0 : _j.yaxis2) === null || _k === void 0 ? void 0 : _k.title) === 'string'
|
|
613
|
+
return __assign(__assign({ data: chartData, secondaryYAxistitle: typeof ((_k = (_j = input.layout) === null || _j === void 0 ? void 0 : _j.yaxis2) === null || _k === void 0 ? void 0 : _k.title) === 'string'
|
|
564
614
|
? (_m = (_l = input.layout) === null || _l === void 0 ? void 0 : _l.yaxis2) === null || _m === void 0 ? void 0 : _m.title
|
|
565
|
-
: ((_q = (_p = (_o = input.layout) === null || _o === void 0 ? void 0 : _o.yaxis2) === null || _p === void 0 ? void 0 : _p.title) === null || _q === void 0 ? void 0 : _q.text) || '', barHeight: barHeight, showYAxisLables: true, height: chartHeight, width: (_r = input.layout) === null || _r === void 0 ? void 0 : _r.width, hideTickOverlap: true, hideLegend: hideLegend, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, roundCorners: true }, getAxisCategoryOrderProps(input.data, input.layout));
|
|
615
|
+
: ((_q = (_p = (_o = input.layout) === null || _o === void 0 ? void 0 : _o.yaxis2) === null || _p === void 0 ? void 0 : _p.title) === null || _q === void 0 ? void 0 : _q.text) || '', barHeight: barHeight, showYAxisLables: true, height: chartHeight, width: (_r = input.layout) === null || _r === void 0 ? void 0 : _r.width, hideTickOverlap: true, hideLegend: hideLegend, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, roundCorners: true }, getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout));
|
|
566
616
|
};
|
|
567
617
|
export var transformPlotlyJsonToHeatmapProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
568
618
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8;
|
|
@@ -676,8 +726,7 @@ export var transformPlotlyJsonToHeatmapProps = function (input, isMultiPlot, col
|
|
|
676
726
|
var rangeValuesForColorScale = Array.isArray(colorscale)
|
|
677
727
|
? colorscale.map(function (arr) { return arr[1]; })
|
|
678
728
|
: defaultRange;
|
|
679
|
-
|
|
680
|
-
return __assign({ data: [heatmapData], domainValuesForColorScale: domainValuesForColorScale, rangeValuesForColorScale: rangeValuesForColorScale, hideLegend: true, showYAxisLables: true, chartTitle: chartTitle, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle, sortOrder: 'none', width: (_6 = input.layout) === null || _6 === void 0 ? void 0 : _6.width, height: (_8 = (_7 = input.layout) === null || _7 === void 0 ? void 0 : _7.height) !== null && _8 !== void 0 ? _8 : 350, hideTickOverlap: true, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true }, getAxisCategoryOrderProps([firstData], input.layout));
|
|
729
|
+
return __assign(__assign({ data: [heatmapData], domainValuesForColorScale: domainValuesForColorScale, rangeValuesForColorScale: rangeValuesForColorScale, hideLegend: true, showYAxisLables: true, sortOrder: 'none', width: (_6 = input.layout) === null || _6 === void 0 ? void 0 : _6.width, height: (_8 = (_7 = input.layout) === null || _7 === void 0 ? void 0 : _7.height) !== null && _8 !== void 0 ? _8 : 350, hideTickOverlap: true, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true }, getTitles(input.layout)), getAxisCategoryOrderProps([firstData], input.layout));
|
|
681
730
|
};
|
|
682
731
|
export var transformPlotlyJsonToSankeyProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
683
732
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
@@ -1133,26 +1182,44 @@ var getLegendShape = function (series) {
|
|
|
1133
1182
|
}
|
|
1134
1183
|
return 'default';
|
|
1135
1184
|
};
|
|
1136
|
-
export var getAllupLegendsProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
1185
|
+
export var getAllupLegendsProps = function (input, colorMap, colorwayType, traceInfo, isDarkTheme) {
|
|
1137
1186
|
var allupLegends = [];
|
|
1138
1187
|
// reduce on showlegend boolean propperty. reduce should return true if at least one series has showlegend true
|
|
1139
1188
|
var toShowLegend = input.data.reduce(function (acc, series) {
|
|
1140
|
-
return acc || series.showlegend === true;
|
|
1189
|
+
return (acc || series.showlegend === true || series.showlegend === undefined);
|
|
1141
1190
|
}, false);
|
|
1142
1191
|
if (toShowLegend) {
|
|
1143
1192
|
input.data.forEach(function (series, index) {
|
|
1144
|
-
var _a, _b, _c, _d, _e;
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1193
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
1194
|
+
if (traceInfo[index].type === 'donut') {
|
|
1195
|
+
var pieSeries = series;
|
|
1196
|
+
var colors_1 = extractColor((_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.piecolorway) !== null && _b !== void 0 ? _b : (_e = (_d = (_c = input.layout) === null || _c === void 0 ? void 0 : _c.template) === null || _d === void 0 ? void 0 : _d.layout) === null || _e === void 0 ? void 0 : _e.colorway, colorwayType, (_g = (_f = input.layout) === null || _f === void 0 ? void 0 : _f.piecolorway) !== null && _g !== void 0 ? _g : (_h = pieSeries === null || pieSeries === void 0 ? void 0 : pieSeries.marker) === null || _h === void 0 ? void 0 : _h.colors, colorMap, isDarkTheme);
|
|
1197
|
+
(_j = pieSeries.labels) === null || _j === void 0 ? void 0 : _j.forEach(function (label, labelIndex) {
|
|
1198
|
+
var legend = "".concat(label);
|
|
1199
|
+
// resolve color for each legend from the extracted colors
|
|
1200
|
+
var color = resolveColor(colors_1, labelIndex, legend, colorMap, isDarkTheme);
|
|
1201
|
+
if (legend !== '' && allupLegends.some(function (group) { return group.title === legend; }) === false) {
|
|
1202
|
+
allupLegends.push({
|
|
1203
|
+
title: legend,
|
|
1204
|
+
color: color,
|
|
1205
|
+
});
|
|
1206
|
+
}
|
|
1154
1207
|
});
|
|
1155
1208
|
}
|
|
1209
|
+
else if (isNonPlotType(traceInfo[index].type) === false) {
|
|
1210
|
+
var plotSeries = series;
|
|
1211
|
+
var name_1 = plotSeries.legendgroup;
|
|
1212
|
+
var color = ((_k = plotSeries.line) === null || _k === void 0 ? void 0 : _k.color) || ((_l = plotSeries.marker) === null || _l === void 0 ? void 0 : _l.color);
|
|
1213
|
+
var legendShape = getLegendShape(plotSeries);
|
|
1214
|
+
var resolvedColor = extractColor((_p = (_o = (_m = input.layout) === null || _m === void 0 ? void 0 : _m.template) === null || _o === void 0 ? void 0 : _o.layout) === null || _p === void 0 ? void 0 : _p.colorway, colorwayType, color, colorMap, isDarkTheme);
|
|
1215
|
+
if (name_1 !== undefined && name_1 !== '' && allupLegends.some(function (group) { return group.title === name_1; }) === false) {
|
|
1216
|
+
allupLegends.push({
|
|
1217
|
+
title: name_1,
|
|
1218
|
+
color: resolvedColor,
|
|
1219
|
+
shape: legendShape,
|
|
1220
|
+
});
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1156
1223
|
});
|
|
1157
1224
|
}
|
|
1158
1225
|
return {
|
|
@@ -1212,153 +1279,162 @@ var getIndexFromKey = function (key, pattern) {
|
|
|
1212
1279
|
var normalizedKey = key.replace(pattern, '') === '' ? '1' : key.replace(pattern, '');
|
|
1213
1280
|
return parseInt(normalizedKey, 10) - 1;
|
|
1214
1281
|
};
|
|
1215
|
-
export var
|
|
1282
|
+
export var isNonPlotType = function (chartType) {
|
|
1283
|
+
return ['donut', 'sankey', 'pie'].includes(chartType);
|
|
1284
|
+
};
|
|
1285
|
+
export var getGridProperties = function (schema, isMultiPlot, validTracesInfo) {
|
|
1216
1286
|
var _a;
|
|
1217
|
-
var
|
|
1218
|
-
var
|
|
1287
|
+
var domainX = [];
|
|
1288
|
+
var domainY = [];
|
|
1289
|
+
var cartesianDomains = 0;
|
|
1219
1290
|
var annotations = {};
|
|
1220
1291
|
var templateRows = '1fr';
|
|
1221
1292
|
var templateColumns = '1fr';
|
|
1222
1293
|
var gridLayout = {};
|
|
1223
|
-
if (layout === undefined || layout === null || Object.keys(layout).length === 0) {
|
|
1224
|
-
return { templateRows: templateRows, templateColumns: templateColumns, layout: gridLayout };
|
|
1225
|
-
}
|
|
1226
|
-
if (!layout.xaxis || !layout.yaxis) {
|
|
1227
|
-
return { templateRows: templateRows, templateColumns: templateColumns, layout: gridLayout };
|
|
1228
|
-
}
|
|
1229
1294
|
if (!isMultiPlot) {
|
|
1230
1295
|
return { templateRows: templateRows, templateColumns: templateColumns, layout: gridLayout };
|
|
1231
1296
|
}
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
var
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1297
|
+
var layout = schema === null || schema === void 0 ? void 0 : schema.layout;
|
|
1298
|
+
if (layout !== undefined && layout !== null && Object.keys(layout).length > 0) {
|
|
1299
|
+
Object.keys(layout !== null && layout !== void 0 ? layout : {}).forEach(function (key) {
|
|
1300
|
+
var _a, _b, _c, _d, _e;
|
|
1301
|
+
if (key.startsWith('xaxis')) {
|
|
1302
|
+
var index = getIndexFromKey(key, 'xaxis');
|
|
1303
|
+
var anchor = (_b = (_a = layout[key]) === null || _a === void 0 ? void 0 : _a.anchor) !== null && _b !== void 0 ? _b : 'y';
|
|
1304
|
+
var anchorIndex = getIndexFromKey(anchor, 'y');
|
|
1305
|
+
if (index !== anchorIndex) {
|
|
1306
|
+
throw new Error("Invalid layout: xaxis ".concat(index + 1, " anchor should be y").concat(anchorIndex + 1));
|
|
1307
|
+
}
|
|
1308
|
+
var xAxisLayout = layout[key];
|
|
1309
|
+
var domainXInfo = {
|
|
1310
|
+
start: (xAxisLayout === null || xAxisLayout === void 0 ? void 0 : xAxisLayout.domain) ? xAxisLayout.domain[0] : 0,
|
|
1311
|
+
end: (xAxisLayout === null || xAxisLayout === void 0 ? void 0 : xAxisLayout.domain) ? xAxisLayout.domain[1] : 1,
|
|
1312
|
+
};
|
|
1313
|
+
domainX.push(domainXInfo);
|
|
1240
1314
|
}
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1315
|
+
else if (key.startsWith('yaxis')) {
|
|
1316
|
+
var index = getIndexFromKey(key, 'yaxis');
|
|
1317
|
+
var anchor = (_d = (_c = layout[key]) === null || _c === void 0 ? void 0 : _c.anchor) !== null && _d !== void 0 ? _d : 'x';
|
|
1318
|
+
var anchorIndex = getIndexFromKey(anchor, 'x');
|
|
1319
|
+
if (index !== anchorIndex) {
|
|
1320
|
+
if ((index === 1 && anchorIndex === 0) || ((_e = layout.yaxis2) === null || _e === void 0 ? void 0 : _e.side) === 'right') {
|
|
1321
|
+
// Special case for secondary y axis where yaxis2 can anchor to x1
|
|
1322
|
+
return { templateRows: templateRows, templateColumns: templateColumns };
|
|
1323
|
+
}
|
|
1324
|
+
throw new Error("Invalid layout: yaxis ".concat(index + 1, " anchor should be x").concat(anchorIndex + 1));
|
|
1251
1325
|
}
|
|
1252
|
-
|
|
1326
|
+
var yAxisLayout = layout[key];
|
|
1327
|
+
var domainYInfo = {
|
|
1328
|
+
start: (yAxisLayout === null || yAxisLayout === void 0 ? void 0 : yAxisLayout.domain) ? yAxisLayout.domain[0] : 0,
|
|
1329
|
+
end: (yAxisLayout === null || yAxisLayout === void 0 ? void 0 : yAxisLayout.domain) ? yAxisLayout.domain[1] : 1,
|
|
1330
|
+
};
|
|
1331
|
+
domainY.push(domainYInfo);
|
|
1253
1332
|
}
|
|
1254
|
-
gridY[index] = (_j = (_h = layout[key]) === null || _h === void 0 ? void 0 : _h.domain) !== null && _j !== void 0 ? _j : [];
|
|
1255
|
-
}
|
|
1256
|
-
});
|
|
1257
|
-
(_a = layout.annotations) === null || _a === void 0 ? void 0 : _a.forEach(function (annotation) {
|
|
1258
|
-
var xMatches = gridX.flatMap(function (interval, idx) {
|
|
1259
|
-
return (annotation === null || annotation === void 0 ? void 0 : annotation.x) >= interval[0] && (annotation === null || annotation === void 0 ? void 0 : annotation.x) <= interval[1] ? [idx] : [];
|
|
1260
1333
|
});
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1334
|
+
}
|
|
1335
|
+
cartesianDomains = domainX.length; // Assuming that the number of x and y axes is the same
|
|
1336
|
+
validTracesInfo.forEach(function (trace, index) {
|
|
1337
|
+
var _a, _b, _c, _d, _e;
|
|
1338
|
+
if (isNonPlotType(trace.type)) {
|
|
1339
|
+
var series = (_a = schema === null || schema === void 0 ? void 0 : schema.data) === null || _a === void 0 ? void 0 : _a[index];
|
|
1340
|
+
var domainXInfo = {
|
|
1341
|
+
start: ((_b = series.domain) === null || _b === void 0 ? void 0 : _b.x) ? series.domain.x[0] : 0,
|
|
1342
|
+
end: ((_c = series.domain) === null || _c === void 0 ? void 0 : _c.x) ? series.domain.x[1] : 1,
|
|
1343
|
+
};
|
|
1344
|
+
var domainYInfo = {
|
|
1345
|
+
start: ((_d = series.domain) === null || _d === void 0 ? void 0 : _d.y) ? series.domain.y[0] : 0,
|
|
1346
|
+
end: ((_e = series.domain) === null || _e === void 0 ? void 0 : _e.y) ? series.domain.y[1] : 1,
|
|
1347
|
+
};
|
|
1348
|
+
domainX.push(domainXInfo);
|
|
1349
|
+
domainY.push(domainYInfo);
|
|
1276
1350
|
}
|
|
1277
1351
|
});
|
|
1278
|
-
if (
|
|
1352
|
+
if (layout !== undefined && layout !== null && Object.keys(layout).length > 0) {
|
|
1353
|
+
(_a = layout.annotations) === null || _a === void 0 ? void 0 : _a.forEach(function (annotation) {
|
|
1354
|
+
var xMatches = domainX.flatMap(function (interval, idx) {
|
|
1355
|
+
return (annotation === null || annotation === void 0 ? void 0 : annotation.x) >= interval.start && (annotation === null || annotation === void 0 ? void 0 : annotation.x) <= interval.end ? [idx] : [];
|
|
1356
|
+
});
|
|
1357
|
+
var yMatch = domainY.findIndex(function (interval, yIndex) {
|
|
1358
|
+
return xMatches.includes(yIndex) &&
|
|
1359
|
+
(annotation === null || annotation === void 0 ? void 0 : annotation.y) >= interval.start &&
|
|
1360
|
+
(annotation === null || annotation === void 0 ? void 0 : annotation.y) <= interval.end;
|
|
1361
|
+
});
|
|
1362
|
+
if (yMatch !== -1) {
|
|
1363
|
+
if (annotations[yMatch] === undefined) {
|
|
1364
|
+
annotations[yMatch] = {};
|
|
1365
|
+
}
|
|
1366
|
+
if ((annotation === null || annotation === void 0 ? void 0 : annotation.textangle) === 90) {
|
|
1367
|
+
annotations[yMatch].yAnnotation = annotation.text;
|
|
1368
|
+
}
|
|
1369
|
+
else {
|
|
1370
|
+
annotations[yMatch].xAnnotation = annotation.text;
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
});
|
|
1374
|
+
}
|
|
1375
|
+
if (domainX.length > 0) {
|
|
1279
1376
|
var uniqueXIntervals_1 = new Map();
|
|
1280
|
-
|
|
1281
|
-
var key = "".concat(interval
|
|
1377
|
+
domainX.forEach(function (interval) {
|
|
1378
|
+
var key = "".concat(interval.start, "-").concat(interval.end);
|
|
1282
1379
|
if (!uniqueXIntervals_1.has(key)) {
|
|
1283
1380
|
uniqueXIntervals_1.set(key, interval);
|
|
1284
1381
|
}
|
|
1285
1382
|
});
|
|
1286
|
-
var
|
|
1287
|
-
|
|
1288
|
-
.
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
var cellName = "x".concat(index === 0 ? '' : index + 1);
|
|
1383
|
+
var sortedXStart_1 = Array.from(uniqueXIntervals_1.values())
|
|
1384
|
+
.map(function (interval) { return interval.start; })
|
|
1385
|
+
.sort();
|
|
1386
|
+
templateColumns = "repeat(".concat(sortedXStart_1.length, ", 1fr)");
|
|
1387
|
+
domainX.forEach(function (interval, index) {
|
|
1388
|
+
var cellName = index >= cartesianDomains
|
|
1389
|
+
? "".concat(NON_PLOT_KEY_PREFIX).concat(index - cartesianDomains + 1)
|
|
1390
|
+
: "x".concat(index === 0 ? '' : index + 1);
|
|
1391
|
+
var columnIndex = sortedXStart_1.findIndex(function (start) { return start === interval.start; });
|
|
1392
|
+
var columnNumber = columnIndex + 1; // Column numbers are 1-based
|
|
1297
1393
|
var annotationProps = annotations[index];
|
|
1298
1394
|
var xAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.xAnnotation;
|
|
1299
|
-
if (interval[0] < lastIntervalEnd_1) {
|
|
1300
|
-
columnNumber_1 = 1;
|
|
1301
|
-
}
|
|
1302
|
-
lastIntervalEnd_1 = interval[1];
|
|
1303
1395
|
var row = {
|
|
1304
1396
|
row: -1,
|
|
1305
|
-
column:
|
|
1397
|
+
column: columnNumber,
|
|
1306
1398
|
xAnnotation: xAnnotation,
|
|
1399
|
+
xDomain: interval,
|
|
1400
|
+
yDomain: { start: 0, end: 1 }, // Default yDomain for x-axis
|
|
1307
1401
|
};
|
|
1308
1402
|
gridLayout[cellName] = row;
|
|
1309
|
-
columnNumber_1 += 1;
|
|
1310
1403
|
});
|
|
1311
1404
|
}
|
|
1312
|
-
|
|
1313
|
-
var columnFill = {};
|
|
1314
|
-
for (var i = 1; i <= numColumns; i++) {
|
|
1315
|
-
columnFill[i] = { row: 1, fillDomain: 0 };
|
|
1316
|
-
}
|
|
1317
|
-
if (gridY.length > 0) {
|
|
1405
|
+
if (domainY.length > 0) {
|
|
1318
1406
|
var uniqueYIntervals_1 = new Map();
|
|
1319
|
-
|
|
1320
|
-
var key = "".concat(interval
|
|
1407
|
+
domainY.forEach(function (interval) {
|
|
1408
|
+
var key = "".concat(interval.start, "-").concat(interval.end);
|
|
1321
1409
|
if (!uniqueYIntervals_1.has(key)) {
|
|
1322
1410
|
uniqueYIntervals_1.set(key, interval);
|
|
1323
1411
|
}
|
|
1324
1412
|
});
|
|
1325
|
-
var
|
|
1326
|
-
|
|
1327
|
-
.
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1413
|
+
var sortedYStart_1 = Array.from(uniqueYIntervals_1.values())
|
|
1414
|
+
.map(function (interval) { return interval.start; })
|
|
1415
|
+
.sort();
|
|
1416
|
+
var numberOfRows_1 = sortedYStart_1.length;
|
|
1417
|
+
templateRows = "repeat(".concat(numberOfRows_1, ", 1fr)");
|
|
1418
|
+
domainY.forEach(function (interval, index) {
|
|
1419
|
+
var cellName = index >= cartesianDomains
|
|
1420
|
+
? "".concat(NON_PLOT_KEY_PREFIX).concat(index - cartesianDomains + 1)
|
|
1421
|
+
: "x".concat(index === 0 ? '' : index + 1);
|
|
1422
|
+
var rowIndex = sortedYStart_1.findIndex(function (start) { return start === interval.start; });
|
|
1423
|
+
var rowNumber = numberOfRows_1 - rowIndex; // Rows are 1-based and we need to reverse the order for CSS grid
|
|
1334
1424
|
var annotationProps = annotations[index];
|
|
1335
1425
|
var yAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.yAnnotation;
|
|
1336
1426
|
var cell = gridLayout[cellName];
|
|
1337
1427
|
if (cell !== undefined) {
|
|
1338
|
-
cell.row =
|
|
1428
|
+
cell.row = rowNumber;
|
|
1339
1429
|
cell.yAnnotation = yAnnotation;
|
|
1430
|
+
cell.yDomain = interval;
|
|
1340
1431
|
}
|
|
1341
|
-
columnFill[cell.column].fillDomain = interval[1];
|
|
1342
|
-
columnFill[cell.column].row += 1;
|
|
1343
1432
|
});
|
|
1344
1433
|
}
|
|
1345
|
-
// reverse the order of rows in grid layout from bottom-top to top-bottom as required by CSS grid
|
|
1346
|
-
var reversedGridLayout = {};
|
|
1347
|
-
// find the maximum row number
|
|
1348
|
-
var maxRowNumber = Math.max.apply(Math, Object.values(gridLayout).map(function (cell) { var _a; return (_a = cell.row) !== null && _a !== void 0 ? _a : 0; }));
|
|
1349
|
-
// iterate over the gridLayout and reverse the row numbers
|
|
1350
|
-
Object.keys(gridLayout).forEach(function (key) {
|
|
1351
|
-
var cell = gridLayout[key];
|
|
1352
|
-
if (cell.row !== undefined) {
|
|
1353
|
-
// reverse the row number
|
|
1354
|
-
cell.row = maxRowNumber - cell.row + 1;
|
|
1355
|
-
}
|
|
1356
|
-
reversedGridLayout[key] = cell;
|
|
1357
|
-
});
|
|
1358
1434
|
return {
|
|
1359
1435
|
templateRows: templateRows,
|
|
1360
1436
|
templateColumns: templateColumns,
|
|
1361
|
-
layout:
|
|
1437
|
+
layout: gridLayout,
|
|
1362
1438
|
};
|
|
1363
1439
|
};
|
|
1364
1440
|
/**
|