@fluentui/react-charts 9.2.2 → 9.2.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.md +35 -2
- package/dist/index.d.ts +89 -10
- package/lib/components/AreaChart/AreaChart.js +4 -1
- package/lib/components/AreaChart/AreaChart.js.map +1 -1
- package/lib/components/AreaChart/useAreaChartStyles.styles.js +2 -1
- package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
- package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js +2 -1
- package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
- package/lib/components/ChartTable/ChartTable.js +3 -2
- package/lib/components/ChartTable/ChartTable.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.js +60 -19
- package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +13 -0
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +12 -0
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +175 -107
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +6 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +791 -199
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.js +2 -2
- package/lib/components/DonutChart/DonutChart.js.map +1 -1
- package/lib/components/GanttChart/useGanttChartStyles.styles.js +2 -1
- package/lib/components/GanttChart/useGanttChartStyles.styles.js.map +1 -1
- package/lib/components/GanttChart/useGanttChartStyles.styles.raw.js +2 -1
- package/lib/components/GanttChart/useGanttChartStyles.styles.raw.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +29 -8
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +2 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +2 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib/components/HeatMapChart/HeatMapChart.js +175 -114
- package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js +2 -1
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +2 -1
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +26 -6
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +2 -1
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +2 -1
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
- package/lib/components/LineChart/LineChart.js +251 -78
- package/lib/components/LineChart/LineChart.js.map +1 -1
- package/lib/components/LineChart/LineChart.types.js.map +1 -1
- package/lib/components/LineChart/useLineChartStyles.styles.js +10 -3
- package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -1
- package/lib/components/LineChart/useLineChartStyles.styles.raw.js +14 -2
- package/lib/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.js +56 -37
- package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -1
- package/lib/components/ScatterChart/useScatterChartStyles.styles.js +21 -4
- package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js +16 -3
- package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.js +27 -4
- package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +2 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +2 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +158 -46
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +2 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +2 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
- package/lib/types/DataPoint.js.map +1 -1
- package/lib/utilities/utilities.js +15 -5
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-commonjs/components/AreaChart/AreaChart.js +4 -1
- package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js +2 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/ChartTable/ChartTable.js +3 -2
- package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.js +60 -18
- package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +13 -0
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +12 -0
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +171 -105
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +9 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +810 -197
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.js +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
- package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js +2 -1
- package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +28 -7
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +2 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +174 -113
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js +2 -1
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +25 -5
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +2 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.js +250 -78
- package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.types.js.map +1 -1
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js +12 -3
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js +14 -2
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.js +56 -37
- package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.types.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js +30 -3
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js +15 -2
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +26 -3
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +2 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +157 -45
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +2 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/types/DataPoint.js.map +1 -1
- package/lib-commonjs/utilities/utilities.js +15 -4
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +10 -10
|
@@ -18,9 +18,27 @@ _export(exports, {
|
|
|
18
18
|
findArrayAttributes: function() {
|
|
19
19
|
return findArrayAttributes;
|
|
20
20
|
},
|
|
21
|
+
getAllupLegendsProps: function() {
|
|
22
|
+
return getAllupLegendsProps;
|
|
23
|
+
},
|
|
24
|
+
getGridProperties: function() {
|
|
25
|
+
return getGridProperties;
|
|
26
|
+
},
|
|
27
|
+
getNumberAtIndexOrDefault: function() {
|
|
28
|
+
return getNumberAtIndexOrDefault;
|
|
29
|
+
},
|
|
30
|
+
getValidXYRanges: function() {
|
|
31
|
+
return getValidXYRanges;
|
|
32
|
+
},
|
|
21
33
|
projectPolarToCartesian: function() {
|
|
22
34
|
return projectPolarToCartesian;
|
|
23
35
|
},
|
|
36
|
+
resolveXAxisPoint: function() {
|
|
37
|
+
return resolveXAxisPoint;
|
|
38
|
+
},
|
|
39
|
+
transformPlotlyJsonToAreaChartProps: function() {
|
|
40
|
+
return transformPlotlyJsonToAreaChartProps;
|
|
41
|
+
},
|
|
24
42
|
transformPlotlyJsonToChartTableProps: function() {
|
|
25
43
|
return transformPlotlyJsonToChartTableProps;
|
|
26
44
|
},
|
|
@@ -39,6 +57,9 @@ _export(exports, {
|
|
|
39
57
|
transformPlotlyJsonToHorizontalBarWithAxisProps: function() {
|
|
40
58
|
return transformPlotlyJsonToHorizontalBarWithAxisProps;
|
|
41
59
|
},
|
|
60
|
+
transformPlotlyJsonToLineChartProps: function() {
|
|
61
|
+
return transformPlotlyJsonToLineChartProps;
|
|
62
|
+
},
|
|
42
63
|
transformPlotlyJsonToSankeyProps: function() {
|
|
43
64
|
return transformPlotlyJsonToSankeyProps;
|
|
44
65
|
},
|
|
@@ -56,11 +77,13 @@ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildc
|
|
|
56
77
|
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
57
78
|
const _d3array = require("d3-array");
|
|
58
79
|
const _d3scale = require("d3-scale");
|
|
80
|
+
const _d3format = require("d3-format");
|
|
59
81
|
const _colors = require("../../utilities/colors");
|
|
60
82
|
const _utilities = require("../../utilities/utilities");
|
|
61
83
|
const _chartutilities = require("@fluentui/chart-utilities");
|
|
62
84
|
const _d3shape = require("d3-shape");
|
|
63
85
|
const _PlotlyColorAdapter = require("./PlotlyColorAdapter");
|
|
86
|
+
const _d3color = require("d3-color");
|
|
64
87
|
const dashOptions = {
|
|
65
88
|
dot: {
|
|
66
89
|
strokeDasharray: '1, 5',
|
|
@@ -118,24 +141,35 @@ const correctYearMonth = (xValues)=>{
|
|
|
118
141
|
const parsedDate = `${possiblyMonthValue} 01, ${presentYear}`;
|
|
119
142
|
return (0, _chartutilities.isDate)(parsedDate) ? new Date(parsedDate) : null;
|
|
120
143
|
});
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
144
|
+
const filteredDateIndexPairs = dates.map((date, index)=>[
|
|
145
|
+
date,
|
|
146
|
+
index
|
|
147
|
+
]).filter(([date])=>date !== null);
|
|
148
|
+
for(let i = filteredDateIndexPairs.length - 1; i > 0; i--){
|
|
149
|
+
const currentDate = filteredDateIndexPairs[i][0];
|
|
150
|
+
const previousDate = filteredDateIndexPairs[i - 1][0];
|
|
151
|
+
const currentMonth = currentDate.getMonth();
|
|
152
|
+
const previousMonth = previousDate.getMonth();
|
|
153
|
+
const currentYear = currentDate.getFullYear();
|
|
154
|
+
const previousYear = previousDate.getFullYear();
|
|
126
155
|
if (previousMonth >= currentMonth) {
|
|
127
|
-
|
|
156
|
+
filteredDateIndexPairs[i - 1][0].setFullYear(currentYear - 1);
|
|
128
157
|
} else if (previousYear > currentYear) {
|
|
129
|
-
|
|
158
|
+
filteredDateIndexPairs[i - 1][0].setFullYear(currentYear);
|
|
130
159
|
}
|
|
160
|
+
dates[filteredDateIndexPairs[i - 1][1]] = filteredDateIndexPairs[i - 1][0];
|
|
131
161
|
}
|
|
132
162
|
xValues = xValues.map((month, index)=>{
|
|
163
|
+
if (dates[index] === null) {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
133
166
|
return `${month} 01, ${dates[index].getFullYear()}`;
|
|
134
167
|
});
|
|
135
168
|
return xValues;
|
|
136
169
|
};
|
|
137
|
-
const usesSecondaryYScale = (series)=>{
|
|
138
|
-
|
|
170
|
+
const usesSecondaryYScale = (series, layout)=>{
|
|
171
|
+
var _layout_yaxis2, _layout_yaxis21;
|
|
172
|
+
return series.yaxis === 'y2' && ((layout === null || layout === void 0 ? void 0 : (_layout_yaxis2 = layout.yaxis2) === null || _layout_yaxis2 === void 0 ? void 0 : _layout_yaxis2.anchor) === 'x' || (layout === null || layout === void 0 ? void 0 : (_layout_yaxis21 = layout.yaxis2) === null || _layout_yaxis21 === void 0 ? void 0 : _layout_yaxis21.side) === 'right');
|
|
139
173
|
};
|
|
140
174
|
const getSecondaryYAxisValues = (data, layout, maxAllowedMinY, minAllowedMaxY)=>{
|
|
141
175
|
var _layout_yaxis2, _layout_yaxis21, _layout_yaxis2_title, _layout_yaxis22;
|
|
@@ -143,7 +177,7 @@ const getSecondaryYAxisValues = (data, layout, maxAllowedMinY, minAllowedMaxY)=>
|
|
|
143
177
|
let yMinValue;
|
|
144
178
|
let yMaxValue;
|
|
145
179
|
data.forEach((series)=>{
|
|
146
|
-
if (usesSecondaryYScale(series)) {
|
|
180
|
+
if (usesSecondaryYScale(series, layout)) {
|
|
147
181
|
containsSecondaryYAxis = true;
|
|
148
182
|
const yValues = series.y;
|
|
149
183
|
if (yValues) {
|
|
@@ -177,32 +211,56 @@ const _getGaugeAxisColor = (colorway, colorwayType, color, colorMap, isDarkTheme
|
|
|
177
211
|
const extractedColors = (0, _PlotlyColorAdapter.extractColor)(colorway, colorwayType, color, colorMap, isDarkTheme);
|
|
178
212
|
return (0, _PlotlyColorAdapter.resolveColor)(extractedColors, 0, '', colorMap, isDarkTheme);
|
|
179
213
|
};
|
|
180
|
-
const
|
|
181
|
-
|
|
214
|
+
const resolveXAxisPoint = (x, isXYearCategory, isXString, isXDate, isXNumber)=>{
|
|
215
|
+
if (x === null || x === undefined) {
|
|
216
|
+
return '';
|
|
217
|
+
}
|
|
218
|
+
if (isXYearCategory) {
|
|
219
|
+
return x.toString();
|
|
220
|
+
}
|
|
221
|
+
if (isXString) {
|
|
222
|
+
if (isXDate) {
|
|
223
|
+
const date = new Date(x);
|
|
224
|
+
return date;
|
|
225
|
+
}
|
|
226
|
+
if (isXNumber) {
|
|
227
|
+
return parseFloat(x);
|
|
228
|
+
}
|
|
229
|
+
return x;
|
|
230
|
+
}
|
|
231
|
+
return x;
|
|
232
|
+
};
|
|
233
|
+
const transformPlotlyJsonToDonutProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
234
|
+
var _input_layout, _input_layout_template_layout, _input_layout_template, _input_layout1, _input_layout2, _firstData_marker, _firstData_labels, _input_layout3, _input_layout4, _input_layout5, _input_layout6;
|
|
182
235
|
const firstData = input.data[0];
|
|
236
|
+
var _input_layout_piecolorway, _input_layout_piecolorway1;
|
|
183
237
|
// extract colors for each series only once
|
|
184
|
-
|
|
238
|
+
// use piecolorway if available
|
|
239
|
+
// otherwise, default to colorway from template
|
|
240
|
+
const colors = (0, _PlotlyColorAdapter.extractColor)((_input_layout_piecolorway = (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.piecolorway) !== null && _input_layout_piecolorway !== void 0 ? _input_layout_piecolorway : (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_template = _input_layout1.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_input_layout_piecolorway1 = (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.piecolorway) !== null && _input_layout_piecolorway1 !== void 0 ? _input_layout_piecolorway1 : firstData === null || firstData === void 0 ? void 0 : (_firstData_marker = firstData.marker) === null || _firstData_marker === void 0 ? void 0 : _firstData_marker.colors, colorMap, isDarkTheme);
|
|
185
241
|
const mapLegendToDataPoint = {};
|
|
186
242
|
(_firstData_labels = firstData.labels) === null || _firstData_labels === void 0 ? void 0 : _firstData_labels.forEach((label, index)=>{
|
|
187
|
-
|
|
243
|
+
const value = getNumberAtIndexOrDefault(firstData.values, index);
|
|
244
|
+
if ((0, _chartutilities.isInvalidValue)(value) || value < 0) {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
const legend = `${label}`;
|
|
188
248
|
// resolve color for each legend from the extracted colors
|
|
189
|
-
const color = (0, _PlotlyColorAdapter.resolveColor)(colors, index,
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
mapLegendToDataPoint[label] = {
|
|
194
|
-
legend: label,
|
|
249
|
+
const color = (0, _PlotlyColorAdapter.resolveColor)(colors, index, legend, colorMap, isDarkTheme);
|
|
250
|
+
if (!mapLegendToDataPoint[legend]) {
|
|
251
|
+
mapLegendToDataPoint[legend] = {
|
|
252
|
+
legend,
|
|
195
253
|
data: value,
|
|
196
254
|
color
|
|
197
255
|
};
|
|
198
256
|
} else {
|
|
199
|
-
mapLegendToDataPoint[
|
|
257
|
+
mapLegendToDataPoint[legend].data += value;
|
|
200
258
|
}
|
|
201
259
|
});
|
|
202
260
|
var _input_layout_width;
|
|
203
|
-
const width = (_input_layout_width = (
|
|
261
|
+
const width = (_input_layout_width = (_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : _input_layout3.width) !== null && _input_layout_width !== void 0 ? _input_layout_width : 440;
|
|
204
262
|
var _input_layout_height;
|
|
205
|
-
const height = (_input_layout_height = (
|
|
263
|
+
const height = (_input_layout_height = (_input_layout4 = input.layout) === null || _input_layout4 === void 0 ? void 0 : _input_layout4.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 220;
|
|
206
264
|
const hideLabels = firstData.textinfo ? ![
|
|
207
265
|
'value',
|
|
208
266
|
'percent',
|
|
@@ -210,15 +268,15 @@ const transformPlotlyJsonToDonutProps = (input, colorMap, colorwayType, isDarkTh
|
|
|
210
268
|
].includes(firstData.textinfo) : false;
|
|
211
269
|
const donutMarginHorizontal = hideLabels ? 0 : 80;
|
|
212
270
|
const donutMarginVertical = 40 + (hideLabels ? 0 : 40);
|
|
213
|
-
const innerRadius = firstData.hole ? firstData.hole * (Math.min(width - donutMarginHorizontal, height - donutMarginVertical) / 2) :
|
|
271
|
+
const innerRadius = firstData.hole ? firstData.hole * (Math.min(width - donutMarginHorizontal, height - donutMarginVertical) / 2) : _utilities.MIN_DONUT_RADIUS;
|
|
214
272
|
const { chartTitle } = getTitles(input.layout);
|
|
215
273
|
return {
|
|
216
274
|
data: {
|
|
217
275
|
chartTitle,
|
|
218
276
|
chartData: Object.values(mapLegendToDataPoint)
|
|
219
277
|
},
|
|
220
|
-
hideLegend: ((
|
|
221
|
-
width: (
|
|
278
|
+
hideLegend: ((_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : _input_layout5.showlegend) === false ? true : false,
|
|
279
|
+
width: (_input_layout6 = input.layout) === null || _input_layout6 === void 0 ? void 0 : _input_layout6.width,
|
|
222
280
|
height,
|
|
223
281
|
innerRadius,
|
|
224
282
|
hideLabels,
|
|
@@ -229,63 +287,84 @@ const transformPlotlyJsonToDonutProps = (input, colorMap, colorwayType, isDarkTh
|
|
|
229
287
|
roundCorners: true
|
|
230
288
|
};
|
|
231
289
|
};
|
|
232
|
-
const transformPlotlyJsonToVSBCProps = (input, colorMap, colorwayType, isDarkTheme, fallbackVSBC)=>{
|
|
290
|
+
const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme, fallbackVSBC)=>{
|
|
233
291
|
var _input_layout, _input_layout1, _vsbcData_;
|
|
234
292
|
const mapXToDataPoints = {};
|
|
235
293
|
let yMaxValue = 0;
|
|
236
294
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
|
|
237
|
-
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
295
|
+
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
296
|
+
let colorScale = undefined;
|
|
238
297
|
let yMinValue = 0;
|
|
239
298
|
input.data.forEach((series, index1)=>{
|
|
240
|
-
var
|
|
299
|
+
var _input_layout_coloraxis_colorscale, _input_layout_coloraxis, _input_layout, _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout1, _series_marker3, _input_layout_template_layout1, _input_layout_template1, _input_layout2, _series_line;
|
|
300
|
+
if (((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_coloraxis = _input_layout.coloraxis) === null || _input_layout_coloraxis === void 0 ? void 0 : (_input_layout_coloraxis_colorscale = _input_layout_coloraxis.colorscale) === null || _input_layout_coloraxis_colorscale === void 0 ? void 0 : _input_layout_coloraxis_colorscale.length) && (0, _chartutilities.isArrayOrTypedArray)((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) && ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length > 0 && typeof ((_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[0]) === 'number') {
|
|
301
|
+
colorScale = createColorScale(input.layout, series);
|
|
302
|
+
}
|
|
241
303
|
const isXYearCategory = (0, _chartutilities.isYearArray)(series.x); // Consider year as categorical not numeric continuous axis
|
|
242
304
|
// extract bar colors for each series only once
|
|
243
|
-
const extractedBarColors = (0, _PlotlyColorAdapter.extractColor)((
|
|
305
|
+
const extractedBarColors = (0, _PlotlyColorAdapter.extractColor)((_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_template = _input_layout1.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_series_marker3 = series.marker) === null || _series_marker3 === void 0 ? void 0 : _series_marker3.color, colorMap, isDarkTheme);
|
|
244
306
|
// extract line colors for each series only once
|
|
245
|
-
const extractedLineColors = (0, _PlotlyColorAdapter.extractColor)((
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
legend,
|
|
263
|
-
data: yVal,
|
|
264
|
-
color
|
|
265
|
-
});
|
|
266
|
-
yMaxValue = Math.max(yMaxValue, yVal);
|
|
267
|
-
} else if (series.type === 'scatter' || !!fallbackVSBC) {
|
|
268
|
-
var _series_line;
|
|
269
|
-
const lineColor = (0, _PlotlyColorAdapter.resolveColor)(extractedLineColors, index1, legend, colorMap, isDarkTheme);
|
|
270
|
-
const lineOptions = getLineOptions(series.line);
|
|
271
|
-
const dashType = ((_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.dash) || 'solid';
|
|
272
|
-
const legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot' ? 'dottedLine' : 'default';
|
|
273
|
-
mapXToDataPoints[x].lineData.push({
|
|
274
|
-
legend,
|
|
275
|
-
legendShape,
|
|
276
|
-
y: yVal,
|
|
277
|
-
color: lineColor,
|
|
278
|
-
...lineOptions ? {
|
|
279
|
-
lineOptions
|
|
280
|
-
} : {},
|
|
281
|
-
useSecondaryYScale: usesSecondaryYScale(series)
|
|
282
|
-
});
|
|
283
|
-
if (!usesSecondaryYScale(series)) {
|
|
284
|
-
yMaxValue = Math.max(yMaxValue, yVal);
|
|
307
|
+
const extractedLineColors = (0, _PlotlyColorAdapter.extractColor)((_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : (_input_layout_template1 = _input_layout2.template) === null || _input_layout_template1 === void 0 ? void 0 : (_input_layout_template_layout1 = _input_layout_template1.layout) === null || _input_layout_template_layout1 === void 0 ? void 0 : _input_layout_template_layout1.colorway, colorwayType, (_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.color, colorMap, isDarkTheme);
|
|
308
|
+
const xValues = series.x;
|
|
309
|
+
const isXDate = (0, _chartutilities.isDateArray)(xValues);
|
|
310
|
+
const isXString = (0, _chartutilities.isStringArray)(xValues);
|
|
311
|
+
const isXNumber = (0, _chartutilities.isNumberArray)(xValues);
|
|
312
|
+
const validXYRanges = getValidXYRanges(series);
|
|
313
|
+
validXYRanges.forEach(([rangeStart, rangeEnd], rangeIdx)=>{
|
|
314
|
+
const rangeXValues = series.x.slice(rangeStart, rangeEnd);
|
|
315
|
+
const rangeYValues = series.y.slice(rangeStart, rangeEnd);
|
|
316
|
+
rangeXValues.forEach((x, index2)=>{
|
|
317
|
+
var _series_marker, _series_marker1, _series_marker_color, _series_marker2;
|
|
318
|
+
if (!mapXToDataPoints[x]) {
|
|
319
|
+
mapXToDataPoints[x] = {
|
|
320
|
+
xAxisPoint: resolveXAxisPoint(x, isXYearCategory, isXString, isXDate, isXNumber),
|
|
321
|
+
chartData: [],
|
|
322
|
+
lineData: []
|
|
323
|
+
};
|
|
285
324
|
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
325
|
+
const legend = legends[index1];
|
|
326
|
+
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
327
|
+
const color = colorScale ? colorScale((0, _chartutilities.isArrayOrTypedArray)((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) ? (_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[index2 % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : (0, _PlotlyColorAdapter.resolveColor)(extractedBarColors, index2, legend, colorMap, isDarkTheme);
|
|
328
|
+
const opacity = (0, _PlotlyColorAdapter.getOpacity)(series, index2);
|
|
329
|
+
const yVal = rangeYValues[index2];
|
|
330
|
+
if (series.type === 'bar') {
|
|
331
|
+
var _rgb_copy_formatHex8;
|
|
332
|
+
mapXToDataPoints[x].chartData.push({
|
|
333
|
+
legend,
|
|
334
|
+
data: yVal,
|
|
335
|
+
color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(color).copy({
|
|
336
|
+
opacity
|
|
337
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
|
|
338
|
+
});
|
|
339
|
+
if (typeof yVal === 'number') {
|
|
340
|
+
yMaxValue = Math.max(yMaxValue, yVal);
|
|
341
|
+
}
|
|
342
|
+
} else if (series.type === 'scatter' || !!fallbackVSBC) {
|
|
343
|
+
var _series_mode;
|
|
344
|
+
const lineColor = (0, _PlotlyColorAdapter.resolveColor)(extractedLineColors, index1, legend, colorMap, isDarkTheme);
|
|
345
|
+
const lineOptions = !((_series_mode = series.mode) === null || _series_mode === void 0 ? void 0 : _series_mode.includes('text')) ? getLineOptions(series.line) : undefined;
|
|
346
|
+
const legendShape = getLegendShape(series);
|
|
347
|
+
var _rgb_copy_formatHex81;
|
|
348
|
+
mapXToDataPoints[x].lineData.push({
|
|
349
|
+
legend: legend + (validXYRanges.length > 1 ? `.${rangeIdx + 1}` : ''),
|
|
350
|
+
legendShape,
|
|
351
|
+
y: yVal,
|
|
352
|
+
color: (_rgb_copy_formatHex81 = (0, _d3color.rgb)(lineColor).copy({
|
|
353
|
+
opacity
|
|
354
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex81 !== void 0 ? _rgb_copy_formatHex81 : color,
|
|
355
|
+
lineOptions: {
|
|
356
|
+
...lineOptions !== null && lineOptions !== void 0 ? lineOptions : {},
|
|
357
|
+
mode: series.mode
|
|
358
|
+
},
|
|
359
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout)
|
|
360
|
+
});
|
|
361
|
+
if (!usesSecondaryYScale(series, input.layout) && typeof yVal === 'number') {
|
|
362
|
+
yMaxValue = Math.max(yMaxValue, yVal);
|
|
363
|
+
yMinValue = Math.min(yMinValue, yVal);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
yMaxValue = Math.max(yMaxValue, yVal);
|
|
367
|
+
});
|
|
289
368
|
});
|
|
290
369
|
});
|
|
291
370
|
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
@@ -307,19 +386,45 @@ const transformPlotlyJsonToVSBCProps = (input, colorMap, colorwayType, isDarkThe
|
|
|
307
386
|
hideTickOverlap: true,
|
|
308
387
|
barGapMax: 2,
|
|
309
388
|
hideLegend,
|
|
310
|
-
roundCorners: true
|
|
389
|
+
roundCorners: true,
|
|
390
|
+
showYAxisLables: true,
|
|
391
|
+
noOfCharsToTruncate: 20,
|
|
392
|
+
showYAxisLablesTooltip: true,
|
|
393
|
+
...getAxisCategoryOrderProps(input.data, input.layout)
|
|
311
394
|
};
|
|
312
395
|
};
|
|
313
|
-
const
|
|
396
|
+
const createColorScale = (layout, series)=>{
|
|
397
|
+
var _layout_coloraxis, _series_marker, _layout_coloraxis1, _layout_coloraxis2;
|
|
398
|
+
const scale = layout === null || layout === void 0 ? void 0 : (_layout_coloraxis = layout.coloraxis) === null || _layout_coloraxis === void 0 ? void 0 : _layout_coloraxis.colorscale;
|
|
399
|
+
const colorValues = (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color;
|
|
400
|
+
var _layout_coloraxis_cmin, _layout_coloraxis_cmax;
|
|
401
|
+
const [dMin, dMax] = [
|
|
402
|
+
(_layout_coloraxis_cmin = layout === null || layout === void 0 ? void 0 : (_layout_coloraxis1 = layout.coloraxis) === null || _layout_coloraxis1 === void 0 ? void 0 : _layout_coloraxis1.cmin) !== null && _layout_coloraxis_cmin !== void 0 ? _layout_coloraxis_cmin : Math.min(...colorValues),
|
|
403
|
+
(_layout_coloraxis_cmax = layout === null || layout === void 0 ? void 0 : (_layout_coloraxis2 = layout.coloraxis) === null || _layout_coloraxis2 === void 0 ? void 0 : _layout_coloraxis2.cmax) !== null && _layout_coloraxis_cmax !== void 0 ? _layout_coloraxis_cmax : Math.max(...colorValues)
|
|
404
|
+
];
|
|
405
|
+
// Normalize colorscale domain to actual data domain
|
|
406
|
+
const scaleDomain = scale.map(([pos])=>dMin + pos * (dMax - dMin));
|
|
407
|
+
const scaleColors = scale.map((item)=>item[1]);
|
|
408
|
+
return (0, _d3scale.scaleLinear)().domain(scaleDomain).range(scaleColors);
|
|
409
|
+
};
|
|
410
|
+
const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
314
411
|
var _input_layout, _input_layout1, _gvbcData_;
|
|
315
412
|
const mapXToDataPoints = {};
|
|
316
413
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, 0, 0);
|
|
317
|
-
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
414
|
+
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
415
|
+
let colorScale = undefined;
|
|
318
416
|
input.data.forEach((series, index1)=>{
|
|
319
|
-
var
|
|
417
|
+
var _input_layout_coloraxis_colorscale, _input_layout_coloraxis, _input_layout, _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout1, _series_marker3, _series_x;
|
|
418
|
+
if (((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_coloraxis = _input_layout.coloraxis) === null || _input_layout_coloraxis === void 0 ? void 0 : (_input_layout_coloraxis_colorscale = _input_layout_coloraxis.colorscale) === null || _input_layout_coloraxis_colorscale === void 0 ? void 0 : _input_layout_coloraxis_colorscale.length) && (0, _chartutilities.isArrayOrTypedArray)((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) && ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length > 0 && typeof ((_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[0]) === 'number') {
|
|
419
|
+
colorScale = createColorScale(input.layout, series);
|
|
420
|
+
}
|
|
320
421
|
// extract colors for each series only once
|
|
321
|
-
const extractedColors = (0, _PlotlyColorAdapter.extractColor)((
|
|
422
|
+
const extractedColors = (0, _PlotlyColorAdapter.extractColor)((_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_template = _input_layout1.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_series_marker3 = series.marker) === null || _series_marker3 === void 0 ? void 0 : _series_marker3.color, colorMap, isDarkTheme);
|
|
322
423
|
(_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x.forEach((x, index2)=>{
|
|
424
|
+
var _series_y;
|
|
425
|
+
if ((0, _chartutilities.isInvalidValue)(x) || (0, _chartutilities.isInvalidValue)((_series_y = series.y) === null || _series_y === void 0 ? void 0 : _series_y[index2])) {
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
323
428
|
if (!mapXToDataPoints[x]) {
|
|
324
429
|
mapXToDataPoints[x] = {
|
|
325
430
|
name: x.toString(),
|
|
@@ -327,18 +432,21 @@ const transformPlotlyJsonToGVBCProps = (input, colorMap, colorwayType, isDarkThe
|
|
|
327
432
|
};
|
|
328
433
|
}
|
|
329
434
|
if (series.type === 'bar') {
|
|
330
|
-
var
|
|
435
|
+
var _series_marker, _series_marker1, _series_marker_color, _series_marker2;
|
|
331
436
|
const legend = legends[index1];
|
|
332
|
-
// resolve color for each legend's bars from the extracted colors
|
|
333
|
-
const color = (0, _PlotlyColorAdapter.resolveColor)(extractedColors,
|
|
334
|
-
|
|
437
|
+
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
438
|
+
const color = colorScale ? colorScale((0, _chartutilities.isArrayOrTypedArray)((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) ? (_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[index2 % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : (0, _PlotlyColorAdapter.resolveColor)(extractedColors, index2, legend, colorMap, isDarkTheme);
|
|
439
|
+
const opacity = (0, _PlotlyColorAdapter.getOpacity)(series, index2);
|
|
440
|
+
var _rgb_copy_formatHex8;
|
|
335
441
|
mapXToDataPoints[x].series.push({
|
|
336
442
|
key: legend,
|
|
337
|
-
data:
|
|
443
|
+
data: series.y[index2],
|
|
338
444
|
xAxisCalloutData: x,
|
|
339
|
-
color,
|
|
445
|
+
color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(color).copy({
|
|
446
|
+
opacity
|
|
447
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
|
|
340
448
|
legend,
|
|
341
|
-
useSecondaryYScale: usesSecondaryYScale(series)
|
|
449
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout)
|
|
342
450
|
});
|
|
343
451
|
}
|
|
344
452
|
});
|
|
@@ -359,32 +467,45 @@ const transformPlotlyJsonToGVBCProps = (input, colorMap, colorwayType, isDarkThe
|
|
|
359
467
|
hideTickOverlap: true,
|
|
360
468
|
wrapXAxisLables: typeof ((_gvbcData_ = gvbcData[0]) === null || _gvbcData_ === void 0 ? void 0 : _gvbcData_.name) === 'string',
|
|
361
469
|
hideLegend,
|
|
362
|
-
roundCorners: true
|
|
470
|
+
roundCorners: true,
|
|
471
|
+
...getAxisCategoryOrderProps(input.data, input.layout)
|
|
363
472
|
};
|
|
364
473
|
};
|
|
365
|
-
const transformPlotlyJsonToVBCProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
474
|
+
const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
366
475
|
var _input_layout, _input_layout1, _vbcData_;
|
|
367
476
|
const vbcData = [];
|
|
368
|
-
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
477
|
+
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
478
|
+
let colorScale = undefined;
|
|
369
479
|
input.data.forEach((series, seriesIdx)=>{
|
|
370
|
-
var
|
|
480
|
+
var _input_layout_coloraxis_colorscale, _input_layout_coloraxis, _input_layout, _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout1, _series_marker3, _series_xbins, _series_xbins1, _series_xbins2;
|
|
371
481
|
if (!series.x) {
|
|
372
482
|
return;
|
|
373
483
|
}
|
|
484
|
+
if (((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_coloraxis = _input_layout.coloraxis) === null || _input_layout_coloraxis === void 0 ? void 0 : (_input_layout_coloraxis_colorscale = _input_layout_coloraxis.colorscale) === null || _input_layout_coloraxis_colorscale === void 0 ? void 0 : _input_layout_coloraxis_colorscale.length) && (0, _chartutilities.isArrayOrTypedArray)((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) && ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length > 0 && typeof ((_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[0]) === 'number') {
|
|
485
|
+
colorScale = createColorScale(input.layout, series);
|
|
486
|
+
}
|
|
374
487
|
// extract colors for each series only once
|
|
375
|
-
const extractedColors = (0, _PlotlyColorAdapter.extractColor)((
|
|
376
|
-
const
|
|
488
|
+
const extractedColors = (0, _PlotlyColorAdapter.extractColor)((_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_template = _input_layout1.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_series_marker3 = series.marker) === null || _series_marker3 === void 0 ? void 0 : _series_marker3.color, colorMap, isDarkTheme);
|
|
489
|
+
const xValues = [];
|
|
490
|
+
const yValues = [];
|
|
491
|
+
series.x.forEach((xVal, index)=>{
|
|
492
|
+
const yVal = getNumberAtIndexOrDefault(series.y, index);
|
|
493
|
+
if ((0, _chartutilities.isInvalidValue)(xVal) || (0, _chartutilities.isInvalidValue)(yVal)) {
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
xValues.push(xVal);
|
|
497
|
+
yValues.push(yVal);
|
|
498
|
+
});
|
|
499
|
+
const isXString = (0, _chartutilities.isStringArray)(xValues);
|
|
377
500
|
// TODO: In case of a single bin, add an empty bin of the same size to prevent the
|
|
378
501
|
// default bar width from being used and ensure the bar spans the full intended range.
|
|
379
|
-
const xBins = createBins(
|
|
502
|
+
const xBins = createBins(xValues, (_series_xbins = series.xbins) === null || _series_xbins === void 0 ? void 0 : _series_xbins.start, (_series_xbins1 = series.xbins) === null || _series_xbins1 === void 0 ? void 0 : _series_xbins1.end, (_series_xbins2 = series.xbins) === null || _series_xbins2 === void 0 ? void 0 : _series_xbins2.size);
|
|
380
503
|
const yBins = xBins.map(()=>[]);
|
|
381
504
|
let total = 0;
|
|
382
|
-
|
|
505
|
+
xValues.forEach((xVal, index)=>{
|
|
383
506
|
const binIdx = findBinIndex(xBins, xVal, isXString);
|
|
384
507
|
if (binIdx !== -1) {
|
|
385
|
-
|
|
386
|
-
var _series_y_index;
|
|
387
|
-
yBins[binIdx].push((_series_y_index = (_series_y = series.y) === null || _series_y === void 0 ? void 0 : _series_y[index]) !== null && _series_y_index !== void 0 ? _series_y_index : 1);
|
|
508
|
+
yBins[binIdx].push(yValues[index]);
|
|
388
509
|
}
|
|
389
510
|
});
|
|
390
511
|
const y = yBins.map((bin)=>{
|
|
@@ -393,15 +514,20 @@ const transformPlotlyJsonToVBCProps = (input, colorMap, colorwayType, isDarkThem
|
|
|
393
514
|
return yVal;
|
|
394
515
|
});
|
|
395
516
|
xBins.forEach((bin, index)=>{
|
|
517
|
+
var _series_marker, _series_marker1, _series_marker_color, _series_marker2;
|
|
396
518
|
const legend = legends[seriesIdx];
|
|
397
|
-
// resolve color for each legend's bars from the extracted colors
|
|
398
|
-
const color = (0, _PlotlyColorAdapter.resolveColor)(extractedColors,
|
|
519
|
+
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
520
|
+
const color = colorScale ? colorScale((0, _chartutilities.isArrayOrTypedArray)((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) ? (_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[index % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : (0, _PlotlyColorAdapter.resolveColor)(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
521
|
+
const opacity = (0, _PlotlyColorAdapter.getOpacity)(series, index);
|
|
399
522
|
const yVal = calculateHistNorm(series.histnorm, y[index], total, isXString ? bin.length : getBinSize(bin));
|
|
523
|
+
var _rgb_copy_formatHex8;
|
|
400
524
|
vbcData.push({
|
|
401
525
|
x: isXString ? bin.join(', ') : getBinCenter(bin),
|
|
402
526
|
y: yVal,
|
|
403
527
|
legend,
|
|
404
|
-
color,
|
|
528
|
+
color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(color).copy({
|
|
529
|
+
opacity
|
|
530
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
|
|
405
531
|
...isXString ? {} : {
|
|
406
532
|
xAxisCalloutData: `[${bin.x0} - ${bin.x1})`
|
|
407
533
|
}
|
|
@@ -422,56 +548,99 @@ const transformPlotlyJsonToVBCProps = (input, colorMap, colorwayType, isDarkThem
|
|
|
422
548
|
wrapXAxisLables: typeof ((_vbcData_ = vbcData[0]) === null || _vbcData_ === void 0 ? void 0 : _vbcData_.x) === 'string',
|
|
423
549
|
maxBarWidth: 50,
|
|
424
550
|
hideLegend,
|
|
425
|
-
roundCorners: true
|
|
551
|
+
roundCorners: true,
|
|
552
|
+
...getAxisCategoryOrderProps(input.data, input.layout)
|
|
426
553
|
};
|
|
427
554
|
};
|
|
428
|
-
const
|
|
555
|
+
const transformPlotlyJsonToAreaChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
556
|
+
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'area', colorMap, colorwayType, isDarkTheme);
|
|
557
|
+
};
|
|
558
|
+
const transformPlotlyJsonToLineChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
559
|
+
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'line', colorMap, colorwayType, isDarkTheme);
|
|
560
|
+
};
|
|
561
|
+
const transformPlotlyJsonToScatterChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
562
|
+
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'scatter', colorMap, colorwayType, isDarkTheme);
|
|
563
|
+
};
|
|
564
|
+
const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme)=>{
|
|
565
|
+
var _input_data_;
|
|
566
|
+
const isScatterMarkers = [
|
|
567
|
+
'markers',
|
|
568
|
+
'text+markers',
|
|
569
|
+
'markers+text',
|
|
570
|
+
'lines+markers',
|
|
571
|
+
'markers+line',
|
|
572
|
+
'text+lines+markers'
|
|
573
|
+
].includes((_input_data_ = input.data[0]) === null || _input_data_ === void 0 ? void 0 : _input_data_.mode);
|
|
574
|
+
const isAreaChart = chartType === 'area';
|
|
575
|
+
const isScatterChart = chartType === 'scatter';
|
|
429
576
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
|
|
430
577
|
let mode = 'tonexty';
|
|
431
|
-
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
578
|
+
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
432
579
|
const chartData = input.data.map((series, index)=>{
|
|
433
|
-
var
|
|
580
|
+
var _series_mode, _series_line, _series_marker, _series_line1, _input_layout_template_layout, _input_layout_template, _input_layout, _series_mode1;
|
|
581
|
+
const colors = isScatterMarkers ? (series === null || series === void 0 ? void 0 : (_series_mode = series.mode) === null || _series_mode === void 0 ? void 0 : _series_mode.includes('line')) ? (_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.color : (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color : (_series_line1 = series.line) === null || _series_line1 === void 0 ? void 0 : _series_line1.color;
|
|
434
582
|
// extract colors for each series only once
|
|
435
|
-
const extractedColors = (0, _PlotlyColorAdapter.extractColor)((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType,
|
|
583
|
+
const extractedColors = (0, _PlotlyColorAdapter.extractColor)((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, colors, colorMap, isDarkTheme);
|
|
436
584
|
const xValues = series.x;
|
|
437
|
-
const
|
|
585
|
+
const isXString = (0, _chartutilities.isStringArray)(xValues);
|
|
438
586
|
const isXDate = (0, _chartutilities.isDateArray)(xValues);
|
|
439
587
|
const isXNumber = (0, _chartutilities.isNumberArray)(xValues);
|
|
588
|
+
const isXYearCategory = (0, _chartutilities.isYearArray)(series.x); // Consider year as categorical not numeric continuous axis
|
|
440
589
|
const legend = legends[index];
|
|
441
590
|
// resolve color for each legend's lines from the extracted colors
|
|
442
591
|
const seriesColor = (0, _PlotlyColorAdapter.resolveColor)(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
592
|
+
const seriesOpacity = (0, _PlotlyColorAdapter.getOpacity)(series, index);
|
|
443
593
|
mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
|
|
444
|
-
const lineOptions = getLineOptions(series.line);
|
|
445
|
-
const
|
|
446
|
-
const
|
|
447
|
-
return {
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
594
|
+
const lineOptions = !((_series_mode1 = series.mode) === null || _series_mode1 === void 0 ? void 0 : _series_mode1.includes('text')) ? getLineOptions(series.line) : undefined;
|
|
595
|
+
const legendShape = getLegendShape(series);
|
|
596
|
+
const validXYRanges = getValidXYRanges(series);
|
|
597
|
+
return validXYRanges.map(([rangeStart, rangeEnd], rangeIdx)=>{
|
|
598
|
+
var _series_marker;
|
|
599
|
+
const rangeXValues = xValues.slice(rangeStart, rangeEnd);
|
|
600
|
+
const rangeYValues = series.y.slice(rangeStart, rangeEnd);
|
|
601
|
+
const markerSizes = (0, _chartutilities.isArrayOrTypedArray)((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.size) ? series.marker.size.slice(rangeStart, rangeEnd) : [];
|
|
602
|
+
const textValues = Array.isArray(series.text) ? series.text.slice(rangeStart, rangeEnd) : undefined;
|
|
603
|
+
var _rgb_copy_formatHex8;
|
|
604
|
+
return {
|
|
605
|
+
legend,
|
|
606
|
+
legendShape,
|
|
607
|
+
data: rangeXValues.map((x, i)=>{
|
|
608
|
+
var _series_marker, _series_marker1;
|
|
609
|
+
return {
|
|
610
|
+
x: resolveXAxisPoint(x, isXYearCategory, isXString, isXDate, isXNumber),
|
|
611
|
+
y: rangeYValues[i],
|
|
612
|
+
...Array.isArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.size) ? {
|
|
613
|
+
markerSize: markerSizes[i]
|
|
614
|
+
} : typeof ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.size) === 'number' ? {
|
|
615
|
+
markerSize: series.marker.size
|
|
616
|
+
} : {},
|
|
617
|
+
...textValues ? {
|
|
618
|
+
text: textValues[i]
|
|
619
|
+
} : {}
|
|
620
|
+
};
|
|
621
|
+
}),
|
|
622
|
+
color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(seriesColor).copy({
|
|
623
|
+
opacity: seriesOpacity
|
|
624
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : seriesColor,
|
|
625
|
+
lineOptions: {
|
|
626
|
+
...lineOptions !== null && lineOptions !== void 0 ? lineOptions : {},
|
|
627
|
+
mode: series.mode
|
|
628
|
+
},
|
|
629
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout)
|
|
630
|
+
};
|
|
631
|
+
});
|
|
632
|
+
}).flat();
|
|
469
633
|
const yMinMaxValues = (0, _utilities.findNumericMinMaxOfY)(chartData);
|
|
470
634
|
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
635
|
+
const numDataPoints = chartData.reduce((total, lineChartPoints)=>total + lineChartPoints.data.length, 0);
|
|
471
636
|
const chartProps = {
|
|
472
637
|
chartTitle,
|
|
473
638
|
lineChartData: chartData
|
|
474
639
|
};
|
|
640
|
+
const scatterChartProps = {
|
|
641
|
+
chartTitle,
|
|
642
|
+
scatterChartData: chartData
|
|
643
|
+
};
|
|
475
644
|
if (isAreaChart) {
|
|
476
645
|
var _input_layout, _input_layout1;
|
|
477
646
|
var _input_layout_height;
|
|
@@ -486,13 +655,14 @@ const transformPlotlyJsonToScatterChartProps = (input, isAreaChart, isScatterMar
|
|
|
486
655
|
height: (_input_layout_height = (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
|
|
487
656
|
hideTickOverlap: true,
|
|
488
657
|
useUTC: false,
|
|
489
|
-
hideLegend
|
|
658
|
+
hideLegend,
|
|
659
|
+
optimizeLargeData: numDataPoints > 1000
|
|
490
660
|
};
|
|
491
661
|
} else {
|
|
492
662
|
var _input_layout2, _input_layout3;
|
|
493
663
|
var _input_layout_height1;
|
|
494
664
|
return {
|
|
495
|
-
data: chartProps,
|
|
665
|
+
data: isScatterChart ? scatterChartProps : chartProps,
|
|
496
666
|
supportNegativeData: true,
|
|
497
667
|
xAxisTitle,
|
|
498
668
|
yAxisTitle,
|
|
@@ -504,30 +674,42 @@ const transformPlotlyJsonToScatterChartProps = (input, isAreaChart, isScatterMar
|
|
|
504
674
|
height: (_input_layout_height1 = (_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : _input_layout3.height) !== null && _input_layout_height1 !== void 0 ? _input_layout_height1 : 350,
|
|
505
675
|
hideTickOverlap: true,
|
|
506
676
|
useUTC: false,
|
|
507
|
-
hideLegend
|
|
677
|
+
hideLegend,
|
|
678
|
+
optimizeLargeData: numDataPoints > 1000
|
|
508
679
|
};
|
|
509
680
|
}
|
|
510
681
|
};
|
|
511
|
-
const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
682
|
+
const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
512
683
|
var _input_layout, _input_layout_margin, _input_layout1, _input_layout_margin1, _input_layout2, _input_layout_yaxis2, _input_layout3, _input_layout_yaxis21, _input_layout4, _input_layout_yaxis2_title, _input_layout_yaxis22, _input_layout5, _input_layout6;
|
|
513
|
-
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
684
|
+
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
685
|
+
let colorScale = undefined;
|
|
514
686
|
const chartData = input.data.map((series, index)=>{
|
|
515
|
-
var _input_layout_template_layout, _input_layout_template,
|
|
687
|
+
var _input_layout_coloraxis_colorscale, _input_layout_coloraxis, _input_layout, _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout1, _series_marker3;
|
|
688
|
+
if (((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_coloraxis = _input_layout.coloraxis) === null || _input_layout_coloraxis === void 0 ? void 0 : (_input_layout_coloraxis_colorscale = _input_layout_coloraxis.colorscale) === null || _input_layout_coloraxis_colorscale === void 0 ? void 0 : _input_layout_coloraxis_colorscale.length) && (0, _chartutilities.isArrayOrTypedArray)((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) && ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length > 0 && typeof ((_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[0]) === 'number') {
|
|
689
|
+
colorScale = createColorScale(input.layout, series);
|
|
690
|
+
}
|
|
516
691
|
// extract colors for each series only once
|
|
517
|
-
const extractedColors = (0, _PlotlyColorAdapter.extractColor)((
|
|
692
|
+
const extractedColors = (0, _PlotlyColorAdapter.extractColor)((_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_template = _input_layout1.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_series_marker3 = series.marker) === null || _series_marker3 === void 0 ? void 0 : _series_marker3.color, colorMap, isDarkTheme);
|
|
518
693
|
const legend = legends[index];
|
|
519
|
-
// resolve color for each legend's bars from the extracted colors
|
|
520
|
-
const color = (0, _PlotlyColorAdapter.resolveColor)(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
521
694
|
return series.y.map((yValue, i)=>{
|
|
695
|
+
var _series_x, _series_marker, _series_marker1, _series_marker_color, _series_marker2;
|
|
696
|
+
if ((0, _chartutilities.isInvalidValue)((_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x[i]) || (0, _chartutilities.isInvalidValue)(yValue)) {
|
|
697
|
+
return null;
|
|
698
|
+
}
|
|
699
|
+
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
700
|
+
const color = colorScale ? colorScale((0, _chartutilities.isArrayOrTypedArray)((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) ? (_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[i % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : (0, _PlotlyColorAdapter.resolveColor)(extractedColors, i, legend, colorMap, isDarkTheme);
|
|
701
|
+
const opacity = (0, _PlotlyColorAdapter.getOpacity)(series, i);
|
|
702
|
+
var _rgb_copy_formatHex8;
|
|
522
703
|
return {
|
|
523
704
|
x: series.x[i],
|
|
524
705
|
y: yValue,
|
|
525
706
|
legend,
|
|
526
|
-
color
|
|
707
|
+
color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(color).copy({
|
|
708
|
+
opacity
|
|
709
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
|
|
527
710
|
};
|
|
528
|
-
});
|
|
529
|
-
}).
|
|
530
|
-
.reverse();
|
|
711
|
+
}).filter((point)=>point !== null);
|
|
712
|
+
}).flat();
|
|
531
713
|
var _input_layout_height;
|
|
532
714
|
const chartHeight = (_input_layout_height = (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 450;
|
|
533
715
|
var _input_layout_margin_l;
|
|
@@ -554,31 +736,42 @@ const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, colorMap, colorw
|
|
|
554
736
|
noOfCharsToTruncate: 20,
|
|
555
737
|
showYAxisLablesTooltip: true,
|
|
556
738
|
hideLegend,
|
|
557
|
-
roundCorners: true
|
|
739
|
+
roundCorners: true,
|
|
740
|
+
...getAxisCategoryOrderProps(input.data, input.layout)
|
|
558
741
|
};
|
|
559
742
|
};
|
|
560
|
-
const transformPlotlyJsonToHeatmapProps = (input)=>{
|
|
561
|
-
var _input_layout, _input_layout1;
|
|
743
|
+
const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
744
|
+
var _input_layout, _input_layout_coloraxis, _input_layout1, _input_layout_template_layout, _input_layout_template, _input_layout2, _input_layout_template_data_histogram2d_, _input_layout_template_data_histogram2d, _input_layout_template_data, _input_layout_template1, _input_layout3, _input_layout_template_data_heatmap_, _input_layout_template_data_heatmap, _input_layout_template_data1, _input_layout_template2, _input_layout4, _input_layout5, _input_layout6;
|
|
562
745
|
const firstData = input.data[0];
|
|
563
746
|
const heatmapDataPoints = [];
|
|
564
747
|
let zMin = Number.POSITIVE_INFINITY;
|
|
565
748
|
let zMax = Number.NEGATIVE_INFINITY;
|
|
566
749
|
if (firstData.type === 'histogram2d') {
|
|
567
|
-
var _firstData_xbins, _firstData_xbins1, _firstData_xbins2, _firstData_ybins, _firstData_ybins1, _firstData_ybins2
|
|
568
|
-
const
|
|
569
|
-
const
|
|
570
|
-
const
|
|
571
|
-
const yBins = createBins(firstData.y, (_firstData_ybins = firstData.ybins) === null || _firstData_ybins === void 0 ? void 0 : _firstData_ybins.start, (_firstData_ybins1 = firstData.ybins) === null || _firstData_ybins1 === void 0 ? void 0 : _firstData_ybins1.end, (_firstData_ybins2 = firstData.ybins) === null || _firstData_ybins2 === void 0 ? void 0 : _firstData_ybins2.size);
|
|
572
|
-
const zBins = yBins.map(()=>xBins.map(()=>[]));
|
|
573
|
-
let total = 0;
|
|
750
|
+
var _firstData_x, _firstData_xbins, _firstData_xbins1, _firstData_xbins2, _firstData_ybins, _firstData_ybins1, _firstData_ybins2;
|
|
751
|
+
const xValues = [];
|
|
752
|
+
const yValues = [];
|
|
753
|
+
const zValues = [];
|
|
574
754
|
(_firstData_x = firstData.x) === null || _firstData_x === void 0 ? void 0 : _firstData_x.forEach((xVal, index)=>{
|
|
575
755
|
var _firstData_y;
|
|
756
|
+
const zVal = getNumberAtIndexOrDefault(firstData.z, index);
|
|
757
|
+
if ((0, _chartutilities.isInvalidValue)(xVal) || (0, _chartutilities.isInvalidValue)((_firstData_y = firstData.y) === null || _firstData_y === void 0 ? void 0 : _firstData_y[index]) || (0, _chartutilities.isInvalidValue)(zVal)) {
|
|
758
|
+
return;
|
|
759
|
+
}
|
|
760
|
+
xValues.push(xVal);
|
|
761
|
+
yValues.push(firstData.y[index]);
|
|
762
|
+
zValues.push(zVal);
|
|
763
|
+
});
|
|
764
|
+
const isXString = (0, _chartutilities.isStringArray)(xValues);
|
|
765
|
+
const isYString = (0, _chartutilities.isStringArray)(yValues);
|
|
766
|
+
const xBins = createBins(xValues, (_firstData_xbins = firstData.xbins) === null || _firstData_xbins === void 0 ? void 0 : _firstData_xbins.start, (_firstData_xbins1 = firstData.xbins) === null || _firstData_xbins1 === void 0 ? void 0 : _firstData_xbins1.end, (_firstData_xbins2 = firstData.xbins) === null || _firstData_xbins2 === void 0 ? void 0 : _firstData_xbins2.size);
|
|
767
|
+
const yBins = createBins(yValues, (_firstData_ybins = firstData.ybins) === null || _firstData_ybins === void 0 ? void 0 : _firstData_ybins.start, (_firstData_ybins1 = firstData.ybins) === null || _firstData_ybins1 === void 0 ? void 0 : _firstData_ybins1.end, (_firstData_ybins2 = firstData.ybins) === null || _firstData_ybins2 === void 0 ? void 0 : _firstData_ybins2.size);
|
|
768
|
+
const zBins = yBins.map(()=>xBins.map(()=>[]));
|
|
769
|
+
let total = 0;
|
|
770
|
+
xValues.forEach((xVal, index)=>{
|
|
576
771
|
const xBinIdx = findBinIndex(xBins, xVal, isXString);
|
|
577
|
-
const yBinIdx = findBinIndex(yBins,
|
|
772
|
+
const yBinIdx = findBinIndex(yBins, yValues[index], isYString);
|
|
578
773
|
if (xBinIdx !== -1 && yBinIdx !== -1) {
|
|
579
|
-
|
|
580
|
-
var _firstData_z_index;
|
|
581
|
-
zBins[yBinIdx][xBinIdx].push((_firstData_z_index = (_firstData_z = firstData.z) === null || _firstData_z === void 0 ? void 0 : _firstData_z[index]) !== null && _firstData_z_index !== void 0 ? _firstData_z_index : 1);
|
|
774
|
+
zBins[yBinIdx][xBinIdx].push(zValues[index]);
|
|
582
775
|
}
|
|
583
776
|
});
|
|
584
777
|
const z = zBins.map((row)=>{
|
|
@@ -640,8 +833,23 @@ const transformPlotlyJsonToHeatmapProps = (input)=>{
|
|
|
640
833
|
(0, _colors.getColorFromToken)(_colors.DataVizPalette.color2),
|
|
641
834
|
(0, _colors.getColorFromToken)(_colors.DataVizPalette.color3)
|
|
642
835
|
];
|
|
643
|
-
|
|
644
|
-
|
|
836
|
+
var _firstData_colorscale, _ref, _ref1, _ref2, _ref3;
|
|
837
|
+
let colorscale = (_ref3 = (_ref2 = (_ref1 = (_ref = (_firstData_colorscale = firstData === null || firstData === void 0 ? void 0 : firstData.colorscale) !== null && _firstData_colorscale !== void 0 ? _firstData_colorscale : (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.colorscale) !== null && _ref !== void 0 ? _ref : (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_coloraxis = _input_layout1.coloraxis) === null || _input_layout_coloraxis === void 0 ? void 0 : _input_layout_coloraxis.colorscale) !== null && _ref1 !== void 0 ? _ref1 : (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : (_input_layout_template = _input_layout2.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorscale) !== null && _ref2 !== void 0 ? _ref2 : firstData.type === 'histogram2d' && ((_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : (_input_layout_template1 = _input_layout3.template) === null || _input_layout_template1 === void 0 ? void 0 : (_input_layout_template_data = _input_layout_template1.data) === null || _input_layout_template_data === void 0 ? void 0 : (_input_layout_template_data_histogram2d = _input_layout_template_data.histogram2d) === null || _input_layout_template_data_histogram2d === void 0 ? void 0 : (_input_layout_template_data_histogram2d_ = _input_layout_template_data_histogram2d[0]) === null || _input_layout_template_data_histogram2d_ === void 0 ? void 0 : _input_layout_template_data_histogram2d_.colorscale)) !== null && _ref3 !== void 0 ? _ref3 : (_input_layout4 = input.layout) === null || _input_layout4 === void 0 ? void 0 : (_input_layout_template2 = _input_layout4.template) === null || _input_layout_template2 === void 0 ? void 0 : (_input_layout_template_data1 = _input_layout_template2.data) === null || _input_layout_template_data1 === void 0 ? void 0 : (_input_layout_template_data_heatmap = _input_layout_template_data1.heatmap) === null || _input_layout_template_data_heatmap === void 0 ? void 0 : (_input_layout_template_data_heatmap_ = _input_layout_template_data_heatmap[0]) === null || _input_layout_template_data_heatmap_ === void 0 ? void 0 : _input_layout_template_data_heatmap_.colorscale;
|
|
838
|
+
// determine if the types diverging, sequential or sequentialminus are present in colorscale
|
|
839
|
+
if (colorscale && typeof colorscale === 'object' && ('diverging' in colorscale || 'sequential' in colorscale || 'sequentialminus' in colorscale)) {
|
|
840
|
+
const isDivergent = zMin < 0 && zMax > 0; // Data spans both positive and negative values
|
|
841
|
+
const isSequential = zMin >= 0; // Data is entirely positive
|
|
842
|
+
const isSequentialMinus = zMax <= 0; // Data is entirely negative
|
|
843
|
+
if (isDivergent) {
|
|
844
|
+
colorscale = colorscale === null || colorscale === void 0 ? void 0 : colorscale.diverging;
|
|
845
|
+
} else if (isSequential) {
|
|
846
|
+
colorscale = colorscale === null || colorscale === void 0 ? void 0 : colorscale.sequential;
|
|
847
|
+
} else if (isSequentialMinus) {
|
|
848
|
+
colorscale = colorscale === null || colorscale === void 0 ? void 0 : colorscale.sequentialminus;
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
const domainValuesForColorScale = Array.isArray(colorscale) ? colorscale.map((arr)=>arr[0] * (zMax - zMin) + zMin) : defaultDomain;
|
|
852
|
+
const rangeValuesForColorScale = Array.isArray(colorscale) ? colorscale.map((arr)=>arr[1]) : defaultRange;
|
|
645
853
|
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
646
854
|
var _input_layout_height;
|
|
647
855
|
return {
|
|
@@ -656,24 +864,33 @@ const transformPlotlyJsonToHeatmapProps = (input)=>{
|
|
|
656
864
|
xAxisTitle,
|
|
657
865
|
yAxisTitle,
|
|
658
866
|
sortOrder: 'none',
|
|
659
|
-
width: (
|
|
660
|
-
height: (_input_layout_height = (
|
|
867
|
+
width: (_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : _input_layout5.width,
|
|
868
|
+
height: (_input_layout_height = (_input_layout6 = input.layout) === null || _input_layout6 === void 0 ? void 0 : _input_layout6.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
|
|
661
869
|
hideTickOverlap: true,
|
|
662
870
|
noOfCharsToTruncate: 20,
|
|
663
871
|
showYAxisLablesTooltip: true,
|
|
664
|
-
wrapXAxisLables: true
|
|
872
|
+
wrapXAxisLables: true,
|
|
873
|
+
...getAxisCategoryOrderProps([
|
|
874
|
+
firstData
|
|
875
|
+
], input.layout)
|
|
665
876
|
};
|
|
666
877
|
};
|
|
667
|
-
const transformPlotlyJsonToSankeyProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
878
|
+
const transformPlotlyJsonToSankeyProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
668
879
|
var _input_layout_template_layout, _input_layout_template, _input_layout, _node_label, _input_layout1, _input_layout2;
|
|
669
880
|
const { link, node } = input.data[0];
|
|
670
881
|
var _link_value;
|
|
671
|
-
const validLinks = ((_link_value = link === null || link === void 0 ? void 0 : link.value) !== null && _link_value !== void 0 ? _link_value : []).map((val, index)=>
|
|
882
|
+
const validLinks = ((_link_value = link === null || link === void 0 ? void 0 : link.value) !== null && _link_value !== void 0 ? _link_value : []).map((val, index)=>{
|
|
883
|
+
var _link_source, _link_target;
|
|
884
|
+
if ((0, _chartutilities.isInvalidValue)(val) || (0, _chartutilities.isInvalidValue)(link === null || link === void 0 ? void 0 : (_link_source = link.source) === null || _link_source === void 0 ? void 0 : _link_source[index]) || (0, _chartutilities.isInvalidValue)(link === null || link === void 0 ? void 0 : (_link_target = link.target) === null || _link_target === void 0 ? void 0 : _link_target[index])) {
|
|
885
|
+
return null;
|
|
886
|
+
}
|
|
887
|
+
return {
|
|
672
888
|
value: val,
|
|
673
889
|
source: link === null || link === void 0 ? void 0 : link.source[index],
|
|
674
890
|
target: link === null || link === void 0 ? void 0 : link.target[index]
|
|
675
|
-
}
|
|
676
|
-
|
|
891
|
+
};
|
|
892
|
+
}) // Filter out negative nodes, unequal nodes and self-references (circular links)
|
|
893
|
+
.filter((x)=>x !== null && x.source >= 0 && x.target >= 0 && x.source !== x.target);
|
|
677
894
|
const extractedNodeColors = (0, _PlotlyColorAdapter.extractColor)((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, node === null || node === void 0 ? void 0 : node.color, colorMap, isDarkTheme);
|
|
678
895
|
const sankeyChartData = {
|
|
679
896
|
nodes: (_node_label = node.label) === null || _node_label === void 0 ? void 0 : _node_label.map((label, index)=>{
|
|
@@ -707,7 +924,7 @@ const transformPlotlyJsonToSankeyProps = (input, colorMap, colorwayType, isDarkT
|
|
|
707
924
|
height: (_input_layout_height = (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 468
|
|
708
925
|
};
|
|
709
926
|
};
|
|
710
|
-
const transformPlotlyJsonToGaugeProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
927
|
+
const transformPlotlyJsonToGaugeProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
711
928
|
var _firstData_gauge, _input_layout_template_layout, _input_layout_template, _input_layout, _firstData_gauge_steps, _firstData_gauge1, _firstData_gauge_axis_range, _firstData_gauge_axis, _firstData_gauge2, _input_layout_template_layout1, _input_layout_template1, _input_layout1, _firstData_gauge_axis1, _firstData_gauge3, _firstData_gauge_axis_range1, _firstData_gauge_axis2, _firstData_gauge4, _firstData_delta, _firstData_gauge_axis_range2, _firstData_gauge_axis3, _firstData_gauge5, _firstData_gauge_axis_range3, _firstData_gauge_axis4, _firstData_gauge6, _firstData_gauge_axis_range4, _firstData_gauge_axis5, _firstData_gauge7, _firstData_gauge_axis_range5, _firstData_gauge_axis6, _firstData_gauge8, _input_layout2, _input_layout3, _firstData_gauge_steps1, _firstData_gauge9;
|
|
712
929
|
const firstData = input.data[0];
|
|
713
930
|
const stepsColors = ((_firstData_gauge = firstData.gauge) === null || _firstData_gauge === void 0 ? void 0 : _firstData_gauge.steps) ? firstData.gauge.steps.map((step)=>step.color) : undefined;
|
|
@@ -782,40 +999,148 @@ const transformPlotlyJsonToGaugeProps = (input, colorMap, colorwayType, isDarkTh
|
|
|
782
999
|
const cleanText = (text)=>{
|
|
783
1000
|
return text.replace(/<[^&]*?>/g, '').replace(/<[^>]*>/g, '').replace(/<br>|\\u003cbr\\u003e|<br>/gi, '').replace(/\$[^$]*\$/g, '$').trim();
|
|
784
1001
|
};
|
|
785
|
-
const
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
1002
|
+
const formatValue = (value, colIndex, cells)=>{
|
|
1003
|
+
if (value === null || typeof value === 'boolean') {
|
|
1004
|
+
return value;
|
|
1005
|
+
}
|
|
1006
|
+
const formatStr = Array.isArray(cells.format) ? cells.format[colIndex] : cells.format;
|
|
1007
|
+
const prefix = Array.isArray(cells.prefix) ? cells.prefix[colIndex] : cells.prefix;
|
|
1008
|
+
const suffix = Array.isArray(cells.suffix) ? cells.suffix[colIndex] : cells.suffix;
|
|
1009
|
+
let formatted = value;
|
|
1010
|
+
if (typeof value === 'number') {
|
|
1011
|
+
if (typeof formatStr === 'string') {
|
|
1012
|
+
try {
|
|
1013
|
+
formatted = (0, _d3format.format)(formatStr)(value);
|
|
1014
|
+
} catch {
|
|
1015
|
+
formatted = (0, _utilities.formatScientificLimitWidth)(value);
|
|
1016
|
+
}
|
|
1017
|
+
} else {
|
|
1018
|
+
formatted = (0, _utilities.formatScientificLimitWidth)(value);
|
|
792
1019
|
}
|
|
793
|
-
|
|
794
|
-
|
|
1020
|
+
}
|
|
1021
|
+
return `${prefix !== null && prefix !== void 0 ? prefix : ''}${formatted}${suffix !== null && suffix !== void 0 ? suffix : ''}`;
|
|
1022
|
+
};
|
|
1023
|
+
const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
1024
|
+
var _tableData_cells, _input_layout_template_data, _input_layout_template, _input_layout, _input_layout_font, _input_layout1, _tableData_header, _tableData_header1, _input_layout_template_data1, _input_layout_template1, _input_layout2, _input_layout3, _input_layout4;
|
|
1025
|
+
const tableData = input.data[0];
|
|
1026
|
+
const normalizeHeaders = (values, header)=>{
|
|
1027
|
+
const cleanedValues = Array.isArray(values[0]) ? values.map((row)=>row.map((cell)=>cleanText(cell)).filter(Boolean).join(' ')) : values.map((cell)=>cleanText(cell));
|
|
1028
|
+
return cleanedValues.map((value, colIndex)=>{
|
|
1029
|
+
var _header_font, _header_font1, _header_fill;
|
|
1030
|
+
const fontColorRaw = header === null || header === void 0 ? void 0 : (_header_font = header.font) === null || _header_font === void 0 ? void 0 : _header_font.color;
|
|
1031
|
+
let fontColor;
|
|
1032
|
+
if (Array.isArray(fontColorRaw)) {
|
|
1033
|
+
const colorEntry = fontColorRaw[colIndex];
|
|
1034
|
+
if (Array.isArray(colorEntry)) {
|
|
1035
|
+
fontColor = typeof colorEntry[0] === 'string' ? colorEntry[0] : undefined;
|
|
1036
|
+
} else if (typeof colorEntry === 'string') {
|
|
1037
|
+
fontColor = colorEntry;
|
|
1038
|
+
}
|
|
1039
|
+
} else if (typeof fontColorRaw === 'string') {
|
|
1040
|
+
fontColor = fontColorRaw;
|
|
1041
|
+
}
|
|
1042
|
+
const fontSizeRaw = header === null || header === void 0 ? void 0 : (_header_font1 = header.font) === null || _header_font1 === void 0 ? void 0 : _header_font1.size;
|
|
1043
|
+
let fontSize;
|
|
1044
|
+
if (Array.isArray(fontSizeRaw)) {
|
|
1045
|
+
fontSize = Array.isArray(fontSizeRaw[0]) ? fontSizeRaw[0][colIndex] : fontSizeRaw[colIndex];
|
|
1046
|
+
} else if (typeof fontSizeRaw === 'number') {
|
|
1047
|
+
fontSize = fontSizeRaw;
|
|
1048
|
+
}
|
|
1049
|
+
const updatedColIndex = colIndex >= 1 ? 1 : 0;
|
|
1050
|
+
const fillColorRaw = header === null || header === void 0 ? void 0 : (_header_fill = header.fill) === null || _header_fill === void 0 ? void 0 : _header_fill.color;
|
|
1051
|
+
const backgroundColor = Array.isArray(fillColorRaw) ? fillColorRaw[updatedColIndex] : fillColorRaw;
|
|
1052
|
+
const textAlignRaw = header === null || header === void 0 ? void 0 : header.align;
|
|
1053
|
+
const textAlign = Array.isArray(textAlignRaw) ? textAlignRaw[colIndex] : textAlignRaw;
|
|
1054
|
+
const style = {
|
|
1055
|
+
...typeof fontColor === 'string' ? {
|
|
1056
|
+
color: fontColor
|
|
1057
|
+
} : {},
|
|
1058
|
+
...typeof fontSize === 'number' ? {
|
|
1059
|
+
fontSize
|
|
1060
|
+
} : {},
|
|
1061
|
+
...typeof backgroundColor === 'string' ? {
|
|
1062
|
+
backgroundColor
|
|
1063
|
+
} : {},
|
|
1064
|
+
...textAlign ? {
|
|
1065
|
+
textAlign
|
|
1066
|
+
} : {}
|
|
1067
|
+
};
|
|
1068
|
+
return {
|
|
1069
|
+
value,
|
|
1070
|
+
style
|
|
1071
|
+
};
|
|
1072
|
+
});
|
|
795
1073
|
};
|
|
796
1074
|
var _tableData_cells_values;
|
|
797
1075
|
const columns = (_tableData_cells_values = (_tableData_cells = tableData.cells) === null || _tableData_cells === void 0 ? void 0 : _tableData_cells.values) !== null && _tableData_cells_values !== void 0 ? _tableData_cells_values : [];
|
|
798
|
-
const
|
|
799
|
-
|
|
1076
|
+
const cells = tableData.cells.font ? tableData.cells : (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_data = _input_layout_template.data) === null || _input_layout_template_data === void 0 ? void 0 : _input_layout_template_data.table[0].cells;
|
|
1077
|
+
const rows = columns[0].map((_, rowIndex)=>columns.map((col, colIndex)=>{
|
|
1078
|
+
var _cells_font, _cells_font1, _cells_fill;
|
|
1079
|
+
const cellValue = col[rowIndex];
|
|
1080
|
+
const cleanValue = typeof cellValue === 'string' ? cleanText(cellValue) : cellValue;
|
|
1081
|
+
const formattedValue = typeof cleanValue === 'string' || typeof cleanValue === 'number' ? formatValue(cleanValue, colIndex, cells) : cleanValue;
|
|
1082
|
+
const rawFontColor = cells === null || cells === void 0 ? void 0 : (_cells_font = cells.font) === null || _cells_font === void 0 ? void 0 : _cells_font.color;
|
|
1083
|
+
let fontColor;
|
|
1084
|
+
if (Array.isArray(rawFontColor)) {
|
|
1085
|
+
const entry = rawFontColor[colIndex];
|
|
1086
|
+
const colorValue = Array.isArray(entry) ? entry[rowIndex] : entry;
|
|
1087
|
+
fontColor = typeof colorValue === 'string' ? colorValue : undefined;
|
|
1088
|
+
} else if (typeof rawFontColor === 'string') {
|
|
1089
|
+
fontColor = rawFontColor;
|
|
1090
|
+
}
|
|
1091
|
+
const rawFontSize = cells === null || cells === void 0 ? void 0 : (_cells_font1 = cells.font) === null || _cells_font1 === void 0 ? void 0 : _cells_font1.size;
|
|
1092
|
+
let fontSize;
|
|
1093
|
+
if (Array.isArray(rawFontSize)) {
|
|
1094
|
+
const entry = rawFontSize[colIndex];
|
|
1095
|
+
const fontSizeValue = Array.isArray(entry) ? entry[rowIndex] : entry;
|
|
1096
|
+
fontSize = typeof fontSizeValue === 'number' ? fontSizeValue : undefined;
|
|
1097
|
+
} else if (typeof rawFontSize === 'number') {
|
|
1098
|
+
fontSize = rawFontSize;
|
|
1099
|
+
}
|
|
1100
|
+
const updatedColIndex = colIndex >= 1 ? 1 : 0;
|
|
1101
|
+
const rawBackgroundColor = cells === null || cells === void 0 ? void 0 : (_cells_fill = cells.fill) === null || _cells_fill === void 0 ? void 0 : _cells_fill.color;
|
|
1102
|
+
let backgroundColor;
|
|
1103
|
+
if (Array.isArray(rawBackgroundColor)) {
|
|
1104
|
+
const entry = rawBackgroundColor[updatedColIndex];
|
|
1105
|
+
const colorValue = Array.isArray(entry) ? entry[rowIndex] : entry;
|
|
1106
|
+
backgroundColor = typeof colorValue === 'string' ? colorValue : undefined;
|
|
1107
|
+
} else if (typeof rawBackgroundColor === 'string') {
|
|
1108
|
+
backgroundColor = rawBackgroundColor;
|
|
1109
|
+
}
|
|
1110
|
+
const rawTextAlign = Array.isArray(cells === null || cells === void 0 ? void 0 : cells.align) ? cells.align[colIndex] : cells === null || cells === void 0 ? void 0 : cells.align;
|
|
1111
|
+
const textAlign = rawTextAlign;
|
|
1112
|
+
const style = {
|
|
1113
|
+
...fontColor ? {
|
|
1114
|
+
color: fontColor
|
|
1115
|
+
} : {},
|
|
1116
|
+
...typeof fontSize === 'number' ? {
|
|
1117
|
+
fontSize
|
|
1118
|
+
} : {},
|
|
1119
|
+
...backgroundColor ? {
|
|
1120
|
+
backgroundColor
|
|
1121
|
+
} : {},
|
|
1122
|
+
...textAlign ? {
|
|
1123
|
+
textAlign
|
|
1124
|
+
} : {}
|
|
1125
|
+
};
|
|
800
1126
|
return {
|
|
801
|
-
value:
|
|
1127
|
+
value: formattedValue,
|
|
1128
|
+
style
|
|
802
1129
|
};
|
|
803
1130
|
}));
|
|
804
1131
|
const styles = {
|
|
805
1132
|
root: {
|
|
806
|
-
...((
|
|
1133
|
+
...((_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_font = _input_layout1.font) === null || _input_layout_font === void 0 ? void 0 : _input_layout_font.size) ? {
|
|
807
1134
|
fontSize: input.layout.font.size
|
|
808
1135
|
} : {}
|
|
809
1136
|
}
|
|
810
1137
|
};
|
|
811
1138
|
var _tableData_header_values;
|
|
812
1139
|
return {
|
|
813
|
-
headers: normalizeHeaders((_tableData_header_values = (_tableData_header = tableData.header) === null || _tableData_header === void 0 ? void 0 : _tableData_header.values) !== null && _tableData_header_values !== void 0 ? _tableData_header_values : []).
|
|
814
|
-
value
|
|
815
|
-
})),
|
|
1140
|
+
headers: normalizeHeaders((_tableData_header_values = (_tableData_header = tableData.header) === null || _tableData_header === void 0 ? void 0 : _tableData_header.values) !== null && _tableData_header_values !== void 0 ? _tableData_header_values : [], ((_tableData_header1 = tableData.header) === null || _tableData_header1 === void 0 ? void 0 : _tableData_header1.font) ? tableData.header : (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : (_input_layout_template1 = _input_layout2.template) === null || _input_layout_template1 === void 0 ? void 0 : (_input_layout_template_data1 = _input_layout_template1.data) === null || _input_layout_template_data1 === void 0 ? void 0 : _input_layout_template_data1.table[0].header),
|
|
816
1141
|
rows,
|
|
817
|
-
width: (
|
|
818
|
-
height: (
|
|
1142
|
+
width: (_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : _input_layout3.width,
|
|
1143
|
+
height: (_input_layout4 = input.layout) === null || _input_layout4 === void 0 ? void 0 : _input_layout4.height,
|
|
819
1144
|
styles
|
|
820
1145
|
};
|
|
821
1146
|
};
|
|
@@ -824,14 +1149,20 @@ const projectPolarToCartesian = (input)=>{
|
|
|
824
1149
|
...input
|
|
825
1150
|
};
|
|
826
1151
|
for(let sindex = 0; sindex < input.data.length; sindex++){
|
|
1152
|
+
var _series_r;
|
|
827
1153
|
const series = input.data[sindex];
|
|
828
1154
|
series.x = [];
|
|
829
1155
|
series.y = [];
|
|
830
|
-
|
|
1156
|
+
var _series_r_length;
|
|
1157
|
+
for(let ptindex = 0; ptindex < ((_series_r_length = (_series_r = series.r) === null || _series_r === void 0 ? void 0 : _series_r.length) !== null && _series_r_length !== void 0 ? _series_r_length : 0); ptindex++){
|
|
1158
|
+
var _series_theta, _series_r1;
|
|
1159
|
+
if ((0, _chartutilities.isInvalidValue)((_series_theta = series.theta) === null || _series_theta === void 0 ? void 0 : _series_theta[ptindex]) || (0, _chartutilities.isInvalidValue)((_series_r1 = series.r) === null || _series_r1 === void 0 ? void 0 : _series_r1[ptindex])) {
|
|
1160
|
+
continue;
|
|
1161
|
+
}
|
|
831
1162
|
const thetaRad = series.theta[ptindex] * Math.PI / 180;
|
|
832
1163
|
const radius = series.r[ptindex];
|
|
833
|
-
series.x
|
|
834
|
-
series.y
|
|
1164
|
+
series.x.push(radius * Math.cos(thetaRad));
|
|
1165
|
+
series.y.push(radius * Math.sin(thetaRad));
|
|
835
1166
|
}
|
|
836
1167
|
projection.data[sindex] = series;
|
|
837
1168
|
}
|
|
@@ -905,11 +1236,6 @@ function getLineOptions(line) {
|
|
|
905
1236
|
}
|
|
906
1237
|
return Object.keys(lineOptions).length > 0 ? lineOptions : undefined;
|
|
907
1238
|
}
|
|
908
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
909
|
-
const isStringArray = (arr)=>{
|
|
910
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
911
|
-
return (0, _chartutilities.isArrayOfType)(arr, (value)=>typeof value === 'string');
|
|
912
|
-
};
|
|
913
1239
|
// TODO: Use binary search to find the appropriate bin for numeric value.
|
|
914
1240
|
const findBinIndex = (bins, value, isString)=>{
|
|
915
1241
|
if (typeof value === 'undefined' || value === null) {
|
|
@@ -928,7 +1254,7 @@ const createBins = (data, binStart, binEnd, binSize)=>{
|
|
|
928
1254
|
if (!data || data.length === 0) {
|
|
929
1255
|
return [];
|
|
930
1256
|
}
|
|
931
|
-
if (isStringArray(data)) {
|
|
1257
|
+
if ((0, _chartutilities.isStringArray)(data)) {
|
|
932
1258
|
const categories = Array.from(new Set(data));
|
|
933
1259
|
const start = typeof binStart === 'number' ? Math.ceil(binStart) : 0;
|
|
934
1260
|
const stop = typeof binEnd === 'number' ? Math.floor(binEnd) + 1 : categories.length;
|
|
@@ -1004,7 +1330,46 @@ const precisionRound = (value, precision)=>{
|
|
|
1004
1330
|
const factor = Math.pow(10, precision);
|
|
1005
1331
|
return Math.round(value * factor) / factor;
|
|
1006
1332
|
};
|
|
1007
|
-
const
|
|
1333
|
+
const getLegendShape = (series)=>{
|
|
1334
|
+
var _series_line, _series_mode;
|
|
1335
|
+
const dashType = ((_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.dash) || 'solid';
|
|
1336
|
+
if (dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot') {
|
|
1337
|
+
return 'dottedLine';
|
|
1338
|
+
} else if ((_series_mode = series.mode) === null || _series_mode === void 0 ? void 0 : _series_mode.includes('markers')) {
|
|
1339
|
+
return 'circle';
|
|
1340
|
+
}
|
|
1341
|
+
return 'default';
|
|
1342
|
+
};
|
|
1343
|
+
const getAllupLegendsProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
1344
|
+
const allupLegends = [];
|
|
1345
|
+
// reduce on showlegend boolean propperty. reduce should return true if at least one series has showlegend true
|
|
1346
|
+
const toShowLegend = input.data.reduce((acc, series)=>{
|
|
1347
|
+
return acc || series.showlegend === true;
|
|
1348
|
+
}, false);
|
|
1349
|
+
if (toShowLegend) {
|
|
1350
|
+
input.data.forEach((series, index)=>{
|
|
1351
|
+
var _series_line, _series_marker, _input_layout_template_layout, _input_layout_template, _input_layout;
|
|
1352
|
+
const name = series.legendgroup;
|
|
1353
|
+
const color = ((_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.color) || ((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color);
|
|
1354
|
+
const legendShape = getLegendShape(series);
|
|
1355
|
+
const resolvedColor = (0, _PlotlyColorAdapter.extractColor)((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, color, colorMap, isDarkTheme);
|
|
1356
|
+
if (name !== undefined && allupLegends.some((group)=>group.title === name) === false) {
|
|
1357
|
+
allupLegends.push({
|
|
1358
|
+
title: name,
|
|
1359
|
+
color: resolvedColor,
|
|
1360
|
+
shape: legendShape
|
|
1361
|
+
});
|
|
1362
|
+
}
|
|
1363
|
+
});
|
|
1364
|
+
}
|
|
1365
|
+
return {
|
|
1366
|
+
legends: allupLegends,
|
|
1367
|
+
centerLegends: true,
|
|
1368
|
+
enabledWrapLines: true,
|
|
1369
|
+
canSelectMultipleLegends: true
|
|
1370
|
+
};
|
|
1371
|
+
};
|
|
1372
|
+
const getLegendProps = (data, layout, isMultiPlot)=>{
|
|
1008
1373
|
const legends = [];
|
|
1009
1374
|
if (data.length === 1) {
|
|
1010
1375
|
legends.push(data[0].name || '');
|
|
@@ -1013,9 +1378,257 @@ const getLegendProps = (data, layout)=>{
|
|
|
1013
1378
|
legends.push(series.name || `Series ${index + 1}`);
|
|
1014
1379
|
});
|
|
1015
1380
|
}
|
|
1016
|
-
const
|
|
1381
|
+
const hideLegendsData = data.every((series)=>series.showlegend === false);
|
|
1382
|
+
const hideLegendsInferred = (layout === null || layout === void 0 ? void 0 : layout.showlegend) === false || (layout === null || layout === void 0 ? void 0 : layout.showlegend) !== true && legends.length < 2;
|
|
1017
1383
|
return {
|
|
1018
1384
|
legends,
|
|
1019
|
-
hideLegend:
|
|
1385
|
+
hideLegend: isMultiPlot || hideLegendsInferred || hideLegendsData
|
|
1386
|
+
};
|
|
1387
|
+
};
|
|
1388
|
+
const getNumberAtIndexOrDefault = (data, index)=>{
|
|
1389
|
+
if ((0, _chartutilities.isArrayOrTypedArray)(data)) {
|
|
1390
|
+
if (typeof data[index] !== 'number' || !isFinite(data[index])) {
|
|
1391
|
+
return;
|
|
1392
|
+
}
|
|
1393
|
+
return data[index];
|
|
1394
|
+
}
|
|
1395
|
+
return 1;
|
|
1396
|
+
};
|
|
1397
|
+
const getValidXYRanges = (series)=>{
|
|
1398
|
+
if (!(0, _chartutilities.isArrayOrTypedArray)(series.x) || !(0, _chartutilities.isArrayOrTypedArray)(series.y)) {
|
|
1399
|
+
return [];
|
|
1400
|
+
}
|
|
1401
|
+
const ranges = [];
|
|
1402
|
+
let start = 0;
|
|
1403
|
+
let end = 0;
|
|
1404
|
+
for(; end < series.x.length; end++){
|
|
1405
|
+
if ((0, _chartutilities.isInvalidValue)(series.x[end]) || (0, _chartutilities.isInvalidValue)(series.y[end])) {
|
|
1406
|
+
if (end - start > 0) {
|
|
1407
|
+
ranges.push([
|
|
1408
|
+
start,
|
|
1409
|
+
end
|
|
1410
|
+
]);
|
|
1411
|
+
}
|
|
1412
|
+
start = end + 1;
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
if (end - start > 0) {
|
|
1416
|
+
ranges.push([
|
|
1417
|
+
start,
|
|
1418
|
+
end
|
|
1419
|
+
]);
|
|
1420
|
+
}
|
|
1421
|
+
return ranges;
|
|
1422
|
+
};
|
|
1423
|
+
const getIndexFromKey = (key, pattern)=>{
|
|
1424
|
+
const normalizedKey = key.replace(pattern, '') === '' ? '1' : key.replace(pattern, '');
|
|
1425
|
+
return parseInt(normalizedKey, 10) - 1;
|
|
1426
|
+
};
|
|
1427
|
+
const getGridProperties = (layout, isMultiPlot)=>{
|
|
1428
|
+
var _layout_annotations;
|
|
1429
|
+
const gridX = [];
|
|
1430
|
+
const gridY = [];
|
|
1431
|
+
const annotations = {};
|
|
1432
|
+
let templateRows = '1fr';
|
|
1433
|
+
let templateColumns = '1fr';
|
|
1434
|
+
const gridLayout = {};
|
|
1435
|
+
if (layout === undefined || layout === null || Object.keys(layout).length === 0) {
|
|
1436
|
+
return {
|
|
1437
|
+
templateRows,
|
|
1438
|
+
templateColumns,
|
|
1439
|
+
layout: gridLayout
|
|
1440
|
+
};
|
|
1441
|
+
}
|
|
1442
|
+
if (!layout.xaxis || !layout.yaxis) {
|
|
1443
|
+
return {
|
|
1444
|
+
templateRows,
|
|
1445
|
+
templateColumns,
|
|
1446
|
+
layout: gridLayout
|
|
1447
|
+
};
|
|
1448
|
+
}
|
|
1449
|
+
if (!isMultiPlot) {
|
|
1450
|
+
return {
|
|
1451
|
+
templateRows,
|
|
1452
|
+
templateColumns,
|
|
1453
|
+
layout: gridLayout
|
|
1454
|
+
};
|
|
1455
|
+
}
|
|
1456
|
+
Object.keys(layout).forEach((key)=>{
|
|
1457
|
+
if (key.startsWith('xaxis')) {
|
|
1458
|
+
var _layout_key, _layout_key1;
|
|
1459
|
+
const index = getIndexFromKey(key, 'xaxis');
|
|
1460
|
+
var _layout_key_anchor;
|
|
1461
|
+
const anchor = (_layout_key_anchor = (_layout_key = layout[key]) === null || _layout_key === void 0 ? void 0 : _layout_key.anchor) !== null && _layout_key_anchor !== void 0 ? _layout_key_anchor : 'y';
|
|
1462
|
+
const anchorIndex = getIndexFromKey(anchor, 'y');
|
|
1463
|
+
if (index !== anchorIndex) {
|
|
1464
|
+
throw new Error(`Invalid layout: xaxis ${index + 1} anchor should be y${anchorIndex + 1}`);
|
|
1465
|
+
}
|
|
1466
|
+
var _layout_key_domain;
|
|
1467
|
+
gridX[index] = (_layout_key_domain = (_layout_key1 = layout[key]) === null || _layout_key1 === void 0 ? void 0 : _layout_key1.domain) !== null && _layout_key_domain !== void 0 ? _layout_key_domain : [];
|
|
1468
|
+
} else if (key.startsWith('yaxis')) {
|
|
1469
|
+
var _layout_key2, _layout_key3;
|
|
1470
|
+
const index = getIndexFromKey(key, 'yaxis');
|
|
1471
|
+
var _layout_key_anchor1;
|
|
1472
|
+
const anchor = (_layout_key_anchor1 = (_layout_key2 = layout[key]) === null || _layout_key2 === void 0 ? void 0 : _layout_key2.anchor) !== null && _layout_key_anchor1 !== void 0 ? _layout_key_anchor1 : 'x';
|
|
1473
|
+
const anchorIndex = getIndexFromKey(anchor, 'x');
|
|
1474
|
+
if (index !== anchorIndex) {
|
|
1475
|
+
var _layout_yaxis2;
|
|
1476
|
+
if (index === 1 && anchorIndex === 0 || ((_layout_yaxis2 = layout.yaxis2) === null || _layout_yaxis2 === void 0 ? void 0 : _layout_yaxis2.side) === 'right') {
|
|
1477
|
+
// Special case for secondary y axis where yaxis2 can anchor to x1
|
|
1478
|
+
return {
|
|
1479
|
+
templateRows,
|
|
1480
|
+
templateColumns
|
|
1481
|
+
};
|
|
1482
|
+
}
|
|
1483
|
+
throw new Error(`Invalid layout: yaxis ${index + 1} anchor should be x${anchorIndex + 1}`);
|
|
1484
|
+
}
|
|
1485
|
+
var _layout_key_domain1;
|
|
1486
|
+
gridY[index] = (_layout_key_domain1 = (_layout_key3 = layout[key]) === null || _layout_key3 === void 0 ? void 0 : _layout_key3.domain) !== null && _layout_key_domain1 !== void 0 ? _layout_key_domain1 : [];
|
|
1487
|
+
}
|
|
1488
|
+
});
|
|
1489
|
+
(_layout_annotations = layout.annotations) === null || _layout_annotations === void 0 ? void 0 : _layout_annotations.forEach((annotation)=>{
|
|
1490
|
+
const xMatches = gridX.flatMap((interval, idx)=>(annotation === null || annotation === void 0 ? void 0 : annotation.x) >= interval[0] && (annotation === null || annotation === void 0 ? void 0 : annotation.x) <= interval[1] ? [
|
|
1491
|
+
idx
|
|
1492
|
+
] : []);
|
|
1493
|
+
const yMatch = gridY.findIndex((interval, yIndex)=>xMatches.includes(yIndex) && (annotation === null || annotation === void 0 ? void 0 : annotation.y) >= interval[0] && (annotation === null || annotation === void 0 ? void 0 : annotation.y) <= interval[1]);
|
|
1494
|
+
if (yMatch !== -1) {
|
|
1495
|
+
if (annotations[yMatch] === undefined) {
|
|
1496
|
+
annotations[yMatch] = {};
|
|
1497
|
+
}
|
|
1498
|
+
if ((annotation === null || annotation === void 0 ? void 0 : annotation.textangle) === 90) {
|
|
1499
|
+
annotations[yMatch].yAnnotation = annotation.text;
|
|
1500
|
+
} else {
|
|
1501
|
+
annotations[yMatch].xAnnotation = annotation.text;
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
});
|
|
1505
|
+
if (gridX.length > 0) {
|
|
1506
|
+
const uniqueXIntervals = new Map();
|
|
1507
|
+
gridX.forEach((interval)=>{
|
|
1508
|
+
const key = `${interval[0]}-${interval[1]}`;
|
|
1509
|
+
if (!uniqueXIntervals.has(key)) {
|
|
1510
|
+
uniqueXIntervals.set(key, interval);
|
|
1511
|
+
}
|
|
1512
|
+
});
|
|
1513
|
+
const minXInterval = Math.min(...Array.from(uniqueXIntervals.values()).map((interval)=>interval[1] - interval[0]));
|
|
1514
|
+
templateColumns = Array.from(uniqueXIntervals.values()).map((interval)=>`${(interval[1] - interval[0]) / minXInterval}fr`).join(' ');
|
|
1515
|
+
let columnNumber = 1;
|
|
1516
|
+
let lastIntervalEnd = 0;
|
|
1517
|
+
gridX.forEach((interval, index)=>{
|
|
1518
|
+
if (interval.length === 0) {
|
|
1519
|
+
return;
|
|
1520
|
+
}
|
|
1521
|
+
const cellName = `x${index === 0 ? '' : index + 1}`;
|
|
1522
|
+
const annotationProps = annotations[index];
|
|
1523
|
+
const xAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.xAnnotation;
|
|
1524
|
+
if (interval[0] < lastIntervalEnd) {
|
|
1525
|
+
columnNumber = 1;
|
|
1526
|
+
}
|
|
1527
|
+
lastIntervalEnd = interval[1];
|
|
1528
|
+
const row = {
|
|
1529
|
+
row: -1,
|
|
1530
|
+
column: columnNumber,
|
|
1531
|
+
xAnnotation
|
|
1532
|
+
};
|
|
1533
|
+
gridLayout[cellName] = row;
|
|
1534
|
+
columnNumber += 1;
|
|
1535
|
+
});
|
|
1536
|
+
}
|
|
1537
|
+
const numColumns = Math.max(...Object.values(gridLayout).map((cell)=>{
|
|
1538
|
+
var _cell_column;
|
|
1539
|
+
return (_cell_column = cell.column) !== null && _cell_column !== void 0 ? _cell_column : 0;
|
|
1540
|
+
}));
|
|
1541
|
+
const columnFill = {};
|
|
1542
|
+
for(let i = 1; i <= numColumns; i++){
|
|
1543
|
+
columnFill[i] = {
|
|
1544
|
+
row: 1,
|
|
1545
|
+
fillDomain: 0
|
|
1546
|
+
};
|
|
1547
|
+
}
|
|
1548
|
+
if (gridY.length > 0) {
|
|
1549
|
+
const uniqueYIntervals = new Map();
|
|
1550
|
+
gridY.forEach((interval)=>{
|
|
1551
|
+
const key = `${interval[0]}-${interval[1]}`;
|
|
1552
|
+
if (!uniqueYIntervals.has(key)) {
|
|
1553
|
+
uniqueYIntervals.set(key, interval);
|
|
1554
|
+
}
|
|
1555
|
+
});
|
|
1556
|
+
const minYInterval = Math.min(...Array.from(uniqueYIntervals.values()).map((interval)=>interval[1] - interval[0]));
|
|
1557
|
+
templateRows = Array.from(uniqueYIntervals.values()).map((interval)=>`${(interval[1] - interval[0]) / minYInterval}fr`).join(' ');
|
|
1558
|
+
gridY.forEach((interval, index)=>{
|
|
1559
|
+
if (interval.length === 0) {
|
|
1560
|
+
return;
|
|
1561
|
+
}
|
|
1562
|
+
const cellName = `x${index === 0 ? '' : index + 1}`;
|
|
1563
|
+
const annotationProps = annotations[index];
|
|
1564
|
+
const yAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.yAnnotation;
|
|
1565
|
+
const cell = gridLayout[cellName];
|
|
1566
|
+
if (cell !== undefined) {
|
|
1567
|
+
cell.row = columnFill[cell.column].row;
|
|
1568
|
+
cell.yAnnotation = yAnnotation;
|
|
1569
|
+
}
|
|
1570
|
+
columnFill[cell.column].fillDomain = interval[1];
|
|
1571
|
+
columnFill[cell.column].row += 1;
|
|
1572
|
+
});
|
|
1573
|
+
}
|
|
1574
|
+
// reverse the order of rows in grid layout from bottom-top to top-bottom as required by CSS grid
|
|
1575
|
+
const reversedGridLayout = {};
|
|
1576
|
+
// find the maximum row number
|
|
1577
|
+
const maxRowNumber = Math.max(...Object.values(gridLayout).map((cell)=>{
|
|
1578
|
+
var _cell_row;
|
|
1579
|
+
return (_cell_row = cell.row) !== null && _cell_row !== void 0 ? _cell_row : 0;
|
|
1580
|
+
}));
|
|
1581
|
+
// iterate over the gridLayout and reverse the row numbers
|
|
1582
|
+
Object.keys(gridLayout).forEach((key)=>{
|
|
1583
|
+
const cell = gridLayout[key];
|
|
1584
|
+
if (cell.row !== undefined) {
|
|
1585
|
+
// reverse the row number
|
|
1586
|
+
cell.row = maxRowNumber - cell.row + 1;
|
|
1587
|
+
}
|
|
1588
|
+
reversedGridLayout[key] = cell;
|
|
1589
|
+
});
|
|
1590
|
+
return {
|
|
1591
|
+
templateRows,
|
|
1592
|
+
templateColumns,
|
|
1593
|
+
layout: reversedGridLayout
|
|
1020
1594
|
};
|
|
1021
1595
|
};
|
|
1596
|
+
/**
|
|
1597
|
+
* @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/category_order_defaults.js#L50}
|
|
1598
|
+
*/ const getAxisCategoryOrderProps = (data, layout)=>{
|
|
1599
|
+
const result = {};
|
|
1600
|
+
const axesById = {
|
|
1601
|
+
x: layout === null || layout === void 0 ? void 0 : layout.xaxis,
|
|
1602
|
+
y: layout === null || layout === void 0 ? void 0 : layout.yaxis
|
|
1603
|
+
};
|
|
1604
|
+
Object.keys(axesById).forEach((axId)=>{
|
|
1605
|
+
const ax = axesById[axId];
|
|
1606
|
+
const axLetter = axId[0];
|
|
1607
|
+
const propName = `${axLetter}AxisCategoryOrder`;
|
|
1608
|
+
const values = [];
|
|
1609
|
+
data.forEach((series)=>{
|
|
1610
|
+
var _series_axLetter;
|
|
1611
|
+
(_series_axLetter = series[axLetter]) === null || _series_axLetter === void 0 ? void 0 : _series_axLetter.forEach((val)=>{
|
|
1612
|
+
if (!(0, _chartutilities.isInvalidValue)(val)) {
|
|
1613
|
+
values.push(val);
|
|
1614
|
+
}
|
|
1615
|
+
});
|
|
1616
|
+
});
|
|
1617
|
+
const isAxisTypeCategory = (ax === null || ax === void 0 ? void 0 : ax.type) === 'category' || (0, _chartutilities.isStringArray)(values) && !(0, _chartutilities.isNumberArray)(values) && !(0, _chartutilities.isDateArray)(values);
|
|
1618
|
+
if (!isAxisTypeCategory) {
|
|
1619
|
+
return;
|
|
1620
|
+
}
|
|
1621
|
+
const isValidArray = (0, _chartutilities.isArrayOrTypedArray)(ax === null || ax === void 0 ? void 0 : ax.categoryarray) && ax.categoryarray.length > 0;
|
|
1622
|
+
if (isValidArray && (!(ax === null || ax === void 0 ? void 0 : ax.categoryorder) || ax.categoryorder === 'array')) {
|
|
1623
|
+
result[propName] = ax.categoryarray;
|
|
1624
|
+
return;
|
|
1625
|
+
}
|
|
1626
|
+
if (!(ax === null || ax === void 0 ? void 0 : ax.categoryorder) || ax.categoryorder === 'trace' || ax.categoryorder === 'array') {
|
|
1627
|
+
const categoriesInTraceOrder = Array.from(new Set(values));
|
|
1628
|
+
result[propName] = categoriesInTraceOrder;
|
|
1629
|
+
return;
|
|
1630
|
+
}
|
|
1631
|
+
result[propName] = ax.categoryorder;
|
|
1632
|
+
});
|
|
1633
|
+
return result;
|
|
1634
|
+
};
|