@fluentui/react-charting 5.24.1 → 5.24.3
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 +61 -1
- package/CHANGELOG.md +25 -2
- package/dist/react-charting.d.ts +171 -33
- package/dist/react-charting.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/etc/react-charting.api.md +60 -10
- package/lib/ScatterChart.d.ts +1 -0
- package/lib/ScatterChart.js +2 -0
- package/lib/ScatterChart.js.map +1 -0
- package/lib/components/CommonComponents/CartesianChart.base.js +45 -9
- package/lib/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.styles.js +48 -26
- package/lib/components/CommonComponents/CartesianChart.styles.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.d.ts +21 -1
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +157 -78
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +29 -13
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +351 -95
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/LineChart/LineChart.base.js +23 -17
- package/lib/components/LineChart/LineChart.base.js.map +1 -1
- package/lib/components/LineChart/LineChart.styles.js +9 -0
- package/lib/components/LineChart/LineChart.styles.js.map +1 -1
- package/lib/components/LineChart/LineChart.types.d.ts +2 -0
- package/lib/components/LineChart/LineChart.types.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.base.d.ts +7 -0
- package/lib/components/ScatterChart/ScatterChart.base.js +453 -0
- package/lib/components/ScatterChart/ScatterChart.base.js.map +1 -0
- package/lib/components/ScatterChart/ScatterChart.d.ts +7 -0
- package/lib/components/ScatterChart/ScatterChart.js +10 -0
- package/lib/components/ScatterChart/ScatterChart.js.map +1 -0
- package/lib/components/ScatterChart/ScatterChart.styles.d.ts +2 -0
- package/lib/components/ScatterChart/ScatterChart.styles.js +7 -0
- package/lib/components/ScatterChart/ScatterChart.styles.js.map +1 -0
- package/lib/components/ScatterChart/ScatterChart.types.d.ts +42 -0
- package/lib/components/ScatterChart/ScatterChart.types.js +2 -0
- package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -0
- package/lib/components/ScatterChart/index.d.ts +2 -0
- package/lib/components/ScatterChart/index.js +3 -0
- package/lib/components/ScatterChart/index.js.map +1 -0
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +8 -2
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/types/IDataPoint.d.ts +77 -11
- package/lib/types/IDataPoint.js.map +1 -1
- package/lib/utilities/SVGTooltipText.d.ts +4 -0
- package/lib/utilities/SVGTooltipText.js +1 -2
- package/lib/utilities/SVGTooltipText.js.map +1 -1
- package/lib/utilities/utilities.d.ts +27 -3
- package/lib/utilities/utilities.js +102 -1
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-amd/ScatterChart.d.ts +1 -0
- package/lib-amd/ScatterChart.js +6 -0
- package/lib-amd/ScatterChart.js.map +1 -0
- package/lib-amd/components/CommonComponents/CartesianChart.base.js +45 -9
- package/lib-amd/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-amd/components/CommonComponents/CartesianChart.styles.js +48 -26
- package/lib-amd/components/CommonComponents/CartesianChart.styles.js.map +1 -1
- package/lib-amd/components/CommonComponents/CartesianChart.types.d.ts +21 -1
- package/lib-amd/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/DeclarativeChart.js +155 -78
- package/lib-amd/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +29 -13
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +362 -102
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-amd/components/LineChart/LineChart.base.js +23 -17
- package/lib-amd/components/LineChart/LineChart.base.js.map +1 -1
- package/lib-amd/components/LineChart/LineChart.styles.js +9 -1
- package/lib-amd/components/LineChart/LineChart.styles.js.map +1 -1
- package/lib-amd/components/LineChart/LineChart.types.d.ts +2 -0
- package/lib-amd/components/LineChart/LineChart.types.js.map +1 -1
- package/lib-amd/components/ScatterChart/ScatterChart.base.d.ts +7 -0
- package/lib-amd/components/ScatterChart/ScatterChart.base.js +447 -0
- package/lib-amd/components/ScatterChart/ScatterChart.base.js.map +1 -0
- package/lib-amd/components/ScatterChart/ScatterChart.d.ts +7 -0
- package/lib-amd/components/ScatterChart/ScatterChart.js +12 -0
- package/lib-amd/components/ScatterChart/ScatterChart.js.map +1 -0
- package/lib-amd/components/ScatterChart/ScatterChart.styles.d.ts +2 -0
- package/lib-amd/components/ScatterChart/ScatterChart.styles.js +12 -0
- package/lib-amd/components/ScatterChart/ScatterChart.styles.js.map +1 -0
- package/lib-amd/components/ScatterChart/ScatterChart.types.d.ts +42 -0
- package/lib-amd/components/ScatterChart/ScatterChart.types.js +5 -0
- package/lib-amd/components/ScatterChart/ScatterChart.types.js.map +1 -0
- package/lib-amd/components/ScatterChart/index.d.ts +2 -0
- package/lib-amd/components/ScatterChart/index.js +7 -0
- package/lib-amd/components/ScatterChart/index.js.map +1 -0
- package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +8 -2
- package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
- package/lib-amd/index.d.ts +3 -1
- package/lib-amd/index.js +3 -2
- package/lib-amd/index.js.map +1 -1
- package/lib-amd/types/IDataPoint.d.ts +77 -11
- package/lib-amd/types/IDataPoint.js.map +1 -1
- package/lib-amd/utilities/SVGTooltipText.d.ts +4 -0
- package/lib-amd/utilities/SVGTooltipText.js +1 -2
- package/lib-amd/utilities/SVGTooltipText.js.map +1 -1
- package/lib-amd/utilities/utilities.d.ts +27 -3
- package/lib-amd/utilities/utilities.js +106 -2
- package/lib-amd/utilities/utilities.js.map +1 -1
- package/lib-commonjs/ScatterChart.d.ts +1 -0
- package/lib-commonjs/ScatterChart.js +5 -0
- package/lib-commonjs/ScatterChart.js.map +1 -0
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js +45 -9
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.styles.js +48 -26
- package/lib-commonjs/components/CommonComponents/CartesianChart.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.d.ts +21 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +157 -78
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +29 -13
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +361 -102
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.base.js +23 -17
- package/lib-commonjs/components/LineChart/LineChart.base.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.styles.js +9 -0
- package/lib-commonjs/components/LineChart/LineChart.styles.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.types.d.ts +2 -0
- package/lib-commonjs/components/LineChart/LineChart.types.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.base.d.ts +7 -0
- package/lib-commonjs/components/ScatterChart/ScatterChart.base.js +456 -0
- package/lib-commonjs/components/ScatterChart/ScatterChart.base.js.map +1 -0
- package/lib-commonjs/components/ScatterChart/ScatterChart.d.ts +7 -0
- package/lib-commonjs/components/ScatterChart/ScatterChart.js +13 -0
- package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -0
- package/lib-commonjs/components/ScatterChart/ScatterChart.styles.d.ts +2 -0
- package/lib-commonjs/components/ScatterChart/ScatterChart.styles.js +11 -0
- package/lib-commonjs/components/ScatterChart/ScatterChart.styles.js.map +1 -0
- package/lib-commonjs/components/ScatterChart/ScatterChart.types.d.ts +42 -0
- package/lib-commonjs/components/ScatterChart/ScatterChart.types.js +3 -0
- package/lib-commonjs/components/ScatterChart/ScatterChart.types.js.map +1 -0
- package/lib-commonjs/components/ScatterChart/index.d.ts +2 -0
- package/lib-commonjs/components/ScatterChart/index.js +6 -0
- package/lib-commonjs/components/ScatterChart/index.js.map +1 -0
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +8 -2
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
- package/lib-commonjs/index.d.ts +3 -1
- package/lib-commonjs/index.js +3 -1
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/types/IDataPoint.d.ts +77 -11
- package/lib-commonjs/types/IDataPoint.js.map +1 -1
- package/lib-commonjs/utilities/SVGTooltipText.d.ts +4 -0
- package/lib-commonjs/utilities/SVGTooltipText.js +1 -2
- package/lib-commonjs/utilities/SVGTooltipText.js.map +1 -1
- package/lib-commonjs/utilities/utilities.d.ts +27 -3
- package/lib-commonjs/utilities/utilities.js +106 -2
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +2 -2
- package/src/components/CommonComponents/CartesianChart.types.ts +25 -1
- package/src/components/LineChart/LineChart.types.ts +4 -1
- package/src/components/ScatterChart/ScatterChart.types.ts +61 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getValidXYRanges = exports.getNumberAtIndexOrDefault = exports.
|
|
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;
|
|
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");
|
|
@@ -9,7 +9,6 @@ var colors_1 = require("../../utilities/colors");
|
|
|
9
9
|
var index_1 = require("../GaugeChart/index");
|
|
10
10
|
var utilities_1 = require("../../utilities/utilities");
|
|
11
11
|
var chart_utilities_1 = require("@fluentui/chart-utilities");
|
|
12
|
-
var d3_time_format_1 = require("d3-time-format");
|
|
13
12
|
var d3_shape_1 = require("d3-shape");
|
|
14
13
|
var PlotlyColorAdapter_1 = require("./PlotlyColorAdapter");
|
|
15
14
|
var dashOptions = {
|
|
@@ -50,17 +49,6 @@ var dashOptions = {
|
|
|
50
49
|
lineBorderWidth: '4',
|
|
51
50
|
},
|
|
52
51
|
};
|
|
53
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
|
-
var isMonth = function (possiblyMonthValue) {
|
|
55
|
-
var parseFullMonth = (0, d3_time_format_1.timeParse)('%B');
|
|
56
|
-
var parseShortMonth = (0, d3_time_format_1.timeParse)('%b');
|
|
57
|
-
return parseFullMonth(possiblyMonthValue) !== null || parseShortMonth(possiblyMonthValue) !== null;
|
|
58
|
-
};
|
|
59
|
-
var isMonthArray = function (data) {
|
|
60
|
-
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
61
|
-
return (0, chart_utilities_1.isArrayOfType)(data, function (value) { return isMonth(value) || value === null; });
|
|
62
|
-
};
|
|
63
|
-
exports.isMonthArray = isMonthArray;
|
|
64
52
|
function getTitles(layout) {
|
|
65
53
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
66
54
|
var titles = {
|
|
@@ -108,8 +96,9 @@ var correctYearMonth = function (xValues) {
|
|
|
108
96
|
return xValues;
|
|
109
97
|
};
|
|
110
98
|
exports.correctYearMonth = correctYearMonth;
|
|
111
|
-
var usesSecondaryYScale = function (series) {
|
|
112
|
-
|
|
99
|
+
var usesSecondaryYScale = function (series, layout) {
|
|
100
|
+
var _a, _b;
|
|
101
|
+
return series.yaxis === 'y2' && (((_a = layout === null || layout === void 0 ? void 0 : layout.yaxis2) === null || _a === void 0 ? void 0 : _a.anchor) === 'x' || ((_b = layout === null || layout === void 0 ? void 0 : layout.yaxis2) === null || _b === void 0 ? void 0 : _b.side) === 'right');
|
|
113
102
|
};
|
|
114
103
|
var getSecondaryYAxisValues = function (data, layout, maxAllowedMinY, minAllowedMaxY) {
|
|
115
104
|
var _a, _b, _c, _d;
|
|
@@ -117,7 +106,7 @@ var getSecondaryYAxisValues = function (data, layout, maxAllowedMinY, minAllowed
|
|
|
117
106
|
var yMinValue;
|
|
118
107
|
var yMaxValue;
|
|
119
108
|
data.forEach(function (series) {
|
|
120
|
-
if (usesSecondaryYScale(series)) {
|
|
109
|
+
if (usesSecondaryYScale(series, layout)) {
|
|
121
110
|
containsSecondaryYAxis = true;
|
|
122
111
|
var yValues = series.y;
|
|
123
112
|
if (yValues) {
|
|
@@ -156,7 +145,27 @@ var _getGaugeAxisColor = function (colorway, colorwayType, color, colorMap, isDa
|
|
|
156
145
|
return (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, 0, '', colorMap, isDarkTheme);
|
|
157
146
|
};
|
|
158
147
|
exports._getGaugeAxisColor = _getGaugeAxisColor;
|
|
159
|
-
var
|
|
148
|
+
var resolveXAxisPoint = function (x, isXYearCategory, isXString, isXDate, isXNumber) {
|
|
149
|
+
if (x === null || x === undefined) {
|
|
150
|
+
return '';
|
|
151
|
+
}
|
|
152
|
+
if (isXYearCategory) {
|
|
153
|
+
return x.toString();
|
|
154
|
+
}
|
|
155
|
+
if (isXString) {
|
|
156
|
+
if (isXDate) {
|
|
157
|
+
var date = new Date(x);
|
|
158
|
+
return date;
|
|
159
|
+
}
|
|
160
|
+
if (isXNumber) {
|
|
161
|
+
return parseFloat(x);
|
|
162
|
+
}
|
|
163
|
+
return x;
|
|
164
|
+
}
|
|
165
|
+
return x;
|
|
166
|
+
};
|
|
167
|
+
exports.resolveXAxisPoint = resolveXAxisPoint;
|
|
168
|
+
var transformPlotlyJsonToDonutProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
160
169
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
161
170
|
var firstData = input.data[0];
|
|
162
171
|
// extract colors for each series only once
|
|
@@ -209,33 +218,52 @@ var transformPlotlyJsonToDonutProps = function (input, colorMap, colorwayType, i
|
|
|
209
218
|
};
|
|
210
219
|
};
|
|
211
220
|
exports.transformPlotlyJsonToDonutProps = transformPlotlyJsonToDonutProps;
|
|
212
|
-
var transformPlotlyJsonToVSBCProps = function (input, colorMap, colorwayType, isDarkTheme, fallbackVSBC) {
|
|
221
|
+
var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme, fallbackVSBC) {
|
|
213
222
|
var _a, _b, _c;
|
|
214
223
|
var mapXToDataPoints = {};
|
|
215
224
|
var yMaxValue = 0;
|
|
216
225
|
var yMinValue = 0;
|
|
217
226
|
var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
|
|
218
|
-
var _d = getLegendProps(input.data, input.layout), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
227
|
+
var _d = getLegendProps(input.data, input.layout, isMultiPlot), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
228
|
+
var colorScale = undefined;
|
|
219
229
|
input.data.forEach(function (series, index1) {
|
|
220
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
230
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
231
|
+
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) &&
|
|
232
|
+
(0, chart_utilities_1.isArrayOrTypedArray)((_d = series.marker) === null || _d === void 0 ? void 0 : _d.color) &&
|
|
233
|
+
((_e = series.marker) === null || _e === void 0 ? void 0 : _e.color).length > 0 &&
|
|
234
|
+
typeof ((_g = (_f = series.marker) === null || _f === void 0 ? void 0 : _f.color) === null || _g === void 0 ? void 0 : _g[0]) === 'number') {
|
|
235
|
+
colorScale = createColorScale(input.layout, series);
|
|
236
|
+
}
|
|
221
237
|
var isXYearCategory = (0, chart_utilities_1.isYearArray)(series.x); // Consider year as categorical not numeric continuous axis
|
|
222
238
|
// extract bar colors for each series only once
|
|
223
|
-
var extractedBarColors = (0, PlotlyColorAdapter_1.extractColor)((
|
|
239
|
+
var extractedBarColors = (0, PlotlyColorAdapter_1.extractColor)((_k = (_j = (_h = input.layout) === null || _h === void 0 ? void 0 : _h.template) === null || _j === void 0 ? void 0 : _j.layout) === null || _k === void 0 ? void 0 : _k.colorway, colorwayType, (_l = series.marker) === null || _l === void 0 ? void 0 : _l.color, colorMap, isDarkTheme);
|
|
224
240
|
// extract line colors for each series only once
|
|
225
|
-
var extractedLineColors = (0, PlotlyColorAdapter_1.extractColor)((
|
|
241
|
+
var extractedLineColors = (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, (_q = series.line) === null || _q === void 0 ? void 0 : _q.color, colorMap, isDarkTheme);
|
|
242
|
+
var xValues = series.x;
|
|
243
|
+
var isXDate = (0, chart_utilities_1.isDateArray)(xValues);
|
|
244
|
+
var isXString = (0, chart_utilities_1.isStringArray)(xValues);
|
|
245
|
+
var isXNumber = (0, chart_utilities_1.isNumberArray)(xValues);
|
|
226
246
|
var validXYRanges = (0, exports.getValidXYRanges)(series);
|
|
227
247
|
validXYRanges.forEach(function (_a, rangeIdx) {
|
|
228
248
|
var rangeStart = _a[0], rangeEnd = _a[1];
|
|
229
249
|
var rangeXValues = series.x.slice(rangeStart, rangeEnd);
|
|
230
250
|
var rangeYValues = series.y.slice(rangeStart, rangeEnd);
|
|
231
251
|
rangeXValues.forEach(function (x, index2) {
|
|
232
|
-
var _a, _b;
|
|
252
|
+
var _a, _b, _c, _d;
|
|
233
253
|
if (!mapXToDataPoints[x]) {
|
|
234
|
-
mapXToDataPoints[x] = {
|
|
254
|
+
mapXToDataPoints[x] = {
|
|
255
|
+
xAxisPoint: (0, exports.resolveXAxisPoint)(x, isXYearCategory, isXString, isXDate, isXNumber),
|
|
256
|
+
chartData: [],
|
|
257
|
+
lineData: [],
|
|
258
|
+
};
|
|
235
259
|
}
|
|
236
260
|
var legend = legends[index1];
|
|
237
|
-
// resolve color for each legend's bars from the extracted colors
|
|
238
|
-
var color =
|
|
261
|
+
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
262
|
+
var color = colorScale
|
|
263
|
+
? colorScale((0, chart_utilities_1.isArrayOrTypedArray)((_a = series.marker) === null || _a === void 0 ? void 0 : _a.color)
|
|
264
|
+
? (_c = (_b = series.marker) === null || _b === void 0 ? void 0 : _b.color) === null || _c === void 0 ? void 0 : _c[index2 % ((_d = series.marker) === null || _d === void 0 ? void 0 : _d.color).length]
|
|
265
|
+
: 0)
|
|
266
|
+
: (0, PlotlyColorAdapter_1.resolveColor)(extractedBarColors, index2, legend, colorMap, isDarkTheme);
|
|
239
267
|
var yVal = rangeYValues[index2];
|
|
240
268
|
if (series.type === 'bar') {
|
|
241
269
|
mapXToDataPoints[x].chartData.push({
|
|
@@ -250,21 +278,16 @@ var transformPlotlyJsonToVSBCProps = function (input, colorMap, colorwayType, is
|
|
|
250
278
|
else if (series.type === 'scatter' || !!fallbackVSBC) {
|
|
251
279
|
var lineColor = (0, PlotlyColorAdapter_1.resolveColor)(extractedLineColors, index1, legend, colorMap, isDarkTheme);
|
|
252
280
|
var lineOptions = getLineOptions(series.line);
|
|
253
|
-
var
|
|
254
|
-
var legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot'
|
|
255
|
-
? 'dottedLine'
|
|
256
|
-
: ((_b = series.mode) === null || _b === void 0 ? void 0 : _b.includes('markers'))
|
|
257
|
-
? 'circle'
|
|
258
|
-
: 'default';
|
|
281
|
+
var legendShape = getLegendShape(series);
|
|
259
282
|
mapXToDataPoints[x].lineData.push({
|
|
260
283
|
legend: legend + (validXYRanges.length > 1 ? ".".concat(rangeIdx + 1) : ''),
|
|
261
284
|
legendShape: legendShape,
|
|
262
285
|
y: yVal,
|
|
263
286
|
color: lineColor,
|
|
264
287
|
lineOptions: tslib_1.__assign(tslib_1.__assign({}, (lineOptions !== null && lineOptions !== void 0 ? lineOptions : {})), { mode: series.mode }),
|
|
265
|
-
useSecondaryYScale: usesSecondaryYScale(series),
|
|
288
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout),
|
|
266
289
|
});
|
|
267
|
-
if (!usesSecondaryYScale(series) && typeof yVal === 'number') {
|
|
290
|
+
if (!usesSecondaryYScale(series, input.layout) && typeof yVal === 'number') {
|
|
268
291
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
269
292
|
yMinValue = Math.min(yMinValue, yVal);
|
|
270
293
|
}
|
|
@@ -276,40 +299,40 @@ var transformPlotlyJsonToVSBCProps = function (input, colorMap, colorwayType, is
|
|
|
276
299
|
return 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 });
|
|
277
300
|
};
|
|
278
301
|
exports.transformPlotlyJsonToVSBCProps = transformPlotlyJsonToVSBCProps;
|
|
279
|
-
var createColorScale = function (
|
|
280
|
-
var
|
|
302
|
+
var createColorScale = function (layout, series) {
|
|
303
|
+
var _a, _b, _c, _d, _e, _f;
|
|
304
|
+
var scale = (_a = layout === null || layout === void 0 ? void 0 : layout.coloraxis) === null || _a === void 0 ? void 0 : _a.colorscale;
|
|
305
|
+
var colorValues = (_b = series.marker) === null || _b === void 0 ? void 0 : _b.color;
|
|
306
|
+
var _g = [
|
|
307
|
+
(_d = (_c = layout === null || layout === void 0 ? void 0 : layout.coloraxis) === null || _c === void 0 ? void 0 : _c.cmin) !== null && _d !== void 0 ? _d : Math.min.apply(Math, colorValues),
|
|
308
|
+
(_f = (_e = layout === null || layout === void 0 ? void 0 : layout.coloraxis) === null || _e === void 0 ? void 0 : _e.cmax) !== null && _f !== void 0 ? _f : Math.max.apply(Math, colorValues),
|
|
309
|
+
], dMin = _g[0], dMax = _g[1];
|
|
281
310
|
// Normalize colorscale domain to actual data domain
|
|
282
|
-
var scaleDomain =
|
|
311
|
+
var scaleDomain = scale.map(function (_a) {
|
|
283
312
|
var pos = _a[0];
|
|
284
313
|
return dMin + pos * (dMax - dMin);
|
|
285
314
|
});
|
|
286
|
-
var scaleColors =
|
|
315
|
+
var scaleColors = scale.map(function (item) { return item[1]; });
|
|
287
316
|
return (0, d3_scale_1.scaleLinear)().domain(scaleDomain).range(scaleColors);
|
|
288
317
|
};
|
|
289
|
-
var transformPlotlyJsonToGVBCProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
318
|
+
var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
290
319
|
var _a, _b, _c;
|
|
291
320
|
var mapXToDataPoints = {};
|
|
292
321
|
var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, 0, 0);
|
|
293
|
-
var _d = getLegendProps(input.data, input.layout), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
322
|
+
var _d = getLegendProps(input.data, input.layout, isMultiPlot), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
294
323
|
var colorScale = undefined;
|
|
295
324
|
input.data.forEach(function (series, index1) {
|
|
296
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m
|
|
325
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
297
326
|
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) &&
|
|
298
327
|
(0, chart_utilities_1.isArrayOrTypedArray)((_d = series.marker) === null || _d === void 0 ? void 0 : _d.color) &&
|
|
299
328
|
((_e = series.marker) === null || _e === void 0 ? void 0 : _e.color).length > 0 &&
|
|
300
329
|
typeof ((_g = (_f = series.marker) === null || _f === void 0 ? void 0 : _f.color) === null || _g === void 0 ? void 0 : _g[0]) === 'number') {
|
|
301
|
-
|
|
302
|
-
var colorValues = (_h = series.marker) === null || _h === void 0 ? void 0 : _h.color;
|
|
303
|
-
var _t = [
|
|
304
|
-
(_k = (_j = input.layout.coloraxis) === null || _j === void 0 ? void 0 : _j.cmin) !== null && _k !== void 0 ? _k : Math.min.apply(Math, colorValues),
|
|
305
|
-
(_m = (_l = input.layout.coloraxis) === null || _l === void 0 ? void 0 : _l.cmax) !== null && _m !== void 0 ? _m : Math.max.apply(Math, colorValues),
|
|
306
|
-
], dMin = _t[0], dMax = _t[1];
|
|
307
|
-
colorScale = createColorScale(scale, [dMin, dMax]);
|
|
330
|
+
colorScale = createColorScale(input.layout, series);
|
|
308
331
|
}
|
|
309
332
|
// extract colors for each series only once
|
|
310
|
-
var extractedColors = (0, PlotlyColorAdapter_1.extractColor)((
|
|
311
|
-
(
|
|
312
|
-
var _a, _b, _c, _d;
|
|
333
|
+
var extractedColors = (0, PlotlyColorAdapter_1.extractColor)((_k = (_j = (_h = input.layout) === null || _h === void 0 ? void 0 : _h.template) === null || _j === void 0 ? void 0 : _j.layout) === null || _k === void 0 ? void 0 : _k.colorway, colorwayType, (_l = series.marker) === null || _l === void 0 ? void 0 : _l.color, colorMap, isDarkTheme);
|
|
334
|
+
(_m = series.x) === null || _m === void 0 ? void 0 : _m.forEach(function (x, xIndex) {
|
|
335
|
+
var _a, _b, _c, _d, _e;
|
|
313
336
|
if ((0, chart_utilities_1.isInvalidValue)(x) || (0, chart_utilities_1.isInvalidValue)((_a = series.y) === null || _a === void 0 ? void 0 : _a[xIndex])) {
|
|
314
337
|
return;
|
|
315
338
|
}
|
|
@@ -320,7 +343,9 @@ var transformPlotlyJsonToGVBCProps = function (input, colorMap, colorwayType, is
|
|
|
320
343
|
var legend = legends[index1];
|
|
321
344
|
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
322
345
|
var color = colorScale
|
|
323
|
-
? colorScale((0, chart_utilities_1.isArrayOrTypedArray)((_b = series.marker) === null || _b === void 0 ? void 0 : _b.color)
|
|
346
|
+
? colorScale((0, chart_utilities_1.isArrayOrTypedArray)((_b = series.marker) === null || _b === void 0 ? void 0 : _b.color)
|
|
347
|
+
? (_d = (_c = series.marker) === null || _c === void 0 ? void 0 : _c.color) === null || _d === void 0 ? void 0 : _d[xIndex % ((_e = series.marker) === null || _e === void 0 ? void 0 : _e.color).length]
|
|
348
|
+
: 0)
|
|
324
349
|
: (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, index1, legend, colorMap, isDarkTheme);
|
|
325
350
|
mapXToDataPoints[x].series.push({
|
|
326
351
|
key: legend,
|
|
@@ -328,7 +353,7 @@ var transformPlotlyJsonToGVBCProps = function (input, colorMap, colorwayType, is
|
|
|
328
353
|
xAxisCalloutData: x,
|
|
329
354
|
color: color,
|
|
330
355
|
legend: legend,
|
|
331
|
-
useSecondaryYScale: usesSecondaryYScale(series),
|
|
356
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout),
|
|
332
357
|
});
|
|
333
358
|
}
|
|
334
359
|
});
|
|
@@ -337,17 +362,24 @@ var transformPlotlyJsonToGVBCProps = function (input, colorMap, colorwayType, is
|
|
|
337
362
|
return 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 });
|
|
338
363
|
};
|
|
339
364
|
exports.transformPlotlyJsonToGVBCProps = transformPlotlyJsonToGVBCProps;
|
|
340
|
-
var transformPlotlyJsonToVBCProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
365
|
+
var transformPlotlyJsonToVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
341
366
|
var _a, _b, _c;
|
|
342
367
|
var vbcData = [];
|
|
343
|
-
var _d = getLegendProps(input.data, input.layout), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
368
|
+
var _d = getLegendProps(input.data, input.layout, isMultiPlot), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
369
|
+
var colorScale = undefined;
|
|
344
370
|
input.data.forEach(function (series, seriesIdx) {
|
|
345
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
371
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
346
372
|
if (!series.x) {
|
|
347
373
|
return;
|
|
348
374
|
}
|
|
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) &&
|
|
376
|
+
(0, chart_utilities_1.isArrayOrTypedArray)((_d = series.marker) === null || _d === void 0 ? void 0 : _d.color) &&
|
|
377
|
+
((_e = series.marker) === null || _e === void 0 ? void 0 : _e.color).length > 0 &&
|
|
378
|
+
typeof ((_g = (_f = series.marker) === null || _f === void 0 ? void 0 : _f.color) === null || _g === void 0 ? void 0 : _g[0]) === 'number') {
|
|
379
|
+
colorScale = createColorScale(input.layout, series);
|
|
380
|
+
}
|
|
349
381
|
// extract colors for each series only once
|
|
350
|
-
var extractedColors = (0, PlotlyColorAdapter_1.extractColor)((
|
|
382
|
+
var extractedColors = (0, PlotlyColorAdapter_1.extractColor)((_k = (_j = (_h = input.layout) === null || _h === void 0 ? void 0 : _h.template) === null || _j === void 0 ? void 0 : _j.layout) === null || _k === void 0 ? void 0 : _k.colorway, colorwayType, (_l = series.marker) === null || _l === void 0 ? void 0 : _l.color, colorMap, isDarkTheme);
|
|
351
383
|
var xValues = [];
|
|
352
384
|
var yValues = [];
|
|
353
385
|
series.x.forEach(function (xVal, index) {
|
|
@@ -358,10 +390,10 @@ var transformPlotlyJsonToVBCProps = function (input, colorMap, colorwayType, isD
|
|
|
358
390
|
xValues.push(xVal);
|
|
359
391
|
yValues.push(yVal);
|
|
360
392
|
});
|
|
361
|
-
var isXString = (0,
|
|
393
|
+
var isXString = (0, chart_utilities_1.isStringArray)(xValues);
|
|
362
394
|
// TODO: In case of a single bin, add an empty bin of the same size to prevent the
|
|
363
395
|
// default bar width from being used and ensure the bar spans the full intended range.
|
|
364
|
-
var xBins = createBins(xValues, (
|
|
396
|
+
var xBins = createBins(xValues, (_m = series.xbins) === null || _m === void 0 ? void 0 : _m.start, (_o = series.xbins) === null || _o === void 0 ? void 0 : _o.end, (_p = series.xbins) === null || _p === void 0 ? void 0 : _p.size);
|
|
365
397
|
var yBins = xBins.map(function () { return []; });
|
|
366
398
|
var total = 0;
|
|
367
399
|
xValues.forEach(function (xVal, index) {
|
|
@@ -376,9 +408,14 @@ var transformPlotlyJsonToVBCProps = function (input, colorMap, colorwayType, isD
|
|
|
376
408
|
return yVal;
|
|
377
409
|
});
|
|
378
410
|
xBins.forEach(function (bin, index) {
|
|
411
|
+
var _a, _b, _c, _d;
|
|
379
412
|
var legend = legends[seriesIdx];
|
|
380
|
-
// resolve color for each legend's bars from the extracted colors
|
|
381
|
-
var color =
|
|
413
|
+
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
414
|
+
var color = colorScale
|
|
415
|
+
? colorScale((0, chart_utilities_1.isArrayOrTypedArray)((_a = series.marker) === null || _a === void 0 ? void 0 : _a.color)
|
|
416
|
+
? (_c = (_b = series.marker) === null || _b === void 0 ? void 0 : _b.color) === null || _c === void 0 ? void 0 : _c[index % ((_d = series.marker) === null || _d === void 0 ? void 0 : _d.color).length]
|
|
417
|
+
: 0)
|
|
418
|
+
: (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
382
419
|
var yVal = calculateHistNorm(series.histnorm, y[index], total, isXString ? bin.length : getBinSize(bin));
|
|
383
420
|
vbcData.push(tslib_1.__assign({ x: isXString ? bin.join(', ') : getBinCenter(bin), y: yVal, legend: legend, color: color }, (isXString
|
|
384
421
|
? {}
|
|
@@ -402,14 +439,35 @@ var transformPlotlyJsonToVBCProps = function (input, colorMap, colorwayType, isD
|
|
|
402
439
|
};
|
|
403
440
|
};
|
|
404
441
|
exports.transformPlotlyJsonToVBCProps = transformPlotlyJsonToVBCProps;
|
|
405
|
-
var
|
|
406
|
-
|
|
442
|
+
var transformPlotlyJsonToAreaChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
443
|
+
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'area', colorMap, colorwayType, isDarkTheme);
|
|
444
|
+
};
|
|
445
|
+
exports.transformPlotlyJsonToAreaChartProps = transformPlotlyJsonToAreaChartProps;
|
|
446
|
+
var transformPlotlyJsonToLineChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
447
|
+
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'line', colorMap, colorwayType, isDarkTheme);
|
|
448
|
+
};
|
|
449
|
+
exports.transformPlotlyJsonToLineChartProps = transformPlotlyJsonToLineChartProps;
|
|
450
|
+
var transformPlotlyJsonToScatterChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
451
|
+
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'scatter', colorMap, colorwayType, isDarkTheme);
|
|
452
|
+
};
|
|
453
|
+
exports.transformPlotlyJsonToScatterChartProps = transformPlotlyJsonToScatterChartProps;
|
|
454
|
+
var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme) {
|
|
455
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
456
|
+
var isScatterMarkers = [
|
|
457
|
+
'text+markers',
|
|
458
|
+
'markers+text',
|
|
459
|
+
'lines+markers',
|
|
460
|
+
'markers+line',
|
|
461
|
+
'text+lines+markers',
|
|
462
|
+
].includes((_a = input.data[0]) === null || _a === void 0 ? void 0 : _a.mode);
|
|
463
|
+
var isAreaChart = chartType === 'area';
|
|
464
|
+
var isScatterChart = chartType === 'scatter';
|
|
407
465
|
var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
|
|
408
466
|
var mode = 'tonexty';
|
|
409
|
-
var
|
|
467
|
+
var _h = getLegendProps(input.data, input.layout, isMultiPlot), legends = _h.legends, hideLegend = _h.hideLegend;
|
|
410
468
|
var chartData = input.data
|
|
411
469
|
.map(function (series, index) {
|
|
412
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
470
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
413
471
|
var colors = isScatterMarkers
|
|
414
472
|
? ((_a = series === null || series === void 0 ? void 0 : series.mode) === null || _a === void 0 ? void 0 : _a.includes('line'))
|
|
415
473
|
? (_b = series.line) === null || _b === void 0 ? void 0 : _b.color
|
|
@@ -418,20 +476,16 @@ var transformPlotlyJsonToScatterChartProps = function (input, isAreaChart, isSca
|
|
|
418
476
|
// extract colors for each series only once
|
|
419
477
|
var extractedColors = (0, PlotlyColorAdapter_1.extractColor)((_g = (_f = (_e = input.layout) === null || _e === void 0 ? void 0 : _e.template) === null || _f === void 0 ? void 0 : _f.layout) === null || _g === void 0 ? void 0 : _g.colorway, colorwayType, colors, colorMap, isDarkTheme);
|
|
420
478
|
var xValues = series.x;
|
|
421
|
-
var
|
|
479
|
+
var isXString = (0, chart_utilities_1.isStringArray)(xValues);
|
|
422
480
|
var isXDate = (0, chart_utilities_1.isDateArray)(xValues);
|
|
423
481
|
var isXNumber = (0, chart_utilities_1.isNumberArray)(xValues);
|
|
482
|
+
var isXYearCategory = (0, chart_utilities_1.isYearArray)(series.x); // Consider year as categorical not numeric continuous axis
|
|
424
483
|
var legend = legends[index];
|
|
425
484
|
// resolve color for each legend's lines from the extracted colors
|
|
426
485
|
var seriesColor = (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
427
486
|
mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
|
|
428
487
|
var lineOptions = getLineOptions(series.line);
|
|
429
|
-
var
|
|
430
|
-
var legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot'
|
|
431
|
-
? 'dottedLine'
|
|
432
|
-
: ((_j = series.mode) === null || _j === void 0 ? void 0 : _j.includes('markers'))
|
|
433
|
-
? 'circle'
|
|
434
|
-
: 'default';
|
|
488
|
+
var legendShape = getLegendShape(series);
|
|
435
489
|
var validXYRanges = (0, exports.getValidXYRanges)(series);
|
|
436
490
|
return validXYRanges.map(function (_a, rangeIdx) {
|
|
437
491
|
var _b;
|
|
@@ -441,56 +495,71 @@ var transformPlotlyJsonToScatterChartProps = function (input, isAreaChart, isSca
|
|
|
441
495
|
var markerSizes = (0, chart_utilities_1.isArrayOrTypedArray)((_b = series.marker) === null || _b === void 0 ? void 0 : _b.size)
|
|
442
496
|
? series.marker.size.slice(rangeStart, rangeEnd)
|
|
443
497
|
: [];
|
|
498
|
+
var textValues = Array.isArray(series.text) ? series.text.slice(rangeStart, rangeEnd) : undefined;
|
|
444
499
|
return {
|
|
445
500
|
legend: legend,
|
|
446
501
|
legendShape: legendShape,
|
|
447
502
|
data: rangeXValues.map(function (x, i) {
|
|
448
503
|
var _a, _b;
|
|
449
|
-
return (tslib_1.__assign({ x:
|
|
504
|
+
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)
|
|
450
505
|
? { markerSize: markerSizes[i] }
|
|
451
506
|
: typeof ((_b = series.marker) === null || _b === void 0 ? void 0 : _b.size) === 'number'
|
|
452
507
|
? { markerSize: series.marker.size }
|
|
453
|
-
: {})));
|
|
508
|
+
: {})), (textValues ? { text: textValues[i] } : {})));
|
|
454
509
|
}),
|
|
455
510
|
color: seriesColor,
|
|
456
511
|
lineOptions: tslib_1.__assign(tslib_1.__assign({}, (lineOptions !== null && lineOptions !== void 0 ? lineOptions : {})), { mode: series.mode }),
|
|
457
|
-
useSecondaryYScale: usesSecondaryYScale(series),
|
|
512
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout),
|
|
458
513
|
};
|
|
459
514
|
});
|
|
460
515
|
})
|
|
461
516
|
.flat();
|
|
462
517
|
var yMinMaxValues = (0, utilities_1.findNumericMinMaxOfY)(chartData);
|
|
463
|
-
var
|
|
518
|
+
var _j = getTitles(input.layout), chartTitle = _j.chartTitle, xAxisTitle = _j.xAxisTitle, yAxisTitle = _j.yAxisTitle;
|
|
464
519
|
var numDataPoints = chartData.reduce(function (total, lineChartPoints) { return total + lineChartPoints.data.length; }, 0);
|
|
465
520
|
var chartProps = {
|
|
466
521
|
chartTitle: chartTitle,
|
|
467
522
|
lineChartData: chartData,
|
|
468
523
|
};
|
|
524
|
+
var scatterChartProps = {
|
|
525
|
+
chartTitle: chartTitle,
|
|
526
|
+
scatterChartData: chartData,
|
|
527
|
+
};
|
|
469
528
|
if (isAreaChart) {
|
|
470
|
-
return tslib_1.__assign(tslib_1.__assign({ data: chartProps, supportNegativeData: true, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle }, secondaryYAxisValues), { mode: mode, width: (
|
|
529
|
+
return tslib_1.__assign(tslib_1.__assign({ data: chartProps, supportNegativeData: true, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle }, secondaryYAxisValues), { mode: mode, 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 });
|
|
471
530
|
}
|
|
472
531
|
else {
|
|
473
|
-
return tslib_1.__assign(tslib_1.__assign({ data: chartProps, supportNegativeData: true, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle }, secondaryYAxisValues), { roundedTicks: true, yMinValue: yMinMaxValues.startValue, yMaxValue: yMinMaxValues.endValue, width: (
|
|
532
|
+
return tslib_1.__assign(tslib_1.__assign({ data: isScatterChart ? scatterChartProps : chartProps, supportNegativeData: true, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle }, secondaryYAxisValues), { roundedTicks: true, yMinValue: yMinMaxValues.startValue, yMaxValue: yMinMaxValues.endValue, width: (_e = input.layout) === null || _e === void 0 ? void 0 : _e.width, height: (_g = (_f = input.layout) === null || _f === void 0 ? void 0 : _f.height) !== null && _g !== void 0 ? _g : 350, hideTickOverlap: true, enableReflow: false, hideLegend: hideLegend, useUTC: false, optimizeLargeData: numDataPoints > 1000 });
|
|
474
533
|
}
|
|
475
534
|
};
|
|
476
|
-
|
|
477
|
-
var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
535
|
+
var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
478
536
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
479
|
-
var _s = getLegendProps(input.data, input.layout), legends = _s.legends, hideLegend = _s.hideLegend;
|
|
537
|
+
var _s = getLegendProps(input.data, input.layout, isMultiPlot), legends = _s.legends, hideLegend = _s.hideLegend;
|
|
538
|
+
var colorScale = undefined;
|
|
480
539
|
var chartData = input.data
|
|
481
540
|
.map(function (series, index) {
|
|
482
|
-
var _a, _b, _c, _d;
|
|
541
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
542
|
+
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) &&
|
|
543
|
+
(0, chart_utilities_1.isArrayOrTypedArray)((_d = series.marker) === null || _d === void 0 ? void 0 : _d.color) &&
|
|
544
|
+
((_e = series.marker) === null || _e === void 0 ? void 0 : _e.color).length > 0 &&
|
|
545
|
+
typeof ((_g = (_f = series.marker) === null || _f === void 0 ? void 0 : _f.color) === null || _g === void 0 ? void 0 : _g[0]) === 'number') {
|
|
546
|
+
colorScale = createColorScale(input.layout, series);
|
|
547
|
+
}
|
|
483
548
|
// extract colors for each series only once
|
|
484
|
-
var extractedColors = (0, PlotlyColorAdapter_1.extractColor)((
|
|
549
|
+
var extractedColors = (0, PlotlyColorAdapter_1.extractColor)((_k = (_j = (_h = input.layout) === null || _h === void 0 ? void 0 : _h.template) === null || _j === void 0 ? void 0 : _j.layout) === null || _k === void 0 ? void 0 : _k.colorway, colorwayType, (_l = series.marker) === null || _l === void 0 ? void 0 : _l.color, colorMap, isDarkTheme);
|
|
485
550
|
var legend = legends[index];
|
|
486
|
-
// resolve color for each legend's bars from the extracted colors
|
|
487
|
-
var color = (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
488
551
|
return series.y
|
|
489
552
|
.map(function (yValue, i) {
|
|
490
|
-
var _a;
|
|
553
|
+
var _a, _b, _c, _d, _e;
|
|
491
554
|
if ((0, chart_utilities_1.isInvalidValue)((_a = series.x) === null || _a === void 0 ? void 0 : _a[i]) || (0, chart_utilities_1.isInvalidValue)(yValue)) {
|
|
492
555
|
return null;
|
|
493
556
|
}
|
|
557
|
+
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
558
|
+
var color = colorScale
|
|
559
|
+
? colorScale((0, chart_utilities_1.isArrayOrTypedArray)((_b = series.marker) === null || _b === void 0 ? void 0 : _b.color)
|
|
560
|
+
? (_d = (_c = series.marker) === null || _c === void 0 ? void 0 : _c.color) === null || _d === void 0 ? void 0 : _d[i % ((_e = series.marker) === null || _e === void 0 ? void 0 : _e.color).length]
|
|
561
|
+
: 0)
|
|
562
|
+
: (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, i, legend, colorMap, isDarkTheme);
|
|
494
563
|
return {
|
|
495
564
|
x: series.x[i],
|
|
496
565
|
y: yValue,
|
|
@@ -533,7 +602,7 @@ var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, colorMap,
|
|
|
533
602
|
};
|
|
534
603
|
};
|
|
535
604
|
exports.transformPlotlyJsonToHorizontalBarWithAxisProps = transformPlotlyJsonToHorizontalBarWithAxisProps;
|
|
536
|
-
var transformPlotlyJsonToHeatmapProps = function (input) {
|
|
605
|
+
var transformPlotlyJsonToHeatmapProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
537
606
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8;
|
|
538
607
|
var firstData = input.data[0];
|
|
539
608
|
var heatmapDataPoints = [];
|
|
@@ -553,8 +622,8 @@ var transformPlotlyJsonToHeatmapProps = function (input) {
|
|
|
553
622
|
yValues_1.push(firstData.y[index]);
|
|
554
623
|
zValues_1.push(zVal);
|
|
555
624
|
});
|
|
556
|
-
var isXString_1 = (0,
|
|
557
|
-
var isYString_1 = (0,
|
|
625
|
+
var isXString_1 = (0, chart_utilities_1.isStringArray)(xValues_1);
|
|
626
|
+
var isYString_1 = (0, chart_utilities_1.isStringArray)(yValues_1);
|
|
558
627
|
var xBins_1 = createBins(xValues_1, (_b = firstData.xbins) === null || _b === void 0 ? void 0 : _b.start, (_c = firstData.xbins) === null || _c === void 0 ? void 0 : _c.end, (_d = firstData.xbins) === null || _d === void 0 ? void 0 : _d.size);
|
|
559
628
|
var yBins_1 = createBins(yValues_1, (_e = firstData.ybins) === null || _e === void 0 ? void 0 : _e.start, (_f = firstData.ybins) === null || _f === void 0 ? void 0 : _f.end, (_g = firstData.ybins) === null || _g === void 0 ? void 0 : _g.size);
|
|
560
629
|
var zBins_1 = yBins_1.map(function () { return xBins_1.map(function () { return []; }); });
|
|
@@ -664,7 +733,7 @@ var transformPlotlyJsonToHeatmapProps = function (input) {
|
|
|
664
733
|
};
|
|
665
734
|
};
|
|
666
735
|
exports.transformPlotlyJsonToHeatmapProps = transformPlotlyJsonToHeatmapProps;
|
|
667
|
-
var transformPlotlyJsonToSankeyProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
736
|
+
var transformPlotlyJsonToSankeyProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
668
737
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
669
738
|
var _m = input.data[0], link = _m.link, node = _m.node;
|
|
670
739
|
var validLinks = ((_a = link === null || link === void 0 ? void 0 : link.value) !== null && _a !== void 0 ? _a : [])
|
|
@@ -712,7 +781,7 @@ var transformPlotlyJsonToSankeyProps = function (input, colorMap, colorwayType,
|
|
|
712
781
|
};
|
|
713
782
|
};
|
|
714
783
|
exports.transformPlotlyJsonToSankeyProps = transformPlotlyJsonToSankeyProps;
|
|
715
|
-
var transformPlotlyJsonToGaugeProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
784
|
+
var transformPlotlyJsonToGaugeProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
716
785
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25;
|
|
717
786
|
var firstData = input.data[0];
|
|
718
787
|
var stepsColors = ((_a = firstData.gauge) === null || _a === void 0 ? void 0 : _a.steps) ? firstData.gauge.steps.map(function (step) { return step.color; }) : undefined;
|
|
@@ -812,7 +881,7 @@ var formatValue = function (value, colIndex, cells) {
|
|
|
812
881
|
}
|
|
813
882
|
return "".concat(prefix !== null && prefix !== void 0 ? prefix : '').concat(formatted).concat(suffix !== null && suffix !== void 0 ? suffix : '');
|
|
814
883
|
};
|
|
815
|
-
var transformPlotlyJsonToChartTableProps = function (input, colorMap, isDarkTheme) {
|
|
884
|
+
var transformPlotlyJsonToChartTableProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
816
885
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
817
886
|
var tableData = input.data[0];
|
|
818
887
|
var normalizeHeaders = function (values, header) {
|
|
@@ -1018,12 +1087,6 @@ function getLineOptions(line) {
|
|
|
1018
1087
|
}
|
|
1019
1088
|
return Object.keys(lineOptions).length > 0 ? lineOptions : undefined;
|
|
1020
1089
|
}
|
|
1021
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1022
|
-
var isStringArray = function (arr) {
|
|
1023
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1024
|
-
return (0, chart_utilities_1.isArrayOfType)(arr, function (value) { return typeof value === 'string' || value === null; });
|
|
1025
|
-
};
|
|
1026
|
-
exports.isStringArray = isStringArray;
|
|
1027
1090
|
// TODO: Use binary search to find the appropriate bin for numeric value.
|
|
1028
1091
|
var findBinIndex = function (bins, value, isString) {
|
|
1029
1092
|
if (typeof value === 'undefined' || value === null) {
|
|
@@ -1047,7 +1110,7 @@ var createBins = function (data, binStart, binEnd, binSize) {
|
|
|
1047
1110
|
if (!data || data.length === 0) {
|
|
1048
1111
|
return [];
|
|
1049
1112
|
}
|
|
1050
|
-
if ((0,
|
|
1113
|
+
if ((0, chart_utilities_1.isStringArray)(data)) {
|
|
1051
1114
|
var categories_1 = Array.from(new Set(data));
|
|
1052
1115
|
var start = typeof binStart === 'number' ? Math.ceil(binStart) : 0;
|
|
1053
1116
|
var stop_1 = typeof binEnd === 'number' ? Math.floor(binEnd) + 1 : categories_1.length;
|
|
@@ -1118,7 +1181,48 @@ var precisionRound = function (value, precision) {
|
|
|
1118
1181
|
var factor = Math.pow(10, precision);
|
|
1119
1182
|
return Math.round(value * factor) / factor;
|
|
1120
1183
|
};
|
|
1121
|
-
var
|
|
1184
|
+
var getLegendShape = function (series) {
|
|
1185
|
+
var _a, _b;
|
|
1186
|
+
var dashType = ((_a = series.line) === null || _a === void 0 ? void 0 : _a.dash) || 'solid';
|
|
1187
|
+
if (dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot') {
|
|
1188
|
+
return 'dottedLine';
|
|
1189
|
+
}
|
|
1190
|
+
else if ((_b = series.mode) === null || _b === void 0 ? void 0 : _b.includes('markers')) {
|
|
1191
|
+
return 'circle';
|
|
1192
|
+
}
|
|
1193
|
+
return 'default';
|
|
1194
|
+
};
|
|
1195
|
+
var getAllupLegendsProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
1196
|
+
var allupLegends = [];
|
|
1197
|
+
// reduce on showlegend boolean propperty. reduce should return true if at least one series has showlegend true
|
|
1198
|
+
var toShowLegend = input.data.reduce(function (acc, series) {
|
|
1199
|
+
return acc || series.showlegend === true;
|
|
1200
|
+
}, false);
|
|
1201
|
+
if (toShowLegend) {
|
|
1202
|
+
input.data.forEach(function (series, index) {
|
|
1203
|
+
var _a, _b, _c, _d, _e;
|
|
1204
|
+
var name = series.legendgroup;
|
|
1205
|
+
var color = ((_a = series.line) === null || _a === void 0 ? void 0 : _a.color) || ((_b = series.marker) === null || _b === void 0 ? void 0 : _b.color);
|
|
1206
|
+
var legendShape = getLegendShape(series);
|
|
1207
|
+
var resolvedColor = (0, PlotlyColorAdapter_1.extractColor)((_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, color, colorMap, isDarkTheme);
|
|
1208
|
+
if (name !== undefined && allupLegends.some(function (group) { return group.title === name; }) === false) {
|
|
1209
|
+
allupLegends.push({
|
|
1210
|
+
title: name,
|
|
1211
|
+
color: resolvedColor,
|
|
1212
|
+
shape: legendShape,
|
|
1213
|
+
});
|
|
1214
|
+
}
|
|
1215
|
+
});
|
|
1216
|
+
}
|
|
1217
|
+
return {
|
|
1218
|
+
legends: allupLegends,
|
|
1219
|
+
centerLegends: true,
|
|
1220
|
+
enabledWrapLines: true,
|
|
1221
|
+
canSelectMultipleLegends: true,
|
|
1222
|
+
};
|
|
1223
|
+
};
|
|
1224
|
+
exports.getAllupLegendsProps = getAllupLegendsProps;
|
|
1225
|
+
var getLegendProps = function (data, layout, isMultiPlot) {
|
|
1122
1226
|
var legends = [];
|
|
1123
1227
|
if (data.length === 1) {
|
|
1124
1228
|
legends.push(data[0].name || '');
|
|
@@ -1128,10 +1232,11 @@ var getLegendProps = function (data, layout) {
|
|
|
1128
1232
|
legends.push(series.name || "Series ".concat(index + 1));
|
|
1129
1233
|
});
|
|
1130
1234
|
}
|
|
1131
|
-
var
|
|
1235
|
+
var hideLegendsData = data.every(function (series) { return series.showlegend === false; });
|
|
1236
|
+
var hideLegendsInferred = (layout === null || layout === void 0 ? void 0 : layout.showlegend) === false || ((layout === null || layout === void 0 ? void 0 : layout.showlegend) !== true && legends.length < 2);
|
|
1132
1237
|
return {
|
|
1133
1238
|
legends: legends,
|
|
1134
|
-
hideLegend:
|
|
1239
|
+
hideLegend: isMultiPlot || hideLegendsInferred || hideLegendsData,
|
|
1135
1240
|
};
|
|
1136
1241
|
};
|
|
1137
1242
|
var getNumberAtIndexOrDefault = function (data, index) {
|
|
@@ -1165,4 +1270,158 @@ var getValidXYRanges = function (series) {
|
|
|
1165
1270
|
return ranges;
|
|
1166
1271
|
};
|
|
1167
1272
|
exports.getValidXYRanges = getValidXYRanges;
|
|
1273
|
+
var getIndexFromKey = function (key, pattern) {
|
|
1274
|
+
var normalizedKey = key.replace(pattern, '') === '' ? '1' : key.replace(pattern, '');
|
|
1275
|
+
return parseInt(normalizedKey, 10) - 1;
|
|
1276
|
+
};
|
|
1277
|
+
var getGridProperties = function (layout, isMultiPlot) {
|
|
1278
|
+
var _a;
|
|
1279
|
+
var gridX = [];
|
|
1280
|
+
var gridY = [];
|
|
1281
|
+
var annotations = {};
|
|
1282
|
+
var templateRows = '1fr';
|
|
1283
|
+
var templateColumns = '1fr';
|
|
1284
|
+
var gridLayout = {};
|
|
1285
|
+
if (layout === undefined || layout === null || Object.keys(layout).length === 0) {
|
|
1286
|
+
return { templateRows: templateRows, templateColumns: templateColumns, layout: gridLayout };
|
|
1287
|
+
}
|
|
1288
|
+
if (!layout.xaxis || !layout.yaxis) {
|
|
1289
|
+
return { templateRows: templateRows, templateColumns: templateColumns, layout: gridLayout };
|
|
1290
|
+
}
|
|
1291
|
+
if (!isMultiPlot) {
|
|
1292
|
+
return { templateRows: templateRows, templateColumns: templateColumns, layout: gridLayout };
|
|
1293
|
+
}
|
|
1294
|
+
Object.keys(layout).forEach(function (key) {
|
|
1295
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
1296
|
+
if (key.startsWith('xaxis')) {
|
|
1297
|
+
var index = getIndexFromKey(key, 'xaxis');
|
|
1298
|
+
var anchor = (_b = (_a = layout[key]) === null || _a === void 0 ? void 0 : _a.anchor) !== null && _b !== void 0 ? _b : 'y';
|
|
1299
|
+
var anchorIndex = getIndexFromKey(anchor, 'y');
|
|
1300
|
+
if (index !== anchorIndex) {
|
|
1301
|
+
throw new Error("Invalid layout: xaxis ".concat(index + 1, " anchor should be y").concat(anchorIndex + 1));
|
|
1302
|
+
}
|
|
1303
|
+
gridX[index] = (_d = (_c = layout[key]) === null || _c === void 0 ? void 0 : _c.domain) !== null && _d !== void 0 ? _d : [];
|
|
1304
|
+
}
|
|
1305
|
+
else if (key.startsWith('yaxis')) {
|
|
1306
|
+
var index = getIndexFromKey(key, 'yaxis');
|
|
1307
|
+
var anchor = (_f = (_e = layout[key]) === null || _e === void 0 ? void 0 : _e.anchor) !== null && _f !== void 0 ? _f : 'x';
|
|
1308
|
+
var anchorIndex = getIndexFromKey(anchor, 'x');
|
|
1309
|
+
if (index !== anchorIndex) {
|
|
1310
|
+
if ((index === 1 && anchorIndex === 0) || ((_g = layout.yaxis2) === null || _g === void 0 ? void 0 : _g.side) === 'right') {
|
|
1311
|
+
// Special case for secondary y axis where yaxis2 can anchor to x1
|
|
1312
|
+
return { templateRows: templateRows, templateColumns: templateColumns };
|
|
1313
|
+
}
|
|
1314
|
+
throw new Error("Invalid layout: yaxis ".concat(index + 1, " anchor should be x").concat(anchorIndex + 1));
|
|
1315
|
+
}
|
|
1316
|
+
gridY[index] = (_j = (_h = layout[key]) === null || _h === void 0 ? void 0 : _h.domain) !== null && _j !== void 0 ? _j : [];
|
|
1317
|
+
}
|
|
1318
|
+
});
|
|
1319
|
+
(_a = layout.annotations) === null || _a === void 0 ? void 0 : _a.forEach(function (annotation) {
|
|
1320
|
+
var xMatches = gridX.flatMap(function (interval, idx) {
|
|
1321
|
+
return (annotation === null || annotation === void 0 ? void 0 : annotation.x) >= interval[0] && (annotation === null || annotation === void 0 ? void 0 : annotation.x) <= interval[1] ? [idx] : [];
|
|
1322
|
+
});
|
|
1323
|
+
var yMatch = gridY.findIndex(function (interval, yIndex) {
|
|
1324
|
+
return xMatches.includes(yIndex) &&
|
|
1325
|
+
(annotation === null || annotation === void 0 ? void 0 : annotation.y) >= interval[0] &&
|
|
1326
|
+
(annotation === null || annotation === void 0 ? void 0 : annotation.y) <= interval[1];
|
|
1327
|
+
});
|
|
1328
|
+
if (yMatch !== -1) {
|
|
1329
|
+
if (annotations[yMatch] === undefined) {
|
|
1330
|
+
annotations[yMatch] = {};
|
|
1331
|
+
}
|
|
1332
|
+
if ((annotation === null || annotation === void 0 ? void 0 : annotation.textangle) === 90) {
|
|
1333
|
+
annotations[yMatch].yAnnotation = annotation.text;
|
|
1334
|
+
}
|
|
1335
|
+
else {
|
|
1336
|
+
annotations[yMatch].xAnnotation = annotation.text;
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
});
|
|
1340
|
+
if (gridX.length > 0) {
|
|
1341
|
+
var uniqueXIntervals_1 = new Map();
|
|
1342
|
+
gridX.forEach(function (interval) {
|
|
1343
|
+
var key = "".concat(interval[0], "-").concat(interval[1]);
|
|
1344
|
+
if (!uniqueXIntervals_1.has(key)) {
|
|
1345
|
+
uniqueXIntervals_1.set(key, interval);
|
|
1346
|
+
}
|
|
1347
|
+
});
|
|
1348
|
+
var minXInterval_1 = Math.min.apply(Math, Array.from(uniqueXIntervals_1.values()).map(function (interval) { return interval[1] - interval[0]; }));
|
|
1349
|
+
templateColumns = Array.from(uniqueXIntervals_1.values())
|
|
1350
|
+
.map(function (interval) { return "".concat((interval[1] - interval[0]) / minXInterval_1, "fr"); })
|
|
1351
|
+
.join(' ');
|
|
1352
|
+
var columnNumber_1 = 1;
|
|
1353
|
+
var lastIntervalEnd_1 = 0;
|
|
1354
|
+
gridX.forEach(function (interval, index) {
|
|
1355
|
+
if (interval.length === 0) {
|
|
1356
|
+
return;
|
|
1357
|
+
}
|
|
1358
|
+
var cellName = "x".concat(index === 0 ? '' : index + 1);
|
|
1359
|
+
var annotationProps = annotations[index];
|
|
1360
|
+
var xAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.xAnnotation;
|
|
1361
|
+
if (interval[0] < lastIntervalEnd_1) {
|
|
1362
|
+
columnNumber_1 = 1;
|
|
1363
|
+
}
|
|
1364
|
+
lastIntervalEnd_1 = interval[1];
|
|
1365
|
+
var row = {
|
|
1366
|
+
row: -1,
|
|
1367
|
+
column: columnNumber_1,
|
|
1368
|
+
xAnnotation: xAnnotation,
|
|
1369
|
+
};
|
|
1370
|
+
gridLayout[cellName] = row;
|
|
1371
|
+
columnNumber_1 += 1;
|
|
1372
|
+
});
|
|
1373
|
+
}
|
|
1374
|
+
var numColumns = Math.max.apply(Math, Object.values(gridLayout).map(function (cell) { var _a; return (_a = cell.column) !== null && _a !== void 0 ? _a : 0; }));
|
|
1375
|
+
var columnFill = {};
|
|
1376
|
+
for (var i = 1; i <= numColumns; i++) {
|
|
1377
|
+
columnFill[i] = { row: 1, fillDomain: 0 };
|
|
1378
|
+
}
|
|
1379
|
+
if (gridY.length > 0) {
|
|
1380
|
+
var uniqueYIntervals_1 = new Map();
|
|
1381
|
+
gridY.forEach(function (interval) {
|
|
1382
|
+
var key = "".concat(interval[0], "-").concat(interval[1]);
|
|
1383
|
+
if (!uniqueYIntervals_1.has(key)) {
|
|
1384
|
+
uniqueYIntervals_1.set(key, interval);
|
|
1385
|
+
}
|
|
1386
|
+
});
|
|
1387
|
+
var minYInterval_1 = Math.min.apply(Math, Array.from(uniqueYIntervals_1.values()).map(function (interval) { return interval[1] - interval[0]; }));
|
|
1388
|
+
templateRows = Array.from(uniqueYIntervals_1.values())
|
|
1389
|
+
.map(function (interval) { return "".concat((interval[1] - interval[0]) / minYInterval_1, "fr"); })
|
|
1390
|
+
.join(' ');
|
|
1391
|
+
gridY.forEach(function (interval, index) {
|
|
1392
|
+
if (interval.length === 0) {
|
|
1393
|
+
return;
|
|
1394
|
+
}
|
|
1395
|
+
var cellName = "x".concat(index === 0 ? '' : index + 1);
|
|
1396
|
+
var annotationProps = annotations[index];
|
|
1397
|
+
var yAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.yAnnotation;
|
|
1398
|
+
var cell = gridLayout[cellName];
|
|
1399
|
+
if (cell !== undefined) {
|
|
1400
|
+
cell.row = columnFill[cell.column].row;
|
|
1401
|
+
cell.yAnnotation = yAnnotation;
|
|
1402
|
+
}
|
|
1403
|
+
columnFill[cell.column].fillDomain = interval[1];
|
|
1404
|
+
columnFill[cell.column].row += 1;
|
|
1405
|
+
});
|
|
1406
|
+
}
|
|
1407
|
+
// reverse the order of rows in grid layout from bottom-top to top-bottom as required by CSS grid
|
|
1408
|
+
var reversedGridLayout = {};
|
|
1409
|
+
// find the maximum row number
|
|
1410
|
+
var maxRowNumber = Math.max.apply(Math, Object.values(gridLayout).map(function (cell) { var _a; return (_a = cell.row) !== null && _a !== void 0 ? _a : 0; }));
|
|
1411
|
+
// iterate over the gridLayout and reverse the row numbers
|
|
1412
|
+
Object.keys(gridLayout).forEach(function (key) {
|
|
1413
|
+
var cell = gridLayout[key];
|
|
1414
|
+
if (cell.row !== undefined) {
|
|
1415
|
+
// reverse the row number
|
|
1416
|
+
cell.row = maxRowNumber - cell.row + 1;
|
|
1417
|
+
}
|
|
1418
|
+
reversedGridLayout[key] = cell;
|
|
1419
|
+
});
|
|
1420
|
+
return {
|
|
1421
|
+
templateRows: templateRows,
|
|
1422
|
+
templateColumns: templateColumns,
|
|
1423
|
+
layout: reversedGridLayout,
|
|
1424
|
+
};
|
|
1425
|
+
};
|
|
1426
|
+
exports.getGridProperties = getGridProperties;
|
|
1168
1427
|
//# sourceMappingURL=PlotlySchemaAdapter.js.map
|