@fluentui/react-charting 5.23.18 → 5.23.19
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 +22 -1
- package/CHANGELOG.md +12 -2
- package/dist/react-charting.d.ts +38 -0
- package/dist/react-charting.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/etc/react-charting.api.md +18 -0
- package/lib/DeclarativeChart.d.ts +1 -0
- package/lib/DeclarativeChart.js +2 -0
- package/lib/DeclarativeChart.js.map +1 -0
- package/lib/components/DeclarativeChart/DeclarativeChart.d.ts +36 -0
- package/lib/components/DeclarativeChart/DeclarativeChart.js +67 -0
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -0
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +27 -0
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +387 -0
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib-amd/DeclarativeChart.d.ts +1 -0
- package/lib-amd/DeclarativeChart.js +6 -0
- package/lib-amd/DeclarativeChart.js.map +1 -0
- package/lib-amd/components/DeclarativeChart/DeclarativeChart.d.ts +36 -0
- package/lib-amd/components/DeclarativeChart/DeclarativeChart.js +58 -0
- package/lib-amd/components/DeclarativeChart/DeclarativeChart.js.map +1 -0
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +27 -0
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +402 -0
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -0
- package/lib-amd/index.d.ts +2 -0
- package/lib-amd/index.js +3 -2
- package/lib-amd/index.js.map +1 -1
- package/lib-commonjs/DeclarativeChart.d.ts +1 -0
- package/lib-commonjs/DeclarativeChart.js +5 -0
- package/lib-commonjs/DeclarativeChart.js.map +1 -0
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.d.ts +36 -0
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +70 -0
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -0
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +27 -0
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +402 -0
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -0
- package/lib-commonjs/index.d.ts +2 -0
- package/lib-commonjs/index.js +3 -1
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -18,5 +18,6 @@ export { HorizontalBarChartWithAxis } from './HorizontalBarChartWithAxis';
|
|
|
18
18
|
export { DataVizPalette, getColorFromToken, getNextColor } from './utilities/colors';
|
|
19
19
|
export { DataVizGradientPalette, getGradientFromToken, getNextGradient } from './utilities/gradients';
|
|
20
20
|
export { GaugeChart, GaugeChartVariant, GaugeValueFormat } from './GaugeChart';
|
|
21
|
+
export { DeclarativeChart } from './DeclarativeChart';
|
|
21
22
|
import './version';
|
|
22
23
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAErF,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAW1C,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAS3C,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAUtC,OAAO,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEvG,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAMtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAMpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AASpE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAwClD,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAE3F,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAQ9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAS5C,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAExE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAMxC,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACrF,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAEtG,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAE/E,OAAO,WAAW,CAAC","sourcesContent":["export type {\n ChartDataMode,\n IHorizontalBarChartProps,\n IHorizontalBarChartStyleProps,\n IHorizontalBarChartStyles,\n} from './HorizontalBarChart';\nexport { HorizontalBarChart, HorizontalBarChartVariant } from './HorizontalBarChart';\nexport type { IDonutChart, IDonutChartProps, IDonutChartStyleProps, IDonutChartStyles } from './DonutChart';\nexport { DonutChart } from './DonutChart';\nexport type {\n ILegend,\n ILegendOverflowData,\n ILegendStyleProps,\n ILegendSubComponentStyles,\n ILegendsProps,\n ILegendsStyles,\n IShapeProps,\n LegendShape,\n} from './Legends';\nexport { Legends, Shape } from './Legends';\nexport type {\n IColorFillBarData,\n IColorFillBarsProps,\n IEventsAnnotationProps,\n ILineChartProps,\n ILineChartStyleProps,\n ILineChartStyles,\n} from './LineChart';\nexport { LineChart, Textbox } from './LineChart';\nexport type { IAreaChartProps, IAreaChartStyleProps, IAreaChartStyles } from './AreaChart';\nexport { AreaChart } from './AreaChart';\nexport type { IPieChart, IPieChartProps, IPieChartStyleProps, IPieChartStyles } from './PieChart';\nexport { PieChart } from './PieChart';\nexport type {\n IMultiStackedBarChartProps,\n IMultiStackedBarChartStyleProps,\n IMultiStackedBarChartStyles,\n IStackedBarChart,\n IStackedBarChartProps,\n IStackedBarChartStyleProps,\n IStackedBarChartStyles,\n} from './StackedBarChart';\nexport { MultiStackedBarChart, MultiStackedBarChartVariant, StackedBarChart } from './StackedBarChart';\nexport type { IVerticalBarChartProps, IVerticalBarChartStyleProps, IVerticalBarChartStyles } from './VerticalBarChart';\nexport { VerticalBarChart } from './VerticalBarChart';\nexport type {\n IVerticalStackedBarChartProps,\n IVerticalStackedBarChartStyleProps,\n IVerticalStackedBarChartStyles,\n} from './VerticalStackedBarChart';\nexport { VerticalStackedBarChart } from './VerticalStackedBarChart';\nexport type {\n IGroupedVerticalBarChartProps,\n IGroupedVerticalBarChartStyleProps,\n IGroupedVerticalBarChartStyles,\n} from './GroupedVerticalBarChart';\nexport { GroupedVerticalBarChart } from './GroupedVerticalBarChart';\nexport type {\n ICartesianChartProps,\n ICartesianChartStyleProps,\n ICartesianChartStyles,\n IChildProps,\n IModifiedCartesianChartProps,\n IYValueHover,\n} from './CartesianChart';\nexport { CartesianChart } from './CartesianChart';\nexport type {\n IAccessibilityProps,\n IBasestate,\n IChartDataPoint,\n IChartProps,\n ICustomizedCalloutData,\n ICustomizedCalloutDataPoint,\n IDataPoint,\n IGVBarChartSeriesPoint,\n IGVDataPoint,\n IGVForBarChart,\n IGVSingleDataPoint,\n IGroupedVerticalBarChartData,\n IHeatMapChartData,\n IHeatMapChartDataPoint,\n IHorizontalBarChartWithAxisDataPoint,\n IHorizontalDataPoint,\n ILegendDataItem,\n ILineChartDataPoint,\n ILineChartGap,\n ILineChartLineOptions,\n ILineChartPoints,\n ILineDataInVerticalBarChart,\n ILineDataInVerticalStackedBarChart,\n IMargins,\n IRefArrayData,\n ISankeyChartData,\n IVSChartDataPoint,\n IVerticalBarChartDataPoint,\n IVerticalStackedBarDataPoint,\n IVerticalStackedChartProps,\n SLink,\n SNode,\n} from './types/index';\nexport type {\n IChartHoverCardProps,\n IChartHoverCardStyleProps,\n IChartHoverCardStyles,\n} from './utilities/ChartHoverCard/index';\nexport { ChartHoverCard, getChartHoverCardStyles } from './utilities/ChartHoverCard/index';\nexport type { IHeatMapChartProps, IHeatMapChartStyleProps, IHeatMapChartStyles } from './HeatMapChart';\nexport { HeatMapChart } from './HeatMapChart';\nexport type {\n ISankeyChartAccessibilityProps,\n ISankeyChartProps,\n ISankeyChartStrings,\n ISankeyChartStyleProps,\n ISankeyChartStyles,\n} from './SankeyChart';\nexport { SankeyChart } from './SankeyChart';\nexport type {\n ITreeChartDataPoint,\n ITreeDataStructure,\n ITreeProps,\n ITreeState,\n ITreeStyleProps,\n ITreeStyles,\n} from './TreeChart';\nexport { NodesComposition, TreeChart, TreeTraverse } from './TreeChart';\nexport type { ISparklineProps, ISparklineStyleProps, ISparklineStyles } from './Sparkline';\nexport { Sparkline } from './Sparkline';\nexport type {\n IHorizontalBarChartWithAxisProps,\n IHorizontalBarChartWithAxisStyleProps,\n IHorizontalBarChartWithAxisStyles,\n} from './HorizontalBarChartWithAxis';\nexport { HorizontalBarChartWithAxis } from './HorizontalBarChartWithAxis';\nexport { DataVizPalette, getColorFromToken, getNextColor } from './utilities/colors';\nexport { DataVizGradientPalette, getGradientFromToken, getNextGradient } from './utilities/gradients';\nexport type { IGaugeChartProps, IGaugeChartSegment, IGaugeChartStyleProps, IGaugeChartStyles } from './GaugeChart';\nexport { GaugeChart, GaugeChartVariant, GaugeValueFormat } from './GaugeChart';\n\nimport './version';\n"]}
|
|
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AAiB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAE/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,WAAW,CAAC","sourcesContent":["export type {\n ChartDataMode,\n IHorizontalBarChartProps,\n IHorizontalBarChartStyleProps,\n IHorizontalBarChartStyles,\n} from './HorizontalBarChart';\nexport { HorizontalBarChart, HorizontalBarChartVariant } from './HorizontalBarChart';\nexport type { IDonutChart, IDonutChartProps, IDonutChartStyleProps, IDonutChartStyles } from './DonutChart';\nexport { DonutChart } from './DonutChart';\nexport type {\n ILegend,\n ILegendOverflowData,\n ILegendStyleProps,\n ILegendSubComponentStyles,\n ILegendsProps,\n ILegendsStyles,\n IShapeProps,\n LegendShape,\n} from './Legends';\nexport { Legends, Shape } from './Legends';\nexport type {\n IColorFillBarData,\n IColorFillBarsProps,\n IEventsAnnotationProps,\n ILineChartProps,\n ILineChartStyleProps,\n ILineChartStyles,\n} from './LineChart';\nexport { LineChart, Textbox } from './LineChart';\nexport type { IAreaChartProps, IAreaChartStyleProps, IAreaChartStyles } from './AreaChart';\nexport { AreaChart } from './AreaChart';\nexport type { IPieChart, IPieChartProps, IPieChartStyleProps, IPieChartStyles } from './PieChart';\nexport { PieChart } from './PieChart';\nexport type {\n IMultiStackedBarChartProps,\n IMultiStackedBarChartStyleProps,\n IMultiStackedBarChartStyles,\n IStackedBarChart,\n IStackedBarChartProps,\n IStackedBarChartStyleProps,\n IStackedBarChartStyles,\n} from './StackedBarChart';\nexport { MultiStackedBarChart, MultiStackedBarChartVariant, StackedBarChart } from './StackedBarChart';\nexport type { IVerticalBarChartProps, IVerticalBarChartStyleProps, IVerticalBarChartStyles } from './VerticalBarChart';\nexport { VerticalBarChart } from './VerticalBarChart';\nexport type {\n IVerticalStackedBarChartProps,\n IVerticalStackedBarChartStyleProps,\n IVerticalStackedBarChartStyles,\n} from './VerticalStackedBarChart';\nexport { VerticalStackedBarChart } from './VerticalStackedBarChart';\nexport type {\n IGroupedVerticalBarChartProps,\n IGroupedVerticalBarChartStyleProps,\n IGroupedVerticalBarChartStyles,\n} from './GroupedVerticalBarChart';\nexport { GroupedVerticalBarChart } from './GroupedVerticalBarChart';\nexport type {\n ICartesianChartProps,\n ICartesianChartStyleProps,\n ICartesianChartStyles,\n IChildProps,\n IModifiedCartesianChartProps,\n IYValueHover,\n} from './CartesianChart';\nexport { CartesianChart } from './CartesianChart';\nexport type {\n IAccessibilityProps,\n IBasestate,\n IChartDataPoint,\n IChartProps,\n ICustomizedCalloutData,\n ICustomizedCalloutDataPoint,\n IDataPoint,\n IGVBarChartSeriesPoint,\n IGVDataPoint,\n IGVForBarChart,\n IGVSingleDataPoint,\n IGroupedVerticalBarChartData,\n IHeatMapChartData,\n IHeatMapChartDataPoint,\n IHorizontalBarChartWithAxisDataPoint,\n IHorizontalDataPoint,\n ILegendDataItem,\n ILineChartDataPoint,\n ILineChartGap,\n ILineChartLineOptions,\n ILineChartPoints,\n ILineDataInVerticalBarChart,\n ILineDataInVerticalStackedBarChart,\n IMargins,\n IRefArrayData,\n ISankeyChartData,\n IVSChartDataPoint,\n IVerticalBarChartDataPoint,\n IVerticalStackedBarDataPoint,\n IVerticalStackedChartProps,\n SLink,\n SNode,\n} from './types/index';\nexport type {\n IChartHoverCardProps,\n IChartHoverCardStyleProps,\n IChartHoverCardStyles,\n} from './utilities/ChartHoverCard/index';\nexport { ChartHoverCard, getChartHoverCardStyles } from './utilities/ChartHoverCard/index';\nexport type { IHeatMapChartProps, IHeatMapChartStyleProps, IHeatMapChartStyles } from './HeatMapChart';\nexport { HeatMapChart } from './HeatMapChart';\nexport type {\n ISankeyChartAccessibilityProps,\n ISankeyChartProps,\n ISankeyChartStrings,\n ISankeyChartStyleProps,\n ISankeyChartStyles,\n} from './SankeyChart';\nexport { SankeyChart } from './SankeyChart';\nexport type {\n ITreeChartDataPoint,\n ITreeDataStructure,\n ITreeProps,\n ITreeState,\n ITreeStyleProps,\n ITreeStyles,\n} from './TreeChart';\nexport { NodesComposition, TreeChart, TreeTraverse } from './TreeChart';\nexport type { ISparklineProps, ISparklineStyleProps, ISparklineStyles } from './Sparkline';\nexport { Sparkline } from './Sparkline';\nexport type {\n IHorizontalBarChartWithAxisProps,\n IHorizontalBarChartWithAxisStyleProps,\n IHorizontalBarChartWithAxisStyles,\n} from './HorizontalBarChartWithAxis';\nexport { HorizontalBarChartWithAxis } from './HorizontalBarChartWithAxis';\nexport { DataVizPalette, getColorFromToken, getNextColor } from './utilities/colors';\nexport { DataVizGradientPalette, getGradientFromToken, getNextGradient } from './utilities/gradients';\nexport type { IGaugeChartProps, IGaugeChartSegment, IGaugeChartStyleProps, IGaugeChartStyles } from './GaugeChart';\nexport { GaugeChart, GaugeChartVariant, GaugeValueFormat } from './GaugeChart';\nexport type { DeclarativeChartProps, Schema } from './DeclarativeChart';\nexport { DeclarativeChart } from './DeclarativeChart';\n\nimport './version';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components/DeclarativeChart/DeclarativeChart';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
define(["require", "exports", "tslib", "./components/DeclarativeChart/DeclarativeChart"], function (require, exports, tslib_1, DeclarativeChart_1) {
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
tslib_1.__exportStar(DeclarativeChart_1, exports);
|
|
5
|
+
});
|
|
6
|
+
//# sourceMappingURL=DeclarativeChart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeclarativeChart.js","sourceRoot":"../src/","sources":["DeclarativeChart.ts"],"names":[],"mappings":";;;IAAA,kDAA+D","sourcesContent":["export * from './components/DeclarativeChart/DeclarativeChart';\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface Schema {
|
|
3
|
+
/**
|
|
4
|
+
* Plotly schema represented as JSON object
|
|
5
|
+
*/
|
|
6
|
+
plotlySchema: any;
|
|
7
|
+
/**
|
|
8
|
+
* The legends selected by the user to persist in the chart
|
|
9
|
+
*/
|
|
10
|
+
selectedLegends?: string[];
|
|
11
|
+
/**
|
|
12
|
+
* Dictionary for localizing the accessibility labels
|
|
13
|
+
*/
|
|
14
|
+
accesibilityLabels?: {
|
|
15
|
+
[key: string]: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* DeclarativeChart props.
|
|
20
|
+
* {@docCategory DeclarativeChart}
|
|
21
|
+
*/
|
|
22
|
+
export interface DeclarativeChartProps extends React.RefAttributes<HTMLDivElement> {
|
|
23
|
+
/**
|
|
24
|
+
* The schema representing the chart data, layout and configuration
|
|
25
|
+
*/
|
|
26
|
+
chartSchema: Schema;
|
|
27
|
+
/**
|
|
28
|
+
* Callback when an event occurs
|
|
29
|
+
*/
|
|
30
|
+
onSchemaChange?: (eventData: Schema) => void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* DeclarativeChart component.
|
|
34
|
+
* {@docCategory DeclarativeChart}
|
|
35
|
+
*/
|
|
36
|
+
export declare const DeclarativeChart: React.FunctionComponent<DeclarativeChartProps>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
define(["require", "exports", "tslib", "react", "../DonutChart/index", "../VerticalStackedBarChart/index", "./PlotlySchemaAdapter", "../LineChart/index", "../HorizontalBarChartWithAxis/index", "../AreaChart/index", "../HeatMapChart/index", "../SankeyChart/SankeyChart", "../GaugeChart/index", "../GroupedVerticalBarChart/index"], function (require, exports, tslib_1, React, index_1, index_2, PlotlySchemaAdapter_1, index_3, index_4, index_5, index_6, SankeyChart_1, index_7, index_8) {
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.DeclarativeChart = void 0;
|
|
5
|
+
var useColorMapping = function () {
|
|
6
|
+
var colorMap = React.useRef(new Map());
|
|
7
|
+
return colorMap;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* DeclarativeChart component.
|
|
11
|
+
* {@docCategory DeclarativeChart}
|
|
12
|
+
*/
|
|
13
|
+
exports.DeclarativeChart = React.forwardRef(function (props, forwardedRef) {
|
|
14
|
+
var _a, _b, _c, _d;
|
|
15
|
+
var plotlySchema = props.chartSchema.plotlySchema;
|
|
16
|
+
var xValues = plotlySchema.data[0].x;
|
|
17
|
+
var isXDate = (0, PlotlySchemaAdapter_1.isDateArray)(xValues);
|
|
18
|
+
var isXNumber = (0, PlotlySchemaAdapter_1.isNumberArray)(xValues);
|
|
19
|
+
var colorMap = useColorMapping();
|
|
20
|
+
switch (plotlySchema.data[0].type) {
|
|
21
|
+
case 'pie':
|
|
22
|
+
return React.createElement(index_1.DonutChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToDonutProps)(plotlySchema, colorMap)));
|
|
23
|
+
case 'bar':
|
|
24
|
+
var orientation_1 = plotlySchema.data[0].orientation;
|
|
25
|
+
if (orientation_1 === 'h') {
|
|
26
|
+
return (React.createElement(index_4.HorizontalBarChartWithAxis, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToHorizontalBarWithAxisProps)(plotlySchema, colorMap))));
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
if (['group', 'overlay'].includes((_a = plotlySchema === null || plotlySchema === void 0 ? void 0 : plotlySchema.layout) === null || _a === void 0 ? void 0 : _a.barmode)) {
|
|
30
|
+
return React.createElement(index_8.GroupedVerticalBarChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToGVBCProps)(plotlySchema, colorMap)));
|
|
31
|
+
}
|
|
32
|
+
return React.createElement(index_2.VerticalStackedBarChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToVSBCProps)(plotlySchema, colorMap)));
|
|
33
|
+
}
|
|
34
|
+
case 'scatter':
|
|
35
|
+
var isAreaChart = plotlySchema.data.some(function (series) { return series.fill === 'tonexty'; });
|
|
36
|
+
if (isXDate || isXNumber) {
|
|
37
|
+
if (isAreaChart) {
|
|
38
|
+
return React.createElement(index_5.AreaChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToScatterChartProps)(plotlySchema, true, colorMap)));
|
|
39
|
+
}
|
|
40
|
+
return React.createElement(index_3.LineChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToScatterChartProps)(plotlySchema, false, colorMap)));
|
|
41
|
+
}
|
|
42
|
+
return React.createElement(index_2.VerticalStackedBarChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToVSBCProps)(plotlySchema, colorMap)));
|
|
43
|
+
case 'heatmap':
|
|
44
|
+
return React.createElement(index_6.HeatMapChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToHeatmapProps)(plotlySchema)));
|
|
45
|
+
case 'sankey':
|
|
46
|
+
return React.createElement(SankeyChart_1.SankeyChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToSankeyProps)(plotlySchema, colorMap)));
|
|
47
|
+
case 'indicator':
|
|
48
|
+
if ((_d = (_c = (_b = plotlySchema === null || plotlySchema === void 0 ? void 0 : plotlySchema.data) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.mode) === null || _d === void 0 ? void 0 : _d.includes('gauge')) {
|
|
49
|
+
return React.createElement(index_7.GaugeChart, tslib_1.__assign({}, (0, PlotlySchemaAdapter_1.transformPlotlyJsonToGaugeProps)(plotlySchema, colorMap)));
|
|
50
|
+
}
|
|
51
|
+
return React.createElement("div", null, "Unsupported Schema");
|
|
52
|
+
default:
|
|
53
|
+
return React.createElement("div", null, "Unsupported Schema");
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
exports.DeclarativeChart.displayName = 'DeclarativeChart';
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=De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BACD,OAAO,sDAA6B,CAAC;YACvC;gBACE,OAAO,sDAA6B,CAAC;SACxC;IACH,CAAC,CAAC,CAAC;IACH,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 { DonutChart } from '../DonutChart/index';\nimport { VerticalStackedBarChart } from '../VerticalStackedBarChart/index';\nimport {\n transformPlotlyJsonToDonutProps,\n transformPlotlyJsonToVSBCProps,\n transformPlotlyJsonToScatterChartProps,\n transformPlotlyJsonToHorizontalBarWithAxisProps,\n isDateArray,\n isNumberArray,\n transformPlotlyJsonToHeatmapProps,\n transformPlotlyJsonToSankeyProps,\n transformPlotlyJsonToGaugeProps,\n transformPlotlyJsonToGVBCProps,\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';\n\nexport interface Schema {\n /**\n * Plotly schema represented as JSON object\n */\n plotlySchema: any;\n\n /**\n * The legends selected by the user to persist in the chart\n */\n selectedLegends?: string[];\n\n /**\n * Dictionary for localizing the accessibility labels\n */\n accesibilityLabels?: { [key: string]: string };\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\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 } = props.chartSchema;\n const xValues = plotlySchema.data[0].x;\n const isXDate = isDateArray(xValues);\n const isXNumber = isNumberArray(xValues);\n const colorMap = useColorMapping();\n\n switch (plotlySchema.data[0].type) {\n case 'pie':\n return <DonutChart {...transformPlotlyJsonToDonutProps(plotlySchema, colorMap)} />;\n case 'bar':\n const orientation = plotlySchema.data[0].orientation;\n if (orientation === 'h') {\n return (\n <HorizontalBarChartWithAxis {...transformPlotlyJsonToHorizontalBarWithAxisProps(plotlySchema, colorMap)} />\n );\n } else {\n if (['group', 'overlay'].includes(plotlySchema?.layout?.barmode)) {\n return <GroupedVerticalBarChart {...transformPlotlyJsonToGVBCProps(plotlySchema, colorMap)} />;\n }\n return <VerticalStackedBarChart {...transformPlotlyJsonToVSBCProps(plotlySchema, colorMap)} />;\n }\n case 'scatter':\n const isAreaChart = plotlySchema.data.some((series: any) => series.fill === 'tonexty');\n if (isXDate || isXNumber) {\n if (isAreaChart) {\n return <AreaChart {...transformPlotlyJsonToScatterChartProps(plotlySchema, true, colorMap)} />;\n }\n return <LineChart {...transformPlotlyJsonToScatterChartProps(plotlySchema, false, colorMap)} />;\n }\n return <VerticalStackedBarChart {...transformPlotlyJsonToVSBCProps(plotlySchema, colorMap)} />;\n case 'heatmap':\n return <HeatMapChart {...transformPlotlyJsonToHeatmapProps(plotlySchema)} />;\n case 'sankey':\n return <SankeyChart {...transformPlotlyJsonToSankeyProps(plotlySchema, colorMap)} />;\n case 'indicator':\n if (plotlySchema?.data?.[0]?.mode?.includes('gauge')) {\n return <GaugeChart {...transformPlotlyJsonToGaugeProps(plotlySchema, colorMap)} />;\n }\n return <div>Unsupported Schema</div>;\n default:\n return <div>Unsupported Schema</div>;\n }\n});\nDeclarativeChart.displayName = 'DeclarativeChart';\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { IDonutChartProps } from '../DonutChart/index';
|
|
3
|
+
import { ISankeyChartProps } from '../SankeyChart/index';
|
|
4
|
+
import { IVerticalStackedBarChartProps } from '../VerticalStackedBarChart/index';
|
|
5
|
+
import { IHorizontalBarChartWithAxisProps } from '../HorizontalBarChartWithAxis/index';
|
|
6
|
+
import { ILineChartProps } from '../LineChart/index';
|
|
7
|
+
import { IAreaChartProps } from '../AreaChart/index';
|
|
8
|
+
import { IHeatMapChartProps } from '../HeatMapChart/index';
|
|
9
|
+
import { IGaugeChartProps } from '../GaugeChart/index';
|
|
10
|
+
import { IGroupedVerticalBarChartProps } from '../GroupedVerticalBarChart/index';
|
|
11
|
+
export declare const isDateArray: (array: any[]) => boolean;
|
|
12
|
+
export declare const isNumberArray: (array: any[]) => boolean;
|
|
13
|
+
export declare const getColor: (legendLabel: string, colorMap: React.MutableRefObject<Map<string, string>>) => string;
|
|
14
|
+
export declare const transformPlotlyJsonToDonutProps: (jsonObj: any, colorMap: React.MutableRefObject<Map<string, string>>) => IDonutChartProps;
|
|
15
|
+
export declare const transformPlotlyJsonToVSBCProps: (jsonObj: any, colorMap: React.MutableRefObject<Map<string, string>>) => IVerticalStackedBarChartProps;
|
|
16
|
+
export declare const transformPlotlyJsonToGVBCProps: (jsonObj: any, colorMap: React.MutableRefObject<Map<string, string>>) => IGroupedVerticalBarChartProps;
|
|
17
|
+
export declare const transformPlotlyJsonToScatterChartProps: (jsonObj: any, isAreaChart: boolean, colorMap: React.MutableRefObject<Map<string, string>>) => ILineChartProps | IAreaChartProps;
|
|
18
|
+
export declare const transformPlotlyJsonToHorizontalBarWithAxisProps: (jsonObj: any, colorMap: React.MutableRefObject<Map<string, string>>) => IHorizontalBarChartWithAxisProps;
|
|
19
|
+
export declare const transformPlotlyJsonToHeatmapProps: (jsonObj: any) => IHeatMapChartProps;
|
|
20
|
+
export declare const transformPlotlyJsonToSankeyProps: (jsonObj: any, colorMap: React.MutableRefObject<Map<string, string>>) => ISankeyChartProps;
|
|
21
|
+
export declare const transformPlotlyJsonToGaugeProps: (jsonObj: any, colorMap: React.MutableRefObject<Map<string, string>>) => IGaugeChartProps;
|
|
22
|
+
/**
|
|
23
|
+
* Interate iteratively through the trace object and find all the array attributes.
|
|
24
|
+
* 1 trace record = 1 series of data
|
|
25
|
+
* @param trace
|
|
26
|
+
*/
|
|
27
|
+
export declare function findArrayAttributes(trace: any): void;
|
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
define(["require", "exports", "tslib", "../../utilities/colors"], function (require, exports, tslib_1, colors_1) {
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.findArrayAttributes = exports.transformPlotlyJsonToGaugeProps = exports.transformPlotlyJsonToSankeyProps = exports.transformPlotlyJsonToHeatmapProps = exports.transformPlotlyJsonToHorizontalBarWithAxisProps = exports.transformPlotlyJsonToScatterChartProps = exports.transformPlotlyJsonToGVBCProps = exports.transformPlotlyJsonToVSBCProps = exports.transformPlotlyJsonToDonutProps = exports.getColor = exports.isNumberArray = exports.isDateArray = void 0;
|
|
5
|
+
var isDate = function (value) { return !isNaN(Date.parse(value)); };
|
|
6
|
+
var isNumber = function (value) { return !isNaN(parseFloat(value)) && isFinite(value); };
|
|
7
|
+
var isDateArray = function (array) { return isArrayOrTypedArray(array) && array.every(isDate); };
|
|
8
|
+
exports.isDateArray = isDateArray;
|
|
9
|
+
var isNumberArray = function (array) { return isArrayOrTypedArray(array) && array.every(isNumber); };
|
|
10
|
+
exports.isNumberArray = isNumberArray;
|
|
11
|
+
var getColor = function (legendLabel, colorMap) {
|
|
12
|
+
if (!colorMap.current.has(legendLabel)) {
|
|
13
|
+
var nextColor = (0, colors_1.getNextColor)(colorMap.current.size + 1);
|
|
14
|
+
colorMap.current.set(legendLabel, nextColor);
|
|
15
|
+
return nextColor;
|
|
16
|
+
}
|
|
17
|
+
return colorMap.current.get(legendLabel);
|
|
18
|
+
};
|
|
19
|
+
exports.getColor = getColor;
|
|
20
|
+
var transformPlotlyJsonToDonutProps = function (jsonObj, colorMap) {
|
|
21
|
+
var _a, _b;
|
|
22
|
+
var data = jsonObj.data, layout = jsonObj.layout;
|
|
23
|
+
var firstData = data[0];
|
|
24
|
+
var donutData = (_a = firstData.labels) === null || _a === void 0 ? void 0 : _a.map(function (label, index) {
|
|
25
|
+
var _a;
|
|
26
|
+
var color = (0, exports.getColor)(label, colorMap);
|
|
27
|
+
return {
|
|
28
|
+
legend: label,
|
|
29
|
+
data: (_a = firstData.values) === null || _a === void 0 ? void 0 : _a[index],
|
|
30
|
+
color: color,
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
// TODO: innerRadius as a fraction needs to be supported internally. The pixel value depends on
|
|
34
|
+
// chart dimensions, arc label dimensions and the legend container height, all of which are subject to change.
|
|
35
|
+
var width = (layout === null || layout === void 0 ? void 0 : layout.width) || 440;
|
|
36
|
+
var height = (layout === null || layout === void 0 ? void 0 : layout.height) || 220;
|
|
37
|
+
var hideLabels = firstData.textinfo ? !['value', 'percent'].includes(firstData.textinfo) : false;
|
|
38
|
+
var donutMarginHorizontal = hideLabels ? 0 : 80;
|
|
39
|
+
var donutMarginVertical = 40 + (hideLabels ? 0 : 40);
|
|
40
|
+
var innerRadius = firstData.hole
|
|
41
|
+
? firstData.hole * (Math.min(width - donutMarginHorizontal, height - donutMarginVertical) / 2)
|
|
42
|
+
: 0;
|
|
43
|
+
var styles = {
|
|
44
|
+
root: {
|
|
45
|
+
'[class^="arcLabel"]': {
|
|
46
|
+
fontSize: (_b = firstData.textfont) === null || _b === void 0 ? void 0 : _b.size,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
return {
|
|
51
|
+
data: {
|
|
52
|
+
chartTitle: layout === null || layout === void 0 ? void 0 : layout.title,
|
|
53
|
+
chartData: donutData,
|
|
54
|
+
},
|
|
55
|
+
hideLegend: (layout === null || layout === void 0 ? void 0 : layout.showlegend) === false ? true : false,
|
|
56
|
+
width: width,
|
|
57
|
+
height: height,
|
|
58
|
+
innerRadius: innerRadius,
|
|
59
|
+
hideLabels: hideLabels,
|
|
60
|
+
showLabelsInPercent: firstData.textinfo ? firstData.textinfo === 'percent' : true,
|
|
61
|
+
styles: styles,
|
|
62
|
+
// TODO: Render custom hover card based on textinfo
|
|
63
|
+
// onRenderCalloutPerDataPoint: undefined,
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
exports.transformPlotlyJsonToDonutProps = transformPlotlyJsonToDonutProps;
|
|
67
|
+
var transformPlotlyJsonToVSBCProps = function (jsonObj, colorMap) {
|
|
68
|
+
var data = jsonObj.data, layout = jsonObj.layout;
|
|
69
|
+
var mapXToDataPoints = {};
|
|
70
|
+
var yMaxValue = 0;
|
|
71
|
+
data.forEach(function (series, index1) {
|
|
72
|
+
var _a;
|
|
73
|
+
(_a = series.x) === null || _a === void 0 ? void 0 : _a.forEach(function (x, index2) {
|
|
74
|
+
var _a, _b, _c;
|
|
75
|
+
if (!mapXToDataPoints[x]) {
|
|
76
|
+
mapXToDataPoints[x] = { xAxisPoint: x, chartData: [], lineData: [] };
|
|
77
|
+
}
|
|
78
|
+
var legend = series.name || "Series ".concat(index1 + 1);
|
|
79
|
+
if (series.type === 'bar') {
|
|
80
|
+
var color = (0, exports.getColor)(legend, colorMap);
|
|
81
|
+
mapXToDataPoints[x].chartData.push({
|
|
82
|
+
legend: legend,
|
|
83
|
+
data: (_a = series.y) === null || _a === void 0 ? void 0 : _a[index2],
|
|
84
|
+
color: color,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
else if (series.type === 'line') {
|
|
88
|
+
var color = (0, exports.getColor)(legend, colorMap);
|
|
89
|
+
mapXToDataPoints[x].lineData.push({
|
|
90
|
+
legend: legend,
|
|
91
|
+
y: (_b = series.y) === null || _b === void 0 ? void 0 : _b[index2],
|
|
92
|
+
color: color,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
yMaxValue = Math.max(yMaxValue, (_c = series.y) === null || _c === void 0 ? void 0 : _c[index2]);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
return {
|
|
99
|
+
data: Object.values(mapXToDataPoints),
|
|
100
|
+
chartTitle: layout === null || layout === void 0 ? void 0 : layout.title,
|
|
101
|
+
// width: layout?.width,
|
|
102
|
+
// height: layout?.height,
|
|
103
|
+
barWidth: 'auto',
|
|
104
|
+
yMaxValue: yMaxValue,
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
exports.transformPlotlyJsonToVSBCProps = transformPlotlyJsonToVSBCProps;
|
|
108
|
+
// TODO: Add support for continuous x-axis in grouped vertical bar chart
|
|
109
|
+
var transformPlotlyJsonToGVBCProps = function (jsonObj, colorMap) {
|
|
110
|
+
var data = jsonObj.data, layout = jsonObj.layout;
|
|
111
|
+
var mapXToDataPoints = {};
|
|
112
|
+
data.forEach(function (series, index1) {
|
|
113
|
+
var _a;
|
|
114
|
+
(_a = series.x) === null || _a === void 0 ? void 0 : _a.forEach(function (x, index2) {
|
|
115
|
+
var _a;
|
|
116
|
+
if (!mapXToDataPoints[x]) {
|
|
117
|
+
mapXToDataPoints[x] = { name: x.toString(), series: [] };
|
|
118
|
+
}
|
|
119
|
+
if (series.type === 'bar') {
|
|
120
|
+
var legend = series.name || "Series ".concat(index1 + 1);
|
|
121
|
+
var color = (0, exports.getColor)(legend, colorMap);
|
|
122
|
+
mapXToDataPoints[x].series.push({
|
|
123
|
+
key: legend,
|
|
124
|
+
data: (_a = series.y) === null || _a === void 0 ? void 0 : _a[index2],
|
|
125
|
+
color: color,
|
|
126
|
+
legend: legend,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
return {
|
|
132
|
+
data: Object.values(mapXToDataPoints),
|
|
133
|
+
chartTitle: layout === null || layout === void 0 ? void 0 : layout.title,
|
|
134
|
+
// width: layout?.width,
|
|
135
|
+
// height: layout?.height,
|
|
136
|
+
barwidth: 'auto',
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
exports.transformPlotlyJsonToGVBCProps = transformPlotlyJsonToGVBCProps;
|
|
140
|
+
var transformPlotlyJsonToScatterChartProps = function (jsonObj, isAreaChart, colorMap) {
|
|
141
|
+
var data = jsonObj.data, layout = jsonObj.layout;
|
|
142
|
+
var chartData = data.map(function (series, index) {
|
|
143
|
+
var xValues = series.x;
|
|
144
|
+
var isString = typeof xValues[0] === 'string';
|
|
145
|
+
var isXDate = (0, exports.isDateArray)(xValues);
|
|
146
|
+
var isXNumber = (0, exports.isNumberArray)(xValues);
|
|
147
|
+
var legend = series.name || "Series ".concat(index + 1);
|
|
148
|
+
var lineColor = (0, exports.getColor)(legend, colorMap);
|
|
149
|
+
return {
|
|
150
|
+
legend: legend,
|
|
151
|
+
data: xValues.map(function (x, i) { return ({
|
|
152
|
+
x: isString ? (isXDate ? new Date(x) : isXNumber ? parseFloat(x) : x) : x,
|
|
153
|
+
y: series.y[i],
|
|
154
|
+
}); }),
|
|
155
|
+
color: lineColor,
|
|
156
|
+
};
|
|
157
|
+
});
|
|
158
|
+
var chartProps = {
|
|
159
|
+
chartTitle: layout.title || '',
|
|
160
|
+
lineChartData: chartData,
|
|
161
|
+
};
|
|
162
|
+
if (isAreaChart) {
|
|
163
|
+
return {
|
|
164
|
+
data: chartProps,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
return {
|
|
169
|
+
data: chartProps,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
exports.transformPlotlyJsonToScatterChartProps = transformPlotlyJsonToScatterChartProps;
|
|
174
|
+
var transformPlotlyJsonToHorizontalBarWithAxisProps = function (jsonObj, colorMap) {
|
|
175
|
+
var _a, _b;
|
|
176
|
+
var data = jsonObj.data, layout = jsonObj.layout;
|
|
177
|
+
var chartData = data
|
|
178
|
+
.map(function (series, index) {
|
|
179
|
+
return series.y.map(function (yValue, i) {
|
|
180
|
+
var color = (0, exports.getColor)(yValue, colorMap);
|
|
181
|
+
return {
|
|
182
|
+
x: series.x[i],
|
|
183
|
+
y: yValue,
|
|
184
|
+
legend: yValue,
|
|
185
|
+
color: color,
|
|
186
|
+
};
|
|
187
|
+
});
|
|
188
|
+
})
|
|
189
|
+
.flat();
|
|
190
|
+
var chartHeight = layout.height || 350;
|
|
191
|
+
var margin = ((_a = layout.margin) === null || _a === void 0 ? void 0 : _a.l) || 0;
|
|
192
|
+
var padding = ((_b = layout.margin) === null || _b === void 0 ? void 0 : _b.pad) || 0;
|
|
193
|
+
var availableHeight = chartHeight - margin - padding;
|
|
194
|
+
var numberOfBars = data[0].y.length;
|
|
195
|
+
var gapFactor = 0.5;
|
|
196
|
+
var barHeight = availableHeight / (numberOfBars * (1 + gapFactor));
|
|
197
|
+
return {
|
|
198
|
+
data: chartData,
|
|
199
|
+
chartTitle: layout.title || '',
|
|
200
|
+
barHeight: barHeight,
|
|
201
|
+
showYAxisLables: true,
|
|
202
|
+
styles: {
|
|
203
|
+
root: {
|
|
204
|
+
height: chartHeight,
|
|
205
|
+
width: layout.width || 600,
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
};
|
|
210
|
+
exports.transformPlotlyJsonToHorizontalBarWithAxisProps = transformPlotlyJsonToHorizontalBarWithAxisProps;
|
|
211
|
+
// FIXME: Order of string axis ticks does not match the order in plotly json
|
|
212
|
+
// TODO: Add support for custom hover card
|
|
213
|
+
var transformPlotlyJsonToHeatmapProps = function (jsonObj) {
|
|
214
|
+
var _a, _b, _c;
|
|
215
|
+
var data = jsonObj.data, layout = jsonObj.layout;
|
|
216
|
+
var firstData = data[0];
|
|
217
|
+
var heatmapDataPoints = [];
|
|
218
|
+
var zMin = Number.POSITIVE_INFINITY;
|
|
219
|
+
var zMax = Number.NEGATIVE_INFINITY;
|
|
220
|
+
(_a = firstData.x) === null || _a === void 0 ? void 0 : _a.forEach(function (xVal, xIdx) {
|
|
221
|
+
var _a;
|
|
222
|
+
(_a = firstData.y) === null || _a === void 0 ? void 0 : _a.forEach(function (yVal, yIdx) {
|
|
223
|
+
var _a, _b, _c, _d;
|
|
224
|
+
var zVal = (_b = (_a = firstData.z) === null || _a === void 0 ? void 0 : _a[yIdx]) === null || _b === void 0 ? void 0 : _b[xIdx];
|
|
225
|
+
heatmapDataPoints.push({
|
|
226
|
+
x: ((_c = layout.xaxis) === null || _c === void 0 ? void 0 : _c.type) === 'date' ? new Date(xVal) : xVal,
|
|
227
|
+
y: ((_d = layout.yaxis) === null || _d === void 0 ? void 0 : _d.type) === 'date' ? new Date(yVal) : yVal,
|
|
228
|
+
value: zVal,
|
|
229
|
+
});
|
|
230
|
+
zMin = Math.min(zMin, zVal);
|
|
231
|
+
zMax = Math.max(zMax, zVal);
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
var heatmapData = {
|
|
235
|
+
legend: firstData.name || '',
|
|
236
|
+
data: heatmapDataPoints,
|
|
237
|
+
value: 0,
|
|
238
|
+
};
|
|
239
|
+
// Convert normalized values to actual values
|
|
240
|
+
var domainValuesForColorScale = (_b = firstData.colorscale) === null || _b === void 0 ? void 0 : _b.map(function (arr) { return arr[0] * (zMax - zMin) + zMin; });
|
|
241
|
+
var rangeValuesForColorScale = (_c = firstData.colorscale) === null || _c === void 0 ? void 0 : _c.map(function (arr) { return arr[1]; });
|
|
242
|
+
return {
|
|
243
|
+
data: [heatmapData],
|
|
244
|
+
domainValuesForColorScale: domainValuesForColorScale,
|
|
245
|
+
rangeValuesForColorScale: rangeValuesForColorScale,
|
|
246
|
+
hideLegend: true,
|
|
247
|
+
};
|
|
248
|
+
};
|
|
249
|
+
exports.transformPlotlyJsonToHeatmapProps = transformPlotlyJsonToHeatmapProps;
|
|
250
|
+
var transformPlotlyJsonToSankeyProps = function (jsonObj, colorMap) {
|
|
251
|
+
var _a;
|
|
252
|
+
var data = jsonObj.data, layout = jsonObj.layout;
|
|
253
|
+
var _b = data[0], link = _b.link, node = _b.node;
|
|
254
|
+
var validLinks = link.value
|
|
255
|
+
.map(function (val, index) { return ({
|
|
256
|
+
value: val,
|
|
257
|
+
source: link.source[index],
|
|
258
|
+
target: link.target[index],
|
|
259
|
+
}); })
|
|
260
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
261
|
+
//@ts-expect-error Dynamic link object. Ignore for now.
|
|
262
|
+
.filter(function (x) { return x.source !== x.target; }); // Filter out self-references (circular links)
|
|
263
|
+
var sankeyChartData = {
|
|
264
|
+
nodes: node.label.map(function (label, index) {
|
|
265
|
+
var color = (0, exports.getColor)(label, colorMap);
|
|
266
|
+
return {
|
|
267
|
+
nodeId: index,
|
|
268
|
+
name: label,
|
|
269
|
+
color: color,
|
|
270
|
+
};
|
|
271
|
+
}),
|
|
272
|
+
links: validLinks.map(function (validLink, index) {
|
|
273
|
+
return tslib_1.__assign({}, validLink);
|
|
274
|
+
}),
|
|
275
|
+
};
|
|
276
|
+
var width = (layout === null || layout === void 0 ? void 0 : layout.width) || 440;
|
|
277
|
+
var height = (layout === null || layout === void 0 ? void 0 : layout.height) || 220;
|
|
278
|
+
var styles = {
|
|
279
|
+
root: {
|
|
280
|
+
fontSize: (_a = layout.font) === null || _a === void 0 ? void 0 : _a.size,
|
|
281
|
+
},
|
|
282
|
+
};
|
|
283
|
+
var shouldResize = width + height;
|
|
284
|
+
return {
|
|
285
|
+
data: {
|
|
286
|
+
chartTitle: layout === null || layout === void 0 ? void 0 : layout.title,
|
|
287
|
+
SankeyChartData: sankeyChartData,
|
|
288
|
+
},
|
|
289
|
+
width: width,
|
|
290
|
+
height: height,
|
|
291
|
+
styles: styles,
|
|
292
|
+
shouldResize: shouldResize,
|
|
293
|
+
enableReflow: true,
|
|
294
|
+
};
|
|
295
|
+
};
|
|
296
|
+
exports.transformPlotlyJsonToSankeyProps = transformPlotlyJsonToSankeyProps;
|
|
297
|
+
var transformPlotlyJsonToGaugeProps = function (jsonObj, colorMap) {
|
|
298
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
299
|
+
var data = jsonObj.data, layout = jsonObj.layout;
|
|
300
|
+
var firstData = data[0];
|
|
301
|
+
var segments = (_b = (_a = firstData.gauge) === null || _a === void 0 ? void 0 : _a.steps) === null || _b === void 0 ? void 0 : _b.map(function (step, index) {
|
|
302
|
+
var _a, _b;
|
|
303
|
+
var legend = step.name || "Segment ".concat(index + 1);
|
|
304
|
+
var color = (0, exports.getColor)(legend, colorMap);
|
|
305
|
+
return {
|
|
306
|
+
legend: legend,
|
|
307
|
+
size: ((_a = step.range) === null || _a === void 0 ? void 0 : _a[1]) - ((_b = step.range) === null || _b === void 0 ? void 0 : _b[0]),
|
|
308
|
+
color: color,
|
|
309
|
+
};
|
|
310
|
+
});
|
|
311
|
+
var sublabel;
|
|
312
|
+
var sublabelColor;
|
|
313
|
+
if (typeof ((_c = firstData.delta) === null || _c === void 0 ? void 0 : _c.reference) === 'number') {
|
|
314
|
+
var diff = firstData.value - firstData.delta.reference;
|
|
315
|
+
if (diff >= 0) {
|
|
316
|
+
sublabel = "\u25B2 ".concat(diff);
|
|
317
|
+
var color = (0, exports.getColor)(((_d = firstData.delta.increasing) === null || _d === void 0 ? void 0 : _d.color) || '', colorMap);
|
|
318
|
+
sublabelColor = color;
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
sublabel = "\u25BC ".concat(Math.abs(diff));
|
|
322
|
+
var color = (0, exports.getColor)(((_e = firstData.delta.decreasing) === null || _e === void 0 ? void 0 : _e.color) || '', colorMap);
|
|
323
|
+
sublabelColor = color;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
var styles = {
|
|
327
|
+
sublabel: {
|
|
328
|
+
fill: sublabelColor,
|
|
329
|
+
},
|
|
330
|
+
};
|
|
331
|
+
return {
|
|
332
|
+
segments: segments,
|
|
333
|
+
chartValue: firstData.value,
|
|
334
|
+
chartTitle: (_f = firstData.title) === null || _f === void 0 ? void 0 : _f.text,
|
|
335
|
+
sublabel: sublabel,
|
|
336
|
+
// range values can be null
|
|
337
|
+
minValue: (_k = (_j = (_h = (_g = firstData.gauge) === null || _g === void 0 ? void 0 : _g.axis) === null || _h === void 0 ? void 0 : _h.range) === null || _j === void 0 ? void 0 : _j[0]) !== null && _k !== void 0 ? _k : undefined,
|
|
338
|
+
maxValue: (_p = (_o = (_m = (_l = firstData.gauge) === null || _l === void 0 ? void 0 : _l.axis) === null || _m === void 0 ? void 0 : _m.range) === null || _o === void 0 ? void 0 : _o[1]) !== null && _p !== void 0 ? _p : undefined,
|
|
339
|
+
chartValueFormat: function () { return firstData.value; },
|
|
340
|
+
width: layout === null || layout === void 0 ? void 0 : layout.width,
|
|
341
|
+
height: layout === null || layout === void 0 ? void 0 : layout.height,
|
|
342
|
+
hideLegend: true,
|
|
343
|
+
styles: styles,
|
|
344
|
+
};
|
|
345
|
+
};
|
|
346
|
+
exports.transformPlotlyJsonToGaugeProps = transformPlotlyJsonToGaugeProps;
|
|
347
|
+
function isTypedArray(a) {
|
|
348
|
+
return ArrayBuffer.isView(a) && !(a instanceof DataView);
|
|
349
|
+
}
|
|
350
|
+
function isArrayOrTypedArray(a) {
|
|
351
|
+
return Array.isArray(a) || isTypedArray(a);
|
|
352
|
+
}
|
|
353
|
+
function isPlainObject(obj) {
|
|
354
|
+
if (window && window.process && window.process.versions) {
|
|
355
|
+
return Object.prototype.toString.call(obj) === '[object Object]';
|
|
356
|
+
}
|
|
357
|
+
return (Object.prototype.toString.call(obj) === '[object Object]' &&
|
|
358
|
+
Object.getPrototypeOf(obj).hasOwnProperty('hasOwnProperty'));
|
|
359
|
+
}
|
|
360
|
+
var arrayAttributes = [];
|
|
361
|
+
var stack = [];
|
|
362
|
+
var isArrayStack = [];
|
|
363
|
+
var baseContainer, baseAttrName;
|
|
364
|
+
/**
|
|
365
|
+
* Interate iteratively through the trace object and find all the array attributes.
|
|
366
|
+
* 1 trace record = 1 series of data
|
|
367
|
+
* @param trace
|
|
368
|
+
*/
|
|
369
|
+
function findArrayAttributes(trace) {
|
|
370
|
+
// Init basecontainer and baseAttrName
|
|
371
|
+
crawlIntoTrace(baseContainer, 0, '');
|
|
372
|
+
for (var _i = 0, arrayAttributes_1 = arrayAttributes; _i < arrayAttributes_1.length; _i++) {
|
|
373
|
+
var attribute = arrayAttributes_1[_i];
|
|
374
|
+
console.log(attribute);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
exports.findArrayAttributes = findArrayAttributes;
|
|
378
|
+
function crawlIntoTrace(container, i, astrPartial) {
|
|
379
|
+
var item = container[stack[i]];
|
|
380
|
+
var newAstrPartial = astrPartial + stack[i];
|
|
381
|
+
if (i === stack.length - 1) {
|
|
382
|
+
if (isArrayOrTypedArray(item)) {
|
|
383
|
+
arrayAttributes.push(baseAttrName + newAstrPartial);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
if (isArrayStack[i]) {
|
|
388
|
+
if (Array.isArray(item)) {
|
|
389
|
+
for (var j = 0; j < item.length; j++) {
|
|
390
|
+
if (isPlainObject(item[j])) {
|
|
391
|
+
crawlIntoTrace(item[j], i + 1, newAstrPartial + '[' + j + '].');
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
else if (isPlainObject(item)) {
|
|
397
|
+
crawlIntoTrace(item, i + 1, newAstrPartial + '.');
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
//# sourceMappingURL=PlotlySchemaAdapter.js.map
|