@fluentui/react-charts 9.2.1 → 9.2.2
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 +24 -2
- package/dist/index.d.ts +79 -5
- package/lib/ChartTable.js +1 -0
- package/lib/ChartTable.js.map +1 -0
- package/lib/components/AreaChart/AreaChart.js.map +1 -1
- package/lib/components/ChartTable/ChartTable.js +57 -0
- package/lib/components/ChartTable/ChartTable.js.map +1 -0
- package/lib/components/ChartTable/ChartTable.types.js +1 -0
- package/lib/components/ChartTable/ChartTable.types.js.map +1 -0
- package/lib/components/ChartTable/index.js +3 -0
- package/lib/components/ChartTable/index.js.map +1 -0
- package/lib/components/ChartTable/useChartTableStyles.styles.js +93 -0
- package/lib/components/ChartTable/useChartTableStyles.styles.js.map +1 -0
- package/lib/components/ChartTable/useChartTableStyles.styles.raw.js +55 -0
- package/lib/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -0
- package/lib/components/CommonComponents/CartesianChart.js +110 -81
- package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/CommonComponents/ChartPopover.types.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +20 -10
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +95 -0
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +164 -77
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.types.js.map +1 -1
- package/lib/components/DonutChart/Pie/Pie.js.map +1 -1
- package/lib/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib/components/GanttChart/GanttChart.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +161 -141
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
- package/lib/components/HorizontalBarChart/HorizontalBarChart.types.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib/components/Legends/Legends.js.map +1 -1
- package/lib/components/Legends/OverflowMenu.js.map +1 -1
- package/lib/components/LineChart/LineChart.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.js +12 -11
- package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +57 -51
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/utilities/FocusableTooltipText.js.map +1 -1
- package/lib/utilities/utilities.js +26 -37
- package/lib/utilities/utilities.js.map +1 -1
- package/lib/utilities/vbc-utils.js +24 -0
- package/lib/utilities/vbc-utils.js.map +1 -1
- package/lib-commonjs/ChartTable.js +6 -0
- package/lib-commonjs/ChartTable.js.map +1 -0
- package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
- package/lib-commonjs/components/ChartTable/ChartTable.js +68 -0
- package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -0
- package/lib-commonjs/components/ChartTable/ChartTable.types.js +6 -0
- package/lib-commonjs/components/ChartTable/ChartTable.types.js.map +1 -0
- package/lib-commonjs/components/ChartTable/index.js +8 -0
- package/lib-commonjs/components/ChartTable/index.js.map +1 -0
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js +196 -0
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js.map +1 -0
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js +69 -0
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -0
- package/lib-commonjs/components/CommonComponents/CartesianChart.js +109 -80
- 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/ChartPopover.types.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +19 -9
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +120 -0
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -0
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +164 -77
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Pie/Pie.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib-commonjs/components/GanttChart/GanttChart.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +159 -139
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.types.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib-commonjs/components/Legends/Legends.js.map +1 -1
- package/lib-commonjs/components/Legends/OverflowMenu.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +11 -10
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +56 -50
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib-commonjs/index.js +1 -0
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/utilities/FocusableTooltipText.js.map +1 -1
- package/lib-commonjs/utilities/utilities.js +29 -37
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/lib-commonjs/utilities/vbc-utils.js +27 -0
- package/lib-commonjs/utilities/vbc-utils.js.map +1 -1
- package/package.json +9 -9
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
/* eslint-disable one-var */ /* eslint-disable vars-on-top */ /* eslint-disable no-var */
|
|
1
|
+
/* eslint-disable one-var */ /* eslint-disable vars-on-top */ /* eslint-disable no-var */ import * as React from 'react';
|
|
2
2
|
import { bin as d3Bin, extent as d3Extent, sum as d3Sum, min as d3Min, max as d3Max, range as d3Range } from 'd3-array';
|
|
3
3
|
import { scaleLinear as d3ScaleLinear } from 'd3-scale';
|
|
4
|
-
import { DataVizPalette, getColorFromToken
|
|
4
|
+
import { DataVizPalette, getColorFromToken } from '../../utilities/colors';
|
|
5
5
|
import { findNumericMinMaxOfY } from '../../utilities/utilities';
|
|
6
6
|
import { isArrayOfType, isArrayOrTypedArray, isDate, isDateArray, isNumberArray, isYearArray } from '@fluentui/chart-utilities';
|
|
7
7
|
import { curveCardinal as d3CurveCardinal } from 'd3-shape';
|
|
8
|
+
import { extractColor, resolveColor } from './PlotlyColorAdapter';
|
|
8
9
|
const dashOptions = {
|
|
9
10
|
dot: {
|
|
10
11
|
strokeDasharray: '1, 5',
|
|
@@ -53,6 +54,7 @@ function getTitles(layout) {
|
|
|
53
54
|
};
|
|
54
55
|
return titles;
|
|
55
56
|
}
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
56
58
|
export const correctYearMonth = (xValues)=>{
|
|
57
59
|
const presentYear = new Date().getFullYear();
|
|
58
60
|
if (xValues.length > 0 && Array.isArray(xValues[0])) {
|
|
@@ -78,14 +80,6 @@ export const correctYearMonth = (xValues)=>{
|
|
|
78
80
|
});
|
|
79
81
|
return xValues;
|
|
80
82
|
};
|
|
81
|
-
export const getColor = (legendLabel, colorMap, isDarkTheme)=>{
|
|
82
|
-
if (!colorMap.current.has(legendLabel)) {
|
|
83
|
-
const nextColor = getNextColor(colorMap.current.size + 1, 0, isDarkTheme);
|
|
84
|
-
colorMap.current.set(legendLabel, nextColor);
|
|
85
|
-
return nextColor;
|
|
86
|
-
}
|
|
87
|
-
return colorMap.current.get(legendLabel);
|
|
88
|
-
};
|
|
89
83
|
const usesSecondaryYScale = (series)=>{
|
|
90
84
|
return series.yaxis === 'y2';
|
|
91
85
|
};
|
|
@@ -125,13 +119,20 @@ const getSecondaryYAxisValues = (data, layout, maxAllowedMinY, minAllowedMaxY)=>
|
|
|
125
119
|
}
|
|
126
120
|
};
|
|
127
121
|
};
|
|
128
|
-
export const
|
|
129
|
-
|
|
122
|
+
export const _getGaugeAxisColor = (colorway, colorwayType, color, colorMap, isDarkTheme)=>{
|
|
123
|
+
const extractedColors = extractColor(colorway, colorwayType, color, colorMap, isDarkTheme);
|
|
124
|
+
return resolveColor(extractedColors, 0, '', colorMap, isDarkTheme);
|
|
125
|
+
};
|
|
126
|
+
export const transformPlotlyJsonToDonutProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
127
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout, _firstData_marker, _firstData_labels, _input_layout1, _input_layout2, _input_layout3, _input_layout4;
|
|
130
128
|
const firstData = input.data[0];
|
|
129
|
+
// extract colors for each series only once
|
|
130
|
+
const colors = 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, firstData === null || firstData === void 0 ? void 0 : (_firstData_marker = firstData.marker) === null || _firstData_marker === void 0 ? void 0 : _firstData_marker.colors, colorMap, isDarkTheme);
|
|
131
131
|
const mapLegendToDataPoint = {};
|
|
132
132
|
(_firstData_labels = firstData.labels) === null || _firstData_labels === void 0 ? void 0 : _firstData_labels.forEach((label, index)=>{
|
|
133
133
|
var _firstData_values;
|
|
134
|
-
|
|
134
|
+
// resolve color for each legend from the extracted colors
|
|
135
|
+
const color = resolveColor(colors, index, label, colorMap, isDarkTheme);
|
|
135
136
|
//ToDo how to handle string data?
|
|
136
137
|
const value = typeof ((_firstData_values = firstData.values) === null || _firstData_values === void 0 ? void 0 : _firstData_values[index]) === 'number' ? firstData.values[index] : 1;
|
|
137
138
|
if (!mapLegendToDataPoint[label]) {
|
|
@@ -145,9 +146,9 @@ export const transformPlotlyJsonToDonutProps = (input, colorMap, isDarkTheme)=>{
|
|
|
145
146
|
}
|
|
146
147
|
});
|
|
147
148
|
var _input_layout_width;
|
|
148
|
-
const width = (_input_layout_width = (
|
|
149
|
+
const width = (_input_layout_width = (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.width) !== null && _input_layout_width !== void 0 ? _input_layout_width : 440;
|
|
149
150
|
var _input_layout_height;
|
|
150
|
-
const height = (_input_layout_height = (
|
|
151
|
+
const 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 : 220;
|
|
151
152
|
const hideLabels = firstData.textinfo ? ![
|
|
152
153
|
'value',
|
|
153
154
|
'percent',
|
|
@@ -162,27 +163,32 @@ export const transformPlotlyJsonToDonutProps = (input, colorMap, isDarkTheme)=>{
|
|
|
162
163
|
chartTitle,
|
|
163
164
|
chartData: Object.values(mapLegendToDataPoint)
|
|
164
165
|
},
|
|
165
|
-
hideLegend: ((
|
|
166
|
-
width: (
|
|
166
|
+
hideLegend: ((_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : _input_layout3.showlegend) === false ? true : false,
|
|
167
|
+
width: (_input_layout4 = input.layout) === null || _input_layout4 === void 0 ? void 0 : _input_layout4.width,
|
|
167
168
|
height,
|
|
168
169
|
innerRadius,
|
|
169
170
|
hideLabels,
|
|
170
171
|
showLabelsInPercent: firstData.textinfo ? [
|
|
171
172
|
'percent',
|
|
172
173
|
'label+percent'
|
|
173
|
-
].includes(firstData.textinfo) : true
|
|
174
|
+
].includes(firstData.textinfo) : true,
|
|
175
|
+
roundCorners: true
|
|
174
176
|
};
|
|
175
177
|
};
|
|
176
|
-
export const transformPlotlyJsonToVSBCProps = (input, colorMap, isDarkTheme, fallbackVSBC)=>{
|
|
177
|
-
var _input_layout, _input_layout1;
|
|
178
|
+
export const transformPlotlyJsonToVSBCProps = (input, colorMap, colorwayType, isDarkTheme, fallbackVSBC)=>{
|
|
179
|
+
var _input_layout, _input_layout1, _vsbcData_;
|
|
178
180
|
const mapXToDataPoints = {};
|
|
179
181
|
let yMaxValue = 0;
|
|
180
182
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
|
|
181
183
|
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
182
184
|
let yMinValue = 0;
|
|
183
185
|
input.data.forEach((series, index1)=>{
|
|
184
|
-
var _series_x;
|
|
186
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _input_layout_template_layout1, _input_layout_template1, _input_layout1, _series_line, _series_x;
|
|
185
187
|
const isXYearCategory = isYearArray(series.x); // Consider year as categorical not numeric continuous axis
|
|
188
|
+
// extract bar colors for each series only once
|
|
189
|
+
const extractedBarColors = 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, (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color, colorMap, isDarkTheme);
|
|
190
|
+
// extract line colors for each series only once
|
|
191
|
+
const extractedLineColors = extractColor((_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_template1 = _input_layout1.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);
|
|
186
192
|
(_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x.forEach((x, index2)=>{
|
|
187
193
|
var _series_y;
|
|
188
194
|
if (!mapXToDataPoints[x]) {
|
|
@@ -193,10 +199,11 @@ export const transformPlotlyJsonToVSBCProps = (input, colorMap, isDarkTheme, fal
|
|
|
193
199
|
};
|
|
194
200
|
}
|
|
195
201
|
const legend = legends[index1];
|
|
202
|
+
// resolve color for each legend's bars from the extracted colors
|
|
203
|
+
const color = resolveColor(extractedBarColors, index1, legend, colorMap, isDarkTheme);
|
|
196
204
|
var _series_y_index2;
|
|
197
205
|
const yVal = (_series_y_index2 = (_series_y = series.y) === null || _series_y === void 0 ? void 0 : _series_y[index2]) !== null && _series_y_index2 !== void 0 ? _series_y_index2 : 0;
|
|
198
206
|
if (series.type === 'bar') {
|
|
199
|
-
const color = getColor(legend, colorMap, isDarkTheme);
|
|
200
207
|
mapXToDataPoints[x].chartData.push({
|
|
201
208
|
legend,
|
|
202
209
|
data: yVal,
|
|
@@ -205,7 +212,7 @@ export const transformPlotlyJsonToVSBCProps = (input, colorMap, isDarkTheme, fal
|
|
|
205
212
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
206
213
|
} else if (series.type === 'scatter' || !!fallbackVSBC) {
|
|
207
214
|
var _series_line;
|
|
208
|
-
const
|
|
215
|
+
const lineColor = resolveColor(extractedLineColors, index1, legend, colorMap, isDarkTheme);
|
|
209
216
|
const lineOptions = getLineOptions(series.line);
|
|
210
217
|
const dashType = ((_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.dash) || 'solid';
|
|
211
218
|
const legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot' ? 'dottedLine' : 'default';
|
|
@@ -213,7 +220,7 @@ export const transformPlotlyJsonToVSBCProps = (input, colorMap, isDarkTheme, fal
|
|
|
213
220
|
legend,
|
|
214
221
|
legendShape,
|
|
215
222
|
y: yVal,
|
|
216
|
-
color,
|
|
223
|
+
color: lineColor,
|
|
217
224
|
...lineOptions ? {
|
|
218
225
|
lineOptions
|
|
219
226
|
} : {},
|
|
@@ -228,9 +235,10 @@ export const transformPlotlyJsonToVSBCProps = (input, colorMap, isDarkTheme, fal
|
|
|
228
235
|
});
|
|
229
236
|
});
|
|
230
237
|
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
238
|
+
const vsbcData = Object.values(mapXToDataPoints);
|
|
231
239
|
var _input_layout_height;
|
|
232
240
|
return {
|
|
233
|
-
data:
|
|
241
|
+
data: vsbcData,
|
|
234
242
|
width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
|
|
235
243
|
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,
|
|
236
244
|
barWidth: 'auto',
|
|
@@ -241,18 +249,22 @@ export const transformPlotlyJsonToVSBCProps = (input, colorMap, isDarkTheme, fal
|
|
|
241
249
|
yAxisTitle,
|
|
242
250
|
mode: 'plotly',
|
|
243
251
|
...secondaryYAxisValues,
|
|
252
|
+
wrapXAxisLables: typeof ((_vsbcData_ = vsbcData[0]) === null || _vsbcData_ === void 0 ? void 0 : _vsbcData_.xAxisPoint) === 'string',
|
|
244
253
|
hideTickOverlap: true,
|
|
245
254
|
barGapMax: 2,
|
|
246
|
-
hideLegend
|
|
255
|
+
hideLegend,
|
|
256
|
+
roundCorners: true
|
|
247
257
|
};
|
|
248
258
|
};
|
|
249
|
-
export const transformPlotlyJsonToGVBCProps = (input, colorMap, isDarkTheme)=>{
|
|
250
|
-
var _input_layout, _input_layout1;
|
|
259
|
+
export const transformPlotlyJsonToGVBCProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
260
|
+
var _input_layout, _input_layout1, _gvbcData_;
|
|
251
261
|
const mapXToDataPoints = {};
|
|
252
262
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, 0, 0);
|
|
253
263
|
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
254
264
|
input.data.forEach((series, index1)=>{
|
|
255
|
-
var _series_x;
|
|
265
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _series_x;
|
|
266
|
+
// extract colors for each series only once
|
|
267
|
+
const extractedColors = 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, (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color, colorMap, isDarkTheme);
|
|
256
268
|
(_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x.forEach((x, index2)=>{
|
|
257
269
|
if (!mapXToDataPoints[x]) {
|
|
258
270
|
mapXToDataPoints[x] = {
|
|
@@ -263,7 +275,8 @@ export const transformPlotlyJsonToGVBCProps = (input, colorMap, isDarkTheme)=>{
|
|
|
263
275
|
if (series.type === 'bar') {
|
|
264
276
|
var _series_y;
|
|
265
277
|
const legend = legends[index1];
|
|
266
|
-
|
|
278
|
+
// resolve color for each legend's bars from the extracted colors
|
|
279
|
+
const color = resolveColor(extractedColors, index1, legend, colorMap, isDarkTheme);
|
|
267
280
|
var _series_y_index2;
|
|
268
281
|
mapXToDataPoints[x].series.push({
|
|
269
282
|
key: legend,
|
|
@@ -277,9 +290,10 @@ export const transformPlotlyJsonToGVBCProps = (input, colorMap, isDarkTheme)=>{
|
|
|
277
290
|
});
|
|
278
291
|
});
|
|
279
292
|
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
293
|
+
const gvbcData = Object.values(mapXToDataPoints);
|
|
280
294
|
var _input_layout_height;
|
|
281
295
|
return {
|
|
282
|
-
data:
|
|
296
|
+
data: gvbcData,
|
|
283
297
|
width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
|
|
284
298
|
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,
|
|
285
299
|
barWidth: 'auto',
|
|
@@ -289,18 +303,22 @@ export const transformPlotlyJsonToGVBCProps = (input, colorMap, isDarkTheme)=>{
|
|
|
289
303
|
mode: 'plotly',
|
|
290
304
|
...secondaryYAxisValues,
|
|
291
305
|
hideTickOverlap: true,
|
|
292
|
-
|
|
306
|
+
wrapXAxisLables: typeof ((_gvbcData_ = gvbcData[0]) === null || _gvbcData_ === void 0 ? void 0 : _gvbcData_.name) === 'string',
|
|
307
|
+
hideLegend,
|
|
308
|
+
roundCorners: true
|
|
293
309
|
};
|
|
294
310
|
};
|
|
295
|
-
export const transformPlotlyJsonToVBCProps = (input, colorMap, isDarkTheme)=>{
|
|
296
|
-
var _input_layout, _input_layout1;
|
|
311
|
+
export const transformPlotlyJsonToVBCProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
312
|
+
var _input_layout, _input_layout1, _vbcData_;
|
|
297
313
|
const vbcData = [];
|
|
298
314
|
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
299
315
|
input.data.forEach((series, seriesIdx)=>{
|
|
300
|
-
var _series_xbins, _series_xbins1, _series_xbins2;
|
|
316
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _series_xbins, _series_xbins1, _series_xbins2;
|
|
301
317
|
if (!series.x) {
|
|
302
318
|
return;
|
|
303
319
|
}
|
|
320
|
+
// extract colors for each series only once
|
|
321
|
+
const extractedColors = 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, (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color, colorMap, isDarkTheme);
|
|
304
322
|
const isXString = isStringArray(series.x);
|
|
305
323
|
// TODO: In case of a single bin, add an empty bin of the same size to prevent the
|
|
306
324
|
// default bar width from being used and ensure the bar spans the full intended range.
|
|
@@ -322,7 +340,8 @@ export const transformPlotlyJsonToVBCProps = (input, colorMap, isDarkTheme)=>{
|
|
|
322
340
|
});
|
|
323
341
|
xBins.forEach((bin, index)=>{
|
|
324
342
|
const legend = legends[seriesIdx];
|
|
325
|
-
|
|
343
|
+
// resolve color for each legend's bars from the extracted colors
|
|
344
|
+
const color = resolveColor(extractedColors, seriesIdx, legend, colorMap, isDarkTheme);
|
|
326
345
|
const yVal = calculateHistNorm(series.histnorm, y[index], total, isXString ? bin.length : getBinSize(bin));
|
|
327
346
|
vbcData.push({
|
|
328
347
|
x: isXString ? bin.join(', ') : getBinCenter(bin),
|
|
@@ -346,25 +365,30 @@ export const transformPlotlyJsonToVBCProps = (input, colorMap, isDarkTheme)=>{
|
|
|
346
365
|
yAxisTitle,
|
|
347
366
|
mode: 'histogram',
|
|
348
367
|
hideTickOverlap: true,
|
|
368
|
+
wrapXAxisLables: typeof ((_vbcData_ = vbcData[0]) === null || _vbcData_ === void 0 ? void 0 : _vbcData_.x) === 'string',
|
|
349
369
|
maxBarWidth: 50,
|
|
350
|
-
hideLegend
|
|
370
|
+
hideLegend,
|
|
371
|
+
roundCorners: true
|
|
351
372
|
};
|
|
352
373
|
};
|
|
353
|
-
export const transformPlotlyJsonToScatterChartProps = (input, isAreaChart, colorMap, isDarkTheme)=>{
|
|
374
|
+
export const transformPlotlyJsonToScatterChartProps = (input, isAreaChart, isScatterMarkers, colorMap, colorwayType, isDarkTheme)=>{
|
|
354
375
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
|
|
355
376
|
let mode = 'tonexty';
|
|
356
377
|
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
357
378
|
const chartData = input.data.map((series, index)=>{
|
|
358
|
-
var _series_line;
|
|
379
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _series_line, _series_line1;
|
|
380
|
+
// extract colors for each series only once
|
|
381
|
+
const extractedColors = 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, isScatterMarkers ? (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color : (_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.color, colorMap, isDarkTheme);
|
|
359
382
|
const xValues = series.x;
|
|
360
383
|
const isString = typeof xValues[0] === 'string';
|
|
361
384
|
const isXDate = isDateArray(xValues);
|
|
362
385
|
const isXNumber = isNumberArray(xValues);
|
|
363
386
|
const legend = legends[index];
|
|
364
|
-
|
|
387
|
+
// resolve color for each legend's lines from the extracted colors
|
|
388
|
+
const seriesColor = resolveColor(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
365
389
|
mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
|
|
366
390
|
const lineOptions = getLineOptions(series.line);
|
|
367
|
-
const dashType = ((
|
|
391
|
+
const dashType = ((_series_line1 = series.line) === null || _series_line1 === void 0 ? void 0 : _series_line1.dash) || 'solid';
|
|
368
392
|
const legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot' ? 'dottedLine' : 'default';
|
|
369
393
|
return {
|
|
370
394
|
legend,
|
|
@@ -381,7 +405,7 @@ export const transformPlotlyJsonToScatterChartProps = (input, isAreaChart, color
|
|
|
381
405
|
} : {}
|
|
382
406
|
};
|
|
383
407
|
}),
|
|
384
|
-
color:
|
|
408
|
+
color: seriesColor,
|
|
385
409
|
...lineOptions ? {
|
|
386
410
|
lineOptions
|
|
387
411
|
} : {},
|
|
@@ -430,12 +454,16 @@ export const transformPlotlyJsonToScatterChartProps = (input, isAreaChart, color
|
|
|
430
454
|
};
|
|
431
455
|
}
|
|
432
456
|
};
|
|
433
|
-
export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, colorMap, isDarkTheme)=>{
|
|
457
|
+
export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
434
458
|
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;
|
|
435
459
|
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
436
460
|
const chartData = input.data.map((series, index)=>{
|
|
461
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker;
|
|
462
|
+
// extract colors for each series only once
|
|
463
|
+
const extractedColors = 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, (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color, colorMap, isDarkTheme);
|
|
437
464
|
const legend = legends[index];
|
|
438
|
-
|
|
465
|
+
// resolve color for each legend's bars from the extracted colors
|
|
466
|
+
const color = resolveColor(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
439
467
|
return series.y.map((yValue, i)=>{
|
|
440
468
|
return {
|
|
441
469
|
x: series.x[i],
|
|
@@ -471,7 +499,8 @@ export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, colorMap,
|
|
|
471
499
|
hideTickOverlap: true,
|
|
472
500
|
noOfCharsToTruncate: 20,
|
|
473
501
|
showYAxisLablesTooltip: true,
|
|
474
|
-
hideLegend
|
|
502
|
+
hideLegend,
|
|
503
|
+
roundCorners: true
|
|
475
504
|
};
|
|
476
505
|
};
|
|
477
506
|
export const transformPlotlyJsonToHeatmapProps = (input)=>{
|
|
@@ -523,7 +552,8 @@ export const transformPlotlyJsonToHeatmapProps = (input)=>{
|
|
|
523
552
|
} else {
|
|
524
553
|
var _firstData_x1;
|
|
525
554
|
(_firstData_x1 = firstData.x) === null || _firstData_x1 === void 0 ? void 0 : _firstData_x1.forEach((xVal, xIdx)=>{
|
|
526
|
-
var
|
|
555
|
+
var // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
556
|
+
_firstData_y;
|
|
527
557
|
(_firstData_y = firstData.y) === null || _firstData_y === void 0 ? void 0 : _firstData_y.forEach((yVal, yIdx)=>{
|
|
528
558
|
var _firstData_z_yIdx, _firstData_z, _input_layout_xaxis, _input_layout, _input_layout_yaxis, _input_layout1;
|
|
529
559
|
const zVal = (_firstData_z = firstData.z) === null || _firstData_z === void 0 ? void 0 : (_firstData_z_yIdx = _firstData_z[yIdx]) === null || _firstData_z_yIdx === void 0 ? void 0 : _firstData_z_yIdx[xIdx];
|
|
@@ -577,29 +607,31 @@ export const transformPlotlyJsonToHeatmapProps = (input)=>{
|
|
|
577
607
|
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,
|
|
578
608
|
hideTickOverlap: true,
|
|
579
609
|
noOfCharsToTruncate: 20,
|
|
580
|
-
showYAxisLablesTooltip: true
|
|
610
|
+
showYAxisLablesTooltip: true,
|
|
611
|
+
wrapXAxisLables: true
|
|
581
612
|
};
|
|
582
613
|
};
|
|
583
|
-
export const transformPlotlyJsonToSankeyProps = (input, colorMap, isDarkTheme)=>{
|
|
584
|
-
var
|
|
614
|
+
export const transformPlotlyJsonToSankeyProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
615
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout, _node_label, _input_layout1, _input_layout2;
|
|
585
616
|
const { link, node } = input.data[0];
|
|
586
617
|
var _link_value;
|
|
587
618
|
const validLinks = ((_link_value = link === null || link === void 0 ? void 0 : link.value) !== null && _link_value !== void 0 ? _link_value : []).map((val, index)=>({
|
|
588
619
|
value: val,
|
|
589
620
|
source: link === null || link === void 0 ? void 0 : link.source[index],
|
|
590
621
|
target: link === null || link === void 0 ? void 0 : link.target[index]
|
|
591
|
-
}))//
|
|
592
|
-
// Filter out negative nodes, unequal nodes and self-references (circular links)
|
|
622
|
+
}))// Filter out negative nodes, unequal nodes and self-references (circular links)
|
|
593
623
|
.filter((x)=>x.source >= 0 && x.target >= 0 && x.source !== x.target);
|
|
624
|
+
const extractedNodeColors = 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);
|
|
594
625
|
const sankeyChartData = {
|
|
595
626
|
nodes: (_node_label = node.label) === null || _node_label === void 0 ? void 0 : _node_label.map((label, index)=>{
|
|
596
|
-
const color =
|
|
627
|
+
const color = resolveColor(extractedNodeColors, index, label, colorMap, isDarkTheme);
|
|
597
628
|
return {
|
|
598
629
|
nodeId: index,
|
|
599
630
|
name: label,
|
|
600
631
|
color
|
|
601
632
|
};
|
|
602
633
|
}),
|
|
634
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
603
635
|
links: validLinks.map((validLink, index)=>{
|
|
604
636
|
return {
|
|
605
637
|
...validLink
|
|
@@ -618,18 +650,20 @@ export const transformPlotlyJsonToSankeyProps = (input, colorMap, isDarkTheme)=>
|
|
|
618
650
|
chartTitle,
|
|
619
651
|
SankeyChartData: sankeyChartData
|
|
620
652
|
},
|
|
621
|
-
width: (
|
|
622
|
-
height: (_input_layout_height = (
|
|
653
|
+
width: (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.width,
|
|
654
|
+
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
|
|
623
655
|
};
|
|
624
656
|
};
|
|
625
|
-
export const transformPlotlyJsonToGaugeProps = (input, colorMap, isDarkTheme)=>{
|
|
626
|
-
var _firstData_gauge_steps,
|
|
657
|
+
export const transformPlotlyJsonToGaugeProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
658
|
+
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;
|
|
627
659
|
const firstData = input.data[0];
|
|
660
|
+
const stepsColors = ((_firstData_gauge = firstData.gauge) === null || _firstData_gauge === void 0 ? void 0 : _firstData_gauge.steps) ? firstData.gauge.steps.map((step)=>step.color) : undefined;
|
|
661
|
+
const extractedColors = 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, stepsColors, colorMap, isDarkTheme);
|
|
628
662
|
var _firstData_gauge_axis_range_, _firstData_value, _firstData_gauge_axis_range_1, _firstData_value1;
|
|
629
|
-
const segments = ((
|
|
663
|
+
const segments = ((_firstData_gauge1 = firstData.gauge) === null || _firstData_gauge1 === void 0 ? void 0 : (_firstData_gauge_steps = _firstData_gauge1.steps) === null || _firstData_gauge_steps === void 0 ? void 0 : _firstData_gauge_steps.length) ? firstData.gauge.steps.map((step, index)=>{
|
|
630
664
|
var _step_range, _step_range1;
|
|
631
665
|
const legend = step.name || `Segment ${index + 1}`;
|
|
632
|
-
const color =
|
|
666
|
+
const color = resolveColor(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
633
667
|
return {
|
|
634
668
|
legend,
|
|
635
669
|
size: ((_step_range = step.range) === null || _step_range === void 0 ? void 0 : _step_range[1]) - ((_step_range1 = step.range) === null || _step_range1 === void 0 ? void 0 : _step_range1[0]),
|
|
@@ -638,34 +672,36 @@ export const transformPlotlyJsonToGaugeProps = (input, colorMap, isDarkTheme)=>{
|
|
|
638
672
|
}) : [
|
|
639
673
|
{
|
|
640
674
|
legend: 'Current',
|
|
641
|
-
size: (_firstData_value = firstData.value) !== null && _firstData_value !== void 0 ? _firstData_value : 0 - ((_firstData_gauge_axis_range_ = (
|
|
642
|
-
color:
|
|
675
|
+
size: (_firstData_value = firstData.value) !== null && _firstData_value !== void 0 ? _firstData_value : 0 - ((_firstData_gauge_axis_range_ = (_firstData_gauge2 = firstData.gauge) === null || _firstData_gauge2 === void 0 ? void 0 : (_firstData_gauge_axis = _firstData_gauge2.axis) === null || _firstData_gauge_axis === void 0 ? void 0 : (_firstData_gauge_axis_range = _firstData_gauge_axis.range) === null || _firstData_gauge_axis_range === void 0 ? void 0 : _firstData_gauge_axis_range[0]) !== null && _firstData_gauge_axis_range_ !== void 0 ? _firstData_gauge_axis_range_ : 0),
|
|
676
|
+
color: _getGaugeAxisColor((_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_template1 = _input_layout1.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, (_firstData_gauge3 = firstData.gauge) === null || _firstData_gauge3 === void 0 ? void 0 : (_firstData_gauge_axis1 = _firstData_gauge3.axis) === null || _firstData_gauge_axis1 === void 0 ? void 0 : _firstData_gauge_axis1.color, colorMap, isDarkTheme)
|
|
643
677
|
},
|
|
644
678
|
{
|
|
645
679
|
legend: 'Target',
|
|
646
|
-
size: ((_firstData_gauge_axis_range_1 = (
|
|
680
|
+
size: ((_firstData_gauge_axis_range_1 = (_firstData_gauge4 = firstData.gauge) === null || _firstData_gauge4 === void 0 ? void 0 : (_firstData_gauge_axis2 = _firstData_gauge4.axis) === null || _firstData_gauge_axis2 === void 0 ? void 0 : (_firstData_gauge_axis_range1 = _firstData_gauge_axis2.range) === null || _firstData_gauge_axis_range1 === void 0 ? void 0 : _firstData_gauge_axis_range1[1]) !== null && _firstData_gauge_axis_range_1 !== void 0 ? _firstData_gauge_axis_range_1 : 100) - ((_firstData_value1 = firstData.value) !== null && _firstData_value1 !== void 0 ? _firstData_value1 : 0),
|
|
647
681
|
color: DataVizPalette.disabled
|
|
648
682
|
}
|
|
649
683
|
];
|
|
650
684
|
let sublabel;
|
|
651
|
-
|
|
685
|
+
let sublabelColor;
|
|
652
686
|
if ((_firstData_delta = firstData.delta) === null || _firstData_delta === void 0 ? void 0 : _firstData_delta.reference) {
|
|
653
687
|
const diff = firstData.value - firstData.delta.reference;
|
|
654
688
|
if (diff >= 0) {
|
|
689
|
+
var _input_layout_template_layout2, _input_layout_template2, _input_layout4, _firstData_delta_increasing, _firstData_delta1;
|
|
655
690
|
sublabel = `\u25B2 ${diff}`;
|
|
656
|
-
|
|
657
|
-
|
|
691
|
+
const extractedIncreasingDeltaColors = extractColor((_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_layout2 = _input_layout_template2.layout) === null || _input_layout_template_layout2 === void 0 ? void 0 : _input_layout_template_layout2.colorway, colorwayType, (_firstData_delta1 = firstData.delta) === null || _firstData_delta1 === void 0 ? void 0 : (_firstData_delta_increasing = _firstData_delta1.increasing) === null || _firstData_delta_increasing === void 0 ? void 0 : _firstData_delta_increasing.color, colorMap, isDarkTheme);
|
|
692
|
+
const color = resolveColor(extractedIncreasingDeltaColors, 0, '', colorMap, isDarkTheme);
|
|
693
|
+
sublabelColor = color;
|
|
658
694
|
} else {
|
|
695
|
+
var _input_layout_template_layout3, _input_layout_template3, _input_layout5, _firstData_delta_decreasing, _firstData_delta2;
|
|
659
696
|
sublabel = `\u25BC ${Math.abs(diff)}`;
|
|
660
|
-
|
|
661
|
-
|
|
697
|
+
const extractedDecreasingDeltaColors = extractColor((_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : (_input_layout_template3 = _input_layout5.template) === null || _input_layout_template3 === void 0 ? void 0 : (_input_layout_template_layout3 = _input_layout_template3.layout) === null || _input_layout_template_layout3 === void 0 ? void 0 : _input_layout_template_layout3.colorway, colorwayType, (_firstData_delta2 = firstData.delta) === null || _firstData_delta2 === void 0 ? void 0 : (_firstData_delta_decreasing = _firstData_delta2.decreasing) === null || _firstData_delta_decreasing === void 0 ? void 0 : _firstData_delta_decreasing.color, colorMap, isDarkTheme);
|
|
698
|
+
const color = resolveColor(extractedDecreasingDeltaColors, 0, '', colorMap, isDarkTheme);
|
|
699
|
+
sublabelColor = color;
|
|
662
700
|
}
|
|
663
701
|
}
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
// },
|
|
668
|
-
// };
|
|
702
|
+
const styles = {
|
|
703
|
+
sublabel: sublabelColor
|
|
704
|
+
};
|
|
669
705
|
const { chartTitle } = getTitles(input.layout);
|
|
670
706
|
var _firstData_value2, _input_layout_height;
|
|
671
707
|
return {
|
|
@@ -674,18 +710,60 @@ export const transformPlotlyJsonToGaugeProps = (input, colorMap, isDarkTheme)=>{
|
|
|
674
710
|
chartTitle,
|
|
675
711
|
sublabel,
|
|
676
712
|
// range values can be null
|
|
677
|
-
minValue: typeof ((
|
|
678
|
-
maxValue: typeof ((
|
|
713
|
+
minValue: typeof ((_firstData_gauge5 = firstData.gauge) === null || _firstData_gauge5 === void 0 ? void 0 : (_firstData_gauge_axis3 = _firstData_gauge5.axis) === null || _firstData_gauge_axis3 === void 0 ? void 0 : (_firstData_gauge_axis_range2 = _firstData_gauge_axis3.range) === null || _firstData_gauge_axis_range2 === void 0 ? void 0 : _firstData_gauge_axis_range2[0]) === 'number' ? (_firstData_gauge6 = firstData.gauge) === null || _firstData_gauge6 === void 0 ? void 0 : (_firstData_gauge_axis4 = _firstData_gauge6.axis) === null || _firstData_gauge_axis4 === void 0 ? void 0 : (_firstData_gauge_axis_range3 = _firstData_gauge_axis4.range) === null || _firstData_gauge_axis_range3 === void 0 ? void 0 : _firstData_gauge_axis_range3[0] : undefined,
|
|
714
|
+
maxValue: typeof ((_firstData_gauge7 = firstData.gauge) === null || _firstData_gauge7 === void 0 ? void 0 : (_firstData_gauge_axis5 = _firstData_gauge7.axis) === null || _firstData_gauge_axis5 === void 0 ? void 0 : (_firstData_gauge_axis_range4 = _firstData_gauge_axis5.range) === null || _firstData_gauge_axis_range4 === void 0 ? void 0 : _firstData_gauge_axis_range4[1]) === 'number' ? (_firstData_gauge8 = firstData.gauge) === null || _firstData_gauge8 === void 0 ? void 0 : (_firstData_gauge_axis6 = _firstData_gauge8.axis) === null || _firstData_gauge_axis6 === void 0 ? void 0 : (_firstData_gauge_axis_range5 = _firstData_gauge_axis6.range) === null || _firstData_gauge_axis_range5 === void 0 ? void 0 : _firstData_gauge_axis_range5[1] : undefined,
|
|
679
715
|
chartValueFormat: ()=>{
|
|
680
716
|
var _firstData_value;
|
|
681
717
|
var _firstData_value_toString;
|
|
682
718
|
return (_firstData_value_toString = (_firstData_value = firstData.value) === null || _firstData_value === void 0 ? void 0 : _firstData_value.toString()) !== null && _firstData_value_toString !== void 0 ? _firstData_value_toString : '';
|
|
683
719
|
},
|
|
684
|
-
width: (
|
|
685
|
-
height: (_input_layout_height = (
|
|
720
|
+
width: (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.width,
|
|
721
|
+
height: (_input_layout_height = (_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : _input_layout3.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 220,
|
|
686
722
|
// TODO
|
|
687
723
|
// styles,
|
|
688
|
-
variant: ((
|
|
724
|
+
variant: ((_firstData_gauge9 = firstData.gauge) === null || _firstData_gauge9 === void 0 ? void 0 : (_firstData_gauge_steps1 = _firstData_gauge9.steps) === null || _firstData_gauge_steps1 === void 0 ? void 0 : _firstData_gauge_steps1.length) ? 'multiple-segments' : 'single-segment',
|
|
725
|
+
styles,
|
|
726
|
+
roundCorners: true
|
|
727
|
+
};
|
|
728
|
+
};
|
|
729
|
+
const cleanText = (text)=>{
|
|
730
|
+
return text.replace(/<[^&]*?>/g, '').replace(/<[^>]*>/g, '').replace(/<br>|\\u003cbr\\u003e|<br>/gi, '').replace(/\$[^$]*\$/g, '$').trim();
|
|
731
|
+
};
|
|
732
|
+
export const transformPlotlyJsonToChartTableProps = (input, colorMap, isDarkTheme)=>{
|
|
733
|
+
var _tableData_cells, _input_layout_font, _input_layout, _tableData_header, _input_layout1, _input_layout2;
|
|
734
|
+
const tableData = input.data[0];
|
|
735
|
+
const normalizeHeaders = (values)=>{
|
|
736
|
+
// Case: values is array of arrays
|
|
737
|
+
if (Array.isArray(values[0])) {
|
|
738
|
+
return values.map((row)=>row.map((cell)=>cleanText(cell)).filter(Boolean).join(' '));
|
|
739
|
+
}
|
|
740
|
+
// Case: values is 1d array
|
|
741
|
+
return values.map((cell)=>cleanText(cell));
|
|
742
|
+
};
|
|
743
|
+
var _tableData_cells_values;
|
|
744
|
+
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 : [];
|
|
745
|
+
const rows = columns[0].map((_, rowIndex)=>columns.map((col)=>{
|
|
746
|
+
const cell = col[rowIndex];
|
|
747
|
+
return {
|
|
748
|
+
value: typeof cell === 'string' ? cleanText(cell) : cell
|
|
749
|
+
};
|
|
750
|
+
}));
|
|
751
|
+
const styles = {
|
|
752
|
+
root: {
|
|
753
|
+
...((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_font = _input_layout.font) === null || _input_layout_font === void 0 ? void 0 : _input_layout_font.size) ? {
|
|
754
|
+
fontSize: input.layout.font.size
|
|
755
|
+
} : {}
|
|
756
|
+
}
|
|
757
|
+
};
|
|
758
|
+
var _tableData_header_values;
|
|
759
|
+
return {
|
|
760
|
+
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 : []).map((value)=>({
|
|
761
|
+
value
|
|
762
|
+
})),
|
|
763
|
+
rows,
|
|
764
|
+
width: (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.width,
|
|
765
|
+
height: (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.height,
|
|
766
|
+
styles
|
|
689
767
|
};
|
|
690
768
|
};
|
|
691
769
|
export const projectPolarToCartesian = (input)=>{
|
|
@@ -706,21 +784,28 @@ export const projectPolarToCartesian = (input)=>{
|
|
|
706
784
|
}
|
|
707
785
|
return projection;
|
|
708
786
|
};
|
|
787
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
709
788
|
function isPlainObject(obj) {
|
|
710
789
|
return Object.prototype.toString.call(obj) === '[object Object]' && Object.getPrototypeOf(obj).hasOwnProperty('hasOwnProperty');
|
|
711
790
|
}
|
|
791
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
712
792
|
var arrayAttributes = [];
|
|
793
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
713
794
|
var stack = [];
|
|
795
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
714
796
|
var isArrayStack = [];
|
|
797
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
715
798
|
var baseContainer, baseAttrName;
|
|
716
799
|
/**
|
|
717
800
|
* Interate iteratively through the trace object and find all the array attributes.
|
|
718
801
|
* 1 trace record = 1 series of data
|
|
719
802
|
* @param trace
|
|
720
|
-
*/
|
|
803
|
+
*/ // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
804
|
+
export function findArrayAttributes(trace) {
|
|
721
805
|
// Init basecontainer and baseAttrName
|
|
722
806
|
crawlIntoTrace(baseContainer, 0, '');
|
|
723
807
|
}
|
|
808
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
724
809
|
function crawlIntoTrace(container, i, astrPartial) {
|
|
725
810
|
var item = container[stack[i]];
|
|
726
811
|
var newAstrPartial = astrPartial + stack[i];
|
|
@@ -772,7 +857,9 @@ function getLineOptions(line) {
|
|
|
772
857
|
}
|
|
773
858
|
return Object.keys(lineOptions).length > 0 ? lineOptions : undefined;
|
|
774
859
|
}
|
|
860
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
775
861
|
const isStringArray = (arr)=>{
|
|
862
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
776
863
|
return isArrayOfType(arr, (value)=>typeof value === 'string');
|
|
777
864
|
};
|
|
778
865
|
// TODO: Use binary search to find the appropriate bin for numeric value.
|