@fluentui/react-charting 5.24.2 → 5.24.4
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 +79 -1
- package/CHANGELOG.md +28 -2
- package/dist/react-charting.d.ts +204 -38
- package/dist/react-charting.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/etc/react-charting.api.md +65 -12
- package/lib/ScatterChart.d.ts +1 -0
- package/lib/ScatterChart.js +2 -0
- package/lib/ScatterChart.js.map +1 -0
- package/lib/components/AreaChart/AreaChart.base.d.ts +1 -0
- package/lib/components/AreaChart/AreaChart.base.js +4 -1
- package/lib/components/AreaChart/AreaChart.base.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.base.js +47 -11
- 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 +33 -3
- 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/PlotlyColorAdapter.d.ts +2 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +9 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +28 -13
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +317 -126
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.d.ts +2 -0
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +22 -3
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
- package/lib/components/HeatMapChart/HeatMapChart.base.d.ts +7 -0
- package/lib/components/HeatMapChart/HeatMapChart.base.js +95 -37
- package/lib/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.d.ts +3 -0
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +24 -3
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.base.d.ts +7 -0
- package/lib/components/ScatterChart/ScatterChart.base.js +482 -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 +19 -0
- package/lib/components/ScatterChart/ScatterChart.styles.js.map +1 -0
- package/lib/components/ScatterChart/ScatterChart.types.d.ts +47 -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/VerticalBarChart/VerticalBarChart.base.d.ts +2 -0
- package/lib/components/VerticalBarChart/VerticalBarChart.base.js +27 -6
- package/lib/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.d.ts +3 -0
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +48 -31
- 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 +91 -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 +32 -5
- package/lib/utilities/utilities.js +132 -2
- 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/AreaChart/AreaChart.base.d.ts +1 -0
- package/lib-amd/components/AreaChart/AreaChart.base.js +4 -1
- package/lib-amd/components/AreaChart/AreaChart.base.js.map +1 -1
- package/lib-amd/components/CommonComponents/CartesianChart.base.js +47 -11
- 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 +33 -3
- 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/PlotlyColorAdapter.d.ts +2 -1
- package/lib-amd/components/DeclarativeChart/PlotlyColorAdapter.js +11 -2
- package/lib-amd/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +28 -13
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +327 -134
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.d.ts +2 -0
- package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +21 -2
- package/lib-amd/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
- package/lib-amd/components/HeatMapChart/HeatMapChart.base.d.ts +7 -0
- package/lib-amd/components/HeatMapChart/HeatMapChart.base.js +94 -36
- package/lib-amd/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
- package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.d.ts +3 -0
- package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +23 -2
- package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
- package/lib-amd/components/ScatterChart/ScatterChart.base.d.ts +7 -0
- package/lib-amd/components/ScatterChart/ScatterChart.base.js +476 -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 +23 -0
- package/lib-amd/components/ScatterChart/ScatterChart.styles.js.map +1 -0
- package/lib-amd/components/ScatterChart/ScatterChart.types.d.ts +47 -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/VerticalBarChart/VerticalBarChart.base.d.ts +2 -0
- package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js +26 -5
- package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.d.ts +3 -0
- package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +47 -30
- 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 +91 -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 +32 -5
- package/lib-amd/utilities/utilities.js +135 -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/AreaChart/AreaChart.base.d.ts +1 -0
- package/lib-commonjs/components/AreaChart/AreaChart.base.js +4 -1
- package/lib-commonjs/components/AreaChart/AreaChart.base.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js +47 -11
- 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 +33 -3
- 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/PlotlyColorAdapter.d.ts +2 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +11 -2
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +28 -13
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +327 -134
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.d.ts +2 -0
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js +21 -2
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.base.d.ts +7 -0
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.base.js +94 -36
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.base.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.d.ts +3 -0
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +23 -2
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.base.d.ts +7 -0
- package/lib-commonjs/components/ScatterChart/ScatterChart.base.js +485 -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 +23 -0
- package/lib-commonjs/components/ScatterChart/ScatterChart.styles.js.map +1 -0
- package/lib-commonjs/components/ScatterChart/ScatterChart.types.d.ts +47 -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/VerticalBarChart/VerticalBarChart.base.d.ts +2 -0
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js +26 -5
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.d.ts +3 -0
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +47 -30
- 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 +91 -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 +32 -5
- package/lib-commonjs/utilities/utilities.js +135 -2
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +2 -2
- package/src/components/CommonComponents/CartesianChart.types.ts +45 -2
- package/src/components/ScatterChart/ScatterChart.types.ts +67 -0
|
@@ -5,10 +5,10 @@ import { format as d3Format } from 'd3-format';
|
|
|
5
5
|
import { DataVizPalette, getColorFromToken } from '../../utilities/colors';
|
|
6
6
|
import { GaugeChartVariant } from '../GaugeChart/index';
|
|
7
7
|
import { findNumericMinMaxOfY, formatScientificLimitWidth, MIN_DONUT_RADIUS } from '../../utilities/utilities';
|
|
8
|
-
import {
|
|
9
|
-
import { timeParse } from 'd3-time-format';
|
|
8
|
+
import { isArrayOrTypedArray, isDate, isDateArray, isNumberArray, isStringArray, isYearArray, isInvalidValue, } from '@fluentui/chart-utilities';
|
|
10
9
|
import { curveCardinal as d3CurveCardinal } from 'd3-shape';
|
|
11
|
-
import { extractColor, resolveColor } from './PlotlyColorAdapter';
|
|
10
|
+
import { getOpacity, extractColor, resolveColor } from './PlotlyColorAdapter';
|
|
11
|
+
import { rgb } from 'd3-color';
|
|
12
12
|
var dashOptions = {
|
|
13
13
|
dot: {
|
|
14
14
|
strokeDasharray: '1, 5',
|
|
@@ -47,16 +47,6 @@ var dashOptions = {
|
|
|
47
47
|
lineBorderWidth: '4',
|
|
48
48
|
},
|
|
49
49
|
};
|
|
50
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
51
|
-
var isMonth = function (possiblyMonthValue) {
|
|
52
|
-
var parseFullMonth = timeParse('%B');
|
|
53
|
-
var parseShortMonth = timeParse('%b');
|
|
54
|
-
return parseFullMonth(possiblyMonthValue) !== null || parseShortMonth(possiblyMonthValue) !== null;
|
|
55
|
-
};
|
|
56
|
-
export var isMonthArray = function (data) {
|
|
57
|
-
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
58
|
-
return isArrayOfType(data, function (value) { return isMonth(value) || value === null; });
|
|
59
|
-
};
|
|
60
50
|
function getTitles(layout) {
|
|
61
51
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
62
52
|
var titles = {
|
|
@@ -103,8 +93,9 @@ export var correctYearMonth = function (xValues) {
|
|
|
103
93
|
});
|
|
104
94
|
return xValues;
|
|
105
95
|
};
|
|
106
|
-
var usesSecondaryYScale = function (series) {
|
|
107
|
-
|
|
96
|
+
var usesSecondaryYScale = function (series, layout) {
|
|
97
|
+
var _a, _b;
|
|
98
|
+
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');
|
|
108
99
|
};
|
|
109
100
|
var getSecondaryYAxisValues = function (data, layout, maxAllowedMinY, minAllowedMaxY) {
|
|
110
101
|
var _a, _b, _c, _d;
|
|
@@ -112,7 +103,7 @@ var getSecondaryYAxisValues = function (data, layout, maxAllowedMinY, minAllowed
|
|
|
112
103
|
var yMinValue;
|
|
113
104
|
var yMaxValue;
|
|
114
105
|
data.forEach(function (series) {
|
|
115
|
-
if (usesSecondaryYScale(series)) {
|
|
106
|
+
if (usesSecondaryYScale(series, layout)) {
|
|
116
107
|
containsSecondaryYAxis = true;
|
|
117
108
|
var yValues = series.y;
|
|
118
109
|
if (yValues) {
|
|
@@ -169,7 +160,7 @@ export var resolveXAxisPoint = function (x, isXYearCategory, isXString, isXDate,
|
|
|
169
160
|
}
|
|
170
161
|
return x;
|
|
171
162
|
};
|
|
172
|
-
export var transformPlotlyJsonToDonutProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
163
|
+
export var transformPlotlyJsonToDonutProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
173
164
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
174
165
|
var firstData = input.data[0];
|
|
175
166
|
// extract colors for each series only once
|
|
@@ -221,13 +212,13 @@ export var transformPlotlyJsonToDonutProps = function (input, colorMap, colorway
|
|
|
221
212
|
roundCorners: true,
|
|
222
213
|
};
|
|
223
214
|
};
|
|
224
|
-
export var transformPlotlyJsonToVSBCProps = function (input, colorMap, colorwayType, isDarkTheme, fallbackVSBC) {
|
|
215
|
+
export var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme, fallbackVSBC) {
|
|
225
216
|
var _a, _b, _c;
|
|
226
217
|
var mapXToDataPoints = {};
|
|
227
218
|
var yMaxValue = 0;
|
|
228
219
|
var yMinValue = 0;
|
|
229
220
|
var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
|
|
230
|
-
var _d = getLegendProps(input.data, input.layout), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
221
|
+
var _d = getLegendProps(input.data, input.layout, isMultiPlot), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
231
222
|
var colorScale = undefined;
|
|
232
223
|
input.data.forEach(function (series, index1) {
|
|
233
224
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
@@ -267,12 +258,13 @@ export var transformPlotlyJsonToVSBCProps = function (input, colorMap, colorwayT
|
|
|
267
258
|
? (_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]
|
|
268
259
|
: 0)
|
|
269
260
|
: resolveColor(extractedBarColors, index2, legend, colorMap, isDarkTheme);
|
|
261
|
+
var opacity = getOpacity(series, index2);
|
|
270
262
|
var yVal = rangeYValues[index2];
|
|
271
263
|
if (series.type === 'bar') {
|
|
272
264
|
mapXToDataPoints[x].chartData.push({
|
|
273
265
|
legend: legend,
|
|
274
266
|
data: yVal,
|
|
275
|
-
color: color,
|
|
267
|
+
color: (_e = rgb(color).copy({ opacity: opacity }).formatHex8()) !== null && _e !== void 0 ? _e : color,
|
|
276
268
|
});
|
|
277
269
|
if (typeof yVal === 'number') {
|
|
278
270
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
@@ -281,21 +273,16 @@ export var transformPlotlyJsonToVSBCProps = function (input, colorMap, colorwayT
|
|
|
281
273
|
else if (series.type === 'scatter' || !!fallbackVSBC) {
|
|
282
274
|
var lineColor = resolveColor(extractedLineColors, index1, legend, colorMap, isDarkTheme);
|
|
283
275
|
var lineOptions = getLineOptions(series.line);
|
|
284
|
-
var
|
|
285
|
-
var legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot'
|
|
286
|
-
? 'dottedLine'
|
|
287
|
-
: ((_f = series.mode) === null || _f === void 0 ? void 0 : _f.includes('markers'))
|
|
288
|
-
? 'circle'
|
|
289
|
-
: 'default';
|
|
276
|
+
var legendShape = getLegendShape(series);
|
|
290
277
|
mapXToDataPoints[x].lineData.push({
|
|
291
278
|
legend: legend + (validXYRanges.length > 1 ? ".".concat(rangeIdx + 1) : ''),
|
|
292
279
|
legendShape: legendShape,
|
|
293
280
|
y: yVal,
|
|
294
|
-
color: lineColor,
|
|
281
|
+
color: (_f = rgb(lineColor).copy({ opacity: opacity }).formatHex8()) !== null && _f !== void 0 ? _f : color,
|
|
295
282
|
lineOptions: __assign(__assign({}, (lineOptions !== null && lineOptions !== void 0 ? lineOptions : {})), { mode: series.mode }),
|
|
296
|
-
useSecondaryYScale: usesSecondaryYScale(series),
|
|
283
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout),
|
|
297
284
|
});
|
|
298
|
-
if (!usesSecondaryYScale(series) && typeof yVal === 'number') {
|
|
285
|
+
if (!usesSecondaryYScale(series, input.layout) && typeof yVal === 'number') {
|
|
299
286
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
300
287
|
yMinValue = Math.min(yMinValue, yVal);
|
|
301
288
|
}
|
|
@@ -304,7 +291,7 @@ export var transformPlotlyJsonToVSBCProps = function (input, colorMap, colorwayT
|
|
|
304
291
|
});
|
|
305
292
|
});
|
|
306
293
|
var _e = getTitles(input.layout), chartTitle = _e.chartTitle, xAxisTitle = _e.xAxisTitle, yAxisTitle = _e.yAxisTitle;
|
|
307
|
-
return __assign(__assign({ data: Object.values(mapXToDataPoints), width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, barWidth: 'auto', yMaxValue: yMaxValue, yMinValue: yMinValue, chartTitle: chartTitle, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle, mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true, supportNegativeData: true, barGapMax: 2, showYAxisLables: true, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true });
|
|
294
|
+
return __assign(__assign(__assign({ data: Object.values(mapXToDataPoints), width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, barWidth: 'auto', yMaxValue: yMaxValue, yMinValue: yMinValue, chartTitle: chartTitle, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle, mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true, supportNegativeData: true, barGapMax: 2, showYAxisLables: true, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true }), getAxisCategoryOrderProps(input.data, input.layout));
|
|
308
295
|
};
|
|
309
296
|
var createColorScale = function (layout, series) {
|
|
310
297
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -322,11 +309,11 @@ var createColorScale = function (layout, series) {
|
|
|
322
309
|
var scaleColors = scale.map(function (item) { return item[1]; });
|
|
323
310
|
return d3ScaleLinear().domain(scaleDomain).range(scaleColors);
|
|
324
311
|
};
|
|
325
|
-
export var transformPlotlyJsonToGVBCProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
312
|
+
export var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
326
313
|
var _a, _b, _c;
|
|
327
314
|
var mapXToDataPoints = {};
|
|
328
315
|
var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, 0, 0);
|
|
329
|
-
var _d = getLegendProps(input.data, input.layout), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
316
|
+
var _d = getLegendProps(input.data, input.layout, isMultiPlot), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
330
317
|
var colorScale = undefined;
|
|
331
318
|
input.data.forEach(function (series, index1) {
|
|
332
319
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
@@ -339,7 +326,7 @@ export var transformPlotlyJsonToGVBCProps = function (input, colorMap, colorwayT
|
|
|
339
326
|
// extract colors for each series only once
|
|
340
327
|
var extractedColors = 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
328
|
(_m = series.x) === null || _m === void 0 ? void 0 : _m.forEach(function (x, xIndex) {
|
|
342
|
-
var _a, _b, _c, _d, _e;
|
|
329
|
+
var _a, _b, _c, _d, _e, _f;
|
|
343
330
|
if (isInvalidValue(x) || isInvalidValue((_a = series.y) === null || _a === void 0 ? void 0 : _a[xIndex])) {
|
|
344
331
|
return;
|
|
345
332
|
}
|
|
@@ -353,25 +340,26 @@ export var transformPlotlyJsonToGVBCProps = function (input, colorMap, colorwayT
|
|
|
353
340
|
? colorScale(isArrayOrTypedArray((_b = series.marker) === null || _b === void 0 ? void 0 : _b.color)
|
|
354
341
|
? (_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]
|
|
355
342
|
: 0)
|
|
356
|
-
: resolveColor(extractedColors,
|
|
343
|
+
: resolveColor(extractedColors, xIndex, legend, colorMap, isDarkTheme);
|
|
344
|
+
var opacity = getOpacity(series, xIndex);
|
|
357
345
|
mapXToDataPoints[x].series.push({
|
|
358
346
|
key: legend,
|
|
359
347
|
data: series.y[xIndex],
|
|
360
348
|
xAxisCalloutData: x,
|
|
361
|
-
color: color,
|
|
349
|
+
color: (_f = rgb(color).copy({ opacity: opacity }).formatHex8()) !== null && _f !== void 0 ? _f : color,
|
|
362
350
|
legend: legend,
|
|
363
|
-
useSecondaryYScale: usesSecondaryYScale(series),
|
|
351
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout),
|
|
364
352
|
});
|
|
365
353
|
}
|
|
366
354
|
});
|
|
367
355
|
});
|
|
368
356
|
var _e = getTitles(input.layout), chartTitle = _e.chartTitle, xAxisTitle = _e.xAxisTitle, yAxisTitle = _e.yAxisTitle;
|
|
369
|
-
return __assign(__assign({ data: Object.values(mapXToDataPoints), width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, barwidth: 'auto', chartTitle: chartTitle, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle, mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true });
|
|
357
|
+
return __assign(__assign(__assign({ data: Object.values(mapXToDataPoints), width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, barwidth: 'auto', chartTitle: chartTitle, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle, mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true }), getAxisCategoryOrderProps(input.data, input.layout));
|
|
370
358
|
};
|
|
371
|
-
export var transformPlotlyJsonToVBCProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
359
|
+
export var transformPlotlyJsonToVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
372
360
|
var _a, _b, _c;
|
|
373
361
|
var vbcData = [];
|
|
374
|
-
var _d = getLegendProps(input.data, input.layout), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
362
|
+
var _d = getLegendProps(input.data, input.layout, isMultiPlot), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
375
363
|
var colorScale = undefined;
|
|
376
364
|
input.data.forEach(function (series, seriesIdx) {
|
|
377
365
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
@@ -414,7 +402,7 @@ export var transformPlotlyJsonToVBCProps = function (input, colorMap, colorwayTy
|
|
|
414
402
|
return yVal;
|
|
415
403
|
});
|
|
416
404
|
xBins.forEach(function (bin, index) {
|
|
417
|
-
var _a, _b, _c, _d;
|
|
405
|
+
var _a, _b, _c, _d, _e;
|
|
418
406
|
var legend = legends[seriesIdx];
|
|
419
407
|
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
420
408
|
var color = colorScale
|
|
@@ -422,36 +410,43 @@ export var transformPlotlyJsonToVBCProps = function (input, colorMap, colorwayTy
|
|
|
422
410
|
? (_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]
|
|
423
411
|
: 0)
|
|
424
412
|
: resolveColor(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
413
|
+
var opacity = getOpacity(series, index);
|
|
425
414
|
var yVal = calculateHistNorm(series.histnorm, y[index], total, isXString ? bin.length : getBinSize(bin));
|
|
426
|
-
vbcData.push(__assign({ x: isXString ? bin.join(', ') : getBinCenter(bin), y: yVal, legend: legend, color: color }, (isXString
|
|
415
|
+
vbcData.push(__assign({ x: isXString ? bin.join(', ') : getBinCenter(bin), y: yVal, legend: legend, color: (_e = rgb(color).copy({ opacity: opacity }).formatHex8()) !== null && _e !== void 0 ? _e : color }, (isXString
|
|
427
416
|
? {}
|
|
428
417
|
: { xAxisCalloutData: "[".concat(bin.x0, " - ").concat(bin.x1, ")") })));
|
|
429
418
|
});
|
|
430
419
|
});
|
|
431
420
|
var _e = getTitles(input.layout), chartTitle = _e.chartTitle, xAxisTitle = _e.xAxisTitle, yAxisTitle = _e.yAxisTitle;
|
|
432
|
-
return {
|
|
433
|
-
data: vbcData,
|
|
434
|
-
width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width,
|
|
435
|
-
height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350,
|
|
436
|
-
supportNegativeData: true,
|
|
437
|
-
chartTitle: chartTitle,
|
|
438
|
-
xAxisTitle: xAxisTitle,
|
|
439
|
-
yAxisTitle: yAxisTitle,
|
|
440
|
-
mode: 'histogram',
|
|
441
|
-
hideTickOverlap: true,
|
|
442
|
-
maxBarWidth: 50,
|
|
443
|
-
hideLegend: hideLegend,
|
|
444
|
-
roundCorners: true,
|
|
445
|
-
};
|
|
421
|
+
return __assign({ data: vbcData, width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, supportNegativeData: true, chartTitle: chartTitle, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle, mode: 'histogram', hideTickOverlap: true, maxBarWidth: 50, hideLegend: hideLegend, roundCorners: true }, getAxisCategoryOrderProps(input.data, input.layout));
|
|
446
422
|
};
|
|
447
|
-
export var
|
|
448
|
-
|
|
423
|
+
export var transformPlotlyJsonToAreaChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
424
|
+
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'area', colorMap, colorwayType, isDarkTheme);
|
|
425
|
+
};
|
|
426
|
+
export var transformPlotlyJsonToLineChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
427
|
+
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'line', colorMap, colorwayType, isDarkTheme);
|
|
428
|
+
};
|
|
429
|
+
export var transformPlotlyJsonToScatterChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
430
|
+
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'scatter', colorMap, colorwayType, isDarkTheme);
|
|
431
|
+
};
|
|
432
|
+
var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme) {
|
|
433
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
434
|
+
var isScatterMarkers = [
|
|
435
|
+
'markers',
|
|
436
|
+
'text+markers',
|
|
437
|
+
'markers+text',
|
|
438
|
+
'lines+markers',
|
|
439
|
+
'markers+line',
|
|
440
|
+
'text+lines+markers',
|
|
441
|
+
].includes((_a = input.data[0]) === null || _a === void 0 ? void 0 : _a.mode);
|
|
442
|
+
var isAreaChart = chartType === 'area';
|
|
443
|
+
var isScatterChart = chartType === 'scatter';
|
|
449
444
|
var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
|
|
450
445
|
var mode = 'tonexty';
|
|
451
|
-
var
|
|
446
|
+
var _h = getLegendProps(input.data, input.layout, isMultiPlot), legends = _h.legends, hideLegend = _h.hideLegend;
|
|
452
447
|
var chartData = input.data
|
|
453
448
|
.map(function (series, index) {
|
|
454
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
449
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
455
450
|
var colors = isScatterMarkers
|
|
456
451
|
? ((_a = series === null || series === void 0 ? void 0 : series.mode) === null || _a === void 0 ? void 0 : _a.includes('line'))
|
|
457
452
|
? (_b = series.line) === null || _b === void 0 ? void 0 : _b.color
|
|
@@ -463,22 +458,17 @@ export var transformPlotlyJsonToScatterChartProps = function (input, isAreaChart
|
|
|
463
458
|
var isXString = isStringArray(xValues);
|
|
464
459
|
var isXDate = isDateArray(xValues);
|
|
465
460
|
var isXNumber = isNumberArray(xValues);
|
|
466
|
-
|
|
467
|
-
var isXYearCategory = false;
|
|
461
|
+
var isXYearCategory = isYearArray(series.x); // Consider year as categorical not numeric continuous axis
|
|
468
462
|
var legend = legends[index];
|
|
469
463
|
// resolve color for each legend's lines from the extracted colors
|
|
470
464
|
var seriesColor = resolveColor(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
465
|
+
var seriesOpacity = getOpacity(series, index);
|
|
471
466
|
mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
|
|
472
467
|
var lineOptions = getLineOptions(series.line);
|
|
473
|
-
var
|
|
474
|
-
var legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot'
|
|
475
|
-
? 'dottedLine'
|
|
476
|
-
: ((_j = series.mode) === null || _j === void 0 ? void 0 : _j.includes('markers'))
|
|
477
|
-
? 'circle'
|
|
478
|
-
: 'default';
|
|
468
|
+
var legendShape = getLegendShape(series);
|
|
479
469
|
var validXYRanges = getValidXYRanges(series);
|
|
480
470
|
return validXYRanges.map(function (_a, rangeIdx) {
|
|
481
|
-
var _b;
|
|
471
|
+
var _b, _c;
|
|
482
472
|
var rangeStart = _a[0], rangeEnd = _a[1];
|
|
483
473
|
var rangeXValues = xValues.slice(rangeStart, rangeEnd);
|
|
484
474
|
var rangeYValues = series.y.slice(rangeStart, rangeEnd);
|
|
@@ -497,30 +487,34 @@ export var transformPlotlyJsonToScatterChartProps = function (input, isAreaChart
|
|
|
497
487
|
? { markerSize: series.marker.size }
|
|
498
488
|
: {})), (textValues ? { text: textValues[i] } : {})));
|
|
499
489
|
}),
|
|
500
|
-
color: seriesColor,
|
|
490
|
+
color: (_c = rgb(seriesColor).copy({ opacity: seriesOpacity }).formatHex8()) !== null && _c !== void 0 ? _c : seriesColor,
|
|
501
491
|
lineOptions: __assign(__assign({}, (lineOptions !== null && lineOptions !== void 0 ? lineOptions : {})), { mode: series.mode }),
|
|
502
|
-
useSecondaryYScale: usesSecondaryYScale(series),
|
|
492
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout),
|
|
503
493
|
};
|
|
504
494
|
});
|
|
505
495
|
})
|
|
506
496
|
.flat();
|
|
507
497
|
var yMinMaxValues = findNumericMinMaxOfY(chartData);
|
|
508
|
-
var
|
|
498
|
+
var _j = getTitles(input.layout), chartTitle = _j.chartTitle, xAxisTitle = _j.xAxisTitle, yAxisTitle = _j.yAxisTitle;
|
|
509
499
|
var numDataPoints = chartData.reduce(function (total, lineChartPoints) { return total + lineChartPoints.data.length; }, 0);
|
|
510
500
|
var chartProps = {
|
|
511
501
|
chartTitle: chartTitle,
|
|
512
502
|
lineChartData: chartData,
|
|
513
503
|
};
|
|
504
|
+
var scatterChartProps = {
|
|
505
|
+
chartTitle: chartTitle,
|
|
506
|
+
scatterChartData: chartData,
|
|
507
|
+
};
|
|
514
508
|
if (isAreaChart) {
|
|
515
|
-
return __assign(__assign({ data: chartProps, supportNegativeData: true, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle }, secondaryYAxisValues), { mode: mode, width: (
|
|
509
|
+
return __assign(__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 });
|
|
516
510
|
}
|
|
517
511
|
else {
|
|
518
|
-
return __assign(__assign({ data: chartProps, supportNegativeData: true, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle }, secondaryYAxisValues), { roundedTicks: true, yMinValue: yMinMaxValues.startValue, yMaxValue: yMinMaxValues.endValue, width: (
|
|
512
|
+
return __assign(__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 });
|
|
519
513
|
}
|
|
520
514
|
};
|
|
521
|
-
export var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
515
|
+
export var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
522
516
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
523
|
-
var _s = getLegendProps(input.data, input.layout), legends = _s.legends, hideLegend = _s.hideLegend;
|
|
517
|
+
var _s = getLegendProps(input.data, input.layout, isMultiPlot), legends = _s.legends, hideLegend = _s.hideLegend;
|
|
524
518
|
var colorScale = undefined;
|
|
525
519
|
var chartData = input.data
|
|
526
520
|
.map(function (series, index) {
|
|
@@ -536,7 +530,7 @@ export var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, co
|
|
|
536
530
|
var legend = legends[index];
|
|
537
531
|
return series.y
|
|
538
532
|
.map(function (yValue, i) {
|
|
539
|
-
var _a, _b, _c, _d, _e;
|
|
533
|
+
var _a, _b, _c, _d, _e, _f;
|
|
540
534
|
if (isInvalidValue((_a = series.x) === null || _a === void 0 ? void 0 : _a[i]) || isInvalidValue(yValue)) {
|
|
541
535
|
return null;
|
|
542
536
|
}
|
|
@@ -546,19 +540,17 @@ export var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, co
|
|
|
546
540
|
? (_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]
|
|
547
541
|
: 0)
|
|
548
542
|
: resolveColor(extractedColors, i, legend, colorMap, isDarkTheme);
|
|
543
|
+
var opacity = getOpacity(series, i);
|
|
549
544
|
return {
|
|
550
545
|
x: series.x[i],
|
|
551
546
|
y: yValue,
|
|
552
547
|
legend: legend,
|
|
553
|
-
color: color,
|
|
548
|
+
color: (_f = rgb(color).copy({ opacity: opacity }).formatHex8()) !== null && _f !== void 0 ? _f : color,
|
|
554
549
|
};
|
|
555
550
|
})
|
|
556
551
|
.filter(function (point) { return point !== null; });
|
|
557
552
|
})
|
|
558
|
-
.
|
|
559
|
-
.flat()
|
|
560
|
-
//reversing the order to invert the Y bars order as required by plotly.
|
|
561
|
-
.reverse();
|
|
553
|
+
.flat();
|
|
562
554
|
var chartHeight = (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.height) !== null && _b !== void 0 ? _b : 450;
|
|
563
555
|
var margin = (_e = (_d = (_c = input.layout) === null || _c === void 0 ? void 0 : _c.margin) === null || _d === void 0 ? void 0 : _d.l) !== null && _e !== void 0 ? _e : 0;
|
|
564
556
|
var padding = (_h = (_g = (_f = input.layout) === null || _f === void 0 ? void 0 : _f.margin) === null || _g === void 0 ? void 0 : _g.pad) !== null && _h !== void 0 ? _h : 0;
|
|
@@ -568,26 +560,11 @@ export var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, co
|
|
|
568
560
|
var gapFactor = 1 / (1 + scalingFactor * numberOfRows);
|
|
569
561
|
var barHeight = availableHeight / (numberOfRows * (1 + gapFactor));
|
|
570
562
|
var _t = getTitles(input.layout), chartTitle = _t.chartTitle, xAxisTitle = _t.xAxisTitle, yAxisTitle = _t.yAxisTitle;
|
|
571
|
-
return {
|
|
572
|
-
data: chartData,
|
|
573
|
-
chartTitle: chartTitle,
|
|
574
|
-
xAxisTitle: xAxisTitle,
|
|
575
|
-
yAxisTitle: yAxisTitle,
|
|
576
|
-
secondaryYAxistitle: typeof ((_k = (_j = input.layout) === null || _j === void 0 ? void 0 : _j.yaxis2) === null || _k === void 0 ? void 0 : _k.title) === 'string'
|
|
563
|
+
return __assign({ data: chartData, chartTitle: chartTitle, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle, secondaryYAxistitle: typeof ((_k = (_j = input.layout) === null || _j === void 0 ? void 0 : _j.yaxis2) === null || _k === void 0 ? void 0 : _k.title) === 'string'
|
|
577
564
|
? (_m = (_l = input.layout) === null || _l === void 0 ? void 0 : _l.yaxis2) === null || _m === void 0 ? void 0 : _m.title
|
|
578
|
-
: ((_q = (_p = (_o = input.layout) === null || _o === void 0 ? void 0 : _o.yaxis2) === null || _p === void 0 ? void 0 : _p.title) === null || _q === void 0 ? void 0 : _q.text) || '',
|
|
579
|
-
barHeight: barHeight,
|
|
580
|
-
showYAxisLables: true,
|
|
581
|
-
height: chartHeight,
|
|
582
|
-
width: (_r = input.layout) === null || _r === void 0 ? void 0 : _r.width,
|
|
583
|
-
hideTickOverlap: true,
|
|
584
|
-
hideLegend: hideLegend,
|
|
585
|
-
noOfCharsToTruncate: 20,
|
|
586
|
-
showYAxisLablesTooltip: true,
|
|
587
|
-
roundCorners: true,
|
|
588
|
-
};
|
|
565
|
+
: ((_q = (_p = (_o = input.layout) === null || _o === void 0 ? void 0 : _o.yaxis2) === null || _p === void 0 ? void 0 : _p.title) === null || _q === void 0 ? void 0 : _q.text) || '', barHeight: barHeight, showYAxisLables: true, height: chartHeight, width: (_r = input.layout) === null || _r === void 0 ? void 0 : _r.width, hideTickOverlap: true, hideLegend: hideLegend, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, roundCorners: true }, getAxisCategoryOrderProps(input.data, input.layout));
|
|
589
566
|
};
|
|
590
|
-
export var transformPlotlyJsonToHeatmapProps = function (input) {
|
|
567
|
+
export var transformPlotlyJsonToHeatmapProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
591
568
|
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;
|
|
592
569
|
var firstData = input.data[0];
|
|
593
570
|
var heatmapDataPoints = [];
|
|
@@ -700,24 +677,9 @@ export var transformPlotlyJsonToHeatmapProps = function (input) {
|
|
|
700
677
|
? colorscale.map(function (arr) { return arr[1]; })
|
|
701
678
|
: defaultRange;
|
|
702
679
|
var _9 = getTitles(input.layout), chartTitle = _9.chartTitle, xAxisTitle = _9.xAxisTitle, yAxisTitle = _9.yAxisTitle;
|
|
703
|
-
return {
|
|
704
|
-
data: [heatmapData],
|
|
705
|
-
domainValuesForColorScale: domainValuesForColorScale,
|
|
706
|
-
rangeValuesForColorScale: rangeValuesForColorScale,
|
|
707
|
-
hideLegend: true,
|
|
708
|
-
showYAxisLables: true,
|
|
709
|
-
chartTitle: chartTitle,
|
|
710
|
-
xAxisTitle: xAxisTitle,
|
|
711
|
-
yAxisTitle: yAxisTitle,
|
|
712
|
-
sortOrder: 'none',
|
|
713
|
-
width: (_6 = input.layout) === null || _6 === void 0 ? void 0 : _6.width,
|
|
714
|
-
height: (_8 = (_7 = input.layout) === null || _7 === void 0 ? void 0 : _7.height) !== null && _8 !== void 0 ? _8 : 350,
|
|
715
|
-
hideTickOverlap: true,
|
|
716
|
-
noOfCharsToTruncate: 20,
|
|
717
|
-
showYAxisLablesTooltip: true,
|
|
718
|
-
};
|
|
680
|
+
return __assign({ data: [heatmapData], domainValuesForColorScale: domainValuesForColorScale, rangeValuesForColorScale: rangeValuesForColorScale, hideLegend: true, showYAxisLables: true, chartTitle: chartTitle, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle, sortOrder: 'none', width: (_6 = input.layout) === null || _6 === void 0 ? void 0 : _6.width, height: (_8 = (_7 = input.layout) === null || _7 === void 0 ? void 0 : _7.height) !== null && _8 !== void 0 ? _8 : 350, hideTickOverlap: true, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true }, getAxisCategoryOrderProps([firstData], input.layout));
|
|
719
681
|
};
|
|
720
|
-
export var transformPlotlyJsonToSankeyProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
682
|
+
export var transformPlotlyJsonToSankeyProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
721
683
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
722
684
|
var _m = input.data[0], link = _m.link, node = _m.node;
|
|
723
685
|
var validLinks = ((_a = link === null || link === void 0 ? void 0 : link.value) !== null && _a !== void 0 ? _a : [])
|
|
@@ -764,7 +726,7 @@ export var transformPlotlyJsonToSankeyProps = function (input, colorMap, colorwa
|
|
|
764
726
|
enableReflow: true,
|
|
765
727
|
};
|
|
766
728
|
};
|
|
767
|
-
export var transformPlotlyJsonToGaugeProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
729
|
+
export var transformPlotlyJsonToGaugeProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
768
730
|
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;
|
|
769
731
|
var firstData = input.data[0];
|
|
770
732
|
var stepsColors = ((_a = firstData.gauge) === null || _a === void 0 ? void 0 : _a.steps) ? firstData.gauge.steps.map(function (step) { return step.color; }) : undefined;
|
|
@@ -863,7 +825,7 @@ var formatValue = function (value, colIndex, cells) {
|
|
|
863
825
|
}
|
|
864
826
|
return "".concat(prefix !== null && prefix !== void 0 ? prefix : '').concat(formatted).concat(suffix !== null && suffix !== void 0 ? suffix : '');
|
|
865
827
|
};
|
|
866
|
-
export var transformPlotlyJsonToChartTableProps = function (input, colorMap, isDarkTheme) {
|
|
828
|
+
export var transformPlotlyJsonToChartTableProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
867
829
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
868
830
|
var tableData = input.data[0];
|
|
869
831
|
var normalizeHeaders = function (values, header) {
|
|
@@ -1066,11 +1028,6 @@ function getLineOptions(line) {
|
|
|
1066
1028
|
}
|
|
1067
1029
|
return Object.keys(lineOptions).length > 0 ? lineOptions : undefined;
|
|
1068
1030
|
}
|
|
1069
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1070
|
-
export var isStringArray = function (arr) {
|
|
1071
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1072
|
-
return isArrayOfType(arr, function (value) { return typeof value === 'string' || value === null; });
|
|
1073
|
-
};
|
|
1074
1031
|
// TODO: Use binary search to find the appropriate bin for numeric value.
|
|
1075
1032
|
var findBinIndex = function (bins, value, isString) {
|
|
1076
1033
|
if (typeof value === 'undefined' || value === null) {
|
|
@@ -1165,7 +1122,47 @@ var precisionRound = function (value, precision) {
|
|
|
1165
1122
|
var factor = Math.pow(10, precision);
|
|
1166
1123
|
return Math.round(value * factor) / factor;
|
|
1167
1124
|
};
|
|
1168
|
-
var
|
|
1125
|
+
var getLegendShape = function (series) {
|
|
1126
|
+
var _a, _b;
|
|
1127
|
+
var dashType = ((_a = series.line) === null || _a === void 0 ? void 0 : _a.dash) || 'solid';
|
|
1128
|
+
if (dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot') {
|
|
1129
|
+
return 'dottedLine';
|
|
1130
|
+
}
|
|
1131
|
+
else if ((_b = series.mode) === null || _b === void 0 ? void 0 : _b.includes('markers')) {
|
|
1132
|
+
return 'circle';
|
|
1133
|
+
}
|
|
1134
|
+
return 'default';
|
|
1135
|
+
};
|
|
1136
|
+
export var getAllupLegendsProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
1137
|
+
var allupLegends = [];
|
|
1138
|
+
// reduce on showlegend boolean propperty. reduce should return true if at least one series has showlegend true
|
|
1139
|
+
var toShowLegend = input.data.reduce(function (acc, series) {
|
|
1140
|
+
return acc || series.showlegend === true;
|
|
1141
|
+
}, false);
|
|
1142
|
+
if (toShowLegend) {
|
|
1143
|
+
input.data.forEach(function (series, index) {
|
|
1144
|
+
var _a, _b, _c, _d, _e;
|
|
1145
|
+
var name = series.legendgroup;
|
|
1146
|
+
var color = ((_a = series.line) === null || _a === void 0 ? void 0 : _a.color) || ((_b = series.marker) === null || _b === void 0 ? void 0 : _b.color);
|
|
1147
|
+
var legendShape = getLegendShape(series);
|
|
1148
|
+
var resolvedColor = 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);
|
|
1149
|
+
if (name !== undefined && allupLegends.some(function (group) { return group.title === name; }) === false) {
|
|
1150
|
+
allupLegends.push({
|
|
1151
|
+
title: name,
|
|
1152
|
+
color: resolvedColor,
|
|
1153
|
+
shape: legendShape,
|
|
1154
|
+
});
|
|
1155
|
+
}
|
|
1156
|
+
});
|
|
1157
|
+
}
|
|
1158
|
+
return {
|
|
1159
|
+
legends: allupLegends,
|
|
1160
|
+
centerLegends: true,
|
|
1161
|
+
enabledWrapLines: true,
|
|
1162
|
+
canSelectMultipleLegends: true,
|
|
1163
|
+
};
|
|
1164
|
+
};
|
|
1165
|
+
var getLegendProps = function (data, layout, isMultiPlot) {
|
|
1169
1166
|
var legends = [];
|
|
1170
1167
|
if (data.length === 1) {
|
|
1171
1168
|
legends.push(data[0].name || '');
|
|
@@ -1175,10 +1172,11 @@ var getLegendProps = function (data, layout) {
|
|
|
1175
1172
|
legends.push(series.name || "Series ".concat(index + 1));
|
|
1176
1173
|
});
|
|
1177
1174
|
}
|
|
1178
|
-
var
|
|
1175
|
+
var hideLegendsData = data.every(function (series) { return series.showlegend === false; });
|
|
1176
|
+
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);
|
|
1179
1177
|
return {
|
|
1180
1178
|
legends: legends,
|
|
1181
|
-
hideLegend:
|
|
1179
|
+
hideLegend: isMultiPlot || hideLegendsInferred || hideLegendsData,
|
|
1182
1180
|
};
|
|
1183
1181
|
};
|
|
1184
1182
|
export var getNumberAtIndexOrDefault = function (data, index) {
|
|
@@ -1210,4 +1208,197 @@ export var getValidXYRanges = function (series) {
|
|
|
1210
1208
|
}
|
|
1211
1209
|
return ranges;
|
|
1212
1210
|
};
|
|
1211
|
+
var getIndexFromKey = function (key, pattern) {
|
|
1212
|
+
var normalizedKey = key.replace(pattern, '') === '' ? '1' : key.replace(pattern, '');
|
|
1213
|
+
return parseInt(normalizedKey, 10) - 1;
|
|
1214
|
+
};
|
|
1215
|
+
export var getGridProperties = function (layout, isMultiPlot) {
|
|
1216
|
+
var _a;
|
|
1217
|
+
var gridX = [];
|
|
1218
|
+
var gridY = [];
|
|
1219
|
+
var annotations = {};
|
|
1220
|
+
var templateRows = '1fr';
|
|
1221
|
+
var templateColumns = '1fr';
|
|
1222
|
+
var gridLayout = {};
|
|
1223
|
+
if (layout === undefined || layout === null || Object.keys(layout).length === 0) {
|
|
1224
|
+
return { templateRows: templateRows, templateColumns: templateColumns, layout: gridLayout };
|
|
1225
|
+
}
|
|
1226
|
+
if (!layout.xaxis || !layout.yaxis) {
|
|
1227
|
+
return { templateRows: templateRows, templateColumns: templateColumns, layout: gridLayout };
|
|
1228
|
+
}
|
|
1229
|
+
if (!isMultiPlot) {
|
|
1230
|
+
return { templateRows: templateRows, templateColumns: templateColumns, layout: gridLayout };
|
|
1231
|
+
}
|
|
1232
|
+
Object.keys(layout).forEach(function (key) {
|
|
1233
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
1234
|
+
if (key.startsWith('xaxis')) {
|
|
1235
|
+
var index = getIndexFromKey(key, 'xaxis');
|
|
1236
|
+
var anchor = (_b = (_a = layout[key]) === null || _a === void 0 ? void 0 : _a.anchor) !== null && _b !== void 0 ? _b : 'y';
|
|
1237
|
+
var anchorIndex = getIndexFromKey(anchor, 'y');
|
|
1238
|
+
if (index !== anchorIndex) {
|
|
1239
|
+
throw new Error("Invalid layout: xaxis ".concat(index + 1, " anchor should be y").concat(anchorIndex + 1));
|
|
1240
|
+
}
|
|
1241
|
+
gridX[index] = (_d = (_c = layout[key]) === null || _c === void 0 ? void 0 : _c.domain) !== null && _d !== void 0 ? _d : [];
|
|
1242
|
+
}
|
|
1243
|
+
else if (key.startsWith('yaxis')) {
|
|
1244
|
+
var index = getIndexFromKey(key, 'yaxis');
|
|
1245
|
+
var anchor = (_f = (_e = layout[key]) === null || _e === void 0 ? void 0 : _e.anchor) !== null && _f !== void 0 ? _f : 'x';
|
|
1246
|
+
var anchorIndex = getIndexFromKey(anchor, 'x');
|
|
1247
|
+
if (index !== anchorIndex) {
|
|
1248
|
+
if ((index === 1 && anchorIndex === 0) || ((_g = layout.yaxis2) === null || _g === void 0 ? void 0 : _g.side) === 'right') {
|
|
1249
|
+
// Special case for secondary y axis where yaxis2 can anchor to x1
|
|
1250
|
+
return { templateRows: templateRows, templateColumns: templateColumns };
|
|
1251
|
+
}
|
|
1252
|
+
throw new Error("Invalid layout: yaxis ".concat(index + 1, " anchor should be x").concat(anchorIndex + 1));
|
|
1253
|
+
}
|
|
1254
|
+
gridY[index] = (_j = (_h = layout[key]) === null || _h === void 0 ? void 0 : _h.domain) !== null && _j !== void 0 ? _j : [];
|
|
1255
|
+
}
|
|
1256
|
+
});
|
|
1257
|
+
(_a = layout.annotations) === null || _a === void 0 ? void 0 : _a.forEach(function (annotation) {
|
|
1258
|
+
var xMatches = gridX.flatMap(function (interval, idx) {
|
|
1259
|
+
return (annotation === null || annotation === void 0 ? void 0 : annotation.x) >= interval[0] && (annotation === null || annotation === void 0 ? void 0 : annotation.x) <= interval[1] ? [idx] : [];
|
|
1260
|
+
});
|
|
1261
|
+
var yMatch = gridY.findIndex(function (interval, yIndex) {
|
|
1262
|
+
return xMatches.includes(yIndex) &&
|
|
1263
|
+
(annotation === null || annotation === void 0 ? void 0 : annotation.y) >= interval[0] &&
|
|
1264
|
+
(annotation === null || annotation === void 0 ? void 0 : annotation.y) <= interval[1];
|
|
1265
|
+
});
|
|
1266
|
+
if (yMatch !== -1) {
|
|
1267
|
+
if (annotations[yMatch] === undefined) {
|
|
1268
|
+
annotations[yMatch] = {};
|
|
1269
|
+
}
|
|
1270
|
+
if ((annotation === null || annotation === void 0 ? void 0 : annotation.textangle) === 90) {
|
|
1271
|
+
annotations[yMatch].yAnnotation = annotation.text;
|
|
1272
|
+
}
|
|
1273
|
+
else {
|
|
1274
|
+
annotations[yMatch].xAnnotation = annotation.text;
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
});
|
|
1278
|
+
if (gridX.length > 0) {
|
|
1279
|
+
var uniqueXIntervals_1 = new Map();
|
|
1280
|
+
gridX.forEach(function (interval) {
|
|
1281
|
+
var key = "".concat(interval[0], "-").concat(interval[1]);
|
|
1282
|
+
if (!uniqueXIntervals_1.has(key)) {
|
|
1283
|
+
uniqueXIntervals_1.set(key, interval);
|
|
1284
|
+
}
|
|
1285
|
+
});
|
|
1286
|
+
var minXInterval_1 = Math.min.apply(Math, Array.from(uniqueXIntervals_1.values()).map(function (interval) { return interval[1] - interval[0]; }));
|
|
1287
|
+
templateColumns = Array.from(uniqueXIntervals_1.values())
|
|
1288
|
+
.map(function (interval) { return "".concat((interval[1] - interval[0]) / minXInterval_1, "fr"); })
|
|
1289
|
+
.join(' ');
|
|
1290
|
+
var columnNumber_1 = 1;
|
|
1291
|
+
var lastIntervalEnd_1 = 0;
|
|
1292
|
+
gridX.forEach(function (interval, index) {
|
|
1293
|
+
if (interval.length === 0) {
|
|
1294
|
+
return;
|
|
1295
|
+
}
|
|
1296
|
+
var cellName = "x".concat(index === 0 ? '' : index + 1);
|
|
1297
|
+
var annotationProps = annotations[index];
|
|
1298
|
+
var xAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.xAnnotation;
|
|
1299
|
+
if (interval[0] < lastIntervalEnd_1) {
|
|
1300
|
+
columnNumber_1 = 1;
|
|
1301
|
+
}
|
|
1302
|
+
lastIntervalEnd_1 = interval[1];
|
|
1303
|
+
var row = {
|
|
1304
|
+
row: -1,
|
|
1305
|
+
column: columnNumber_1,
|
|
1306
|
+
xAnnotation: xAnnotation,
|
|
1307
|
+
};
|
|
1308
|
+
gridLayout[cellName] = row;
|
|
1309
|
+
columnNumber_1 += 1;
|
|
1310
|
+
});
|
|
1311
|
+
}
|
|
1312
|
+
var numColumns = Math.max.apply(Math, Object.values(gridLayout).map(function (cell) { var _a; return (_a = cell.column) !== null && _a !== void 0 ? _a : 0; }));
|
|
1313
|
+
var columnFill = {};
|
|
1314
|
+
for (var i = 1; i <= numColumns; i++) {
|
|
1315
|
+
columnFill[i] = { row: 1, fillDomain: 0 };
|
|
1316
|
+
}
|
|
1317
|
+
if (gridY.length > 0) {
|
|
1318
|
+
var uniqueYIntervals_1 = new Map();
|
|
1319
|
+
gridY.forEach(function (interval) {
|
|
1320
|
+
var key = "".concat(interval[0], "-").concat(interval[1]);
|
|
1321
|
+
if (!uniqueYIntervals_1.has(key)) {
|
|
1322
|
+
uniqueYIntervals_1.set(key, interval);
|
|
1323
|
+
}
|
|
1324
|
+
});
|
|
1325
|
+
var minYInterval_1 = Math.min.apply(Math, Array.from(uniqueYIntervals_1.values()).map(function (interval) { return interval[1] - interval[0]; }));
|
|
1326
|
+
templateRows = Array.from(uniqueYIntervals_1.values())
|
|
1327
|
+
.map(function (interval) { return "".concat((interval[1] - interval[0]) / minYInterval_1, "fr"); })
|
|
1328
|
+
.join(' ');
|
|
1329
|
+
gridY.forEach(function (interval, index) {
|
|
1330
|
+
if (interval.length === 0) {
|
|
1331
|
+
return;
|
|
1332
|
+
}
|
|
1333
|
+
var cellName = "x".concat(index === 0 ? '' : index + 1);
|
|
1334
|
+
var annotationProps = annotations[index];
|
|
1335
|
+
var yAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.yAnnotation;
|
|
1336
|
+
var cell = gridLayout[cellName];
|
|
1337
|
+
if (cell !== undefined) {
|
|
1338
|
+
cell.row = columnFill[cell.column].row;
|
|
1339
|
+
cell.yAnnotation = yAnnotation;
|
|
1340
|
+
}
|
|
1341
|
+
columnFill[cell.column].fillDomain = interval[1];
|
|
1342
|
+
columnFill[cell.column].row += 1;
|
|
1343
|
+
});
|
|
1344
|
+
}
|
|
1345
|
+
// reverse the order of rows in grid layout from bottom-top to top-bottom as required by CSS grid
|
|
1346
|
+
var reversedGridLayout = {};
|
|
1347
|
+
// find the maximum row number
|
|
1348
|
+
var maxRowNumber = Math.max.apply(Math, Object.values(gridLayout).map(function (cell) { var _a; return (_a = cell.row) !== null && _a !== void 0 ? _a : 0; }));
|
|
1349
|
+
// iterate over the gridLayout and reverse the row numbers
|
|
1350
|
+
Object.keys(gridLayout).forEach(function (key) {
|
|
1351
|
+
var cell = gridLayout[key];
|
|
1352
|
+
if (cell.row !== undefined) {
|
|
1353
|
+
// reverse the row number
|
|
1354
|
+
cell.row = maxRowNumber - cell.row + 1;
|
|
1355
|
+
}
|
|
1356
|
+
reversedGridLayout[key] = cell;
|
|
1357
|
+
});
|
|
1358
|
+
return {
|
|
1359
|
+
templateRows: templateRows,
|
|
1360
|
+
templateColumns: templateColumns,
|
|
1361
|
+
layout: reversedGridLayout,
|
|
1362
|
+
};
|
|
1363
|
+
};
|
|
1364
|
+
/**
|
|
1365
|
+
* @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/category_order_defaults.js#L50}
|
|
1366
|
+
*/
|
|
1367
|
+
var getAxisCategoryOrderProps = function (data, layout) {
|
|
1368
|
+
var result = {};
|
|
1369
|
+
var axesById = {
|
|
1370
|
+
x: layout === null || layout === void 0 ? void 0 : layout.xaxis,
|
|
1371
|
+
y: layout === null || layout === void 0 ? void 0 : layout.yaxis,
|
|
1372
|
+
};
|
|
1373
|
+
Object.keys(axesById).forEach(function (axId) {
|
|
1374
|
+
var ax = axesById[axId];
|
|
1375
|
+
var axLetter = axId[0];
|
|
1376
|
+
var propName = "".concat(axLetter, "AxisCategoryOrder");
|
|
1377
|
+
var values = [];
|
|
1378
|
+
data.forEach(function (series) {
|
|
1379
|
+
var _a;
|
|
1380
|
+
(_a = series[axLetter]) === null || _a === void 0 ? void 0 : _a.forEach(function (val) {
|
|
1381
|
+
if (!isInvalidValue(val)) {
|
|
1382
|
+
values.push(val);
|
|
1383
|
+
}
|
|
1384
|
+
});
|
|
1385
|
+
});
|
|
1386
|
+
var isAxisTypeCategory = (ax === null || ax === void 0 ? void 0 : ax.type) === 'category' || (isStringArray(values) && !isNumberArray(values) && !isDateArray(values));
|
|
1387
|
+
if (!isAxisTypeCategory) {
|
|
1388
|
+
return;
|
|
1389
|
+
}
|
|
1390
|
+
var isValidArray = isArrayOrTypedArray(ax === null || ax === void 0 ? void 0 : ax.categoryarray) && ax.categoryarray.length > 0;
|
|
1391
|
+
if (isValidArray && (!(ax === null || ax === void 0 ? void 0 : ax.categoryorder) || ax.categoryorder === 'array')) {
|
|
1392
|
+
result[propName] = ax.categoryarray;
|
|
1393
|
+
return;
|
|
1394
|
+
}
|
|
1395
|
+
if (!(ax === null || ax === void 0 ? void 0 : ax.categoryorder) || ax.categoryorder === 'trace' || ax.categoryorder === 'array') {
|
|
1396
|
+
var categoriesInTraceOrder = Array.from(new Set(values));
|
|
1397
|
+
result[propName] = categoriesInTraceOrder;
|
|
1398
|
+
return;
|
|
1399
|
+
}
|
|
1400
|
+
result[propName] = ax.categoryorder;
|
|
1401
|
+
});
|
|
1402
|
+
return result;
|
|
1403
|
+
};
|
|
1213
1404
|
//# sourceMappingURL=PlotlySchemaAdapter.js.map
|