@fluentui/react-charting 5.24.4 → 5.24.6
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 +55 -1
- package/CHANGELOG.md +24 -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/AreaChart/AreaChart.styles.js +2 -2
- package/lib/components/AreaChart/AreaChart.styles.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.base.js +28 -21
- package/lib/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.styles.js +35 -58
- 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 +2 -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/GroupedVerticalBarChart/GroupedVerticalBarChart.styles.js +3 -14
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.styles.js.map +1 -1
- package/lib/components/LineChart/LineChart.styles.js +3 -11
- package/lib/components/LineChart/LineChart.styles.js.map +1 -1
- package/lib/components/SankeyChart/SankeyChart.styles.js +2 -1
- package/lib/components/SankeyChart/SankeyChart.styles.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.styles.js +3 -14
- package/lib/components/ScatterChart/ScatterChart.styles.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/VerticalBarChart/VerticalBarChart.styles.js +3 -14
- package/lib/components/VerticalBarChart/VerticalBarChart.styles.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/components/VerticalStackedBarChart/VerticalStackedBarChart.styles.js +3 -14
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.styles.js.map +1 -1
- package/lib/utilities/Common.styles.d.ts +6 -0
- package/lib/utilities/Common.styles.js +51 -0
- package/lib/utilities/Common.styles.js.map +1 -0
- package/lib/utilities/SVGTooltipText.d.ts +1 -1
- package/lib/utilities/SVGTooltipText.js +3 -3
- package/lib/utilities/SVGTooltipText.js.map +1 -1
- package/lib/utilities/index.d.ts +1 -0
- package/lib/utilities/index.js +1 -0
- package/lib/utilities/index.js.map +1 -1
- package/lib-amd/components/AreaChart/AreaChart.styles.js +2 -2
- package/lib-amd/components/AreaChart/AreaChart.styles.js.map +1 -1
- package/lib-amd/components/CommonComponents/CartesianChart.base.js +28 -21
- package/lib-amd/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-amd/components/CommonComponents/CartesianChart.styles.js +33 -57
- 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 +2 -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/GroupedVerticalBarChart/GroupedVerticalBarChart.styles.js +3 -13
- package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.styles.js.map +1 -1
- package/lib-amd/components/LineChart/LineChart.styles.js +3 -10
- package/lib-amd/components/LineChart/LineChart.styles.js.map +1 -1
- package/lib-amd/components/SankeyChart/SankeyChart.styles.js +2 -2
- package/lib-amd/components/SankeyChart/SankeyChart.styles.js.map +1 -1
- package/lib-amd/components/ScatterChart/ScatterChart.styles.js +3 -13
- package/lib-amd/components/ScatterChart/ScatterChart.styles.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/VerticalBarChart/VerticalBarChart.styles.js +3 -13
- package/lib-amd/components/VerticalBarChart/VerticalBarChart.styles.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/components/VerticalStackedBarChart/VerticalStackedBarChart.styles.js +3 -13
- package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.styles.js.map +1 -1
- package/lib-amd/utilities/Common.styles.d.ts +6 -0
- package/lib-amd/utilities/Common.styles.js +57 -0
- package/lib-amd/utilities/Common.styles.js.map +1 -0
- package/lib-amd/utilities/SVGTooltipText.d.ts +1 -1
- package/lib-amd/utilities/SVGTooltipText.js +3 -3
- package/lib-amd/utilities/SVGTooltipText.js.map +1 -1
- package/lib-amd/utilities/index.d.ts +1 -0
- package/lib-amd/utilities/index.js +2 -1
- package/lib-amd/utilities/index.js.map +1 -1
- package/lib-commonjs/components/AreaChart/AreaChart.styles.js +2 -2
- package/lib-commonjs/components/AreaChart/AreaChart.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js +28 -21
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.styles.js +33 -56
- 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 +2 -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/GroupedVerticalBarChart/GroupedVerticalBarChart.styles.js +3 -14
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.styles.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.styles.js +3 -11
- package/lib-commonjs/components/LineChart/LineChart.styles.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/SankeyChart.styles.js +2 -1
- package/lib-commonjs/components/SankeyChart/SankeyChart.styles.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.styles.js +3 -14
- package/lib-commonjs/components/ScatterChart/ScatterChart.styles.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/VerticalBarChart/VerticalBarChart.styles.js +3 -14
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.styles.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/components/VerticalStackedBarChart/VerticalStackedBarChart.styles.js +3 -14
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.styles.js.map +1 -1
- package/lib-commonjs/utilities/Common.styles.d.ts +6 -0
- package/lib-commonjs/utilities/Common.styles.js +58 -0
- package/lib-commonjs/utilities/Common.styles.js.map +1 -0
- package/lib-commonjs/utilities/SVGTooltipText.d.ts +1 -1
- package/lib-commonjs/utilities/SVGTooltipText.js +3 -3
- package/lib-commonjs/utilities/SVGTooltipText.js.map +1 -1
- package/lib-commonjs/utilities/index.d.ts +1 -0
- package/lib-commonjs/utilities/index.js +1 -0
- package/lib-commonjs/utilities/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/DonutChart/DonutChart.types.ts +5 -0
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../../utilities/colors", "../GaugeChart/index", "../../utilities/utilities", "@fluentui/chart-utilities", "d3-shape", "./PlotlyColorAdapter", "d3-color"], function (require, exports, tslib_1, d3_array_1, d3_scale_1, d3_format_1, colors_1, index_1, utilities_1, chart_utilities_1, d3_shape_1, PlotlyColorAdapter_1, d3_color_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
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;
|
|
4
|
+
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;
|
|
5
|
+
exports.NON_PLOT_KEY_PREFIX = 'nonplot_';
|
|
6
|
+
exports.SINGLE_REPEAT = 'repeat(1, 1fr)';
|
|
5
7
|
var dashOptions = {
|
|
6
8
|
dot: {
|
|
7
9
|
strokeDasharray: '1, 5',
|
|
@@ -49,6 +51,47 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
49
51
|
};
|
|
50
52
|
return titles;
|
|
51
53
|
}
|
|
54
|
+
var getXAxisTickFormat = function (series, layout) {
|
|
55
|
+
var xAxis = getXAxisProperties(series, layout);
|
|
56
|
+
if (xAxis === null || xAxis === void 0 ? void 0 : xAxis.tickformat) {
|
|
57
|
+
return {
|
|
58
|
+
tickFormat: xAxis === null || xAxis === void 0 ? void 0 : xAxis.tickformat,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return {};
|
|
62
|
+
};
|
|
63
|
+
var getYAxisTickFormat = function (series, layout) {
|
|
64
|
+
var yAxis = getYAxisProperties(series, layout);
|
|
65
|
+
if (yAxis === null || yAxis === void 0 ? void 0 : yAxis.tickformat) {
|
|
66
|
+
return {
|
|
67
|
+
yAxisTickFormat: (0, d3_format_1.format)(yAxis === null || yAxis === void 0 ? void 0 : yAxis.tickformat),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return {};
|
|
71
|
+
};
|
|
72
|
+
var getYMinMaxValues = function (series, layout) {
|
|
73
|
+
var _a;
|
|
74
|
+
var range = (_a = getYAxisProperties(series, layout)) === null || _a === void 0 ? void 0 : _a.range;
|
|
75
|
+
if (range && range.length === 2) {
|
|
76
|
+
return {
|
|
77
|
+
yMinValue: range[0],
|
|
78
|
+
yMaxValue: range[1],
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
return {};
|
|
82
|
+
};
|
|
83
|
+
var getYAxisProperties = function (series, layout) {
|
|
84
|
+
return layout === null || layout === void 0 ? void 0 : layout.yaxis;
|
|
85
|
+
};
|
|
86
|
+
var getXAxisProperties = function (series, layout) {
|
|
87
|
+
return layout === null || layout === void 0 ? void 0 : layout.xaxis;
|
|
88
|
+
};
|
|
89
|
+
var getFormattedCalloutYData = function (yVal, yAxisFormat) {
|
|
90
|
+
if (typeof (yAxisFormat === null || yAxisFormat === void 0 ? void 0 : yAxisFormat.yAxisTickFormat) === 'function' && typeof yVal === 'number') {
|
|
91
|
+
return yAxisFormat.yAxisTickFormat(yVal);
|
|
92
|
+
}
|
|
93
|
+
return (0, chart_utilities_1.formatToLocaleString)(yVal);
|
|
94
|
+
};
|
|
52
95
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53
96
|
var correctYearMonth = function (xValues) {
|
|
54
97
|
var presentYear = new Date().getFullYear();
|
|
@@ -199,7 +242,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
199
242
|
chartTitle: chartTitle,
|
|
200
243
|
chartData: Object.values(mapLegendToDataPoint),
|
|
201
244
|
},
|
|
202
|
-
hideLegend: ((_p = input.layout) === null || _p === void 0 ? void 0 : _p.showlegend) === false
|
|
245
|
+
hideLegend: isMultiPlot || ((_p = input.layout) === null || _p === void 0 ? void 0 : _p.showlegend) === false,
|
|
203
246
|
width: (_q = input.layout) === null || _q === void 0 ? void 0 : _q.width,
|
|
204
247
|
height: height,
|
|
205
248
|
innerRadius: innerRadius,
|
|
@@ -217,6 +260,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
217
260
|
var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
|
|
218
261
|
var _d = getLegendProps(input.data, input.layout, isMultiPlot), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
219
262
|
var colorScale = undefined;
|
|
263
|
+
var yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
220
264
|
input.data.forEach(function (series, index1) {
|
|
221
265
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
222
266
|
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) &&
|
|
@@ -257,11 +301,13 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
257
301
|
: (0, PlotlyColorAdapter_1.resolveColor)(extractedBarColors, index2, legend, colorMap, isDarkTheme);
|
|
258
302
|
var opacity = (0, PlotlyColorAdapter_1.getOpacity)(series, index2);
|
|
259
303
|
var yVal = rangeYValues[index2];
|
|
304
|
+
var yAxisCalloutData = getFormattedCalloutYData(yVal, yAxisTickFormat);
|
|
260
305
|
if (series.type === 'bar') {
|
|
261
306
|
mapXToDataPoints[x].chartData.push({
|
|
262
307
|
legend: legend,
|
|
263
308
|
data: yVal,
|
|
264
309
|
color: (_e = (0, d3_color_1.rgb)(color).copy({ opacity: opacity }).formatHex8()) !== null && _e !== void 0 ? _e : color,
|
|
310
|
+
yAxisCalloutData: yAxisCalloutData,
|
|
265
311
|
});
|
|
266
312
|
if (typeof yVal === 'number') {
|
|
267
313
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
@@ -278,6 +324,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
278
324
|
color: (_f = (0, d3_color_1.rgb)(lineColor).copy({ opacity: opacity }).formatHex8()) !== null && _f !== void 0 ? _f : color,
|
|
279
325
|
lineOptions: tslib_1.__assign(tslib_1.__assign({}, (lineOptions !== null && lineOptions !== void 0 ? lineOptions : {})), { mode: series.mode }),
|
|
280
326
|
useSecondaryYScale: usesSecondaryYScale(series, input.layout),
|
|
327
|
+
yAxisCalloutData: yAxisCalloutData,
|
|
281
328
|
});
|
|
282
329
|
if (!usesSecondaryYScale(series, input.layout) && typeof yVal === 'number') {
|
|
283
330
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
@@ -287,8 +334,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
287
334
|
});
|
|
288
335
|
});
|
|
289
336
|
});
|
|
290
|
-
|
|
291
|
-
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));
|
|
337
|
+
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);
|
|
292
338
|
};
|
|
293
339
|
exports.transformPlotlyJsonToVSBCProps = transformPlotlyJsonToVSBCProps;
|
|
294
340
|
var createColorScale = function (layout, series) {
|
|
@@ -313,6 +359,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
313
359
|
var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, 0, 0);
|
|
314
360
|
var _d = getLegendProps(input.data, input.layout, isMultiPlot), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
315
361
|
var colorScale = undefined;
|
|
362
|
+
var yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
316
363
|
input.data.forEach(function (series, index1) {
|
|
317
364
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
318
365
|
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) &&
|
|
@@ -340,19 +387,20 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
340
387
|
: 0)
|
|
341
388
|
: (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, xIndex, legend, colorMap, isDarkTheme);
|
|
342
389
|
var opacity = (0, PlotlyColorAdapter_1.getOpacity)(series, xIndex);
|
|
390
|
+
var yVal = series.y[xIndex];
|
|
343
391
|
mapXToDataPoints[x].series.push({
|
|
344
392
|
key: legend,
|
|
345
|
-
data:
|
|
393
|
+
data: yVal,
|
|
346
394
|
xAxisCalloutData: x,
|
|
347
395
|
color: (_f = (0, d3_color_1.rgb)(color).copy({ opacity: opacity }).formatHex8()) !== null && _f !== void 0 ? _f : color,
|
|
348
396
|
legend: legend,
|
|
349
397
|
useSecondaryYScale: usesSecondaryYScale(series, input.layout),
|
|
398
|
+
yAxisCalloutData: getFormattedCalloutYData(yVal, yAxisTickFormat),
|
|
350
399
|
});
|
|
351
400
|
}
|
|
352
401
|
});
|
|
353
402
|
});
|
|
354
|
-
|
|
355
|
-
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));
|
|
403
|
+
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);
|
|
356
404
|
};
|
|
357
405
|
exports.transformPlotlyJsonToGVBCProps = transformPlotlyJsonToGVBCProps;
|
|
358
406
|
var transformPlotlyJsonToVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -416,8 +464,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
416
464
|
: { xAxisCalloutData: "[".concat(bin.x0, " - ").concat(bin.x1, ")") })));
|
|
417
465
|
});
|
|
418
466
|
});
|
|
419
|
-
|
|
420
|
-
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));
|
|
467
|
+
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));
|
|
421
468
|
};
|
|
422
469
|
exports.transformPlotlyJsonToVBCProps = transformPlotlyJsonToVBCProps;
|
|
423
470
|
var transformPlotlyJsonToAreaChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -433,7 +480,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
433
480
|
};
|
|
434
481
|
exports.transformPlotlyJsonToScatterChartProps = transformPlotlyJsonToScatterChartProps;
|
|
435
482
|
var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme) {
|
|
436
|
-
var _a, _b, _c, _d
|
|
483
|
+
var _a, _b, _c, _d;
|
|
437
484
|
var isScatterMarkers = [
|
|
438
485
|
'markers',
|
|
439
486
|
'text+markers',
|
|
@@ -446,7 +493,8 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
446
493
|
var isScatterChart = chartType === 'scatter';
|
|
447
494
|
var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
|
|
448
495
|
var mode = 'tonexty';
|
|
449
|
-
var
|
|
496
|
+
var _e = getLegendProps(input.data, input.layout, isMultiPlot), legends = _e.legends, hideLegend = _e.hideLegend;
|
|
497
|
+
var yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
450
498
|
var chartData = input.data
|
|
451
499
|
.map(function (series, index) {
|
|
452
500
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
@@ -484,11 +532,11 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
484
532
|
legendShape: legendShape,
|
|
485
533
|
data: rangeXValues.map(function (x, i) {
|
|
486
534
|
var _a, _b;
|
|
487
|
-
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)
|
|
535
|
+
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)
|
|
488
536
|
? { markerSize: markerSizes[i] }
|
|
489
537
|
: typeof ((_b = series.marker) === null || _b === void 0 ? void 0 : _b.size) === 'number'
|
|
490
538
|
? { markerSize: series.marker.size }
|
|
491
|
-
: {})), (textValues ? { text: textValues[i] } : {})));
|
|
539
|
+
: {})), (textValues ? { text: textValues[i] } : {})), { yAxisCalloutData: getFormattedCalloutYData(rangeYValues[i], yAxisTickFormat) }));
|
|
492
540
|
}),
|
|
493
541
|
color: (_c = (0, d3_color_1.rgb)(seriesColor).copy({ opacity: seriesOpacity }).formatHex8()) !== null && _c !== void 0 ? _c : seriesColor,
|
|
494
542
|
lineOptions: tslib_1.__assign(tslib_1.__assign({}, (lineOptions !== null && lineOptions !== void 0 ? lineOptions : {})), { mode: series.mode }),
|
|
@@ -497,22 +545,25 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
497
545
|
});
|
|
498
546
|
})
|
|
499
547
|
.flat();
|
|
500
|
-
var
|
|
501
|
-
|
|
548
|
+
var yMinMax = getYMinMaxValues(input.data[0], input.layout);
|
|
549
|
+
if (yMinMax.yMinValue === undefined && yMinMax.yMaxValue === undefined) {
|
|
550
|
+
var yMinMaxValues = (0, utilities_1.findNumericMinMaxOfY)(chartData);
|
|
551
|
+
yMinMax.yMinValue = yMinMaxValues.startValue;
|
|
552
|
+
yMinMax.yMaxValue = yMinMaxValues.endValue;
|
|
553
|
+
}
|
|
502
554
|
var numDataPoints = chartData.reduce(function (total, lineChartPoints) { return total + lineChartPoints.data.length; }, 0);
|
|
503
555
|
var chartProps = {
|
|
504
|
-
chartTitle: chartTitle,
|
|
505
556
|
lineChartData: chartData,
|
|
506
557
|
};
|
|
507
558
|
var scatterChartProps = {
|
|
508
|
-
chartTitle: chartTitle,
|
|
509
559
|
scatterChartData: chartData,
|
|
510
560
|
};
|
|
561
|
+
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);
|
|
511
562
|
if (isAreaChart) {
|
|
512
|
-
return tslib_1.__assign(
|
|
563
|
+
return tslib_1.__assign({ data: chartProps, mode: mode }, commonProps);
|
|
513
564
|
}
|
|
514
565
|
else {
|
|
515
|
-
return tslib_1.__assign(tslib_1.__assign({ data: isScatterChart ? scatterChartProps : chartProps,
|
|
566
|
+
return tslib_1.__assign(tslib_1.__assign({ data: isScatterChart ? scatterChartProps : chartProps, roundedTicks: true, enableReflow: false }, commonProps), yMinMax);
|
|
516
567
|
}
|
|
517
568
|
};
|
|
518
569
|
var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -562,10 +613,9 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
562
613
|
var scalingFactor = 0.01;
|
|
563
614
|
var gapFactor = 1 / (1 + scalingFactor * numberOfRows);
|
|
564
615
|
var barHeight = availableHeight / (numberOfRows * (1 + gapFactor));
|
|
565
|
-
|
|
566
|
-
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'
|
|
616
|
+
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'
|
|
567
617
|
? (_m = (_l = input.layout) === null || _l === void 0 ? void 0 : _l.yaxis2) === null || _m === void 0 ? void 0 : _m.title
|
|
568
|
-
: ((_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));
|
|
618
|
+
: ((_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));
|
|
569
619
|
};
|
|
570
620
|
exports.transformPlotlyJsonToHorizontalBarWithAxisProps = transformPlotlyJsonToHorizontalBarWithAxisProps;
|
|
571
621
|
var transformPlotlyJsonToHeatmapProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -680,8 +730,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
680
730
|
var rangeValuesForColorScale = Array.isArray(colorscale)
|
|
681
731
|
? colorscale.map(function (arr) { return arr[1]; })
|
|
682
732
|
: defaultRange;
|
|
683
|
-
|
|
684
|
-
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));
|
|
733
|
+
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));
|
|
685
734
|
};
|
|
686
735
|
exports.transformPlotlyJsonToHeatmapProps = transformPlotlyJsonToHeatmapProps;
|
|
687
736
|
var transformPlotlyJsonToSankeyProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -1143,26 +1192,44 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
1143
1192
|
}
|
|
1144
1193
|
return 'default';
|
|
1145
1194
|
};
|
|
1146
|
-
var getAllupLegendsProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
1195
|
+
var getAllupLegendsProps = function (input, colorMap, colorwayType, traceInfo, isDarkTheme) {
|
|
1147
1196
|
var allupLegends = [];
|
|
1148
1197
|
// reduce on showlegend boolean propperty. reduce should return true if at least one series has showlegend true
|
|
1149
1198
|
var toShowLegend = input.data.reduce(function (acc, series) {
|
|
1150
|
-
return acc || series.showlegend === true;
|
|
1199
|
+
return (acc || series.showlegend === true || series.showlegend === undefined);
|
|
1151
1200
|
}, false);
|
|
1152
1201
|
if (toShowLegend) {
|
|
1153
1202
|
input.data.forEach(function (series, index) {
|
|
1154
|
-
var _a, _b, _c, _d, _e;
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1203
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
1204
|
+
if (traceInfo[index].type === 'donut') {
|
|
1205
|
+
var pieSeries = series;
|
|
1206
|
+
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);
|
|
1207
|
+
(_j = pieSeries.labels) === null || _j === void 0 ? void 0 : _j.forEach(function (label, labelIndex) {
|
|
1208
|
+
var legend = "".concat(label);
|
|
1209
|
+
// resolve color for each legend from the extracted colors
|
|
1210
|
+
var color = (0, PlotlyColorAdapter_1.resolveColor)(colors_2, labelIndex, legend, colorMap, isDarkTheme);
|
|
1211
|
+
if (legend !== '' && allupLegends.some(function (group) { return group.title === legend; }) === false) {
|
|
1212
|
+
allupLegends.push({
|
|
1213
|
+
title: legend,
|
|
1214
|
+
color: color,
|
|
1215
|
+
});
|
|
1216
|
+
}
|
|
1164
1217
|
});
|
|
1165
1218
|
}
|
|
1219
|
+
else if ((0, exports.isNonPlotType)(traceInfo[index].type) === false) {
|
|
1220
|
+
var plotSeries = series;
|
|
1221
|
+
var name_1 = plotSeries.legendgroup;
|
|
1222
|
+
var color = ((_k = plotSeries.line) === null || _k === void 0 ? void 0 : _k.color) || ((_l = plotSeries.marker) === null || _l === void 0 ? void 0 : _l.color);
|
|
1223
|
+
var legendShape = getLegendShape(plotSeries);
|
|
1224
|
+
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);
|
|
1225
|
+
if (name_1 !== undefined && name_1 !== '' && allupLegends.some(function (group) { return group.title === name_1; }) === false) {
|
|
1226
|
+
allupLegends.push({
|
|
1227
|
+
title: name_1,
|
|
1228
|
+
color: resolvedColor,
|
|
1229
|
+
shape: legendShape,
|
|
1230
|
+
});
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1166
1233
|
});
|
|
1167
1234
|
}
|
|
1168
1235
|
return {
|
|
@@ -1225,153 +1292,163 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
1225
1292
|
var normalizedKey = key.replace(pattern, '') === '' ? '1' : key.replace(pattern, '');
|
|
1226
1293
|
return parseInt(normalizedKey, 10) - 1;
|
|
1227
1294
|
};
|
|
1228
|
-
var
|
|
1295
|
+
var isNonPlotType = function (chartType) {
|
|
1296
|
+
return ['donut', 'sankey', 'pie'].includes(chartType);
|
|
1297
|
+
};
|
|
1298
|
+
exports.isNonPlotType = isNonPlotType;
|
|
1299
|
+
var getGridProperties = function (schema, isMultiPlot, validTracesInfo) {
|
|
1229
1300
|
var _a;
|
|
1230
|
-
var
|
|
1231
|
-
var
|
|
1301
|
+
var domainX = [];
|
|
1302
|
+
var domainY = [];
|
|
1303
|
+
var cartesianDomains = 0;
|
|
1232
1304
|
var annotations = {};
|
|
1233
1305
|
var templateRows = '1fr';
|
|
1234
1306
|
var templateColumns = '1fr';
|
|
1235
1307
|
var gridLayout = {};
|
|
1236
|
-
if (layout === undefined || layout === null || Object.keys(layout).length === 0) {
|
|
1237
|
-
return { templateRows: templateRows, templateColumns: templateColumns, layout: gridLayout };
|
|
1238
|
-
}
|
|
1239
|
-
if (!layout.xaxis || !layout.yaxis) {
|
|
1240
|
-
return { templateRows: templateRows, templateColumns: templateColumns, layout: gridLayout };
|
|
1241
|
-
}
|
|
1242
1308
|
if (!isMultiPlot) {
|
|
1243
1309
|
return { templateRows: templateRows, templateColumns: templateColumns, layout: gridLayout };
|
|
1244
1310
|
}
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
var
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1311
|
+
var layout = schema === null || schema === void 0 ? void 0 : schema.layout;
|
|
1312
|
+
if (layout !== undefined && layout !== null && Object.keys(layout).length > 0) {
|
|
1313
|
+
Object.keys(layout !== null && layout !== void 0 ? layout : {}).forEach(function (key) {
|
|
1314
|
+
var _a, _b, _c, _d, _e;
|
|
1315
|
+
if (key.startsWith('xaxis')) {
|
|
1316
|
+
var index = getIndexFromKey(key, 'xaxis');
|
|
1317
|
+
var anchor = (_b = (_a = layout[key]) === null || _a === void 0 ? void 0 : _a.anchor) !== null && _b !== void 0 ? _b : 'y';
|
|
1318
|
+
var anchorIndex = getIndexFromKey(anchor, 'y');
|
|
1319
|
+
if (index !== anchorIndex) {
|
|
1320
|
+
throw new Error("Invalid layout: xaxis ".concat(index + 1, " anchor should be y").concat(anchorIndex + 1));
|
|
1321
|
+
}
|
|
1322
|
+
var xAxisLayout = layout[key];
|
|
1323
|
+
var domainXInfo = {
|
|
1324
|
+
start: (xAxisLayout === null || xAxisLayout === void 0 ? void 0 : xAxisLayout.domain) ? xAxisLayout.domain[0] : 0,
|
|
1325
|
+
end: (xAxisLayout === null || xAxisLayout === void 0 ? void 0 : xAxisLayout.domain) ? xAxisLayout.domain[1] : 1,
|
|
1326
|
+
};
|
|
1327
|
+
domainX.push(domainXInfo);
|
|
1253
1328
|
}
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1329
|
+
else if (key.startsWith('yaxis')) {
|
|
1330
|
+
var index = getIndexFromKey(key, 'yaxis');
|
|
1331
|
+
var anchor = (_d = (_c = layout[key]) === null || _c === void 0 ? void 0 : _c.anchor) !== null && _d !== void 0 ? _d : 'x';
|
|
1332
|
+
var anchorIndex = getIndexFromKey(anchor, 'x');
|
|
1333
|
+
if (index !== anchorIndex) {
|
|
1334
|
+
if ((index === 1 && anchorIndex === 0) || ((_e = layout.yaxis2) === null || _e === void 0 ? void 0 : _e.side) === 'right') {
|
|
1335
|
+
// Special case for secondary y axis where yaxis2 can anchor to x1
|
|
1336
|
+
return { templateRows: templateRows, templateColumns: templateColumns };
|
|
1337
|
+
}
|
|
1338
|
+
throw new Error("Invalid layout: yaxis ".concat(index + 1, " anchor should be x").concat(anchorIndex + 1));
|
|
1264
1339
|
}
|
|
1265
|
-
|
|
1340
|
+
var yAxisLayout = layout[key];
|
|
1341
|
+
var domainYInfo = {
|
|
1342
|
+
start: (yAxisLayout === null || yAxisLayout === void 0 ? void 0 : yAxisLayout.domain) ? yAxisLayout.domain[0] : 0,
|
|
1343
|
+
end: (yAxisLayout === null || yAxisLayout === void 0 ? void 0 : yAxisLayout.domain) ? yAxisLayout.domain[1] : 1,
|
|
1344
|
+
};
|
|
1345
|
+
domainY.push(domainYInfo);
|
|
1266
1346
|
}
|
|
1267
|
-
gridY[index] = (_j = (_h = layout[key]) === null || _h === void 0 ? void 0 : _h.domain) !== null && _j !== void 0 ? _j : [];
|
|
1268
|
-
}
|
|
1269
|
-
});
|
|
1270
|
-
(_a = layout.annotations) === null || _a === void 0 ? void 0 : _a.forEach(function (annotation) {
|
|
1271
|
-
var xMatches = gridX.flatMap(function (interval, idx) {
|
|
1272
|
-
return (annotation === null || annotation === void 0 ? void 0 : annotation.x) >= interval[0] && (annotation === null || annotation === void 0 ? void 0 : annotation.x) <= interval[1] ? [idx] : [];
|
|
1273
1347
|
});
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1348
|
+
}
|
|
1349
|
+
cartesianDomains = domainX.length; // Assuming that the number of x and y axes is the same
|
|
1350
|
+
validTracesInfo.forEach(function (trace, index) {
|
|
1351
|
+
var _a, _b, _c, _d, _e;
|
|
1352
|
+
if ((0, exports.isNonPlotType)(trace.type)) {
|
|
1353
|
+
var series = (_a = schema === null || schema === void 0 ? void 0 : schema.data) === null || _a === void 0 ? void 0 : _a[index];
|
|
1354
|
+
var domainXInfo = {
|
|
1355
|
+
start: ((_b = series.domain) === null || _b === void 0 ? void 0 : _b.x) ? series.domain.x[0] : 0,
|
|
1356
|
+
end: ((_c = series.domain) === null || _c === void 0 ? void 0 : _c.x) ? series.domain.x[1] : 1,
|
|
1357
|
+
};
|
|
1358
|
+
var domainYInfo = {
|
|
1359
|
+
start: ((_d = series.domain) === null || _d === void 0 ? void 0 : _d.y) ? series.domain.y[0] : 0,
|
|
1360
|
+
end: ((_e = series.domain) === null || _e === void 0 ? void 0 : _e.y) ? series.domain.y[1] : 1,
|
|
1361
|
+
};
|
|
1362
|
+
domainX.push(domainXInfo);
|
|
1363
|
+
domainY.push(domainYInfo);
|
|
1289
1364
|
}
|
|
1290
1365
|
});
|
|
1291
|
-
if (
|
|
1366
|
+
if (layout !== undefined && layout !== null && Object.keys(layout).length > 0) {
|
|
1367
|
+
(_a = layout.annotations) === null || _a === void 0 ? void 0 : _a.forEach(function (annotation) {
|
|
1368
|
+
var xMatches = domainX.flatMap(function (interval, idx) {
|
|
1369
|
+
return (annotation === null || annotation === void 0 ? void 0 : annotation.x) >= interval.start && (annotation === null || annotation === void 0 ? void 0 : annotation.x) <= interval.end ? [idx] : [];
|
|
1370
|
+
});
|
|
1371
|
+
var yMatch = domainY.findIndex(function (interval, yIndex) {
|
|
1372
|
+
return xMatches.includes(yIndex) &&
|
|
1373
|
+
(annotation === null || annotation === void 0 ? void 0 : annotation.y) >= interval.start &&
|
|
1374
|
+
(annotation === null || annotation === void 0 ? void 0 : annotation.y) <= interval.end;
|
|
1375
|
+
});
|
|
1376
|
+
if (yMatch !== -1) {
|
|
1377
|
+
if (annotations[yMatch] === undefined) {
|
|
1378
|
+
annotations[yMatch] = {};
|
|
1379
|
+
}
|
|
1380
|
+
if ((annotation === null || annotation === void 0 ? void 0 : annotation.textangle) === 90) {
|
|
1381
|
+
annotations[yMatch].yAnnotation = annotation.text;
|
|
1382
|
+
}
|
|
1383
|
+
else {
|
|
1384
|
+
annotations[yMatch].xAnnotation = annotation.text;
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
});
|
|
1388
|
+
}
|
|
1389
|
+
if (domainX.length > 0) {
|
|
1292
1390
|
var uniqueXIntervals_1 = new Map();
|
|
1293
|
-
|
|
1294
|
-
var key = "".concat(interval
|
|
1391
|
+
domainX.forEach(function (interval) {
|
|
1392
|
+
var key = "".concat(interval.start, "-").concat(interval.end);
|
|
1295
1393
|
if (!uniqueXIntervals_1.has(key)) {
|
|
1296
1394
|
uniqueXIntervals_1.set(key, interval);
|
|
1297
1395
|
}
|
|
1298
1396
|
});
|
|
1299
|
-
var
|
|
1300
|
-
|
|
1301
|
-
.
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
var cellName = "x".concat(index === 0 ? '' : index + 1);
|
|
1397
|
+
var sortedXStart_1 = Array.from(uniqueXIntervals_1.values())
|
|
1398
|
+
.map(function (interval) { return interval.start; })
|
|
1399
|
+
.sort();
|
|
1400
|
+
templateColumns = "repeat(".concat(sortedXStart_1.length, ", 1fr)");
|
|
1401
|
+
domainX.forEach(function (interval, index) {
|
|
1402
|
+
var cellName = index >= cartesianDomains
|
|
1403
|
+
? "".concat(exports.NON_PLOT_KEY_PREFIX).concat(index - cartesianDomains + 1)
|
|
1404
|
+
: "x".concat(index === 0 ? '' : index + 1);
|
|
1405
|
+
var columnIndex = sortedXStart_1.findIndex(function (start) { return start === interval.start; });
|
|
1406
|
+
var columnNumber = columnIndex + 1; // Column numbers are 1-based
|
|
1310
1407
|
var annotationProps = annotations[index];
|
|
1311
1408
|
var xAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.xAnnotation;
|
|
1312
|
-
if (interval[0] < lastIntervalEnd_1) {
|
|
1313
|
-
columnNumber_1 = 1;
|
|
1314
|
-
}
|
|
1315
|
-
lastIntervalEnd_1 = interval[1];
|
|
1316
1409
|
var row = {
|
|
1317
1410
|
row: -1,
|
|
1318
|
-
column:
|
|
1411
|
+
column: columnNumber,
|
|
1319
1412
|
xAnnotation: xAnnotation,
|
|
1413
|
+
xDomain: interval,
|
|
1414
|
+
yDomain: { start: 0, end: 1 }, // Default yDomain for x-axis
|
|
1320
1415
|
};
|
|
1321
1416
|
gridLayout[cellName] = row;
|
|
1322
|
-
columnNumber_1 += 1;
|
|
1323
1417
|
});
|
|
1324
1418
|
}
|
|
1325
|
-
|
|
1326
|
-
var columnFill = {};
|
|
1327
|
-
for (var i = 1; i <= numColumns; i++) {
|
|
1328
|
-
columnFill[i] = { row: 1, fillDomain: 0 };
|
|
1329
|
-
}
|
|
1330
|
-
if (gridY.length > 0) {
|
|
1419
|
+
if (domainY.length > 0) {
|
|
1331
1420
|
var uniqueYIntervals_1 = new Map();
|
|
1332
|
-
|
|
1333
|
-
var key = "".concat(interval
|
|
1421
|
+
domainY.forEach(function (interval) {
|
|
1422
|
+
var key = "".concat(interval.start, "-").concat(interval.end);
|
|
1334
1423
|
if (!uniqueYIntervals_1.has(key)) {
|
|
1335
1424
|
uniqueYIntervals_1.set(key, interval);
|
|
1336
1425
|
}
|
|
1337
1426
|
});
|
|
1338
|
-
var
|
|
1339
|
-
|
|
1340
|
-
.
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1427
|
+
var sortedYStart_1 = Array.from(uniqueYIntervals_1.values())
|
|
1428
|
+
.map(function (interval) { return interval.start; })
|
|
1429
|
+
.sort();
|
|
1430
|
+
var numberOfRows_1 = sortedYStart_1.length;
|
|
1431
|
+
templateRows = "repeat(".concat(numberOfRows_1, ", 1fr)");
|
|
1432
|
+
domainY.forEach(function (interval, index) {
|
|
1433
|
+
var cellName = index >= cartesianDomains
|
|
1434
|
+
? "".concat(exports.NON_PLOT_KEY_PREFIX).concat(index - cartesianDomains + 1)
|
|
1435
|
+
: "x".concat(index === 0 ? '' : index + 1);
|
|
1436
|
+
var rowIndex = sortedYStart_1.findIndex(function (start) { return start === interval.start; });
|
|
1437
|
+
var rowNumber = numberOfRows_1 - rowIndex; // Rows are 1-based and we need to reverse the order for CSS grid
|
|
1347
1438
|
var annotationProps = annotations[index];
|
|
1348
1439
|
var yAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.yAnnotation;
|
|
1349
1440
|
var cell = gridLayout[cellName];
|
|
1350
1441
|
if (cell !== undefined) {
|
|
1351
|
-
cell.row =
|
|
1442
|
+
cell.row = rowNumber;
|
|
1352
1443
|
cell.yAnnotation = yAnnotation;
|
|
1444
|
+
cell.yDomain = interval;
|
|
1353
1445
|
}
|
|
1354
|
-
columnFill[cell.column].fillDomain = interval[1];
|
|
1355
|
-
columnFill[cell.column].row += 1;
|
|
1356
1446
|
});
|
|
1357
1447
|
}
|
|
1358
|
-
// reverse the order of rows in grid layout from bottom-top to top-bottom as required by CSS grid
|
|
1359
|
-
var reversedGridLayout = {};
|
|
1360
|
-
// find the maximum row number
|
|
1361
|
-
var maxRowNumber = Math.max.apply(Math, Object.values(gridLayout).map(function (cell) { var _a; return (_a = cell.row) !== null && _a !== void 0 ? _a : 0; }));
|
|
1362
|
-
// iterate over the gridLayout and reverse the row numbers
|
|
1363
|
-
Object.keys(gridLayout).forEach(function (key) {
|
|
1364
|
-
var cell = gridLayout[key];
|
|
1365
|
-
if (cell.row !== undefined) {
|
|
1366
|
-
// reverse the row number
|
|
1367
|
-
cell.row = maxRowNumber - cell.row + 1;
|
|
1368
|
-
}
|
|
1369
|
-
reversedGridLayout[key] = cell;
|
|
1370
|
-
});
|
|
1371
1448
|
return {
|
|
1372
1449
|
templateRows: templateRows,
|
|
1373
1450
|
templateColumns: templateColumns,
|
|
1374
|
-
layout:
|
|
1451
|
+
layout: gridLayout,
|
|
1375
1452
|
};
|
|
1376
1453
|
};
|
|
1377
1454
|
exports.getGridProperties = getGridProperties;
|