@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,7 +1,7 @@
|
|
|
1
|
-
define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../../utilities/colors", "../GaugeChart/index", "../../utilities/utilities", "@fluentui/chart-utilities", "d3-
|
|
1
|
+
define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../../utilities/colors", "../GaugeChart/index", "../../utilities/utilities", "@fluentui/chart-utilities", "d3-shape", "./PlotlyColorAdapter"], 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) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.getValidXYRanges = exports.getNumberAtIndexOrDefault = exports.
|
|
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;
|
|
5
5
|
var dashOptions = {
|
|
6
6
|
dot: {
|
|
7
7
|
strokeDasharray: '1, 5',
|
|
@@ -40,17 +40,6 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
40
40
|
lineBorderWidth: '4',
|
|
41
41
|
},
|
|
42
42
|
};
|
|
43
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
|
-
var isMonth = function (possiblyMonthValue) {
|
|
45
|
-
var parseFullMonth = (0, d3_time_format_1.timeParse)('%B');
|
|
46
|
-
var parseShortMonth = (0, d3_time_format_1.timeParse)('%b');
|
|
47
|
-
return parseFullMonth(possiblyMonthValue) !== null || parseShortMonth(possiblyMonthValue) !== null;
|
|
48
|
-
};
|
|
49
|
-
var isMonthArray = function (data) {
|
|
50
|
-
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
51
|
-
return (0, chart_utilities_1.isArrayOfType)(data, function (value) { return isMonth(value) || value === null; });
|
|
52
|
-
};
|
|
53
|
-
exports.isMonthArray = isMonthArray;
|
|
54
43
|
function getTitles(layout) {
|
|
55
44
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
56
45
|
var titles = {
|
|
@@ -98,8 +87,9 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
98
87
|
return xValues;
|
|
99
88
|
};
|
|
100
89
|
exports.correctYearMonth = correctYearMonth;
|
|
101
|
-
var usesSecondaryYScale = function (series) {
|
|
102
|
-
|
|
90
|
+
var usesSecondaryYScale = function (series, layout) {
|
|
91
|
+
var _a, _b;
|
|
92
|
+
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');
|
|
103
93
|
};
|
|
104
94
|
var getSecondaryYAxisValues = function (data, layout, maxAllowedMinY, minAllowedMaxY) {
|
|
105
95
|
var _a, _b, _c, _d;
|
|
@@ -107,7 +97,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
107
97
|
var yMinValue;
|
|
108
98
|
var yMaxValue;
|
|
109
99
|
data.forEach(function (series) {
|
|
110
|
-
if (usesSecondaryYScale(series)) {
|
|
100
|
+
if (usesSecondaryYScale(series, layout)) {
|
|
111
101
|
containsSecondaryYAxis = true;
|
|
112
102
|
var yValues = series.y;
|
|
113
103
|
if (yValues) {
|
|
@@ -146,7 +136,27 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
146
136
|
return (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, 0, '', colorMap, isDarkTheme);
|
|
147
137
|
};
|
|
148
138
|
exports._getGaugeAxisColor = _getGaugeAxisColor;
|
|
149
|
-
var
|
|
139
|
+
var resolveXAxisPoint = function (x, isXYearCategory, isXString, isXDate, isXNumber) {
|
|
140
|
+
if (x === null || x === undefined) {
|
|
141
|
+
return '';
|
|
142
|
+
}
|
|
143
|
+
if (isXYearCategory) {
|
|
144
|
+
return x.toString();
|
|
145
|
+
}
|
|
146
|
+
if (isXString) {
|
|
147
|
+
if (isXDate) {
|
|
148
|
+
var date = new Date(x);
|
|
149
|
+
return date;
|
|
150
|
+
}
|
|
151
|
+
if (isXNumber) {
|
|
152
|
+
return parseFloat(x);
|
|
153
|
+
}
|
|
154
|
+
return x;
|
|
155
|
+
}
|
|
156
|
+
return x;
|
|
157
|
+
};
|
|
158
|
+
exports.resolveXAxisPoint = resolveXAxisPoint;
|
|
159
|
+
var transformPlotlyJsonToDonutProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
150
160
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
151
161
|
var firstData = input.data[0];
|
|
152
162
|
// extract colors for each series only once
|
|
@@ -199,33 +209,52 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
199
209
|
};
|
|
200
210
|
};
|
|
201
211
|
exports.transformPlotlyJsonToDonutProps = transformPlotlyJsonToDonutProps;
|
|
202
|
-
var transformPlotlyJsonToVSBCProps = function (input, colorMap, colorwayType, isDarkTheme, fallbackVSBC) {
|
|
212
|
+
var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme, fallbackVSBC) {
|
|
203
213
|
var _a, _b, _c;
|
|
204
214
|
var mapXToDataPoints = {};
|
|
205
215
|
var yMaxValue = 0;
|
|
206
216
|
var yMinValue = 0;
|
|
207
217
|
var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
|
|
208
|
-
var _d = getLegendProps(input.data, input.layout), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
218
|
+
var _d = getLegendProps(input.data, input.layout, isMultiPlot), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
219
|
+
var colorScale = undefined;
|
|
209
220
|
input.data.forEach(function (series, index1) {
|
|
210
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
221
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
222
|
+
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) &&
|
|
223
|
+
(0, chart_utilities_1.isArrayOrTypedArray)((_d = series.marker) === null || _d === void 0 ? void 0 : _d.color) &&
|
|
224
|
+
((_e = series.marker) === null || _e === void 0 ? void 0 : _e.color).length > 0 &&
|
|
225
|
+
typeof ((_g = (_f = series.marker) === null || _f === void 0 ? void 0 : _f.color) === null || _g === void 0 ? void 0 : _g[0]) === 'number') {
|
|
226
|
+
colorScale = createColorScale(input.layout, series);
|
|
227
|
+
}
|
|
211
228
|
var isXYearCategory = (0, chart_utilities_1.isYearArray)(series.x); // Consider year as categorical not numeric continuous axis
|
|
212
229
|
// extract bar colors for each series only once
|
|
213
|
-
var extractedBarColors = (0, PlotlyColorAdapter_1.extractColor)((
|
|
230
|
+
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);
|
|
214
231
|
// extract line colors for each series only once
|
|
215
|
-
var extractedLineColors = (0, PlotlyColorAdapter_1.extractColor)((
|
|
232
|
+
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);
|
|
233
|
+
var xValues = series.x;
|
|
234
|
+
var isXDate = (0, chart_utilities_1.isDateArray)(xValues);
|
|
235
|
+
var isXString = (0, chart_utilities_1.isStringArray)(xValues);
|
|
236
|
+
var isXNumber = (0, chart_utilities_1.isNumberArray)(xValues);
|
|
216
237
|
var validXYRanges = (0, exports.getValidXYRanges)(series);
|
|
217
238
|
validXYRanges.forEach(function (_a, rangeIdx) {
|
|
218
239
|
var rangeStart = _a[0], rangeEnd = _a[1];
|
|
219
240
|
var rangeXValues = series.x.slice(rangeStart, rangeEnd);
|
|
220
241
|
var rangeYValues = series.y.slice(rangeStart, rangeEnd);
|
|
221
242
|
rangeXValues.forEach(function (x, index2) {
|
|
222
|
-
var _a, _b;
|
|
243
|
+
var _a, _b, _c, _d;
|
|
223
244
|
if (!mapXToDataPoints[x]) {
|
|
224
|
-
mapXToDataPoints[x] = {
|
|
245
|
+
mapXToDataPoints[x] = {
|
|
246
|
+
xAxisPoint: (0, exports.resolveXAxisPoint)(x, isXYearCategory, isXString, isXDate, isXNumber),
|
|
247
|
+
chartData: [],
|
|
248
|
+
lineData: [],
|
|
249
|
+
};
|
|
225
250
|
}
|
|
226
251
|
var legend = legends[index1];
|
|
227
|
-
// resolve color for each legend's bars from the extracted colors
|
|
228
|
-
var color =
|
|
252
|
+
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
253
|
+
var color = colorScale
|
|
254
|
+
? colorScale((0, chart_utilities_1.isArrayOrTypedArray)((_a = series.marker) === null || _a === void 0 ? void 0 : _a.color)
|
|
255
|
+
? (_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]
|
|
256
|
+
: 0)
|
|
257
|
+
: (0, PlotlyColorAdapter_1.resolveColor)(extractedBarColors, index2, legend, colorMap, isDarkTheme);
|
|
229
258
|
var yVal = rangeYValues[index2];
|
|
230
259
|
if (series.type === 'bar') {
|
|
231
260
|
mapXToDataPoints[x].chartData.push({
|
|
@@ -240,21 +269,16 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
240
269
|
else if (series.type === 'scatter' || !!fallbackVSBC) {
|
|
241
270
|
var lineColor = (0, PlotlyColorAdapter_1.resolveColor)(extractedLineColors, index1, legend, colorMap, isDarkTheme);
|
|
242
271
|
var lineOptions = getLineOptions(series.line);
|
|
243
|
-
var
|
|
244
|
-
var legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot'
|
|
245
|
-
? 'dottedLine'
|
|
246
|
-
: ((_b = series.mode) === null || _b === void 0 ? void 0 : _b.includes('markers'))
|
|
247
|
-
? 'circle'
|
|
248
|
-
: 'default';
|
|
272
|
+
var legendShape = getLegendShape(series);
|
|
249
273
|
mapXToDataPoints[x].lineData.push({
|
|
250
274
|
legend: legend + (validXYRanges.length > 1 ? ".".concat(rangeIdx + 1) : ''),
|
|
251
275
|
legendShape: legendShape,
|
|
252
276
|
y: yVal,
|
|
253
277
|
color: lineColor,
|
|
254
278
|
lineOptions: tslib_1.__assign(tslib_1.__assign({}, (lineOptions !== null && lineOptions !== void 0 ? lineOptions : {})), { mode: series.mode }),
|
|
255
|
-
useSecondaryYScale: usesSecondaryYScale(series),
|
|
279
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout),
|
|
256
280
|
});
|
|
257
|
-
if (!usesSecondaryYScale(series) && typeof yVal === 'number') {
|
|
281
|
+
if (!usesSecondaryYScale(series, input.layout) && typeof yVal === 'number') {
|
|
258
282
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
259
283
|
yMinValue = Math.min(yMinValue, yVal);
|
|
260
284
|
}
|
|
@@ -266,40 +290,40 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
266
290
|
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 });
|
|
267
291
|
};
|
|
268
292
|
exports.transformPlotlyJsonToVSBCProps = transformPlotlyJsonToVSBCProps;
|
|
269
|
-
var createColorScale = function (
|
|
270
|
-
var
|
|
293
|
+
var createColorScale = function (layout, series) {
|
|
294
|
+
var _a, _b, _c, _d, _e, _f;
|
|
295
|
+
var scale = (_a = layout === null || layout === void 0 ? void 0 : layout.coloraxis) === null || _a === void 0 ? void 0 : _a.colorscale;
|
|
296
|
+
var colorValues = (_b = series.marker) === null || _b === void 0 ? void 0 : _b.color;
|
|
297
|
+
var _g = [
|
|
298
|
+
(_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),
|
|
299
|
+
(_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),
|
|
300
|
+
], dMin = _g[0], dMax = _g[1];
|
|
271
301
|
// Normalize colorscale domain to actual data domain
|
|
272
|
-
var scaleDomain =
|
|
302
|
+
var scaleDomain = scale.map(function (_a) {
|
|
273
303
|
var pos = _a[0];
|
|
274
304
|
return dMin + pos * (dMax - dMin);
|
|
275
305
|
});
|
|
276
|
-
var scaleColors =
|
|
306
|
+
var scaleColors = scale.map(function (item) { return item[1]; });
|
|
277
307
|
return (0, d3_scale_1.scaleLinear)().domain(scaleDomain).range(scaleColors);
|
|
278
308
|
};
|
|
279
|
-
var transformPlotlyJsonToGVBCProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
309
|
+
var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
280
310
|
var _a, _b, _c;
|
|
281
311
|
var mapXToDataPoints = {};
|
|
282
312
|
var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, 0, 0);
|
|
283
|
-
var _d = getLegendProps(input.data, input.layout), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
313
|
+
var _d = getLegendProps(input.data, input.layout, isMultiPlot), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
284
314
|
var colorScale = undefined;
|
|
285
315
|
input.data.forEach(function (series, index1) {
|
|
286
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m
|
|
316
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
287
317
|
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) &&
|
|
288
318
|
(0, chart_utilities_1.isArrayOrTypedArray)((_d = series.marker) === null || _d === void 0 ? void 0 : _d.color) &&
|
|
289
319
|
((_e = series.marker) === null || _e === void 0 ? void 0 : _e.color).length > 0 &&
|
|
290
320
|
typeof ((_g = (_f = series.marker) === null || _f === void 0 ? void 0 : _f.color) === null || _g === void 0 ? void 0 : _g[0]) === 'number') {
|
|
291
|
-
|
|
292
|
-
var colorValues = (_h = series.marker) === null || _h === void 0 ? void 0 : _h.color;
|
|
293
|
-
var _t = [
|
|
294
|
-
(_k = (_j = input.layout.coloraxis) === null || _j === void 0 ? void 0 : _j.cmin) !== null && _k !== void 0 ? _k : Math.min.apply(Math, colorValues),
|
|
295
|
-
(_m = (_l = input.layout.coloraxis) === null || _l === void 0 ? void 0 : _l.cmax) !== null && _m !== void 0 ? _m : Math.max.apply(Math, colorValues),
|
|
296
|
-
], dMin = _t[0], dMax = _t[1];
|
|
297
|
-
colorScale = createColorScale(scale, [dMin, dMax]);
|
|
321
|
+
colorScale = createColorScale(input.layout, series);
|
|
298
322
|
}
|
|
299
323
|
// extract colors for each series only once
|
|
300
|
-
var extractedColors = (0, PlotlyColorAdapter_1.extractColor)((
|
|
301
|
-
(
|
|
302
|
-
var _a, _b, _c, _d;
|
|
324
|
+
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);
|
|
325
|
+
(_m = series.x) === null || _m === void 0 ? void 0 : _m.forEach(function (x, xIndex) {
|
|
326
|
+
var _a, _b, _c, _d, _e;
|
|
303
327
|
if ((0, chart_utilities_1.isInvalidValue)(x) || (0, chart_utilities_1.isInvalidValue)((_a = series.y) === null || _a === void 0 ? void 0 : _a[xIndex])) {
|
|
304
328
|
return;
|
|
305
329
|
}
|
|
@@ -310,7 +334,9 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
310
334
|
var legend = legends[index1];
|
|
311
335
|
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
312
336
|
var color = colorScale
|
|
313
|
-
? colorScale((0, chart_utilities_1.isArrayOrTypedArray)((_b = series.marker) === null || _b === void 0 ? void 0 : _b.color)
|
|
337
|
+
? colorScale((0, chart_utilities_1.isArrayOrTypedArray)((_b = series.marker) === null || _b === void 0 ? void 0 : _b.color)
|
|
338
|
+
? (_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]
|
|
339
|
+
: 0)
|
|
314
340
|
: (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, index1, legend, colorMap, isDarkTheme);
|
|
315
341
|
mapXToDataPoints[x].series.push({
|
|
316
342
|
key: legend,
|
|
@@ -318,7 +344,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
318
344
|
xAxisCalloutData: x,
|
|
319
345
|
color: color,
|
|
320
346
|
legend: legend,
|
|
321
|
-
useSecondaryYScale: usesSecondaryYScale(series),
|
|
347
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout),
|
|
322
348
|
});
|
|
323
349
|
}
|
|
324
350
|
});
|
|
@@ -327,17 +353,24 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
327
353
|
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 });
|
|
328
354
|
};
|
|
329
355
|
exports.transformPlotlyJsonToGVBCProps = transformPlotlyJsonToGVBCProps;
|
|
330
|
-
var transformPlotlyJsonToVBCProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
356
|
+
var transformPlotlyJsonToVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
331
357
|
var _a, _b, _c;
|
|
332
358
|
var vbcData = [];
|
|
333
|
-
var _d = getLegendProps(input.data, input.layout), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
359
|
+
var _d = getLegendProps(input.data, input.layout, isMultiPlot), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
360
|
+
var colorScale = undefined;
|
|
334
361
|
input.data.forEach(function (series, seriesIdx) {
|
|
335
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
362
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
336
363
|
if (!series.x) {
|
|
337
364
|
return;
|
|
338
365
|
}
|
|
366
|
+
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) &&
|
|
367
|
+
(0, chart_utilities_1.isArrayOrTypedArray)((_d = series.marker) === null || _d === void 0 ? void 0 : _d.color) &&
|
|
368
|
+
((_e = series.marker) === null || _e === void 0 ? void 0 : _e.color).length > 0 &&
|
|
369
|
+
typeof ((_g = (_f = series.marker) === null || _f === void 0 ? void 0 : _f.color) === null || _g === void 0 ? void 0 : _g[0]) === 'number') {
|
|
370
|
+
colorScale = createColorScale(input.layout, series);
|
|
371
|
+
}
|
|
339
372
|
// extract colors for each series only once
|
|
340
|
-
var extractedColors = (0, PlotlyColorAdapter_1.extractColor)((
|
|
373
|
+
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);
|
|
341
374
|
var xValues = [];
|
|
342
375
|
var yValues = [];
|
|
343
376
|
series.x.forEach(function (xVal, index) {
|
|
@@ -348,10 +381,10 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
348
381
|
xValues.push(xVal);
|
|
349
382
|
yValues.push(yVal);
|
|
350
383
|
});
|
|
351
|
-
var isXString = (0,
|
|
384
|
+
var isXString = (0, chart_utilities_1.isStringArray)(xValues);
|
|
352
385
|
// TODO: In case of a single bin, add an empty bin of the same size to prevent the
|
|
353
386
|
// default bar width from being used and ensure the bar spans the full intended range.
|
|
354
|
-
var xBins = createBins(xValues, (
|
|
387
|
+
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);
|
|
355
388
|
var yBins = xBins.map(function () { return []; });
|
|
356
389
|
var total = 0;
|
|
357
390
|
xValues.forEach(function (xVal, index) {
|
|
@@ -366,9 +399,14 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
366
399
|
return yVal;
|
|
367
400
|
});
|
|
368
401
|
xBins.forEach(function (bin, index) {
|
|
402
|
+
var _a, _b, _c, _d;
|
|
369
403
|
var legend = legends[seriesIdx];
|
|
370
|
-
// resolve color for each legend's bars from the extracted colors
|
|
371
|
-
var color =
|
|
404
|
+
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
405
|
+
var color = colorScale
|
|
406
|
+
? colorScale((0, chart_utilities_1.isArrayOrTypedArray)((_a = series.marker) === null || _a === void 0 ? void 0 : _a.color)
|
|
407
|
+
? (_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]
|
|
408
|
+
: 0)
|
|
409
|
+
: (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
372
410
|
var yVal = calculateHistNorm(series.histnorm, y[index], total, isXString ? bin.length : getBinSize(bin));
|
|
373
411
|
vbcData.push(tslib_1.__assign({ x: isXString ? bin.join(', ') : getBinCenter(bin), y: yVal, legend: legend, color: color }, (isXString
|
|
374
412
|
? {}
|
|
@@ -392,14 +430,35 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
392
430
|
};
|
|
393
431
|
};
|
|
394
432
|
exports.transformPlotlyJsonToVBCProps = transformPlotlyJsonToVBCProps;
|
|
395
|
-
var
|
|
396
|
-
|
|
433
|
+
var transformPlotlyJsonToAreaChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
434
|
+
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'area', colorMap, colorwayType, isDarkTheme);
|
|
435
|
+
};
|
|
436
|
+
exports.transformPlotlyJsonToAreaChartProps = transformPlotlyJsonToAreaChartProps;
|
|
437
|
+
var transformPlotlyJsonToLineChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
438
|
+
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'line', colorMap, colorwayType, isDarkTheme);
|
|
439
|
+
};
|
|
440
|
+
exports.transformPlotlyJsonToLineChartProps = transformPlotlyJsonToLineChartProps;
|
|
441
|
+
var transformPlotlyJsonToScatterChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
442
|
+
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'scatter', colorMap, colorwayType, isDarkTheme);
|
|
443
|
+
};
|
|
444
|
+
exports.transformPlotlyJsonToScatterChartProps = transformPlotlyJsonToScatterChartProps;
|
|
445
|
+
var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme) {
|
|
446
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
447
|
+
var isScatterMarkers = [
|
|
448
|
+
'text+markers',
|
|
449
|
+
'markers+text',
|
|
450
|
+
'lines+markers',
|
|
451
|
+
'markers+line',
|
|
452
|
+
'text+lines+markers',
|
|
453
|
+
].includes((_a = input.data[0]) === null || _a === void 0 ? void 0 : _a.mode);
|
|
454
|
+
var isAreaChart = chartType === 'area';
|
|
455
|
+
var isScatterChart = chartType === 'scatter';
|
|
397
456
|
var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
|
|
398
457
|
var mode = 'tonexty';
|
|
399
|
-
var
|
|
458
|
+
var _h = getLegendProps(input.data, input.layout, isMultiPlot), legends = _h.legends, hideLegend = _h.hideLegend;
|
|
400
459
|
var chartData = input.data
|
|
401
460
|
.map(function (series, index) {
|
|
402
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
461
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
403
462
|
var colors = isScatterMarkers
|
|
404
463
|
? ((_a = series === null || series === void 0 ? void 0 : series.mode) === null || _a === void 0 ? void 0 : _a.includes('line'))
|
|
405
464
|
? (_b = series.line) === null || _b === void 0 ? void 0 : _b.color
|
|
@@ -408,20 +467,16 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
408
467
|
// extract colors for each series only once
|
|
409
468
|
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);
|
|
410
469
|
var xValues = series.x;
|
|
411
|
-
var
|
|
470
|
+
var isXString = (0, chart_utilities_1.isStringArray)(xValues);
|
|
412
471
|
var isXDate = (0, chart_utilities_1.isDateArray)(xValues);
|
|
413
472
|
var isXNumber = (0, chart_utilities_1.isNumberArray)(xValues);
|
|
473
|
+
var isXYearCategory = (0, chart_utilities_1.isYearArray)(series.x); // Consider year as categorical not numeric continuous axis
|
|
414
474
|
var legend = legends[index];
|
|
415
475
|
// resolve color for each legend's lines from the extracted colors
|
|
416
476
|
var seriesColor = (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
417
477
|
mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
|
|
418
478
|
var lineOptions = getLineOptions(series.line);
|
|
419
|
-
var
|
|
420
|
-
var legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot'
|
|
421
|
-
? 'dottedLine'
|
|
422
|
-
: ((_j = series.mode) === null || _j === void 0 ? void 0 : _j.includes('markers'))
|
|
423
|
-
? 'circle'
|
|
424
|
-
: 'default';
|
|
479
|
+
var legendShape = getLegendShape(series);
|
|
425
480
|
var validXYRanges = (0, exports.getValidXYRanges)(series);
|
|
426
481
|
return validXYRanges.map(function (_a, rangeIdx) {
|
|
427
482
|
var _b;
|
|
@@ -431,56 +486,71 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
431
486
|
var markerSizes = (0, chart_utilities_1.isArrayOrTypedArray)((_b = series.marker) === null || _b === void 0 ? void 0 : _b.size)
|
|
432
487
|
? series.marker.size.slice(rangeStart, rangeEnd)
|
|
433
488
|
: [];
|
|
489
|
+
var textValues = Array.isArray(series.text) ? series.text.slice(rangeStart, rangeEnd) : undefined;
|
|
434
490
|
return {
|
|
435
491
|
legend: legend,
|
|
436
492
|
legendShape: legendShape,
|
|
437
493
|
data: rangeXValues.map(function (x, i) {
|
|
438
494
|
var _a, _b;
|
|
439
|
-
return (tslib_1.__assign({ x:
|
|
495
|
+
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)
|
|
440
496
|
? { markerSize: markerSizes[i] }
|
|
441
497
|
: typeof ((_b = series.marker) === null || _b === void 0 ? void 0 : _b.size) === 'number'
|
|
442
498
|
? { markerSize: series.marker.size }
|
|
443
|
-
: {})));
|
|
499
|
+
: {})), (textValues ? { text: textValues[i] } : {})));
|
|
444
500
|
}),
|
|
445
501
|
color: seriesColor,
|
|
446
502
|
lineOptions: tslib_1.__assign(tslib_1.__assign({}, (lineOptions !== null && lineOptions !== void 0 ? lineOptions : {})), { mode: series.mode }),
|
|
447
|
-
useSecondaryYScale: usesSecondaryYScale(series),
|
|
503
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout),
|
|
448
504
|
};
|
|
449
505
|
});
|
|
450
506
|
})
|
|
451
507
|
.flat();
|
|
452
508
|
var yMinMaxValues = (0, utilities_1.findNumericMinMaxOfY)(chartData);
|
|
453
|
-
var
|
|
509
|
+
var _j = getTitles(input.layout), chartTitle = _j.chartTitle, xAxisTitle = _j.xAxisTitle, yAxisTitle = _j.yAxisTitle;
|
|
454
510
|
var numDataPoints = chartData.reduce(function (total, lineChartPoints) { return total + lineChartPoints.data.length; }, 0);
|
|
455
511
|
var chartProps = {
|
|
456
512
|
chartTitle: chartTitle,
|
|
457
513
|
lineChartData: chartData,
|
|
458
514
|
};
|
|
515
|
+
var scatterChartProps = {
|
|
516
|
+
chartTitle: chartTitle,
|
|
517
|
+
scatterChartData: chartData,
|
|
518
|
+
};
|
|
459
519
|
if (isAreaChart) {
|
|
460
|
-
return tslib_1.__assign(tslib_1.__assign({ data: chartProps, supportNegativeData: true, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle }, secondaryYAxisValues), { mode: mode, width: (
|
|
520
|
+
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 });
|
|
461
521
|
}
|
|
462
522
|
else {
|
|
463
|
-
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: (
|
|
523
|
+
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 });
|
|
464
524
|
}
|
|
465
525
|
};
|
|
466
|
-
|
|
467
|
-
var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
526
|
+
var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
468
527
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
469
|
-
var _s = getLegendProps(input.data, input.layout), legends = _s.legends, hideLegend = _s.hideLegend;
|
|
528
|
+
var _s = getLegendProps(input.data, input.layout, isMultiPlot), legends = _s.legends, hideLegend = _s.hideLegend;
|
|
529
|
+
var colorScale = undefined;
|
|
470
530
|
var chartData = input.data
|
|
471
531
|
.map(function (series, index) {
|
|
472
|
-
var _a, _b, _c, _d;
|
|
532
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
533
|
+
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) &&
|
|
534
|
+
(0, chart_utilities_1.isArrayOrTypedArray)((_d = series.marker) === null || _d === void 0 ? void 0 : _d.color) &&
|
|
535
|
+
((_e = series.marker) === null || _e === void 0 ? void 0 : _e.color).length > 0 &&
|
|
536
|
+
typeof ((_g = (_f = series.marker) === null || _f === void 0 ? void 0 : _f.color) === null || _g === void 0 ? void 0 : _g[0]) === 'number') {
|
|
537
|
+
colorScale = createColorScale(input.layout, series);
|
|
538
|
+
}
|
|
473
539
|
// extract colors for each series only once
|
|
474
|
-
var extractedColors = (0, PlotlyColorAdapter_1.extractColor)((
|
|
540
|
+
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);
|
|
475
541
|
var legend = legends[index];
|
|
476
|
-
// resolve color for each legend's bars from the extracted colors
|
|
477
|
-
var color = (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
478
542
|
return series.y
|
|
479
543
|
.map(function (yValue, i) {
|
|
480
|
-
var _a;
|
|
544
|
+
var _a, _b, _c, _d, _e;
|
|
481
545
|
if ((0, chart_utilities_1.isInvalidValue)((_a = series.x) === null || _a === void 0 ? void 0 : _a[i]) || (0, chart_utilities_1.isInvalidValue)(yValue)) {
|
|
482
546
|
return null;
|
|
483
547
|
}
|
|
548
|
+
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
549
|
+
var color = colorScale
|
|
550
|
+
? colorScale((0, chart_utilities_1.isArrayOrTypedArray)((_b = series.marker) === null || _b === void 0 ? void 0 : _b.color)
|
|
551
|
+
? (_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]
|
|
552
|
+
: 0)
|
|
553
|
+
: (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, i, legend, colorMap, isDarkTheme);
|
|
484
554
|
return {
|
|
485
555
|
x: series.x[i],
|
|
486
556
|
y: yValue,
|
|
@@ -523,7 +593,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
523
593
|
};
|
|
524
594
|
};
|
|
525
595
|
exports.transformPlotlyJsonToHorizontalBarWithAxisProps = transformPlotlyJsonToHorizontalBarWithAxisProps;
|
|
526
|
-
var transformPlotlyJsonToHeatmapProps = function (input) {
|
|
596
|
+
var transformPlotlyJsonToHeatmapProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
527
597
|
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;
|
|
528
598
|
var firstData = input.data[0];
|
|
529
599
|
var heatmapDataPoints = [];
|
|
@@ -543,8 +613,8 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
543
613
|
yValues_1.push(firstData.y[index]);
|
|
544
614
|
zValues_1.push(zVal);
|
|
545
615
|
});
|
|
546
|
-
var isXString_1 = (0,
|
|
547
|
-
var isYString_1 = (0,
|
|
616
|
+
var isXString_1 = (0, chart_utilities_1.isStringArray)(xValues_1);
|
|
617
|
+
var isYString_1 = (0, chart_utilities_1.isStringArray)(yValues_1);
|
|
548
618
|
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);
|
|
549
619
|
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);
|
|
550
620
|
var zBins_1 = yBins_1.map(function () { return xBins_1.map(function () { return []; }); });
|
|
@@ -654,7 +724,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
654
724
|
};
|
|
655
725
|
};
|
|
656
726
|
exports.transformPlotlyJsonToHeatmapProps = transformPlotlyJsonToHeatmapProps;
|
|
657
|
-
var transformPlotlyJsonToSankeyProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
727
|
+
var transformPlotlyJsonToSankeyProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
658
728
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
659
729
|
var _m = input.data[0], link = _m.link, node = _m.node;
|
|
660
730
|
var validLinks = ((_a = link === null || link === void 0 ? void 0 : link.value) !== null && _a !== void 0 ? _a : [])
|
|
@@ -702,7 +772,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
702
772
|
};
|
|
703
773
|
};
|
|
704
774
|
exports.transformPlotlyJsonToSankeyProps = transformPlotlyJsonToSankeyProps;
|
|
705
|
-
var transformPlotlyJsonToGaugeProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
775
|
+
var transformPlotlyJsonToGaugeProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
706
776
|
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;
|
|
707
777
|
var firstData = input.data[0];
|
|
708
778
|
var stepsColors = ((_a = firstData.gauge) === null || _a === void 0 ? void 0 : _a.steps) ? firstData.gauge.steps.map(function (step) { return step.color; }) : undefined;
|
|
@@ -802,7 +872,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
802
872
|
}
|
|
803
873
|
return "".concat(prefix !== null && prefix !== void 0 ? prefix : '').concat(formatted).concat(suffix !== null && suffix !== void 0 ? suffix : '');
|
|
804
874
|
};
|
|
805
|
-
var transformPlotlyJsonToChartTableProps = function (input, colorMap, isDarkTheme) {
|
|
875
|
+
var transformPlotlyJsonToChartTableProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
806
876
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
807
877
|
var tableData = input.data[0];
|
|
808
878
|
var normalizeHeaders = function (values, header) {
|
|
@@ -1008,12 +1078,6 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
1008
1078
|
}
|
|
1009
1079
|
return Object.keys(lineOptions).length > 0 ? lineOptions : undefined;
|
|
1010
1080
|
}
|
|
1011
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1012
|
-
var isStringArray = function (arr) {
|
|
1013
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1014
|
-
return (0, chart_utilities_1.isArrayOfType)(arr, function (value) { return typeof value === 'string' || value === null; });
|
|
1015
|
-
};
|
|
1016
|
-
exports.isStringArray = isStringArray;
|
|
1017
1081
|
// TODO: Use binary search to find the appropriate bin for numeric value.
|
|
1018
1082
|
var findBinIndex = function (bins, value, isString) {
|
|
1019
1083
|
if (typeof value === 'undefined' || value === null) {
|
|
@@ -1037,7 +1101,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
1037
1101
|
if (!data || data.length === 0) {
|
|
1038
1102
|
return [];
|
|
1039
1103
|
}
|
|
1040
|
-
if ((0,
|
|
1104
|
+
if ((0, chart_utilities_1.isStringArray)(data)) {
|
|
1041
1105
|
var categories_1 = Array.from(new Set(data));
|
|
1042
1106
|
var start = typeof binStart === 'number' ? Math.ceil(binStart) : 0;
|
|
1043
1107
|
var stop_1 = typeof binEnd === 'number' ? Math.floor(binEnd) + 1 : categories_1.length;
|
|
@@ -1108,7 +1172,48 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
1108
1172
|
var factor = Math.pow(10, precision);
|
|
1109
1173
|
return Math.round(value * factor) / factor;
|
|
1110
1174
|
};
|
|
1111
|
-
var
|
|
1175
|
+
var getLegendShape = function (series) {
|
|
1176
|
+
var _a, _b;
|
|
1177
|
+
var dashType = ((_a = series.line) === null || _a === void 0 ? void 0 : _a.dash) || 'solid';
|
|
1178
|
+
if (dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot') {
|
|
1179
|
+
return 'dottedLine';
|
|
1180
|
+
}
|
|
1181
|
+
else if ((_b = series.mode) === null || _b === void 0 ? void 0 : _b.includes('markers')) {
|
|
1182
|
+
return 'circle';
|
|
1183
|
+
}
|
|
1184
|
+
return 'default';
|
|
1185
|
+
};
|
|
1186
|
+
var getAllupLegendsProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
1187
|
+
var allupLegends = [];
|
|
1188
|
+
// reduce on showlegend boolean propperty. reduce should return true if at least one series has showlegend true
|
|
1189
|
+
var toShowLegend = input.data.reduce(function (acc, series) {
|
|
1190
|
+
return acc || series.showlegend === true;
|
|
1191
|
+
}, false);
|
|
1192
|
+
if (toShowLegend) {
|
|
1193
|
+
input.data.forEach(function (series, index) {
|
|
1194
|
+
var _a, _b, _c, _d, _e;
|
|
1195
|
+
var name = series.legendgroup;
|
|
1196
|
+
var color = ((_a = series.line) === null || _a === void 0 ? void 0 : _a.color) || ((_b = series.marker) === null || _b === void 0 ? void 0 : _b.color);
|
|
1197
|
+
var legendShape = getLegendShape(series);
|
|
1198
|
+
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);
|
|
1199
|
+
if (name !== undefined && allupLegends.some(function (group) { return group.title === name; }) === false) {
|
|
1200
|
+
allupLegends.push({
|
|
1201
|
+
title: name,
|
|
1202
|
+
color: resolvedColor,
|
|
1203
|
+
shape: legendShape,
|
|
1204
|
+
});
|
|
1205
|
+
}
|
|
1206
|
+
});
|
|
1207
|
+
}
|
|
1208
|
+
return {
|
|
1209
|
+
legends: allupLegends,
|
|
1210
|
+
centerLegends: true,
|
|
1211
|
+
enabledWrapLines: true,
|
|
1212
|
+
canSelectMultipleLegends: true,
|
|
1213
|
+
};
|
|
1214
|
+
};
|
|
1215
|
+
exports.getAllupLegendsProps = getAllupLegendsProps;
|
|
1216
|
+
var getLegendProps = function (data, layout, isMultiPlot) {
|
|
1112
1217
|
var legends = [];
|
|
1113
1218
|
if (data.length === 1) {
|
|
1114
1219
|
legends.push(data[0].name || '');
|
|
@@ -1118,10 +1223,11 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
1118
1223
|
legends.push(series.name || "Series ".concat(index + 1));
|
|
1119
1224
|
});
|
|
1120
1225
|
}
|
|
1121
|
-
var
|
|
1226
|
+
var hideLegendsData = data.every(function (series) { return series.showlegend === false; });
|
|
1227
|
+
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);
|
|
1122
1228
|
return {
|
|
1123
1229
|
legends: legends,
|
|
1124
|
-
hideLegend:
|
|
1230
|
+
hideLegend: isMultiPlot || hideLegendsInferred || hideLegendsData,
|
|
1125
1231
|
};
|
|
1126
1232
|
};
|
|
1127
1233
|
var getNumberAtIndexOrDefault = function (data, index) {
|
|
@@ -1155,5 +1261,159 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
1155
1261
|
return ranges;
|
|
1156
1262
|
};
|
|
1157
1263
|
exports.getValidXYRanges = getValidXYRanges;
|
|
1264
|
+
var getIndexFromKey = function (key, pattern) {
|
|
1265
|
+
var normalizedKey = key.replace(pattern, '') === '' ? '1' : key.replace(pattern, '');
|
|
1266
|
+
return parseInt(normalizedKey, 10) - 1;
|
|
1267
|
+
};
|
|
1268
|
+
var getGridProperties = function (layout, isMultiPlot) {
|
|
1269
|
+
var _a;
|
|
1270
|
+
var gridX = [];
|
|
1271
|
+
var gridY = [];
|
|
1272
|
+
var annotations = {};
|
|
1273
|
+
var templateRows = '1fr';
|
|
1274
|
+
var templateColumns = '1fr';
|
|
1275
|
+
var gridLayout = {};
|
|
1276
|
+
if (layout === undefined || layout === null || Object.keys(layout).length === 0) {
|
|
1277
|
+
return { templateRows: templateRows, templateColumns: templateColumns, layout: gridLayout };
|
|
1278
|
+
}
|
|
1279
|
+
if (!layout.xaxis || !layout.yaxis) {
|
|
1280
|
+
return { templateRows: templateRows, templateColumns: templateColumns, layout: gridLayout };
|
|
1281
|
+
}
|
|
1282
|
+
if (!isMultiPlot) {
|
|
1283
|
+
return { templateRows: templateRows, templateColumns: templateColumns, layout: gridLayout };
|
|
1284
|
+
}
|
|
1285
|
+
Object.keys(layout).forEach(function (key) {
|
|
1286
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
1287
|
+
if (key.startsWith('xaxis')) {
|
|
1288
|
+
var index = getIndexFromKey(key, 'xaxis');
|
|
1289
|
+
var anchor = (_b = (_a = layout[key]) === null || _a === void 0 ? void 0 : _a.anchor) !== null && _b !== void 0 ? _b : 'y';
|
|
1290
|
+
var anchorIndex = getIndexFromKey(anchor, 'y');
|
|
1291
|
+
if (index !== anchorIndex) {
|
|
1292
|
+
throw new Error("Invalid layout: xaxis ".concat(index + 1, " anchor should be y").concat(anchorIndex + 1));
|
|
1293
|
+
}
|
|
1294
|
+
gridX[index] = (_d = (_c = layout[key]) === null || _c === void 0 ? void 0 : _c.domain) !== null && _d !== void 0 ? _d : [];
|
|
1295
|
+
}
|
|
1296
|
+
else if (key.startsWith('yaxis')) {
|
|
1297
|
+
var index = getIndexFromKey(key, 'yaxis');
|
|
1298
|
+
var anchor = (_f = (_e = layout[key]) === null || _e === void 0 ? void 0 : _e.anchor) !== null && _f !== void 0 ? _f : 'x';
|
|
1299
|
+
var anchorIndex = getIndexFromKey(anchor, 'x');
|
|
1300
|
+
if (index !== anchorIndex) {
|
|
1301
|
+
if ((index === 1 && anchorIndex === 0) || ((_g = layout.yaxis2) === null || _g === void 0 ? void 0 : _g.side) === 'right') {
|
|
1302
|
+
// Special case for secondary y axis where yaxis2 can anchor to x1
|
|
1303
|
+
return { templateRows: templateRows, templateColumns: templateColumns };
|
|
1304
|
+
}
|
|
1305
|
+
throw new Error("Invalid layout: yaxis ".concat(index + 1, " anchor should be x").concat(anchorIndex + 1));
|
|
1306
|
+
}
|
|
1307
|
+
gridY[index] = (_j = (_h = layout[key]) === null || _h === void 0 ? void 0 : _h.domain) !== null && _j !== void 0 ? _j : [];
|
|
1308
|
+
}
|
|
1309
|
+
});
|
|
1310
|
+
(_a = layout.annotations) === null || _a === void 0 ? void 0 : _a.forEach(function (annotation) {
|
|
1311
|
+
var xMatches = gridX.flatMap(function (interval, idx) {
|
|
1312
|
+
return (annotation === null || annotation === void 0 ? void 0 : annotation.x) >= interval[0] && (annotation === null || annotation === void 0 ? void 0 : annotation.x) <= interval[1] ? [idx] : [];
|
|
1313
|
+
});
|
|
1314
|
+
var yMatch = gridY.findIndex(function (interval, yIndex) {
|
|
1315
|
+
return xMatches.includes(yIndex) &&
|
|
1316
|
+
(annotation === null || annotation === void 0 ? void 0 : annotation.y) >= interval[0] &&
|
|
1317
|
+
(annotation === null || annotation === void 0 ? void 0 : annotation.y) <= interval[1];
|
|
1318
|
+
});
|
|
1319
|
+
if (yMatch !== -1) {
|
|
1320
|
+
if (annotations[yMatch] === undefined) {
|
|
1321
|
+
annotations[yMatch] = {};
|
|
1322
|
+
}
|
|
1323
|
+
if ((annotation === null || annotation === void 0 ? void 0 : annotation.textangle) === 90) {
|
|
1324
|
+
annotations[yMatch].yAnnotation = annotation.text;
|
|
1325
|
+
}
|
|
1326
|
+
else {
|
|
1327
|
+
annotations[yMatch].xAnnotation = annotation.text;
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
});
|
|
1331
|
+
if (gridX.length > 0) {
|
|
1332
|
+
var uniqueXIntervals_1 = new Map();
|
|
1333
|
+
gridX.forEach(function (interval) {
|
|
1334
|
+
var key = "".concat(interval[0], "-").concat(interval[1]);
|
|
1335
|
+
if (!uniqueXIntervals_1.has(key)) {
|
|
1336
|
+
uniqueXIntervals_1.set(key, interval);
|
|
1337
|
+
}
|
|
1338
|
+
});
|
|
1339
|
+
var minXInterval_1 = Math.min.apply(Math, Array.from(uniqueXIntervals_1.values()).map(function (interval) { return interval[1] - interval[0]; }));
|
|
1340
|
+
templateColumns = Array.from(uniqueXIntervals_1.values())
|
|
1341
|
+
.map(function (interval) { return "".concat((interval[1] - interval[0]) / minXInterval_1, "fr"); })
|
|
1342
|
+
.join(' ');
|
|
1343
|
+
var columnNumber_1 = 1;
|
|
1344
|
+
var lastIntervalEnd_1 = 0;
|
|
1345
|
+
gridX.forEach(function (interval, index) {
|
|
1346
|
+
if (interval.length === 0) {
|
|
1347
|
+
return;
|
|
1348
|
+
}
|
|
1349
|
+
var cellName = "x".concat(index === 0 ? '' : index + 1);
|
|
1350
|
+
var annotationProps = annotations[index];
|
|
1351
|
+
var xAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.xAnnotation;
|
|
1352
|
+
if (interval[0] < lastIntervalEnd_1) {
|
|
1353
|
+
columnNumber_1 = 1;
|
|
1354
|
+
}
|
|
1355
|
+
lastIntervalEnd_1 = interval[1];
|
|
1356
|
+
var row = {
|
|
1357
|
+
row: -1,
|
|
1358
|
+
column: columnNumber_1,
|
|
1359
|
+
xAnnotation: xAnnotation,
|
|
1360
|
+
};
|
|
1361
|
+
gridLayout[cellName] = row;
|
|
1362
|
+
columnNumber_1 += 1;
|
|
1363
|
+
});
|
|
1364
|
+
}
|
|
1365
|
+
var numColumns = Math.max.apply(Math, Object.values(gridLayout).map(function (cell) { var _a; return (_a = cell.column) !== null && _a !== void 0 ? _a : 0; }));
|
|
1366
|
+
var columnFill = {};
|
|
1367
|
+
for (var i = 1; i <= numColumns; i++) {
|
|
1368
|
+
columnFill[i] = { row: 1, fillDomain: 0 };
|
|
1369
|
+
}
|
|
1370
|
+
if (gridY.length > 0) {
|
|
1371
|
+
var uniqueYIntervals_1 = new Map();
|
|
1372
|
+
gridY.forEach(function (interval) {
|
|
1373
|
+
var key = "".concat(interval[0], "-").concat(interval[1]);
|
|
1374
|
+
if (!uniqueYIntervals_1.has(key)) {
|
|
1375
|
+
uniqueYIntervals_1.set(key, interval);
|
|
1376
|
+
}
|
|
1377
|
+
});
|
|
1378
|
+
var minYInterval_1 = Math.min.apply(Math, Array.from(uniqueYIntervals_1.values()).map(function (interval) { return interval[1] - interval[0]; }));
|
|
1379
|
+
templateRows = Array.from(uniqueYIntervals_1.values())
|
|
1380
|
+
.map(function (interval) { return "".concat((interval[1] - interval[0]) / minYInterval_1, "fr"); })
|
|
1381
|
+
.join(' ');
|
|
1382
|
+
gridY.forEach(function (interval, index) {
|
|
1383
|
+
if (interval.length === 0) {
|
|
1384
|
+
return;
|
|
1385
|
+
}
|
|
1386
|
+
var cellName = "x".concat(index === 0 ? '' : index + 1);
|
|
1387
|
+
var annotationProps = annotations[index];
|
|
1388
|
+
var yAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.yAnnotation;
|
|
1389
|
+
var cell = gridLayout[cellName];
|
|
1390
|
+
if (cell !== undefined) {
|
|
1391
|
+
cell.row = columnFill[cell.column].row;
|
|
1392
|
+
cell.yAnnotation = yAnnotation;
|
|
1393
|
+
}
|
|
1394
|
+
columnFill[cell.column].fillDomain = interval[1];
|
|
1395
|
+
columnFill[cell.column].row += 1;
|
|
1396
|
+
});
|
|
1397
|
+
}
|
|
1398
|
+
// reverse the order of rows in grid layout from bottom-top to top-bottom as required by CSS grid
|
|
1399
|
+
var reversedGridLayout = {};
|
|
1400
|
+
// find the maximum row number
|
|
1401
|
+
var maxRowNumber = Math.max.apply(Math, Object.values(gridLayout).map(function (cell) { var _a; return (_a = cell.row) !== null && _a !== void 0 ? _a : 0; }));
|
|
1402
|
+
// iterate over the gridLayout and reverse the row numbers
|
|
1403
|
+
Object.keys(gridLayout).forEach(function (key) {
|
|
1404
|
+
var cell = gridLayout[key];
|
|
1405
|
+
if (cell.row !== undefined) {
|
|
1406
|
+
// reverse the row number
|
|
1407
|
+
cell.row = maxRowNumber - cell.row + 1;
|
|
1408
|
+
}
|
|
1409
|
+
reversedGridLayout[key] = cell;
|
|
1410
|
+
});
|
|
1411
|
+
return {
|
|
1412
|
+
templateRows: templateRows,
|
|
1413
|
+
templateColumns: templateColumns,
|
|
1414
|
+
layout: reversedGridLayout,
|
|
1415
|
+
};
|
|
1416
|
+
};
|
|
1417
|
+
exports.getGridProperties = getGridProperties;
|
|
1158
1418
|
});
|
|
1159
1419
|
//# sourceMappingURL=PlotlySchemaAdapter.js.map
|