@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getGridProperties = exports.getValidXYRanges = exports.getNumberAtIndexOrDefault = exports.getAllupLegendsProps = exports.findArrayAttributes = exports.projectPolarToCartesian = exports.transformPlotlyJsonToChartTableProps = exports.transformPlotlyJsonToGaugeProps = exports.transformPlotlyJsonToSankeyProps = exports.transformPlotlyJsonToHeatmapProps = exports.transformPlotlyJsonToHorizontalBarWithAxisProps = exports.transformPlotlyJsonToScatterChartProps = exports.transformPlotlyJsonToLineChartProps = exports.transformPlotlyJsonToAreaChartProps = exports.transformPlotlyJsonToVBCProps = exports.transformPlotlyJsonToGVBCProps = exports.transformPlotlyJsonToVSBCProps = exports.transformPlotlyJsonToDonutProps = exports.resolveXAxisPoint = exports._getGaugeAxisColor = exports.correctYearMonth = void 0;
|
|
3
|
+
exports.getGridProperties = exports.isNonPlotType = exports.getValidXYRanges = exports.getNumberAtIndexOrDefault = exports.getAllupLegendsProps = exports.findArrayAttributes = exports.projectPolarToCartesian = exports.transformPlotlyJsonToChartTableProps = exports.transformPlotlyJsonToGaugeProps = exports.transformPlotlyJsonToSankeyProps = exports.transformPlotlyJsonToHeatmapProps = exports.transformPlotlyJsonToHorizontalBarWithAxisProps = exports.transformPlotlyJsonToScatterChartProps = exports.transformPlotlyJsonToLineChartProps = exports.transformPlotlyJsonToAreaChartProps = exports.transformPlotlyJsonToVBCProps = exports.transformPlotlyJsonToGVBCProps = exports.transformPlotlyJsonToVSBCProps = exports.transformPlotlyJsonToDonutProps = exports.resolveXAxisPoint = exports._getGaugeAxisColor = exports.correctYearMonth = exports.SINGLE_REPEAT = exports.NON_PLOT_KEY_PREFIX = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var d3_array_1 = require("d3-array");
|
|
6
6
|
var d3_scale_1 = require("d3-scale");
|
|
@@ -12,6 +12,8 @@ var chart_utilities_1 = require("@fluentui/chart-utilities");
|
|
|
12
12
|
var d3_shape_1 = require("d3-shape");
|
|
13
13
|
var PlotlyColorAdapter_1 = require("./PlotlyColorAdapter");
|
|
14
14
|
var d3_color_1 = require("d3-color");
|
|
15
|
+
exports.NON_PLOT_KEY_PREFIX = 'nonplot_';
|
|
16
|
+
exports.SINGLE_REPEAT = 'repeat(1, 1fr)';
|
|
15
17
|
var dashOptions = {
|
|
16
18
|
dot: {
|
|
17
19
|
strokeDasharray: '1, 5',
|
|
@@ -59,6 +61,47 @@ function getTitles(layout) {
|
|
|
59
61
|
};
|
|
60
62
|
return titles;
|
|
61
63
|
}
|
|
64
|
+
var getXAxisTickFormat = function (series, layout) {
|
|
65
|
+
var xAxis = getXAxisProperties(series, layout);
|
|
66
|
+
if (xAxis === null || xAxis === void 0 ? void 0 : xAxis.tickformat) {
|
|
67
|
+
return {
|
|
68
|
+
tickFormat: xAxis === null || xAxis === void 0 ? void 0 : xAxis.tickformat,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
return {};
|
|
72
|
+
};
|
|
73
|
+
var getYAxisTickFormat = function (series, layout) {
|
|
74
|
+
var yAxis = getYAxisProperties(series, layout);
|
|
75
|
+
if (yAxis === null || yAxis === void 0 ? void 0 : yAxis.tickformat) {
|
|
76
|
+
return {
|
|
77
|
+
yAxisTickFormat: (0, d3_format_1.format)(yAxis === null || yAxis === void 0 ? void 0 : yAxis.tickformat),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
return {};
|
|
81
|
+
};
|
|
82
|
+
var getYMinMaxValues = function (series, layout) {
|
|
83
|
+
var _a;
|
|
84
|
+
var range = (_a = getYAxisProperties(series, layout)) === null || _a === void 0 ? void 0 : _a.range;
|
|
85
|
+
if (range && range.length === 2) {
|
|
86
|
+
return {
|
|
87
|
+
yMinValue: range[0],
|
|
88
|
+
yMaxValue: range[1],
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
return {};
|
|
92
|
+
};
|
|
93
|
+
var getYAxisProperties = function (series, layout) {
|
|
94
|
+
return layout === null || layout === void 0 ? void 0 : layout.yaxis;
|
|
95
|
+
};
|
|
96
|
+
var getXAxisProperties = function (series, layout) {
|
|
97
|
+
return layout === null || layout === void 0 ? void 0 : layout.xaxis;
|
|
98
|
+
};
|
|
99
|
+
var getFormattedCalloutYData = function (yVal, yAxisFormat) {
|
|
100
|
+
if (typeof (yAxisFormat === null || yAxisFormat === void 0 ? void 0 : yAxisFormat.yAxisTickFormat) === 'function' && typeof yVal === 'number') {
|
|
101
|
+
return yAxisFormat.yAxisTickFormat(yVal);
|
|
102
|
+
}
|
|
103
|
+
return (0, chart_utilities_1.formatToLocaleString)(yVal);
|
|
104
|
+
};
|
|
62
105
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
63
106
|
var correctYearMonth = function (xValues) {
|
|
64
107
|
var presentYear = new Date().getFullYear();
|
|
@@ -209,7 +252,7 @@ var transformPlotlyJsonToDonutProps = function (input, isMultiPlot, colorMap, co
|
|
|
209
252
|
chartTitle: chartTitle,
|
|
210
253
|
chartData: Object.values(mapLegendToDataPoint),
|
|
211
254
|
},
|
|
212
|
-
hideLegend: ((_p = input.layout) === null || _p === void 0 ? void 0 : _p.showlegend) === false
|
|
255
|
+
hideLegend: isMultiPlot || ((_p = input.layout) === null || _p === void 0 ? void 0 : _p.showlegend) === false,
|
|
213
256
|
width: (_q = input.layout) === null || _q === void 0 ? void 0 : _q.width,
|
|
214
257
|
height: height,
|
|
215
258
|
innerRadius: innerRadius,
|
|
@@ -227,6 +270,7 @@ var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorMap, col
|
|
|
227
270
|
var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
|
|
228
271
|
var _d = getLegendProps(input.data, input.layout, isMultiPlot), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
229
272
|
var colorScale = undefined;
|
|
273
|
+
var yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
230
274
|
input.data.forEach(function (series, index1) {
|
|
231
275
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
232
276
|
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) &&
|
|
@@ -267,11 +311,13 @@ var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorMap, col
|
|
|
267
311
|
: (0, PlotlyColorAdapter_1.resolveColor)(extractedBarColors, index2, legend, colorMap, isDarkTheme);
|
|
268
312
|
var opacity = (0, PlotlyColorAdapter_1.getOpacity)(series, index2);
|
|
269
313
|
var yVal = rangeYValues[index2];
|
|
314
|
+
var yAxisCalloutData = getFormattedCalloutYData(yVal, yAxisTickFormat);
|
|
270
315
|
if (series.type === 'bar') {
|
|
271
316
|
mapXToDataPoints[x].chartData.push({
|
|
272
317
|
legend: legend,
|
|
273
318
|
data: yVal,
|
|
274
319
|
color: (_e = (0, d3_color_1.rgb)(color).copy({ opacity: opacity }).formatHex8()) !== null && _e !== void 0 ? _e : color,
|
|
320
|
+
yAxisCalloutData: yAxisCalloutData,
|
|
275
321
|
});
|
|
276
322
|
if (typeof yVal === 'number') {
|
|
277
323
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
@@ -288,6 +334,7 @@ var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorMap, col
|
|
|
288
334
|
color: (_f = (0, d3_color_1.rgb)(lineColor).copy({ opacity: opacity }).formatHex8()) !== null && _f !== void 0 ? _f : color,
|
|
289
335
|
lineOptions: tslib_1.__assign(tslib_1.__assign({}, (lineOptions !== null && lineOptions !== void 0 ? lineOptions : {})), { mode: series.mode }),
|
|
290
336
|
useSecondaryYScale: usesSecondaryYScale(series, input.layout),
|
|
337
|
+
yAxisCalloutData: yAxisCalloutData,
|
|
291
338
|
});
|
|
292
339
|
if (!usesSecondaryYScale(series, input.layout) && typeof yVal === 'number') {
|
|
293
340
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
@@ -297,8 +344,7 @@ var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorMap, col
|
|
|
297
344
|
});
|
|
298
345
|
});
|
|
299
346
|
});
|
|
300
|
-
|
|
301
|
-
return tslib_1.__assign(tslib_1.__assign(tslib_1.__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));
|
|
347
|
+
return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__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);
|
|
302
348
|
};
|
|
303
349
|
exports.transformPlotlyJsonToVSBCProps = transformPlotlyJsonToVSBCProps;
|
|
304
350
|
var createColorScale = function (layout, series) {
|
|
@@ -323,6 +369,7 @@ var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorMap, col
|
|
|
323
369
|
var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, 0, 0);
|
|
324
370
|
var _d = getLegendProps(input.data, input.layout, isMultiPlot), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
325
371
|
var colorScale = undefined;
|
|
372
|
+
var yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
326
373
|
input.data.forEach(function (series, index1) {
|
|
327
374
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
328
375
|
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) &&
|
|
@@ -350,19 +397,20 @@ var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorMap, col
|
|
|
350
397
|
: 0)
|
|
351
398
|
: (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, xIndex, legend, colorMap, isDarkTheme);
|
|
352
399
|
var opacity = (0, PlotlyColorAdapter_1.getOpacity)(series, xIndex);
|
|
400
|
+
var yVal = series.y[xIndex];
|
|
353
401
|
mapXToDataPoints[x].series.push({
|
|
354
402
|
key: legend,
|
|
355
|
-
data:
|
|
403
|
+
data: yVal,
|
|
356
404
|
xAxisCalloutData: x,
|
|
357
405
|
color: (_f = (0, d3_color_1.rgb)(color).copy({ opacity: opacity }).formatHex8()) !== null && _f !== void 0 ? _f : color,
|
|
358
406
|
legend: legend,
|
|
359
407
|
useSecondaryYScale: usesSecondaryYScale(series, input.layout),
|
|
408
|
+
yAxisCalloutData: getFormattedCalloutYData(yVal, yAxisTickFormat),
|
|
360
409
|
});
|
|
361
410
|
}
|
|
362
411
|
});
|
|
363
412
|
});
|
|
364
|
-
|
|
365
|
-
return tslib_1.__assign(tslib_1.__assign(tslib_1.__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));
|
|
413
|
+
return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__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);
|
|
366
414
|
};
|
|
367
415
|
exports.transformPlotlyJsonToGVBCProps = transformPlotlyJsonToGVBCProps;
|
|
368
416
|
var transformPlotlyJsonToVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -426,8 +474,7 @@ var transformPlotlyJsonToVBCProps = function (input, isMultiPlot, colorMap, colo
|
|
|
426
474
|
: { xAxisCalloutData: "[".concat(bin.x0, " - ").concat(bin.x1, ")") })));
|
|
427
475
|
});
|
|
428
476
|
});
|
|
429
|
-
|
|
430
|
-
return tslib_1.__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));
|
|
477
|
+
return tslib_1.__assign(tslib_1.__assign(tslib_1.__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));
|
|
431
478
|
};
|
|
432
479
|
exports.transformPlotlyJsonToVBCProps = transformPlotlyJsonToVBCProps;
|
|
433
480
|
var transformPlotlyJsonToAreaChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -443,7 +490,7 @@ var transformPlotlyJsonToScatterChartProps = function (input, isMultiPlot, color
|
|
|
443
490
|
};
|
|
444
491
|
exports.transformPlotlyJsonToScatterChartProps = transformPlotlyJsonToScatterChartProps;
|
|
445
492
|
var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme) {
|
|
446
|
-
var _a, _b, _c, _d
|
|
493
|
+
var _a, _b, _c, _d;
|
|
447
494
|
var isScatterMarkers = [
|
|
448
495
|
'markers',
|
|
449
496
|
'text+markers',
|
|
@@ -456,7 +503,8 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
|
|
|
456
503
|
var isScatterChart = chartType === 'scatter';
|
|
457
504
|
var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
|
|
458
505
|
var mode = 'tonexty';
|
|
459
|
-
var
|
|
506
|
+
var _e = getLegendProps(input.data, input.layout, isMultiPlot), legends = _e.legends, hideLegend = _e.hideLegend;
|
|
507
|
+
var yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
460
508
|
var chartData = input.data
|
|
461
509
|
.map(function (series, index) {
|
|
462
510
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
@@ -494,11 +542,11 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
|
|
|
494
542
|
legendShape: legendShape,
|
|
495
543
|
data: rangeXValues.map(function (x, i) {
|
|
496
544
|
var _a, _b;
|
|
497
|
-
return (tslib_1.__assign(tslib_1.__assign({ x: (0, exports.resolveXAxisPoint)(x, isXYearCategory, isXString, isXDate, isXNumber), y: rangeYValues[i] }, (Array.isArray((_a = series.marker) === null || _a === void 0 ? void 0 : _a.size)
|
|
545
|
+
return (tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ x: (0, exports.resolveXAxisPoint)(x, isXYearCategory, isXString, isXDate, isXNumber), y: rangeYValues[i] }, (Array.isArray((_a = series.marker) === null || _a === void 0 ? void 0 : _a.size)
|
|
498
546
|
? { markerSize: markerSizes[i] }
|
|
499
547
|
: typeof ((_b = series.marker) === null || _b === void 0 ? void 0 : _b.size) === 'number'
|
|
500
548
|
? { markerSize: series.marker.size }
|
|
501
|
-
: {})), (textValues ? { text: textValues[i] } : {})));
|
|
549
|
+
: {})), (textValues ? { text: textValues[i] } : {})), { yAxisCalloutData: getFormattedCalloutYData(rangeYValues[i], yAxisTickFormat) }));
|
|
502
550
|
}),
|
|
503
551
|
color: (_c = (0, d3_color_1.rgb)(seriesColor).copy({ opacity: seriesOpacity }).formatHex8()) !== null && _c !== void 0 ? _c : seriesColor,
|
|
504
552
|
lineOptions: tslib_1.__assign(tslib_1.__assign({}, (lineOptions !== null && lineOptions !== void 0 ? lineOptions : {})), { mode: series.mode }),
|
|
@@ -507,22 +555,25 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
|
|
|
507
555
|
});
|
|
508
556
|
})
|
|
509
557
|
.flat();
|
|
510
|
-
var
|
|
511
|
-
|
|
558
|
+
var yMinMax = getYMinMaxValues(input.data[0], input.layout);
|
|
559
|
+
if (yMinMax.yMinValue === undefined && yMinMax.yMaxValue === undefined) {
|
|
560
|
+
var yMinMaxValues = (0, utilities_1.findNumericMinMaxOfY)(chartData);
|
|
561
|
+
yMinMax.yMinValue = yMinMaxValues.startValue;
|
|
562
|
+
yMinMax.yMaxValue = yMinMaxValues.endValue;
|
|
563
|
+
}
|
|
512
564
|
var numDataPoints = chartData.reduce(function (total, lineChartPoints) { return total + lineChartPoints.data.length; }, 0);
|
|
513
565
|
var chartProps = {
|
|
514
|
-
chartTitle: chartTitle,
|
|
515
566
|
lineChartData: chartData,
|
|
516
567
|
};
|
|
517
568
|
var scatterChartProps = {
|
|
518
|
-
chartTitle: chartTitle,
|
|
519
569
|
scatterChartData: chartData,
|
|
520
570
|
};
|
|
571
|
+
var commonProps = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__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);
|
|
521
572
|
if (isAreaChart) {
|
|
522
|
-
return tslib_1.__assign(
|
|
573
|
+
return tslib_1.__assign({ data: chartProps, mode: mode }, commonProps);
|
|
523
574
|
}
|
|
524
575
|
else {
|
|
525
|
-
return tslib_1.__assign(tslib_1.__assign({ data: isScatterChart ? scatterChartProps : chartProps,
|
|
576
|
+
return tslib_1.__assign(tslib_1.__assign({ data: isScatterChart ? scatterChartProps : chartProps, roundedTicks: true, enableReflow: false }, commonProps), yMinMax);
|
|
526
577
|
}
|
|
527
578
|
};
|
|
528
579
|
var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -572,10 +623,9 @@ var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, isMultiPl
|
|
|
572
623
|
var scalingFactor = 0.01;
|
|
573
624
|
var gapFactor = 1 / (1 + scalingFactor * numberOfRows);
|
|
574
625
|
var barHeight = availableHeight / (numberOfRows * (1 + gapFactor));
|
|
575
|
-
|
|
576
|
-
return tslib_1.__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'
|
|
626
|
+
return tslib_1.__assign(tslib_1.__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'
|
|
577
627
|
? (_m = (_l = input.layout) === null || _l === void 0 ? void 0 : _l.yaxis2) === null || _m === void 0 ? void 0 : _m.title
|
|
578
|
-
: ((_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));
|
|
628
|
+
: ((_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));
|
|
579
629
|
};
|
|
580
630
|
exports.transformPlotlyJsonToHorizontalBarWithAxisProps = transformPlotlyJsonToHorizontalBarWithAxisProps;
|
|
581
631
|
var transformPlotlyJsonToHeatmapProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -690,8 +740,7 @@ var transformPlotlyJsonToHeatmapProps = function (input, isMultiPlot, colorMap,
|
|
|
690
740
|
var rangeValuesForColorScale = Array.isArray(colorscale)
|
|
691
741
|
? colorscale.map(function (arr) { return arr[1]; })
|
|
692
742
|
: defaultRange;
|
|
693
|
-
|
|
694
|
-
return tslib_1.__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));
|
|
743
|
+
return tslib_1.__assign(tslib_1.__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));
|
|
695
744
|
};
|
|
696
745
|
exports.transformPlotlyJsonToHeatmapProps = transformPlotlyJsonToHeatmapProps;
|
|
697
746
|
var transformPlotlyJsonToSankeyProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -1153,26 +1202,44 @@ var getLegendShape = function (series) {
|
|
|
1153
1202
|
}
|
|
1154
1203
|
return 'default';
|
|
1155
1204
|
};
|
|
1156
|
-
var getAllupLegendsProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
1205
|
+
var getAllupLegendsProps = function (input, colorMap, colorwayType, traceInfo, isDarkTheme) {
|
|
1157
1206
|
var allupLegends = [];
|
|
1158
1207
|
// reduce on showlegend boolean propperty. reduce should return true if at least one series has showlegend true
|
|
1159
1208
|
var toShowLegend = input.data.reduce(function (acc, series) {
|
|
1160
|
-
return acc || series.showlegend === true;
|
|
1209
|
+
return (acc || series.showlegend === true || series.showlegend === undefined);
|
|
1161
1210
|
}, false);
|
|
1162
1211
|
if (toShowLegend) {
|
|
1163
1212
|
input.data.forEach(function (series, index) {
|
|
1164
|
-
var _a, _b, _c, _d, _e;
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1213
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
1214
|
+
if (traceInfo[index].type === 'donut') {
|
|
1215
|
+
var pieSeries = series;
|
|
1216
|
+
var colors_2 = (0, PlotlyColorAdapter_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);
|
|
1217
|
+
(_j = pieSeries.labels) === null || _j === void 0 ? void 0 : _j.forEach(function (label, labelIndex) {
|
|
1218
|
+
var legend = "".concat(label);
|
|
1219
|
+
// resolve color for each legend from the extracted colors
|
|
1220
|
+
var color = (0, PlotlyColorAdapter_1.resolveColor)(colors_2, labelIndex, legend, colorMap, isDarkTheme);
|
|
1221
|
+
if (legend !== '' && allupLegends.some(function (group) { return group.title === legend; }) === false) {
|
|
1222
|
+
allupLegends.push({
|
|
1223
|
+
title: legend,
|
|
1224
|
+
color: color,
|
|
1225
|
+
});
|
|
1226
|
+
}
|
|
1174
1227
|
});
|
|
1175
1228
|
}
|
|
1229
|
+
else if ((0, exports.isNonPlotType)(traceInfo[index].type) === false) {
|
|
1230
|
+
var plotSeries = series;
|
|
1231
|
+
var name_1 = plotSeries.legendgroup;
|
|
1232
|
+
var color = ((_k = plotSeries.line) === null || _k === void 0 ? void 0 : _k.color) || ((_l = plotSeries.marker) === null || _l === void 0 ? void 0 : _l.color);
|
|
1233
|
+
var legendShape = getLegendShape(plotSeries);
|
|
1234
|
+
var resolvedColor = (0, PlotlyColorAdapter_1.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);
|
|
1235
|
+
if (name_1 !== undefined && name_1 !== '' && allupLegends.some(function (group) { return group.title === name_1; }) === false) {
|
|
1236
|
+
allupLegends.push({
|
|
1237
|
+
title: name_1,
|
|
1238
|
+
color: resolvedColor,
|
|
1239
|
+
shape: legendShape,
|
|
1240
|
+
});
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1176
1243
|
});
|
|
1177
1244
|
}
|
|
1178
1245
|
return {
|
|
@@ -1235,153 +1302,163 @@ var getIndexFromKey = function (key, pattern) {
|
|
|
1235
1302
|
var normalizedKey = key.replace(pattern, '') === '' ? '1' : key.replace(pattern, '');
|
|
1236
1303
|
return parseInt(normalizedKey, 10) - 1;
|
|
1237
1304
|
};
|
|
1238
|
-
var
|
|
1305
|
+
var isNonPlotType = function (chartType) {
|
|
1306
|
+
return ['donut', 'sankey', 'pie'].includes(chartType);
|
|
1307
|
+
};
|
|
1308
|
+
exports.isNonPlotType = isNonPlotType;
|
|
1309
|
+
var getGridProperties = function (schema, isMultiPlot, validTracesInfo) {
|
|
1239
1310
|
var _a;
|
|
1240
|
-
var
|
|
1241
|
-
var
|
|
1311
|
+
var domainX = [];
|
|
1312
|
+
var domainY = [];
|
|
1313
|
+
var cartesianDomains = 0;
|
|
1242
1314
|
var annotations = {};
|
|
1243
1315
|
var templateRows = '1fr';
|
|
1244
1316
|
var templateColumns = '1fr';
|
|
1245
1317
|
var gridLayout = {};
|
|
1246
|
-
if (layout === undefined || layout === null || Object.keys(layout).length === 0) {
|
|
1247
|
-
return { templateRows: templateRows, templateColumns: templateColumns, layout: gridLayout };
|
|
1248
|
-
}
|
|
1249
|
-
if (!layout.xaxis || !layout.yaxis) {
|
|
1250
|
-
return { templateRows: templateRows, templateColumns: templateColumns, layout: gridLayout };
|
|
1251
|
-
}
|
|
1252
1318
|
if (!isMultiPlot) {
|
|
1253
1319
|
return { templateRows: templateRows, templateColumns: templateColumns, layout: gridLayout };
|
|
1254
1320
|
}
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
var
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1321
|
+
var layout = schema === null || schema === void 0 ? void 0 : schema.layout;
|
|
1322
|
+
if (layout !== undefined && layout !== null && Object.keys(layout).length > 0) {
|
|
1323
|
+
Object.keys(layout !== null && layout !== void 0 ? layout : {}).forEach(function (key) {
|
|
1324
|
+
var _a, _b, _c, _d, _e;
|
|
1325
|
+
if (key.startsWith('xaxis')) {
|
|
1326
|
+
var index = getIndexFromKey(key, 'xaxis');
|
|
1327
|
+
var anchor = (_b = (_a = layout[key]) === null || _a === void 0 ? void 0 : _a.anchor) !== null && _b !== void 0 ? _b : 'y';
|
|
1328
|
+
var anchorIndex = getIndexFromKey(anchor, 'y');
|
|
1329
|
+
if (index !== anchorIndex) {
|
|
1330
|
+
throw new Error("Invalid layout: xaxis ".concat(index + 1, " anchor should be y").concat(anchorIndex + 1));
|
|
1331
|
+
}
|
|
1332
|
+
var xAxisLayout = layout[key];
|
|
1333
|
+
var domainXInfo = {
|
|
1334
|
+
start: (xAxisLayout === null || xAxisLayout === void 0 ? void 0 : xAxisLayout.domain) ? xAxisLayout.domain[0] : 0,
|
|
1335
|
+
end: (xAxisLayout === null || xAxisLayout === void 0 ? void 0 : xAxisLayout.domain) ? xAxisLayout.domain[1] : 1,
|
|
1336
|
+
};
|
|
1337
|
+
domainX.push(domainXInfo);
|
|
1263
1338
|
}
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1339
|
+
else if (key.startsWith('yaxis')) {
|
|
1340
|
+
var index = getIndexFromKey(key, 'yaxis');
|
|
1341
|
+
var anchor = (_d = (_c = layout[key]) === null || _c === void 0 ? void 0 : _c.anchor) !== null && _d !== void 0 ? _d : 'x';
|
|
1342
|
+
var anchorIndex = getIndexFromKey(anchor, 'x');
|
|
1343
|
+
if (index !== anchorIndex) {
|
|
1344
|
+
if ((index === 1 && anchorIndex === 0) || ((_e = layout.yaxis2) === null || _e === void 0 ? void 0 : _e.side) === 'right') {
|
|
1345
|
+
// Special case for secondary y axis where yaxis2 can anchor to x1
|
|
1346
|
+
return { templateRows: templateRows, templateColumns: templateColumns };
|
|
1347
|
+
}
|
|
1348
|
+
throw new Error("Invalid layout: yaxis ".concat(index + 1, " anchor should be x").concat(anchorIndex + 1));
|
|
1274
1349
|
}
|
|
1275
|
-
|
|
1350
|
+
var yAxisLayout = layout[key];
|
|
1351
|
+
var domainYInfo = {
|
|
1352
|
+
start: (yAxisLayout === null || yAxisLayout === void 0 ? void 0 : yAxisLayout.domain) ? yAxisLayout.domain[0] : 0,
|
|
1353
|
+
end: (yAxisLayout === null || yAxisLayout === void 0 ? void 0 : yAxisLayout.domain) ? yAxisLayout.domain[1] : 1,
|
|
1354
|
+
};
|
|
1355
|
+
domainY.push(domainYInfo);
|
|
1276
1356
|
}
|
|
1277
|
-
gridY[index] = (_j = (_h = layout[key]) === null || _h === void 0 ? void 0 : _h.domain) !== null && _j !== void 0 ? _j : [];
|
|
1278
|
-
}
|
|
1279
|
-
});
|
|
1280
|
-
(_a = layout.annotations) === null || _a === void 0 ? void 0 : _a.forEach(function (annotation) {
|
|
1281
|
-
var xMatches = gridX.flatMap(function (interval, idx) {
|
|
1282
|
-
return (annotation === null || annotation === void 0 ? void 0 : annotation.x) >= interval[0] && (annotation === null || annotation === void 0 ? void 0 : annotation.x) <= interval[1] ? [idx] : [];
|
|
1283
1357
|
});
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1358
|
+
}
|
|
1359
|
+
cartesianDomains = domainX.length; // Assuming that the number of x and y axes is the same
|
|
1360
|
+
validTracesInfo.forEach(function (trace, index) {
|
|
1361
|
+
var _a, _b, _c, _d, _e;
|
|
1362
|
+
if ((0, exports.isNonPlotType)(trace.type)) {
|
|
1363
|
+
var series = (_a = schema === null || schema === void 0 ? void 0 : schema.data) === null || _a === void 0 ? void 0 : _a[index];
|
|
1364
|
+
var domainXInfo = {
|
|
1365
|
+
start: ((_b = series.domain) === null || _b === void 0 ? void 0 : _b.x) ? series.domain.x[0] : 0,
|
|
1366
|
+
end: ((_c = series.domain) === null || _c === void 0 ? void 0 : _c.x) ? series.domain.x[1] : 1,
|
|
1367
|
+
};
|
|
1368
|
+
var domainYInfo = {
|
|
1369
|
+
start: ((_d = series.domain) === null || _d === void 0 ? void 0 : _d.y) ? series.domain.y[0] : 0,
|
|
1370
|
+
end: ((_e = series.domain) === null || _e === void 0 ? void 0 : _e.y) ? series.domain.y[1] : 1,
|
|
1371
|
+
};
|
|
1372
|
+
domainX.push(domainXInfo);
|
|
1373
|
+
domainY.push(domainYInfo);
|
|
1299
1374
|
}
|
|
1300
1375
|
});
|
|
1301
|
-
if (
|
|
1376
|
+
if (layout !== undefined && layout !== null && Object.keys(layout).length > 0) {
|
|
1377
|
+
(_a = layout.annotations) === null || _a === void 0 ? void 0 : _a.forEach(function (annotation) {
|
|
1378
|
+
var xMatches = domainX.flatMap(function (interval, idx) {
|
|
1379
|
+
return (annotation === null || annotation === void 0 ? void 0 : annotation.x) >= interval.start && (annotation === null || annotation === void 0 ? void 0 : annotation.x) <= interval.end ? [idx] : [];
|
|
1380
|
+
});
|
|
1381
|
+
var yMatch = domainY.findIndex(function (interval, yIndex) {
|
|
1382
|
+
return xMatches.includes(yIndex) &&
|
|
1383
|
+
(annotation === null || annotation === void 0 ? void 0 : annotation.y) >= interval.start &&
|
|
1384
|
+
(annotation === null || annotation === void 0 ? void 0 : annotation.y) <= interval.end;
|
|
1385
|
+
});
|
|
1386
|
+
if (yMatch !== -1) {
|
|
1387
|
+
if (annotations[yMatch] === undefined) {
|
|
1388
|
+
annotations[yMatch] = {};
|
|
1389
|
+
}
|
|
1390
|
+
if ((annotation === null || annotation === void 0 ? void 0 : annotation.textangle) === 90) {
|
|
1391
|
+
annotations[yMatch].yAnnotation = annotation.text;
|
|
1392
|
+
}
|
|
1393
|
+
else {
|
|
1394
|
+
annotations[yMatch].xAnnotation = annotation.text;
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
});
|
|
1398
|
+
}
|
|
1399
|
+
if (domainX.length > 0) {
|
|
1302
1400
|
var uniqueXIntervals_1 = new Map();
|
|
1303
|
-
|
|
1304
|
-
var key = "".concat(interval
|
|
1401
|
+
domainX.forEach(function (interval) {
|
|
1402
|
+
var key = "".concat(interval.start, "-").concat(interval.end);
|
|
1305
1403
|
if (!uniqueXIntervals_1.has(key)) {
|
|
1306
1404
|
uniqueXIntervals_1.set(key, interval);
|
|
1307
1405
|
}
|
|
1308
1406
|
});
|
|
1309
|
-
var
|
|
1310
|
-
|
|
1311
|
-
.
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
var cellName = "x".concat(index === 0 ? '' : index + 1);
|
|
1407
|
+
var sortedXStart_1 = Array.from(uniqueXIntervals_1.values())
|
|
1408
|
+
.map(function (interval) { return interval.start; })
|
|
1409
|
+
.sort();
|
|
1410
|
+
templateColumns = "repeat(".concat(sortedXStart_1.length, ", 1fr)");
|
|
1411
|
+
domainX.forEach(function (interval, index) {
|
|
1412
|
+
var cellName = index >= cartesianDomains
|
|
1413
|
+
? "".concat(exports.NON_PLOT_KEY_PREFIX).concat(index - cartesianDomains + 1)
|
|
1414
|
+
: "x".concat(index === 0 ? '' : index + 1);
|
|
1415
|
+
var columnIndex = sortedXStart_1.findIndex(function (start) { return start === interval.start; });
|
|
1416
|
+
var columnNumber = columnIndex + 1; // Column numbers are 1-based
|
|
1320
1417
|
var annotationProps = annotations[index];
|
|
1321
1418
|
var xAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.xAnnotation;
|
|
1322
|
-
if (interval[0] < lastIntervalEnd_1) {
|
|
1323
|
-
columnNumber_1 = 1;
|
|
1324
|
-
}
|
|
1325
|
-
lastIntervalEnd_1 = interval[1];
|
|
1326
1419
|
var row = {
|
|
1327
1420
|
row: -1,
|
|
1328
|
-
column:
|
|
1421
|
+
column: columnNumber,
|
|
1329
1422
|
xAnnotation: xAnnotation,
|
|
1423
|
+
xDomain: interval,
|
|
1424
|
+
yDomain: { start: 0, end: 1 }, // Default yDomain for x-axis
|
|
1330
1425
|
};
|
|
1331
1426
|
gridLayout[cellName] = row;
|
|
1332
|
-
columnNumber_1 += 1;
|
|
1333
1427
|
});
|
|
1334
1428
|
}
|
|
1335
|
-
|
|
1336
|
-
var columnFill = {};
|
|
1337
|
-
for (var i = 1; i <= numColumns; i++) {
|
|
1338
|
-
columnFill[i] = { row: 1, fillDomain: 0 };
|
|
1339
|
-
}
|
|
1340
|
-
if (gridY.length > 0) {
|
|
1429
|
+
if (domainY.length > 0) {
|
|
1341
1430
|
var uniqueYIntervals_1 = new Map();
|
|
1342
|
-
|
|
1343
|
-
var key = "".concat(interval
|
|
1431
|
+
domainY.forEach(function (interval) {
|
|
1432
|
+
var key = "".concat(interval.start, "-").concat(interval.end);
|
|
1344
1433
|
if (!uniqueYIntervals_1.has(key)) {
|
|
1345
1434
|
uniqueYIntervals_1.set(key, interval);
|
|
1346
1435
|
}
|
|
1347
1436
|
});
|
|
1348
|
-
var
|
|
1349
|
-
|
|
1350
|
-
.
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1437
|
+
var sortedYStart_1 = Array.from(uniqueYIntervals_1.values())
|
|
1438
|
+
.map(function (interval) { return interval.start; })
|
|
1439
|
+
.sort();
|
|
1440
|
+
var numberOfRows_1 = sortedYStart_1.length;
|
|
1441
|
+
templateRows = "repeat(".concat(numberOfRows_1, ", 1fr)");
|
|
1442
|
+
domainY.forEach(function (interval, index) {
|
|
1443
|
+
var cellName = index >= cartesianDomains
|
|
1444
|
+
? "".concat(exports.NON_PLOT_KEY_PREFIX).concat(index - cartesianDomains + 1)
|
|
1445
|
+
: "x".concat(index === 0 ? '' : index + 1);
|
|
1446
|
+
var rowIndex = sortedYStart_1.findIndex(function (start) { return start === interval.start; });
|
|
1447
|
+
var rowNumber = numberOfRows_1 - rowIndex; // Rows are 1-based and we need to reverse the order for CSS grid
|
|
1357
1448
|
var annotationProps = annotations[index];
|
|
1358
1449
|
var yAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.yAnnotation;
|
|
1359
1450
|
var cell = gridLayout[cellName];
|
|
1360
1451
|
if (cell !== undefined) {
|
|
1361
|
-
cell.row =
|
|
1452
|
+
cell.row = rowNumber;
|
|
1362
1453
|
cell.yAnnotation = yAnnotation;
|
|
1454
|
+
cell.yDomain = interval;
|
|
1363
1455
|
}
|
|
1364
|
-
columnFill[cell.column].fillDomain = interval[1];
|
|
1365
|
-
columnFill[cell.column].row += 1;
|
|
1366
1456
|
});
|
|
1367
1457
|
}
|
|
1368
|
-
// reverse the order of rows in grid layout from bottom-top to top-bottom as required by CSS grid
|
|
1369
|
-
var reversedGridLayout = {};
|
|
1370
|
-
// find the maximum row number
|
|
1371
|
-
var maxRowNumber = Math.max.apply(Math, Object.values(gridLayout).map(function (cell) { var _a; return (_a = cell.row) !== null && _a !== void 0 ? _a : 0; }));
|
|
1372
|
-
// iterate over the gridLayout and reverse the row numbers
|
|
1373
|
-
Object.keys(gridLayout).forEach(function (key) {
|
|
1374
|
-
var cell = gridLayout[key];
|
|
1375
|
-
if (cell.row !== undefined) {
|
|
1376
|
-
// reverse the row number
|
|
1377
|
-
cell.row = maxRowNumber - cell.row + 1;
|
|
1378
|
-
}
|
|
1379
|
-
reversedGridLayout[key] = cell;
|
|
1380
|
-
});
|
|
1381
1458
|
return {
|
|
1382
1459
|
templateRows: templateRows,
|
|
1383
1460
|
templateColumns: templateColumns,
|
|
1384
|
-
layout:
|
|
1461
|
+
layout: gridLayout,
|
|
1385
1462
|
};
|
|
1386
1463
|
};
|
|
1387
1464
|
exports.getGridProperties = getGridProperties;
|