@fluentui/react-charting 5.23.41 → 5.23.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +69 -1
- package/CHANGELOG.md +25 -2
- package/bundle-size/DeclarativeChart.fixture.js +7 -0
- package/dist/react-charting.d.ts +5 -0
- package/dist/react-charting.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/etc/react-charting.api.md +1 -0
- package/lib/Styling.js +3 -3
- package/lib/Styling.js.map +1 -1
- package/lib/Utilities.js +1 -19
- package/lib/Utilities.js.map +1 -1
- package/lib/components/AreaChart/AreaChart.base.d.ts +3 -3
- package/lib/components/AreaChart/AreaChart.base.js +53 -30
- package/lib/components/AreaChart/AreaChart.base.js.map +1 -1
- package/lib/components/AreaChart/AreaChart.types.d.ts +5 -0
- package/lib/components/AreaChart/AreaChart.types.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +66 -49
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchema.d.ts +1516 -0
- package/lib/components/DeclarativeChart/PlotlySchema.js +4 -0
- package/lib/components/DeclarativeChart/PlotlySchema.js.map +1 -0
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +16 -13
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +232 -118
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.base.js +3 -1
- package/lib/components/DonutChart/DonutChart.base.js.map +1 -1
- package/lib/components/HorizontalBarChart/HorizontalBarChart.base.js +3 -1
- package/lib/components/HorizontalBarChart/HorizontalBarChart.base.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +5 -4
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
- package/lib/components/StackedBarChart/MultiStackedBarChart.base.js +3 -1
- package/lib/components/StackedBarChart/MultiStackedBarChart.base.js.map +1 -1
- package/lib/components/StackedBarChart/StackedBarChart.base.js +3 -1
- package/lib/components/StackedBarChart/StackedBarChart.base.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.base.js +10 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +2 -2
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
- package/lib/utilities/SVGTooltipText.js +1 -1
- package/lib/utilities/SVGTooltipText.js.map +1 -1
- package/lib/utilities/utilities.js +2 -9
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-amd/Styling.js +3 -3
- package/lib-amd/Styling.js.map +1 -1
- package/lib-amd/Utilities.js +0 -9
- package/lib-amd/Utilities.js.map +1 -1
- package/lib-amd/components/AreaChart/AreaChart.base.d.ts +3 -3
- package/lib-amd/components/AreaChart/AreaChart.base.js +53 -30
- package/lib-amd/components/AreaChart/AreaChart.base.js.map +1 -1
- package/lib-amd/components/AreaChart/AreaChart.types.d.ts +5 -0
- package/lib-amd/components/AreaChart/AreaChart.types.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/DeclarativeChart.js +64 -47
- package/lib-amd/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/PlotlySchema.d.ts +1516 -0
- package/lib-amd/components/DeclarativeChart/PlotlySchema.js +7 -0
- package/lib-amd/components/DeclarativeChart/PlotlySchema.js.map +1 -0
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +16 -13
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +233 -119
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-amd/components/DonutChart/DonutChart.base.js +3 -1
- package/lib-amd/components/DonutChart/DonutChart.base.js.map +1 -1
- package/lib-amd/components/HorizontalBarChart/HorizontalBarChart.base.js +3 -1
- package/lib-amd/components/HorizontalBarChart/HorizontalBarChart.base.js.map +1 -1
- package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +5 -4
- package/lib-amd/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
- package/lib-amd/components/StackedBarChart/MultiStackedBarChart.base.js +3 -1
- package/lib-amd/components/StackedBarChart/MultiStackedBarChart.base.js.map +1 -1
- package/lib-amd/components/StackedBarChart/StackedBarChart.base.js +3 -1
- package/lib-amd/components/StackedBarChart/StackedBarChart.base.js.map +1 -1
- package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js +10 -1
- package/lib-amd/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +2 -2
- package/lib-amd/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
- package/lib-amd/utilities/SVGTooltipText.js +1 -1
- package/lib-amd/utilities/SVGTooltipText.js.map +1 -1
- package/lib-amd/utilities/utilities.js +2 -9
- package/lib-amd/utilities/utilities.js.map +1 -1
- package/lib-commonjs/Styling.js +3 -3
- package/lib-commonjs/Styling.js.map +1 -1
- package/lib-commonjs/Utilities.js +0 -9
- package/lib-commonjs/Utilities.js.map +1 -1
- package/lib-commonjs/components/AreaChart/AreaChart.base.d.ts +3 -3
- package/lib-commonjs/components/AreaChart/AreaChart.base.js +53 -30
- package/lib-commonjs/components/AreaChart/AreaChart.base.js.map +1 -1
- package/lib-commonjs/components/AreaChart/AreaChart.types.d.ts +5 -0
- package/lib-commonjs/components/AreaChart/AreaChart.types.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +65 -48
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchema.d.ts +1516 -0
- package/lib-commonjs/components/DeclarativeChart/PlotlySchema.js +5 -0
- package/lib-commonjs/components/DeclarativeChart/PlotlySchema.js.map +1 -0
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +16 -13
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +233 -118
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.base.js +3 -1
- package/lib-commonjs/components/DonutChart/DonutChart.base.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.base.js +3 -1
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.base.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js +5 -4
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.js.map +1 -1
- package/lib-commonjs/components/StackedBarChart/MultiStackedBarChart.base.js +3 -1
- package/lib-commonjs/components/StackedBarChart/MultiStackedBarChart.base.js.map +1 -1
- package/lib-commonjs/components/StackedBarChart/StackedBarChart.base.js +3 -1
- package/lib-commonjs/components/StackedBarChart/StackedBarChart.base.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js +10 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.base.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js +2 -2
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.base.js.map +1 -1
- package/lib-commonjs/utilities/SVGTooltipText.js +1 -1
- package/lib-commonjs/utilities/SVGTooltipText.js.map +1 -1
- package/lib-commonjs/utilities/utilities.js +2 -9
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +1 -1
- package/src/components/AreaChart/AreaChart.types.ts +6 -0
|
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DeclarativeChart = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
6
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
7
6
|
var React = require("react");
|
|
8
7
|
var react_1 = require("@fluentui/react");
|
|
9
8
|
var index_1 = require("../DonutChart/index");
|
|
10
9
|
var index_2 = require("../VerticalStackedBarChart/index");
|
|
10
|
+
//import type { Data, Layout } from './PlotlySchema';
|
|
11
11
|
var PlotlySchemaAdapter_1 = require("./PlotlySchemaAdapter");
|
|
12
12
|
var index_3 = require("../LineChart/index");
|
|
13
13
|
var index_4 = require("../HorizontalBarChartWithAxis/index");
|
|
@@ -27,14 +27,10 @@ var useColorMapping = function () {
|
|
|
27
27
|
* {@docCategory DeclarativeChart}
|
|
28
28
|
*/
|
|
29
29
|
exports.DeclarativeChart = React.forwardRef(function (props, forwardedRef) {
|
|
30
|
-
var _a, _b, _c, _d;
|
|
30
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
31
31
|
var plotlySchema = (0, PlotlySchemaAdapter_1.sanitizeJson)(props.chartSchema).plotlySchema;
|
|
32
|
-
var
|
|
32
|
+
var plotlyInput = plotlySchema;
|
|
33
33
|
var selectedLegends = plotlySchema.selectedLegends;
|
|
34
|
-
var xValues = data[0].x;
|
|
35
|
-
var isXDate = (0, PlotlySchemaAdapter_1.isDateArray)(xValues);
|
|
36
|
-
var isXNumber = (0, PlotlySchemaAdapter_1.isNumberArray)(xValues);
|
|
37
|
-
var isXMonth = (0, PlotlySchemaAdapter_1.isMonthArray)(xValues);
|
|
38
34
|
var colorMap = useColorMapping();
|
|
39
35
|
var theme = (0, react_1.useTheme)();
|
|
40
36
|
var isDarkTheme = (_a = theme === null || theme === void 0 ? void 0 : theme.isInverted) !== null && _a !== void 0 ? _a : false;
|
|
@@ -42,11 +38,11 @@ exports.DeclarativeChart = React.forwardRef(function (props, forwardedRef) {
|
|
|
42
38
|
if (!(0, PlotlySchemaAdapter_1.isArrayOrTypedArray)(selectedLegends)) {
|
|
43
39
|
selectedLegends = [];
|
|
44
40
|
}
|
|
45
|
-
var
|
|
41
|
+
var _l = React.useState(selectedLegends), activeLegends = _l[0], setActiveLegends = _l[1];
|
|
46
42
|
var onActiveLegendsChange = function (keys) {
|
|
47
43
|
setActiveLegends(keys);
|
|
48
44
|
if (props.onSchemaChange) {
|
|
49
|
-
props.onSchemaChange({ plotlySchema: {
|
|
45
|
+
props.onSchemaChange({ plotlySchema: { plotlyInput: plotlyInput, selectedLegends: keys } });
|
|
50
46
|
}
|
|
51
47
|
};
|
|
52
48
|
React.useEffect(function () {
|
|
@@ -56,70 +52,91 @@ exports.DeclarativeChart = React.forwardRef(function (props, forwardedRef) {
|
|
|
56
52
|
var selectedLegends = plotlySchema.selectedLegends;
|
|
57
53
|
setActiveLegends(selectedLegends !== null && selectedLegends !== void 0 ? selectedLegends : []);
|
|
58
54
|
}, [props.chartSchema]);
|
|
59
|
-
var
|
|
60
|
-
canSelectMultipleLegends:
|
|
55
|
+
var multiSelectLegendProps = {
|
|
56
|
+
canSelectMultipleLegends: true,
|
|
61
57
|
onChange: onActiveLegendsChange,
|
|
62
|
-
|
|
58
|
+
selectedLegends: activeLegends,
|
|
59
|
+
};
|
|
60
|
+
var commonProps = {
|
|
61
|
+
legendProps: multiSelectLegendProps,
|
|
62
|
+
componentRef: chartRef,
|
|
63
|
+
calloutProps: { layerProps: { eventBubblingEnabled: true } },
|
|
64
|
+
};
|
|
65
|
+
var checkAndRenderChart = function (renderChartJsx, isAreaChart) {
|
|
66
|
+
if (isAreaChart === void 0) { isAreaChart = false; }
|
|
67
|
+
var fallbackVSBC = false;
|
|
68
|
+
var xValues = plotlyInput.data[0].x;
|
|
69
|
+
var isXDate = (0, PlotlySchemaAdapter_1.isDateArray)(xValues);
|
|
70
|
+
var isXNumber = (0, PlotlySchemaAdapter_1.isNumberArray)(xValues);
|
|
71
|
+
var isXMonth = (0, PlotlySchemaAdapter_1.isMonthArray)(xValues);
|
|
72
|
+
if (isXDate || isXNumber) {
|
|
73
|
+
var chartProps = tslib_1.__assign(tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToScatterChartProps)({ data: plotlyInput.data, layout: plotlyInput.layout }, isAreaChart, colorMap, isDarkTheme)), commonProps);
|
|
74
|
+
return renderChartJsx(chartProps);
|
|
75
|
+
}
|
|
76
|
+
else if (isXMonth) {
|
|
77
|
+
var updatedData = plotlyInput.data.map(function (dataPoint) { return (tslib_1.__assign(tslib_1.__assign({}, dataPoint), { x: (0, PlotlySchemaAdapter_1.updateXValues)(dataPoint.x) })); });
|
|
78
|
+
var chartProps = tslib_1.__assign(tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToScatterChartProps)({ data: updatedData, layout: plotlyInput.layout }, isAreaChart, colorMap, isDarkTheme)), commonProps);
|
|
79
|
+
return renderChartJsx(chartProps);
|
|
80
|
+
}
|
|
81
|
+
// Unsupported schema, render as VerticalStackedBarChart
|
|
82
|
+
fallbackVSBC = true;
|
|
83
|
+
return (React.createElement(index_2.VerticalStackedBarChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToVSBCProps)(plotlySchema, colorMap, isDarkTheme, fallbackVSBC), commonProps)));
|
|
63
84
|
};
|
|
64
85
|
var exportAsImage = React.useCallback(function (opts) {
|
|
65
86
|
var _a;
|
|
66
|
-
return (0, imageExporter_1.toImage)((_a = chartRef.current) === null || _a === void 0 ? void 0 : _a.chartContainer, tslib_1.__assign({ background: theme.semanticColors.bodyBackground }, opts));
|
|
87
|
+
return (0, imageExporter_1.toImage)((_a = chartRef.current) === null || _a === void 0 ? void 0 : _a.chartContainer, tslib_1.__assign({ background: theme.semanticColors.bodyBackground, scale: 5 }, opts));
|
|
67
88
|
}, [theme]);
|
|
68
89
|
React.useImperativeHandle(props.componentRef, function () { return ({
|
|
69
90
|
exportAsImage: exportAsImage,
|
|
70
91
|
}); }, [exportAsImage]);
|
|
71
|
-
|
|
72
|
-
switch (data[0].type) {
|
|
92
|
+
switch (plotlyInput.data[0].type) {
|
|
73
93
|
case 'pie':
|
|
74
|
-
return
|
|
75
|
-
// Bubble event to prevent right click to open menu on the callout
|
|
76
|
-
calloutProps: { layerProps: { eventBubblingEnabled: true } } })));
|
|
94
|
+
return React.createElement(index_1.DonutChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToDonutProps)(plotlySchema, colorMap, isDarkTheme), commonProps));
|
|
77
95
|
case 'bar':
|
|
78
|
-
var orientation_1 = data[0].orientation;
|
|
96
|
+
var orientation_1 = plotlyInput.data[0].orientation;
|
|
79
97
|
if (orientation_1 === 'h') {
|
|
80
|
-
return (React.createElement(index_4.HorizontalBarChartWithAxis, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToHorizontalBarWithAxisProps)(plotlySchema, colorMap, isDarkTheme),
|
|
98
|
+
return (React.createElement(index_4.HorizontalBarChartWithAxis, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToHorizontalBarWithAxisProps)(plotlySchema, colorMap, isDarkTheme), commonProps)));
|
|
81
99
|
}
|
|
82
100
|
else {
|
|
83
|
-
|
|
84
|
-
|
|
101
|
+
var containsLines = plotlyInput.data.some(function (series) { return series.type === 'scatter' || (0, PlotlySchemaAdapter_1.isLineData)(series); });
|
|
102
|
+
if (['group', 'overlay'].includes((_b = plotlySchema === null || plotlySchema === void 0 ? void 0 : plotlySchema.layout) === null || _b === void 0 ? void 0 : _b.barmode) && !containsLines) {
|
|
103
|
+
return (React.createElement(index_8.GroupedVerticalBarChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToGVBCProps)(plotlySchema, colorMap, isDarkTheme), commonProps)));
|
|
85
104
|
}
|
|
86
|
-
return (React.createElement(index_2.VerticalStackedBarChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToVSBCProps)(plotlySchema, colorMap, isDarkTheme),
|
|
105
|
+
return (React.createElement(index_2.VerticalStackedBarChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToVSBCProps)(plotlySchema, colorMap, isDarkTheme), commonProps)));
|
|
87
106
|
}
|
|
88
107
|
case 'scatter':
|
|
89
|
-
|
|
90
|
-
|
|
108
|
+
if (plotlyInput.data[0].mode === 'markers') {
|
|
109
|
+
throw new Error("Unsupported chart - type :".concat((_c = plotlyInput.data[0]) === null || _c === void 0 ? void 0 : _c.type, ", mode: ").concat((_d = plotlyInput.data[0]) === null || _d === void 0 ? void 0 : _d.mode));
|
|
110
|
+
}
|
|
111
|
+
var isAreaChart_1 = plotlyInput.data.some(function (series) { return series.fill === 'tonexty' || series.fill === 'tozeroy'; });
|
|
112
|
+
var renderChartJsx = function (chartProps) {
|
|
91
113
|
if (isAreaChart_1) {
|
|
92
|
-
return
|
|
114
|
+
return React.createElement(index_5.AreaChart, tslib_1.__assign({}, chartProps));
|
|
93
115
|
}
|
|
94
|
-
return
|
|
95
|
-
onChange: onActiveLegendsChange,
|
|
96
|
-
canSelectMultipleLegends: true,
|
|
97
|
-
selectedLegends: activeLegends,
|
|
98
|
-
} })));
|
|
116
|
+
return React.createElement(index_3.LineChart, tslib_1.__assign({}, chartProps));
|
|
99
117
|
};
|
|
100
|
-
|
|
101
|
-
var chartProps = tslib_1.__assign(tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToScatterChartProps)({ data: data, layout: layout }, isAreaChart_1, colorMap, isDarkTheme)), { legendProps: legendProps, componentRef: chartRef, calloutProps: { layerProps: { eventBubblingEnabled: true } } });
|
|
102
|
-
return renderChart(chartProps);
|
|
103
|
-
}
|
|
104
|
-
else if (isXMonth) {
|
|
105
|
-
var updatedData = data.map(function (dataPoint) { return (tslib_1.__assign(tslib_1.__assign({}, dataPoint), { x: (0, PlotlySchemaAdapter_1.updateXValues)(dataPoint.x) })); });
|
|
106
|
-
var chartProps = tslib_1.__assign(tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToScatterChartProps)({ data: updatedData, layout: layout }, isAreaChart_1, colorMap, isDarkTheme)), { legendProps: legendProps, componentRef: chartRef, calloutProps: { layerProps: { eventBubblingEnabled: true } } });
|
|
107
|
-
return renderChart(chartProps);
|
|
108
|
-
}
|
|
109
|
-
return (React.createElement(index_2.VerticalStackedBarChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToVSBCProps)(plotlySchema, colorMap, isDarkTheme), { legendProps: multiSelectLegendProps, componentRef: chartRef, calloutProps: { layerProps: { eventBubblingEnabled: true } } })));
|
|
118
|
+
return checkAndRenderChart(renderChartJsx, isAreaChart_1);
|
|
110
119
|
case 'heatmap':
|
|
111
|
-
return
|
|
120
|
+
return React.createElement(index_6.HeatMapChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToHeatmapProps)(plotlySchema), commonProps, { legendProps: {} }));
|
|
112
121
|
case 'sankey':
|
|
113
|
-
return (React.createElement(SankeyChart_1.SankeyChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToSankeyProps)(plotlySchema, colorMap, isDarkTheme),
|
|
122
|
+
return (React.createElement(SankeyChart_1.SankeyChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToSankeyProps)(plotlySchema, colorMap, isDarkTheme), commonProps)));
|
|
114
123
|
case 'indicator':
|
|
115
|
-
if ((
|
|
116
|
-
return (React.createElement(index_7.GaugeChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToGaugeProps)(plotlySchema, colorMap, isDarkTheme),
|
|
124
|
+
if ((_g = (_f = (_e = plotlyInput.data) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.mode) === null || _g === void 0 ? void 0 : _g.includes('gauge')) {
|
|
125
|
+
return (React.createElement(index_7.GaugeChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToGaugeProps)(plotlySchema, colorMap, isDarkTheme), commonProps)));
|
|
117
126
|
}
|
|
118
|
-
|
|
127
|
+
throw new Error("Unsupported chart - type: ".concat((_h = plotlyInput.data[0]) === null || _h === void 0 ? void 0 : _h.type, ", mode: ").concat((_j = plotlyInput.data[0]) === null || _j === void 0 ? void 0 : _j.mode));
|
|
119
128
|
case 'histogram':
|
|
120
|
-
return (React.createElement(index_9.VerticalBarChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToVBCProps)(plotlySchema, colorMap, isDarkTheme),
|
|
129
|
+
return (React.createElement(index_9.VerticalBarChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToVBCProps)(plotlySchema, colorMap, isDarkTheme), commonProps)));
|
|
121
130
|
default:
|
|
122
|
-
|
|
131
|
+
var xValues = plotlyInput.data[0].x;
|
|
132
|
+
var yValues = plotlyInput.data[0].y;
|
|
133
|
+
if (xValues && yValues && xValues.length > 0 && yValues.length > 0) {
|
|
134
|
+
var renderLineChartJsx = function (chartProps) {
|
|
135
|
+
return React.createElement(index_3.LineChart, tslib_1.__assign({}, chartProps));
|
|
136
|
+
};
|
|
137
|
+
return checkAndRenderChart(renderLineChartJsx);
|
|
138
|
+
}
|
|
139
|
+
throw new Error("Unsupported chart type :".concat((_k = plotlyInput.data[0]) === null || _k === void 0 ? void 0 : _k.type));
|
|
123
140
|
}
|
|
124
141
|
});
|
|
125
142
|
exports.DeclarativeChart.displayName = 'DeclarativeChart';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeclarativeChart.js","sourceRoot":"../src/","sources":["components/DeclarativeChart/DeclarativeChart.tsx"],"names":[],"mappings":";;;;AAAA,yDAAyD;AACzD,uDAAuD;AACvD,6BAA+B;AAC/B,yCAA2C;AAE3C,6CAAiD;AACjD,0DAA2E;AAC3E,6DAgB+B;AAC/B,4CAA+C;AAC/C,6DAAiF;AACjF,4CAA+C;AAC/C,+CAAqD;AACrD,0DA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E,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;gBACvC,OAAO,CACL,oBAAC,kBAAU,uBACL,IAAA,qDAA+B,EAAC,YAAY,EAAE,QAAQ,EAAE,WAAW,CAAC,IACxE,WAAW,EAAE,sBAAsB,EACnC,YAAY,EAAE,QAAQ,EACtB,YAAY,EAAE,EAAE,UAAU,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,EAAE,IAC5D,CACH,CAAC;YACJ,CAAC;YACD,OAAO,sDAA6B,CAAC;QACvC,KAAK,WAAW;YACd,OAAO,CACL,oBAAC,wBAAgB,uBACX,IAAA,mDAA6B,EAAC,YAAY,EAAE,QAAQ,EAAE,WAAW,CAAC,IACtE,WAAW,EAAE,sBAAsB,EACnC,YAAY,EAAE,QAAQ,EACtB,YAAY,EAAE,EAAE,UAAU,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,EAAE,IAC5D,CACH,CAAC;QACJ;YACE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAChD,CAAC;AACH,CAAC,CAAC,CAAC;AACH,wBAAgB,CAAC,WAAW,GAAG,kBAAkB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport * as React from 'react';\nimport { useTheme } from '@fluentui/react';\nimport { IRefObject } from '@fluentui/react/lib/Utilities';\nimport { DonutChart } from '../DonutChart/index';\nimport { VerticalStackedBarChart } from '../VerticalStackedBarChart/index';\nimport {\n isArrayOrTypedArray,\n isDateArray,\n isNumberArray,\n isMonthArray,\n sanitizeJson,\n updateXValues,\n transformPlotlyJsonToDonutProps,\n transformPlotlyJsonToVSBCProps,\n transformPlotlyJsonToScatterChartProps,\n transformPlotlyJsonToHorizontalBarWithAxisProps,\n transformPlotlyJsonToHeatmapProps,\n transformPlotlyJsonToSankeyProps,\n transformPlotlyJsonToGaugeProps,\n transformPlotlyJsonToGVBCProps,\n transformPlotlyJsonToVBCProps,\n} from './PlotlySchemaAdapter';\nimport { LineChart } from '../LineChart/index';\nimport { HorizontalBarChartWithAxis } from '../HorizontalBarChartWithAxis/index';\nimport { AreaChart } from '../AreaChart/index';\nimport { HeatMapChart } from '../HeatMapChart/index';\nimport { SankeyChart } from '../SankeyChart/SankeyChart';\nimport { GaugeChart } from '../GaugeChart/index';\nimport { GroupedVerticalBarChart } from '../GroupedVerticalBarChart/index';\nimport { VerticalBarChart } from '../VerticalBarChart/index';\nimport { IImageExportOptions, toImage } from './imageExporter';\nimport { IChart } from '../../types/index';\n\n/**\n * DeclarativeChart schema.\n * {@docCategory DeclarativeChart}\n */\nexport interface Schema {\n /**\n * Plotly schema represented as JSON object\n */\n plotlySchema: any;\n}\n\n/**\n * DeclarativeChart props.\n * {@docCategory DeclarativeChart}\n */\nexport interface DeclarativeChartProps extends React.RefAttributes<HTMLDivElement> {\n /**\n * The schema representing the chart data, layout and configuration\n */\n chartSchema: Schema;\n\n /**\n * Callback when an event occurs\n */\n onSchemaChange?: (eventData: Schema) => void;\n\n /**\n * Optional callback to access the IDeclarativeChart interface. Use this instead of ref for accessing\n * the public methods and properties of the component.\n */\n componentRef?: IRefObject<IDeclarativeChart>;\n}\n\n/**\n * {@docCategory DeclarativeChart}\n */\nexport interface IDeclarativeChart {\n exportAsImage: (opts?: IImageExportOptions) => Promise<string>;\n}\n\nconst useColorMapping = () => {\n const colorMap = React.useRef(new Map<string, string>());\n return colorMap;\n};\n\n/**\n * DeclarativeChart component.\n * {@docCategory DeclarativeChart}\n */\nexport const DeclarativeChart: React.FunctionComponent<DeclarativeChartProps> = React.forwardRef<\n HTMLDivElement,\n DeclarativeChartProps\n>((props, forwardedRef) => {\n const { plotlySchema } = sanitizeJson(props.chartSchema);\n const { data, layout } = plotlySchema;\n let { selectedLegends } = plotlySchema;\n const xValues = data[0].x;\n const isXDate = isDateArray(xValues);\n const isXNumber = isNumberArray(xValues);\n const isXMonth = isMonthArray(xValues);\n const colorMap = useColorMapping();\n const theme = useTheme();\n const isDarkTheme = theme?.isInverted ?? false;\n const chartRef = React.useRef<IChart>(null);\n\n if (!isArrayOrTypedArray(selectedLegends)) {\n selectedLegends = [];\n }\n\n const [activeLegends, setActiveLegends] = React.useState<string[]>(selectedLegends);\n const onActiveLegendsChange = (keys: string[]) => {\n setActiveLegends(keys);\n if (props.onSchemaChange) {\n props.onSchemaChange({ plotlySchema: { data, layout, selectedLegends: keys } });\n }\n };\n\n React.useEffect(() => {\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const { plotlySchema } = sanitizeJson(props.chartSchema);\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const { selectedLegends } = plotlySchema;\n setActiveLegends(selectedLegends ?? []);\n }, [props.chartSchema]);\n\n const legendProps = {\n canSelectMultipleLegends: false,\n onChange: onActiveLegendsChange,\n selectedLegend: activeLegends.slice(0, 1)[0],\n };\n\n const exportAsImage = React.useCallback(\n (opts?: IImageExportOptions) => {\n return toImage(chartRef.current?.chartContainer, {\n background: theme.semanticColors.bodyBackground,\n ...opts,\n });\n },\n [theme],\n );\n\n React.useImperativeHandle(\n props.componentRef,\n () => ({\n exportAsImage,\n }),\n [exportAsImage],\n );\n\n const multiSelectLegendProps = {\n ...legendProps,\n canSelectMultipleLegends: true,\n selectedLegends: activeLegends,\n };\n\n switch (data[0].type) {\n case 'pie':\n return (\n <DonutChart\n {...transformPlotlyJsonToDonutProps(plotlySchema, colorMap, isDarkTheme)}\n legendProps={multiSelectLegendProps}\n componentRef={chartRef}\n // Bubble event to prevent right click to open menu on the callout\n calloutProps={{ layerProps: { eventBubblingEnabled: true } }}\n />\n );\n case 'bar':\n const orientation = data[0].orientation;\n if (orientation === 'h') {\n return (\n <HorizontalBarChartWithAxis\n {...transformPlotlyJsonToHorizontalBarWithAxisProps(plotlySchema, colorMap, isDarkTheme)}\n legendProps={multiSelectLegendProps}\n componentRef={chartRef}\n calloutProps={{ layerProps: { eventBubblingEnabled: true } }}\n />\n );\n } else {\n if (['group', 'overlay'].includes(plotlySchema?.layout?.barmode)) {\n return (\n <GroupedVerticalBarChart\n {...transformPlotlyJsonToGVBCProps(plotlySchema, colorMap, isDarkTheme)}\n legendProps={multiSelectLegendProps}\n componentRef={chartRef}\n calloutProps={{ layerProps: { eventBubblingEnabled: true } }}\n />\n );\n }\n return (\n <VerticalStackedBarChart\n {...transformPlotlyJsonToVSBCProps(plotlySchema, colorMap, isDarkTheme)}\n legendProps={multiSelectLegendProps}\n componentRef={chartRef}\n calloutProps={{ layerProps: { eventBubblingEnabled: true } }}\n />\n );\n }\n case 'scatter':\n const isAreaChart = data.some((series: any) => series.fill === 'tonexty' || series.fill === 'tozeroy');\n const renderChart = (chartProps: any) => {\n if (isAreaChart) {\n return (\n <AreaChart\n {...chartProps}\n legendProps={{ ...legendProps, canSelectMultipleLegends: true, selectedLegends: activeLegends }}\n />\n );\n }\n return (\n <LineChart\n {...{\n ...chartProps,\n legendProps: {\n onChange: onActiveLegendsChange,\n canSelectMultipleLegends: true,\n selectedLegends: activeLegends,\n },\n }}\n />\n );\n };\n if (isXDate || isXNumber) {\n const chartProps = {\n ...transformPlotlyJsonToScatterChartProps({ data, layout }, isAreaChart, colorMap, isDarkTheme),\n legendProps,\n componentRef: chartRef,\n calloutProps: { layerProps: { eventBubblingEnabled: true } },\n };\n return renderChart(chartProps);\n } else if (isXMonth) {\n const updatedData = data.map((dataPoint: any) => ({\n ...dataPoint,\n x: updateXValues(dataPoint.x),\n }));\n const chartProps = {\n ...transformPlotlyJsonToScatterChartProps({ data: updatedData, layout }, isAreaChart, colorMap, isDarkTheme),\n legendProps,\n componentRef: chartRef,\n calloutProps: { layerProps: { eventBubblingEnabled: true } },\n };\n return renderChart(chartProps);\n }\n return (\n <VerticalStackedBarChart\n {...transformPlotlyJsonToVSBCProps(plotlySchema, colorMap, isDarkTheme)}\n legendProps={multiSelectLegendProps}\n componentRef={chartRef}\n calloutProps={{ layerProps: { eventBubblingEnabled: true } }}\n />\n );\n case 'heatmap':\n return (\n <HeatMapChart\n {...transformPlotlyJsonToHeatmapProps(plotlySchema)}\n componentRef={chartRef}\n calloutProps={{ layerProps: { eventBubblingEnabled: true } }}\n />\n );\n case 'sankey':\n return (\n <SankeyChart\n {...transformPlotlyJsonToSankeyProps(plotlySchema, colorMap, isDarkTheme)}\n componentRef={chartRef}\n calloutProps={{ layerProps: { eventBubblingEnabled: true } }}\n />\n );\n case 'indicator':\n if (data?.[0]?.mode?.includes('gauge')) {\n return (\n <GaugeChart\n {...transformPlotlyJsonToGaugeProps(plotlySchema, colorMap, isDarkTheme)}\n legendProps={multiSelectLegendProps}\n componentRef={chartRef}\n calloutProps={{ layerProps: { eventBubblingEnabled: true } }}\n />\n );\n }\n return <div>Unsupported Schema</div>;\n case 'histogram':\n return (\n <VerticalBarChart\n {...transformPlotlyJsonToVBCProps(plotlySchema, colorMap, isDarkTheme)}\n legendProps={multiSelectLegendProps}\n componentRef={chartRef}\n calloutProps={{ layerProps: { eventBubblingEnabled: true } }}\n />\n );\n default:\n throw new Error('Unsupported chart schema');\n }\n});\nDeclarativeChart.displayName = 'DeclarativeChart';\n"]}
|
|
1
|
+
{"version":3,"file":"DeclarativeChart.js","sourceRoot":"../src/","sources":["components/DeclarativeChart/DeclarativeChart.tsx"],"names":[],"mappings":";;;;AAAA,yDAAyD;AACzD,6BAA+B;AAC/B,yCAA2C;AAE3C,6CAAiD;AACjD,0DAA2E;AAE3E,qDAAqD;AACrD,6DAiB+B;AAC/B,4CAAgE;AAChE,6DAAiF;AACjF,4CAAgE;AAChE,+CAAqD;AACrD,0DAAyD;AACzD,6CAAiD;AACjD,0DAA2E;AAC3E,mDAA6D;AAC7D,iDAA+D;AA4C/D,IAAM,eAAe,GAAG;IACtB,IAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,GAAG,EAAkB,CAAC,CAAC;IACzD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAEF;;;GAGG;AACU,QAAA,gBAAgB,GAAmD,KAAK,CAAC,UAAU,CA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AI,OAAO,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACnE,IAAM,kBAAkB,GAAG,UAAC,UAA2B;oBACrD,OAAO,oBAAC,iBAAS,uBAAK,UAAU,EAAI,CAAC;gBACvC,CAAC,CAAC;gBACF,OAAO,mBAAmB,CAAC,kBAAkB,CAAC,CAAC;YACjD,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,kCAA2B,MAAA,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,0CAAE,IAAI,CAAE,CAAC,CAAC;IAC5E,CAAC;AACH,CAAC,CAAC,CAAC;AACH,wBAAgB,CAAC,WAAW,GAAG,kBAAkB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\nimport * as React from 'react';\nimport { useTheme } from '@fluentui/react';\nimport { IRefObject } from '@fluentui/react/lib/Utilities';\nimport { DonutChart } from '../DonutChart/index';\nimport { VerticalStackedBarChart } from '../VerticalStackedBarChart/index';\nimport { PlotData, PlotlySchema } from './PlotlySchema';\n//import type { Data, Layout } from './PlotlySchema';\nimport {\n isArrayOrTypedArray,\n isDateArray,\n isNumberArray,\n isMonthArray,\n sanitizeJson,\n updateXValues,\n transformPlotlyJsonToDonutProps,\n transformPlotlyJsonToVSBCProps,\n transformPlotlyJsonToScatterChartProps,\n transformPlotlyJsonToHorizontalBarWithAxisProps,\n transformPlotlyJsonToHeatmapProps,\n transformPlotlyJsonToSankeyProps,\n transformPlotlyJsonToGaugeProps,\n transformPlotlyJsonToGVBCProps,\n transformPlotlyJsonToVBCProps,\n isLineData,\n} from './PlotlySchemaAdapter';\nimport { LineChart, ILineChartProps } from '../LineChart/index';\nimport { HorizontalBarChartWithAxis } from '../HorizontalBarChartWithAxis/index';\nimport { AreaChart, IAreaChartProps } from '../AreaChart/index';\nimport { HeatMapChart } from '../HeatMapChart/index';\nimport { SankeyChart } from '../SankeyChart/SankeyChart';\nimport { GaugeChart } from '../GaugeChart/index';\nimport { GroupedVerticalBarChart } from '../GroupedVerticalBarChart/index';\nimport { VerticalBarChart } from '../VerticalBarChart/index';\nimport { IImageExportOptions, toImage } from './imageExporter';\nimport { IChart } from '../../types/index';\n\n/**\n * DeclarativeChart schema.\n * {@docCategory DeclarativeChart}\n */\nexport interface Schema {\n /**\n * Plotly schema represented as JSON object\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n plotlySchema: any;\n}\n\n/**\n * DeclarativeChart props.\n * {@docCategory DeclarativeChart}\n */\nexport interface DeclarativeChartProps extends React.RefAttributes<HTMLDivElement> {\n /**\n * The schema representing the chart data, layout and configuration\n */\n chartSchema: Schema;\n\n /**\n * Callback when an event occurs\n */\n onSchemaChange?: (eventData: Schema) => void;\n\n /**\n * Optional callback to access the IDeclarativeChart interface. Use this instead of ref for accessing\n * the public methods and properties of the component.\n */\n componentRef?: IRefObject<IDeclarativeChart>;\n}\n\n/**\n * {@docCategory DeclarativeChart}\n */\nexport interface IDeclarativeChart {\n exportAsImage: (opts?: IImageExportOptions) => Promise<string>;\n}\n\nconst useColorMapping = () => {\n const colorMap = React.useRef(new Map<string, string>());\n return colorMap;\n};\n\n/**\n * DeclarativeChart component.\n * {@docCategory DeclarativeChart}\n */\nexport const DeclarativeChart: React.FunctionComponent<DeclarativeChartProps> = React.forwardRef<\n HTMLDivElement,\n DeclarativeChartProps\n>((props, forwardedRef) => {\n const { plotlySchema } = sanitizeJson(props.chartSchema);\n const plotlyInput = plotlySchema as PlotlySchema;\n let { selectedLegends } = plotlySchema;\n const colorMap = useColorMapping();\n const theme = useTheme();\n const isDarkTheme = theme?.isInverted ?? false;\n const chartRef = React.useRef<IChart>(null);\n\n if (!isArrayOrTypedArray(selectedLegends)) {\n selectedLegends = [];\n }\n\n const [activeLegends, setActiveLegends] = React.useState<string[]>(selectedLegends);\n const onActiveLegendsChange = (keys: string[]) => {\n setActiveLegends(keys);\n if (props.onSchemaChange) {\n props.onSchemaChange({ plotlySchema: { plotlyInput, selectedLegends: keys } });\n }\n };\n\n React.useEffect(() => {\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const { plotlySchema } = sanitizeJson(props.chartSchema);\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const { selectedLegends } = plotlySchema;\n setActiveLegends(selectedLegends ?? []);\n }, [props.chartSchema]);\n\n const multiSelectLegendProps = {\n canSelectMultipleLegends: true,\n onChange: onActiveLegendsChange,\n selectedLegends: activeLegends,\n };\n\n const commonProps = {\n legendProps: multiSelectLegendProps,\n componentRef: chartRef,\n calloutProps: { layerProps: { eventBubblingEnabled: true } },\n };\n\n const checkAndRenderChart = (\n renderChartJsx: (chartProps: ILineChartProps | IAreaChartProps) => JSX.Element,\n isAreaChart: boolean = false,\n ) => {\n let fallbackVSBC = false;\n const xValues = (plotlyInput.data[0] as PlotData).x;\n const isXDate = isDateArray(xValues);\n const isXNumber = isNumberArray(xValues);\n const isXMonth = isMonthArray(xValues);\n if (isXDate || isXNumber) {\n const chartProps: ILineChartProps | IAreaChartProps = {\n ...transformPlotlyJsonToScatterChartProps(\n { data: plotlyInput.data, layout: plotlyInput.layout },\n isAreaChart,\n colorMap,\n isDarkTheme,\n ),\n ...commonProps,\n };\n return renderChartJsx(chartProps);\n } else if (isXMonth) {\n const updatedData = plotlyInput.data.map((dataPoint: PlotData) => ({\n ...dataPoint,\n x: updateXValues(dataPoint.x),\n }));\n const chartProps: ILineChartProps | IAreaChartProps = {\n ...transformPlotlyJsonToScatterChartProps(\n { data: updatedData, layout: plotlyInput.layout },\n isAreaChart,\n colorMap,\n isDarkTheme,\n ),\n ...commonProps,\n };\n return renderChartJsx(chartProps);\n }\n // Unsupported schema, render as VerticalStackedBarChart\n fallbackVSBC = true;\n return (\n <VerticalStackedBarChart\n {...transformPlotlyJsonToVSBCProps(plotlySchema, colorMap, isDarkTheme, fallbackVSBC)}\n {...commonProps}\n />\n );\n };\n\n const exportAsImage = React.useCallback(\n (opts?: IImageExportOptions) => {\n return toImage(chartRef.current?.chartContainer, {\n background: theme.semanticColors.bodyBackground,\n scale: 5,\n ...opts,\n });\n },\n [theme],\n );\n\n React.useImperativeHandle(\n props.componentRef,\n () => ({\n exportAsImage,\n }),\n [exportAsImage],\n );\n\n switch (plotlyInput.data[0].type) {\n case 'pie':\n return <DonutChart {...transformPlotlyJsonToDonutProps(plotlySchema, colorMap, isDarkTheme)} {...commonProps} />;\n case 'bar':\n const orientation = plotlyInput.data[0].orientation;\n if (orientation === 'h') {\n return (\n <HorizontalBarChartWithAxis\n {...transformPlotlyJsonToHorizontalBarWithAxisProps(plotlySchema, colorMap, isDarkTheme)}\n {...commonProps}\n />\n );\n } else {\n const containsLines = plotlyInput.data.some(\n series => series.type === 'scatter' || isLineData(series as Partial<PlotData>),\n );\n if (['group', 'overlay'].includes(plotlySchema?.layout?.barmode) && !containsLines) {\n return (\n <GroupedVerticalBarChart\n {...transformPlotlyJsonToGVBCProps(plotlySchema, colorMap, isDarkTheme)}\n {...commonProps}\n />\n );\n }\n return (\n <VerticalStackedBarChart\n {...transformPlotlyJsonToVSBCProps(plotlySchema, colorMap, isDarkTheme)}\n {...commonProps}\n />\n );\n }\n case 'scatter':\n if (plotlyInput.data[0].mode === 'markers') {\n throw new Error(`Unsupported chart - type :${plotlyInput.data[0]?.type}, mode: ${plotlyInput.data[0]?.mode}`);\n }\n const isAreaChart = plotlyInput.data.some(\n (series: PlotData) => series.fill === 'tonexty' || series.fill === 'tozeroy',\n );\n const renderChartJsx = (chartProps: ILineChartProps | IAreaChartProps) => {\n if (isAreaChart) {\n return <AreaChart {...chartProps} />;\n }\n return <LineChart {...chartProps} />;\n };\n return checkAndRenderChart(renderChartJsx, isAreaChart);\n case 'heatmap':\n return <HeatMapChart {...transformPlotlyJsonToHeatmapProps(plotlySchema)} {...commonProps} legendProps={{}} />;\n case 'sankey':\n return (\n <SankeyChart {...transformPlotlyJsonToSankeyProps(plotlySchema, colorMap, isDarkTheme)} {...commonProps} />\n );\n case 'indicator':\n if (plotlyInput.data?.[0]?.mode?.includes('gauge')) {\n return (\n <GaugeChart {...transformPlotlyJsonToGaugeProps(plotlySchema, colorMap, isDarkTheme)} {...commonProps} />\n );\n }\n throw new Error(`Unsupported chart - type: ${plotlyInput.data[0]?.type}, mode: ${plotlyInput.data[0]?.mode}`);\n case 'histogram':\n return (\n <VerticalBarChart {...transformPlotlyJsonToVBCProps(plotlySchema, colorMap, isDarkTheme)} {...commonProps} />\n );\n default:\n const xValues = (plotlyInput.data[0] as PlotData).x;\n const yValues = (plotlyInput.data[0] as PlotData).y;\n if (xValues && yValues && xValues.length > 0 && yValues.length > 0) {\n const renderLineChartJsx = (chartProps: ILineChartProps) => {\n return <LineChart {...chartProps} />;\n };\n return checkAndRenderChart(renderLineChartJsx);\n }\n throw new Error(`Unsupported chart type :${plotlyInput.data[0]?.type}`);\n }\n});\nDeclarativeChart.displayName = 'DeclarativeChart';\n"]}
|