@fluentui/react-charting 5.24.2 → 5.24.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +34 -1
- package/CHANGELOG.md +14 -2
- package/dist/react-charting.d.ts +170 -37
- package/dist/react-charting.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/etc/react-charting.api.md +58 -11
- package/lib/ScatterChart.d.ts +1 -0
- package/lib/ScatterChart.js +2 -0
- package/lib/ScatterChart.js.map +1 -0
- package/lib/components/CommonComponents/CartesianChart.base.js +45 -9
- package/lib/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.styles.js +48 -26
- package/lib/components/CommonComponents/CartesianChart.styles.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.d.ts +21 -1
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +157 -78
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +28 -13
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +252 -62
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.base.d.ts +7 -0
- package/lib/components/ScatterChart/ScatterChart.base.js +453 -0
- package/lib/components/ScatterChart/ScatterChart.base.js.map +1 -0
- package/lib/components/ScatterChart/ScatterChart.d.ts +7 -0
- package/lib/components/ScatterChart/ScatterChart.js +10 -0
- package/lib/components/ScatterChart/ScatterChart.js.map +1 -0
- package/lib/components/ScatterChart/ScatterChart.styles.d.ts +2 -0
- package/lib/components/ScatterChart/ScatterChart.styles.js +7 -0
- package/lib/components/ScatterChart/ScatterChart.styles.js.map +1 -0
- package/lib/components/ScatterChart/ScatterChart.types.d.ts +42 -0
- package/lib/components/ScatterChart/ScatterChart.types.js +2 -0
- package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -0
- package/lib/components/ScatterChart/index.d.ts +2 -0
- package/lib/components/ScatterChart/index.js +3 -0
- package/lib/components/ScatterChart/index.js.map +1 -0
- package/lib/index.d.ts +3 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/types/IDataPoint.d.ts +73 -11
- package/lib/types/IDataPoint.js.map +1 -1
- package/lib/utilities/SVGTooltipText.d.ts +4 -0
- package/lib/utilities/SVGTooltipText.js +1 -2
- package/lib/utilities/SVGTooltipText.js.map +1 -1
- package/lib/utilities/utilities.d.ts +27 -3
- package/lib/utilities/utilities.js +102 -1
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-amd/ScatterChart.d.ts +1 -0
- package/lib-amd/ScatterChart.js +6 -0
- package/lib-amd/ScatterChart.js.map +1 -0
- package/lib-amd/components/CommonComponents/CartesianChart.base.js +45 -9
- package/lib-amd/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-amd/components/CommonComponents/CartesianChart.styles.js +48 -26
- package/lib-amd/components/CommonComponents/CartesianChart.styles.js.map +1 -1
- package/lib-amd/components/CommonComponents/CartesianChart.types.d.ts +21 -1
- package/lib-amd/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/DeclarativeChart.js +155 -78
- package/lib-amd/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +28 -13
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +264 -71
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-amd/components/ScatterChart/ScatterChart.base.d.ts +7 -0
- package/lib-amd/components/ScatterChart/ScatterChart.base.js +447 -0
- package/lib-amd/components/ScatterChart/ScatterChart.base.js.map +1 -0
- package/lib-amd/components/ScatterChart/ScatterChart.d.ts +7 -0
- package/lib-amd/components/ScatterChart/ScatterChart.js +12 -0
- package/lib-amd/components/ScatterChart/ScatterChart.js.map +1 -0
- package/lib-amd/components/ScatterChart/ScatterChart.styles.d.ts +2 -0
- package/lib-amd/components/ScatterChart/ScatterChart.styles.js +12 -0
- package/lib-amd/components/ScatterChart/ScatterChart.styles.js.map +1 -0
- package/lib-amd/components/ScatterChart/ScatterChart.types.d.ts +42 -0
- package/lib-amd/components/ScatterChart/ScatterChart.types.js +5 -0
- package/lib-amd/components/ScatterChart/ScatterChart.types.js.map +1 -0
- package/lib-amd/components/ScatterChart/index.d.ts +2 -0
- package/lib-amd/components/ScatterChart/index.js +7 -0
- package/lib-amd/components/ScatterChart/index.js.map +1 -0
- package/lib-amd/index.d.ts +3 -1
- package/lib-amd/index.js +3 -2
- package/lib-amd/index.js.map +1 -1
- package/lib-amd/types/IDataPoint.d.ts +73 -11
- package/lib-amd/types/IDataPoint.js.map +1 -1
- package/lib-amd/utilities/SVGTooltipText.d.ts +4 -0
- package/lib-amd/utilities/SVGTooltipText.js +1 -2
- package/lib-amd/utilities/SVGTooltipText.js.map +1 -1
- package/lib-amd/utilities/utilities.d.ts +27 -3
- package/lib-amd/utilities/utilities.js +106 -2
- package/lib-amd/utilities/utilities.js.map +1 -1
- package/lib-commonjs/ScatterChart.d.ts +1 -0
- package/lib-commonjs/ScatterChart.js +5 -0
- package/lib-commonjs/ScatterChart.js.map +1 -0
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js +45 -9
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.styles.js +48 -26
- package/lib-commonjs/components/CommonComponents/CartesianChart.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.d.ts +21 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +157 -78
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +28 -13
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +263 -71
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.base.d.ts +7 -0
- package/lib-commonjs/components/ScatterChart/ScatterChart.base.js +456 -0
- package/lib-commonjs/components/ScatterChart/ScatterChart.base.js.map +1 -0
- package/lib-commonjs/components/ScatterChart/ScatterChart.d.ts +7 -0
- package/lib-commonjs/components/ScatterChart/ScatterChart.js +13 -0
- package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -0
- package/lib-commonjs/components/ScatterChart/ScatterChart.styles.d.ts +2 -0
- package/lib-commonjs/components/ScatterChart/ScatterChart.styles.js +11 -0
- package/lib-commonjs/components/ScatterChart/ScatterChart.styles.js.map +1 -0
- package/lib-commonjs/components/ScatterChart/ScatterChart.types.d.ts +42 -0
- package/lib-commonjs/components/ScatterChart/ScatterChart.types.js +3 -0
- package/lib-commonjs/components/ScatterChart/ScatterChart.types.js.map +1 -0
- package/lib-commonjs/components/ScatterChart/index.d.ts +2 -0
- package/lib-commonjs/components/ScatterChart/index.js +6 -0
- package/lib-commonjs/components/ScatterChart/index.js.map +1 -0
- package/lib-commonjs/index.d.ts +3 -1
- package/lib-commonjs/index.js +3 -1
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/types/IDataPoint.d.ts +73 -11
- package/lib-commonjs/types/IDataPoint.js.map +1 -1
- package/lib-commonjs/utilities/SVGTooltipText.d.ts +4 -0
- package/lib-commonjs/utilities/SVGTooltipText.js +1 -2
- package/lib-commonjs/utilities/SVGTooltipText.js.map +1 -1
- package/lib-commonjs/utilities/utilities.d.ts +27 -3
- package/lib-commonjs/utilities/utilities.js +106 -2
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +2 -2
- package/src/components/CommonComponents/CartesianChart.types.ts +25 -1
- package/src/components/ScatterChart/ScatterChart.types.ts +61 -0
|
@@ -10,22 +10,36 @@ import { IGaugeChartProps } from '../GaugeChart/index';
|
|
|
10
10
|
import { IGroupedVerticalBarChartProps } from '../GroupedVerticalBarChart/index';
|
|
11
11
|
import { IVerticalBarChartProps } from '../VerticalBarChart/index';
|
|
12
12
|
import { IChartTableProps } from '../ChartTable/index';
|
|
13
|
-
import type { Datum, PlotlySchema, PlotData, TypedArray, Color } from '@fluentui/chart-utilities';
|
|
13
|
+
import type { Datum, Layout, PlotlySchema, PlotData, TypedArray, Color } from '@fluentui/chart-utilities';
|
|
14
14
|
import type { ColorwayType } from './PlotlyColorAdapter';
|
|
15
|
-
|
|
15
|
+
import { ILegendsProps } from '../Legends/index';
|
|
16
|
+
export type AxisProperties = {
|
|
17
|
+
xAnnotation?: string;
|
|
18
|
+
yAnnotation?: string;
|
|
19
|
+
row: number;
|
|
20
|
+
column: number;
|
|
21
|
+
};
|
|
22
|
+
export type GridAxisProperties = Record<string, AxisProperties>;
|
|
23
|
+
export type GridProperties = {
|
|
24
|
+
templateRows: string;
|
|
25
|
+
templateColumns: string;
|
|
26
|
+
layout: GridAxisProperties;
|
|
27
|
+
};
|
|
16
28
|
export declare const correctYearMonth: (xValues: Datum[] | Datum[][] | TypedArray) => any[];
|
|
17
29
|
export declare const _getGaugeAxisColor: (colorway: string[] | undefined, colorwayType: ColorwayType, color: Color | undefined, colorMap: React.MutableRefObject<Map<string, string>>, isDarkTheme?: boolean) => string;
|
|
18
30
|
export declare const resolveXAxisPoint: (x: Datum, isXYearCategory: boolean, isXString: boolean, isXDate: boolean, isXNumber: boolean) => string | Date | number;
|
|
19
|
-
export declare const transformPlotlyJsonToDonutProps: (input: PlotlySchema, colorMap: React.MutableRefObject<Map<string, string>>, colorwayType: ColorwayType, isDarkTheme?: boolean) => IDonutChartProps;
|
|
20
|
-
export declare const transformPlotlyJsonToVSBCProps: (input: PlotlySchema, colorMap: React.MutableRefObject<Map<string, string>>, colorwayType: ColorwayType, isDarkTheme?: boolean, fallbackVSBC?: boolean) => IVerticalStackedBarChartProps;
|
|
21
|
-
export declare const transformPlotlyJsonToGVBCProps: (input: PlotlySchema, colorMap: React.MutableRefObject<Map<string, string>>, colorwayType: ColorwayType, isDarkTheme?: boolean) => IGroupedVerticalBarChartProps;
|
|
22
|
-
export declare const transformPlotlyJsonToVBCProps: (input: PlotlySchema, colorMap: React.MutableRefObject<Map<string, string>>, colorwayType: ColorwayType, isDarkTheme?: boolean) => IVerticalBarChartProps;
|
|
23
|
-
export declare const
|
|
24
|
-
export declare const
|
|
25
|
-
export declare const
|
|
26
|
-
export declare const
|
|
27
|
-
export declare const
|
|
28
|
-
export declare const
|
|
31
|
+
export declare const transformPlotlyJsonToDonutProps: (input: PlotlySchema, isMultiPlot: boolean, colorMap: React.MutableRefObject<Map<string, string>>, colorwayType: ColorwayType, isDarkTheme?: boolean) => IDonutChartProps;
|
|
32
|
+
export declare const transformPlotlyJsonToVSBCProps: (input: PlotlySchema, isMultiPlot: boolean, colorMap: React.MutableRefObject<Map<string, string>>, colorwayType: ColorwayType, isDarkTheme?: boolean, fallbackVSBC?: boolean) => IVerticalStackedBarChartProps;
|
|
33
|
+
export declare const transformPlotlyJsonToGVBCProps: (input: PlotlySchema, isMultiPlot: boolean, colorMap: React.MutableRefObject<Map<string, string>>, colorwayType: ColorwayType, isDarkTheme?: boolean) => IGroupedVerticalBarChartProps;
|
|
34
|
+
export declare const transformPlotlyJsonToVBCProps: (input: PlotlySchema, isMultiPlot: boolean, colorMap: React.MutableRefObject<Map<string, string>>, colorwayType: ColorwayType, isDarkTheme?: boolean) => IVerticalBarChartProps;
|
|
35
|
+
export declare const transformPlotlyJsonToAreaChartProps: (input: PlotlySchema, isMultiPlot: boolean, colorMap: React.MutableRefObject<Map<string, string>>, colorwayType: ColorwayType, isDarkTheme?: boolean) => IAreaChartProps;
|
|
36
|
+
export declare const transformPlotlyJsonToLineChartProps: (input: PlotlySchema, isMultiPlot: boolean, colorMap: React.MutableRefObject<Map<string, string>>, colorwayType: ColorwayType, isDarkTheme?: boolean) => ILineChartProps;
|
|
37
|
+
export declare const transformPlotlyJsonToScatterChartProps: (input: PlotlySchema, isMultiPlot: boolean, colorMap: React.MutableRefObject<Map<string, string>>, colorwayType: ColorwayType, isDarkTheme?: boolean) => ILineChartProps;
|
|
38
|
+
export declare const transformPlotlyJsonToHorizontalBarWithAxisProps: (input: PlotlySchema, isMultiPlot: boolean, colorMap: React.MutableRefObject<Map<string, string>>, colorwayType: ColorwayType, isDarkTheme?: boolean) => IHorizontalBarChartWithAxisProps;
|
|
39
|
+
export declare const transformPlotlyJsonToHeatmapProps: (input: PlotlySchema, isMultiPlot: boolean, colorMap: React.MutableRefObject<Map<string, string>>, colorwayType: ColorwayType, isDarkTheme?: boolean) => IHeatMapChartProps;
|
|
40
|
+
export declare const transformPlotlyJsonToSankeyProps: (input: PlotlySchema, isMultiPlot: boolean, colorMap: React.MutableRefObject<Map<string, string>>, colorwayType: ColorwayType, isDarkTheme?: boolean) => ISankeyChartProps;
|
|
41
|
+
export declare const transformPlotlyJsonToGaugeProps: (input: PlotlySchema, isMultiPlot: boolean, colorMap: React.MutableRefObject<Map<string, string>>, colorwayType: ColorwayType, isDarkTheme?: boolean) => IGaugeChartProps;
|
|
42
|
+
export declare const transformPlotlyJsonToChartTableProps: (input: PlotlySchema, isMultiPlot: boolean, colorMap: React.MutableRefObject<Map<string, string>>, colorwayType: ColorwayType, isDarkTheme?: boolean) => IChartTableProps;
|
|
29
43
|
export declare const projectPolarToCartesian: (input: PlotlySchema) => PlotlySchema;
|
|
30
44
|
/**
|
|
31
45
|
* Interate iteratively through the trace object and find all the array attributes.
|
|
@@ -33,6 +47,7 @@ export declare const projectPolarToCartesian: (input: PlotlySchema) => PlotlySch
|
|
|
33
47
|
* @param trace
|
|
34
48
|
*/
|
|
35
49
|
export declare function findArrayAttributes(trace: any): void;
|
|
36
|
-
export declare const
|
|
50
|
+
export declare const getAllupLegendsProps: (input: PlotlySchema, colorMap: React.MutableRefObject<Map<string, string>>, colorwayType: ColorwayType, isDarkTheme?: boolean) => ILegendsProps;
|
|
37
51
|
export declare const getNumberAtIndexOrDefault: (data: PlotData['z'] | undefined, index: number) => number | undefined;
|
|
38
52
|
export declare const getValidXYRanges: (series: Partial<PlotData>) => [number, number][];
|
|
53
|
+
export declare const getGridProperties: (layout: Partial<Layout> | undefined, isMultiPlot: boolean) => GridProperties;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getValidXYRanges = exports.getNumberAtIndexOrDefault = exports.
|
|
3
|
+
exports.getGridProperties = exports.getValidXYRanges = exports.getNumberAtIndexOrDefault = exports.getAllupLegendsProps = exports.findArrayAttributes = exports.projectPolarToCartesian = exports.transformPlotlyJsonToChartTableProps = exports.transformPlotlyJsonToGaugeProps = exports.transformPlotlyJsonToSankeyProps = exports.transformPlotlyJsonToHeatmapProps = exports.transformPlotlyJsonToHorizontalBarWithAxisProps = exports.transformPlotlyJsonToScatterChartProps = exports.transformPlotlyJsonToLineChartProps = exports.transformPlotlyJsonToAreaChartProps = exports.transformPlotlyJsonToVBCProps = exports.transformPlotlyJsonToGVBCProps = exports.transformPlotlyJsonToVSBCProps = exports.transformPlotlyJsonToDonutProps = exports.resolveXAxisPoint = exports._getGaugeAxisColor = exports.correctYearMonth = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var d3_array_1 = require("d3-array");
|
|
6
6
|
var d3_scale_1 = require("d3-scale");
|
|
@@ -9,7 +9,6 @@ var colors_1 = require("../../utilities/colors");
|
|
|
9
9
|
var index_1 = require("../GaugeChart/index");
|
|
10
10
|
var utilities_1 = require("../../utilities/utilities");
|
|
11
11
|
var chart_utilities_1 = require("@fluentui/chart-utilities");
|
|
12
|
-
var d3_time_format_1 = require("d3-time-format");
|
|
13
12
|
var d3_shape_1 = require("d3-shape");
|
|
14
13
|
var PlotlyColorAdapter_1 = require("./PlotlyColorAdapter");
|
|
15
14
|
var dashOptions = {
|
|
@@ -50,17 +49,6 @@ var dashOptions = {
|
|
|
50
49
|
lineBorderWidth: '4',
|
|
51
50
|
},
|
|
52
51
|
};
|
|
53
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
|
-
var isMonth = function (possiblyMonthValue) {
|
|
55
|
-
var parseFullMonth = (0, d3_time_format_1.timeParse)('%B');
|
|
56
|
-
var parseShortMonth = (0, d3_time_format_1.timeParse)('%b');
|
|
57
|
-
return parseFullMonth(possiblyMonthValue) !== null || parseShortMonth(possiblyMonthValue) !== null;
|
|
58
|
-
};
|
|
59
|
-
var isMonthArray = function (data) {
|
|
60
|
-
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
61
|
-
return (0, chart_utilities_1.isArrayOfType)(data, function (value) { return isMonth(value) || value === null; });
|
|
62
|
-
};
|
|
63
|
-
exports.isMonthArray = isMonthArray;
|
|
64
52
|
function getTitles(layout) {
|
|
65
53
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
66
54
|
var titles = {
|
|
@@ -108,8 +96,9 @@ var correctYearMonth = function (xValues) {
|
|
|
108
96
|
return xValues;
|
|
109
97
|
};
|
|
110
98
|
exports.correctYearMonth = correctYearMonth;
|
|
111
|
-
var usesSecondaryYScale = function (series) {
|
|
112
|
-
|
|
99
|
+
var usesSecondaryYScale = function (series, layout) {
|
|
100
|
+
var _a, _b;
|
|
101
|
+
return series.yaxis === 'y2' && (((_a = layout === null || layout === void 0 ? void 0 : layout.yaxis2) === null || _a === void 0 ? void 0 : _a.anchor) === 'x' || ((_b = layout === null || layout === void 0 ? void 0 : layout.yaxis2) === null || _b === void 0 ? void 0 : _b.side) === 'right');
|
|
113
102
|
};
|
|
114
103
|
var getSecondaryYAxisValues = function (data, layout, maxAllowedMinY, minAllowedMaxY) {
|
|
115
104
|
var _a, _b, _c, _d;
|
|
@@ -117,7 +106,7 @@ var getSecondaryYAxisValues = function (data, layout, maxAllowedMinY, minAllowed
|
|
|
117
106
|
var yMinValue;
|
|
118
107
|
var yMaxValue;
|
|
119
108
|
data.forEach(function (series) {
|
|
120
|
-
if (usesSecondaryYScale(series)) {
|
|
109
|
+
if (usesSecondaryYScale(series, layout)) {
|
|
121
110
|
containsSecondaryYAxis = true;
|
|
122
111
|
var yValues = series.y;
|
|
123
112
|
if (yValues) {
|
|
@@ -176,7 +165,7 @@ var resolveXAxisPoint = function (x, isXYearCategory, isXString, isXDate, isXNum
|
|
|
176
165
|
return x;
|
|
177
166
|
};
|
|
178
167
|
exports.resolveXAxisPoint = resolveXAxisPoint;
|
|
179
|
-
var transformPlotlyJsonToDonutProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
168
|
+
var transformPlotlyJsonToDonutProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
180
169
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
181
170
|
var firstData = input.data[0];
|
|
182
171
|
// extract colors for each series only once
|
|
@@ -229,13 +218,13 @@ var transformPlotlyJsonToDonutProps = function (input, colorMap, colorwayType, i
|
|
|
229
218
|
};
|
|
230
219
|
};
|
|
231
220
|
exports.transformPlotlyJsonToDonutProps = transformPlotlyJsonToDonutProps;
|
|
232
|
-
var transformPlotlyJsonToVSBCProps = function (input, colorMap, colorwayType, isDarkTheme, fallbackVSBC) {
|
|
221
|
+
var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme, fallbackVSBC) {
|
|
233
222
|
var _a, _b, _c;
|
|
234
223
|
var mapXToDataPoints = {};
|
|
235
224
|
var yMaxValue = 0;
|
|
236
225
|
var yMinValue = 0;
|
|
237
226
|
var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
|
|
238
|
-
var _d = getLegendProps(input.data, input.layout), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
227
|
+
var _d = getLegendProps(input.data, input.layout, isMultiPlot), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
239
228
|
var colorScale = undefined;
|
|
240
229
|
input.data.forEach(function (series, index1) {
|
|
241
230
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
@@ -252,7 +241,7 @@ var transformPlotlyJsonToVSBCProps = function (input, colorMap, colorwayType, is
|
|
|
252
241
|
var extractedLineColors = (0, PlotlyColorAdapter_1.extractColor)((_p = (_o = (_m = input.layout) === null || _m === void 0 ? void 0 : _m.template) === null || _o === void 0 ? void 0 : _o.layout) === null || _p === void 0 ? void 0 : _p.colorway, colorwayType, (_q = series.line) === null || _q === void 0 ? void 0 : _q.color, colorMap, isDarkTheme);
|
|
253
242
|
var xValues = series.x;
|
|
254
243
|
var isXDate = (0, chart_utilities_1.isDateArray)(xValues);
|
|
255
|
-
var isXString = (0,
|
|
244
|
+
var isXString = (0, chart_utilities_1.isStringArray)(xValues);
|
|
256
245
|
var isXNumber = (0, chart_utilities_1.isNumberArray)(xValues);
|
|
257
246
|
var validXYRanges = (0, exports.getValidXYRanges)(series);
|
|
258
247
|
validXYRanges.forEach(function (_a, rangeIdx) {
|
|
@@ -260,7 +249,7 @@ var transformPlotlyJsonToVSBCProps = function (input, colorMap, colorwayType, is
|
|
|
260
249
|
var rangeXValues = series.x.slice(rangeStart, rangeEnd);
|
|
261
250
|
var rangeYValues = series.y.slice(rangeStart, rangeEnd);
|
|
262
251
|
rangeXValues.forEach(function (x, index2) {
|
|
263
|
-
var _a, _b, _c, _d
|
|
252
|
+
var _a, _b, _c, _d;
|
|
264
253
|
if (!mapXToDataPoints[x]) {
|
|
265
254
|
mapXToDataPoints[x] = {
|
|
266
255
|
xAxisPoint: (0, exports.resolveXAxisPoint)(x, isXYearCategory, isXString, isXDate, isXNumber),
|
|
@@ -289,21 +278,16 @@ var transformPlotlyJsonToVSBCProps = function (input, colorMap, colorwayType, is
|
|
|
289
278
|
else if (series.type === 'scatter' || !!fallbackVSBC) {
|
|
290
279
|
var lineColor = (0, PlotlyColorAdapter_1.resolveColor)(extractedLineColors, index1, legend, colorMap, isDarkTheme);
|
|
291
280
|
var lineOptions = getLineOptions(series.line);
|
|
292
|
-
var
|
|
293
|
-
var legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot'
|
|
294
|
-
? 'dottedLine'
|
|
295
|
-
: ((_f = series.mode) === null || _f === void 0 ? void 0 : _f.includes('markers'))
|
|
296
|
-
? 'circle'
|
|
297
|
-
: 'default';
|
|
281
|
+
var legendShape = getLegendShape(series);
|
|
298
282
|
mapXToDataPoints[x].lineData.push({
|
|
299
283
|
legend: legend + (validXYRanges.length > 1 ? ".".concat(rangeIdx + 1) : ''),
|
|
300
284
|
legendShape: legendShape,
|
|
301
285
|
y: yVal,
|
|
302
286
|
color: lineColor,
|
|
303
287
|
lineOptions: tslib_1.__assign(tslib_1.__assign({}, (lineOptions !== null && lineOptions !== void 0 ? lineOptions : {})), { mode: series.mode }),
|
|
304
|
-
useSecondaryYScale: usesSecondaryYScale(series),
|
|
288
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout),
|
|
305
289
|
});
|
|
306
|
-
if (!usesSecondaryYScale(series) && typeof yVal === 'number') {
|
|
290
|
+
if (!usesSecondaryYScale(series, input.layout) && typeof yVal === 'number') {
|
|
307
291
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
308
292
|
yMinValue = Math.min(yMinValue, yVal);
|
|
309
293
|
}
|
|
@@ -331,11 +315,11 @@ var createColorScale = function (layout, series) {
|
|
|
331
315
|
var scaleColors = scale.map(function (item) { return item[1]; });
|
|
332
316
|
return (0, d3_scale_1.scaleLinear)().domain(scaleDomain).range(scaleColors);
|
|
333
317
|
};
|
|
334
|
-
var transformPlotlyJsonToGVBCProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
318
|
+
var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
335
319
|
var _a, _b, _c;
|
|
336
320
|
var mapXToDataPoints = {};
|
|
337
321
|
var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, 0, 0);
|
|
338
|
-
var _d = getLegendProps(input.data, input.layout), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
322
|
+
var _d = getLegendProps(input.data, input.layout, isMultiPlot), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
339
323
|
var colorScale = undefined;
|
|
340
324
|
input.data.forEach(function (series, index1) {
|
|
341
325
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
@@ -369,7 +353,7 @@ var transformPlotlyJsonToGVBCProps = function (input, colorMap, colorwayType, is
|
|
|
369
353
|
xAxisCalloutData: x,
|
|
370
354
|
color: color,
|
|
371
355
|
legend: legend,
|
|
372
|
-
useSecondaryYScale: usesSecondaryYScale(series),
|
|
356
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout),
|
|
373
357
|
});
|
|
374
358
|
}
|
|
375
359
|
});
|
|
@@ -378,10 +362,10 @@ var transformPlotlyJsonToGVBCProps = function (input, colorMap, colorwayType, is
|
|
|
378
362
|
return tslib_1.__assign(tslib_1.__assign({ data: Object.values(mapXToDataPoints), width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, barwidth: 'auto', chartTitle: chartTitle, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle, mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true });
|
|
379
363
|
};
|
|
380
364
|
exports.transformPlotlyJsonToGVBCProps = transformPlotlyJsonToGVBCProps;
|
|
381
|
-
var transformPlotlyJsonToVBCProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
365
|
+
var transformPlotlyJsonToVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
382
366
|
var _a, _b, _c;
|
|
383
367
|
var vbcData = [];
|
|
384
|
-
var _d = getLegendProps(input.data, input.layout), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
368
|
+
var _d = getLegendProps(input.data, input.layout, isMultiPlot), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
385
369
|
var colorScale = undefined;
|
|
386
370
|
input.data.forEach(function (series, seriesIdx) {
|
|
387
371
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
@@ -406,7 +390,7 @@ var transformPlotlyJsonToVBCProps = function (input, colorMap, colorwayType, isD
|
|
|
406
390
|
xValues.push(xVal);
|
|
407
391
|
yValues.push(yVal);
|
|
408
392
|
});
|
|
409
|
-
var isXString = (0,
|
|
393
|
+
var isXString = (0, chart_utilities_1.isStringArray)(xValues);
|
|
410
394
|
// TODO: In case of a single bin, add an empty bin of the same size to prevent the
|
|
411
395
|
// default bar width from being used and ensure the bar spans the full intended range.
|
|
412
396
|
var xBins = createBins(xValues, (_m = series.xbins) === null || _m === void 0 ? void 0 : _m.start, (_o = series.xbins) === null || _o === void 0 ? void 0 : _o.end, (_p = series.xbins) === null || _p === void 0 ? void 0 : _p.size);
|
|
@@ -455,14 +439,35 @@ var transformPlotlyJsonToVBCProps = function (input, colorMap, colorwayType, isD
|
|
|
455
439
|
};
|
|
456
440
|
};
|
|
457
441
|
exports.transformPlotlyJsonToVBCProps = transformPlotlyJsonToVBCProps;
|
|
458
|
-
var
|
|
459
|
-
|
|
442
|
+
var transformPlotlyJsonToAreaChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
443
|
+
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'area', colorMap, colorwayType, isDarkTheme);
|
|
444
|
+
};
|
|
445
|
+
exports.transformPlotlyJsonToAreaChartProps = transformPlotlyJsonToAreaChartProps;
|
|
446
|
+
var transformPlotlyJsonToLineChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
447
|
+
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'line', colorMap, colorwayType, isDarkTheme);
|
|
448
|
+
};
|
|
449
|
+
exports.transformPlotlyJsonToLineChartProps = transformPlotlyJsonToLineChartProps;
|
|
450
|
+
var transformPlotlyJsonToScatterChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
451
|
+
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'scatter', colorMap, colorwayType, isDarkTheme);
|
|
452
|
+
};
|
|
453
|
+
exports.transformPlotlyJsonToScatterChartProps = transformPlotlyJsonToScatterChartProps;
|
|
454
|
+
var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme) {
|
|
455
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
456
|
+
var isScatterMarkers = [
|
|
457
|
+
'text+markers',
|
|
458
|
+
'markers+text',
|
|
459
|
+
'lines+markers',
|
|
460
|
+
'markers+line',
|
|
461
|
+
'text+lines+markers',
|
|
462
|
+
].includes((_a = input.data[0]) === null || _a === void 0 ? void 0 : _a.mode);
|
|
463
|
+
var isAreaChart = chartType === 'area';
|
|
464
|
+
var isScatterChart = chartType === 'scatter';
|
|
460
465
|
var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
|
|
461
466
|
var mode = 'tonexty';
|
|
462
|
-
var
|
|
467
|
+
var _h = getLegendProps(input.data, input.layout, isMultiPlot), legends = _h.legends, hideLegend = _h.hideLegend;
|
|
463
468
|
var chartData = input.data
|
|
464
469
|
.map(function (series, index) {
|
|
465
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
470
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
466
471
|
var colors = isScatterMarkers
|
|
467
472
|
? ((_a = series === null || series === void 0 ? void 0 : series.mode) === null || _a === void 0 ? void 0 : _a.includes('line'))
|
|
468
473
|
? (_b = series.line) === null || _b === void 0 ? void 0 : _b.color
|
|
@@ -471,22 +476,16 @@ var transformPlotlyJsonToScatterChartProps = function (input, isAreaChart, isSca
|
|
|
471
476
|
// extract colors for each series only once
|
|
472
477
|
var extractedColors = (0, PlotlyColorAdapter_1.extractColor)((_g = (_f = (_e = input.layout) === null || _e === void 0 ? void 0 : _e.template) === null || _f === void 0 ? void 0 : _f.layout) === null || _g === void 0 ? void 0 : _g.colorway, colorwayType, colors, colorMap, isDarkTheme);
|
|
473
478
|
var xValues = series.x;
|
|
474
|
-
var isXString = (0,
|
|
479
|
+
var isXString = (0, chart_utilities_1.isStringArray)(xValues);
|
|
475
480
|
var isXDate = (0, chart_utilities_1.isDateArray)(xValues);
|
|
476
481
|
var isXNumber = (0, chart_utilities_1.isNumberArray)(xValues);
|
|
477
|
-
|
|
478
|
-
var isXYearCategory = false;
|
|
482
|
+
var isXYearCategory = (0, chart_utilities_1.isYearArray)(series.x); // Consider year as categorical not numeric continuous axis
|
|
479
483
|
var legend = legends[index];
|
|
480
484
|
// resolve color for each legend's lines from the extracted colors
|
|
481
485
|
var seriesColor = (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
482
486
|
mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
|
|
483
487
|
var lineOptions = getLineOptions(series.line);
|
|
484
|
-
var
|
|
485
|
-
var legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot'
|
|
486
|
-
? 'dottedLine'
|
|
487
|
-
: ((_j = series.mode) === null || _j === void 0 ? void 0 : _j.includes('markers'))
|
|
488
|
-
? 'circle'
|
|
489
|
-
: 'default';
|
|
488
|
+
var legendShape = getLegendShape(series);
|
|
490
489
|
var validXYRanges = (0, exports.getValidXYRanges)(series);
|
|
491
490
|
return validXYRanges.map(function (_a, rangeIdx) {
|
|
492
491
|
var _b;
|
|
@@ -510,29 +509,32 @@ var transformPlotlyJsonToScatterChartProps = function (input, isAreaChart, isSca
|
|
|
510
509
|
}),
|
|
511
510
|
color: seriesColor,
|
|
512
511
|
lineOptions: tslib_1.__assign(tslib_1.__assign({}, (lineOptions !== null && lineOptions !== void 0 ? lineOptions : {})), { mode: series.mode }),
|
|
513
|
-
useSecondaryYScale: usesSecondaryYScale(series),
|
|
512
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout),
|
|
514
513
|
};
|
|
515
514
|
});
|
|
516
515
|
})
|
|
517
516
|
.flat();
|
|
518
517
|
var yMinMaxValues = (0, utilities_1.findNumericMinMaxOfY)(chartData);
|
|
519
|
-
var
|
|
518
|
+
var _j = getTitles(input.layout), chartTitle = _j.chartTitle, xAxisTitle = _j.xAxisTitle, yAxisTitle = _j.yAxisTitle;
|
|
520
519
|
var numDataPoints = chartData.reduce(function (total, lineChartPoints) { return total + lineChartPoints.data.length; }, 0);
|
|
521
520
|
var chartProps = {
|
|
522
521
|
chartTitle: chartTitle,
|
|
523
522
|
lineChartData: chartData,
|
|
524
523
|
};
|
|
524
|
+
var scatterChartProps = {
|
|
525
|
+
chartTitle: chartTitle,
|
|
526
|
+
scatterChartData: chartData,
|
|
527
|
+
};
|
|
525
528
|
if (isAreaChart) {
|
|
526
|
-
return tslib_1.__assign(tslib_1.__assign({ data: chartProps, supportNegativeData: true, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle }, secondaryYAxisValues), { mode: mode, width: (
|
|
529
|
+
return tslib_1.__assign(tslib_1.__assign({ data: chartProps, supportNegativeData: true, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle }, secondaryYAxisValues), { mode: mode, width: (_b = input.layout) === null || _b === void 0 ? void 0 : _b.width, height: (_d = (_c = input.layout) === null || _c === void 0 ? void 0 : _c.height) !== null && _d !== void 0 ? _d : 350, hideTickOverlap: true, hideLegend: hideLegend, useUTC: false, optimizeLargeData: numDataPoints > 1000 });
|
|
527
530
|
}
|
|
528
531
|
else {
|
|
529
|
-
return tslib_1.__assign(tslib_1.__assign({ data: chartProps, supportNegativeData: true, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle }, secondaryYAxisValues), { roundedTicks: true, yMinValue: yMinMaxValues.startValue, yMaxValue: yMinMaxValues.endValue, width: (
|
|
532
|
+
return tslib_1.__assign(tslib_1.__assign({ data: isScatterChart ? scatterChartProps : chartProps, supportNegativeData: true, xAxisTitle: xAxisTitle, yAxisTitle: yAxisTitle }, secondaryYAxisValues), { roundedTicks: true, yMinValue: yMinMaxValues.startValue, yMaxValue: yMinMaxValues.endValue, width: (_e = input.layout) === null || _e === void 0 ? void 0 : _e.width, height: (_g = (_f = input.layout) === null || _f === void 0 ? void 0 : _f.height) !== null && _g !== void 0 ? _g : 350, hideTickOverlap: true, enableReflow: false, hideLegend: hideLegend, useUTC: false, optimizeLargeData: numDataPoints > 1000 });
|
|
530
533
|
}
|
|
531
534
|
};
|
|
532
|
-
|
|
533
|
-
var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
535
|
+
var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
534
536
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
535
|
-
var _s = getLegendProps(input.data, input.layout), legends = _s.legends, hideLegend = _s.hideLegend;
|
|
537
|
+
var _s = getLegendProps(input.data, input.layout, isMultiPlot), legends = _s.legends, hideLegend = _s.hideLegend;
|
|
536
538
|
var colorScale = undefined;
|
|
537
539
|
var chartData = input.data
|
|
538
540
|
.map(function (series, index) {
|
|
@@ -600,7 +602,7 @@ var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, colorMap,
|
|
|
600
602
|
};
|
|
601
603
|
};
|
|
602
604
|
exports.transformPlotlyJsonToHorizontalBarWithAxisProps = transformPlotlyJsonToHorizontalBarWithAxisProps;
|
|
603
|
-
var transformPlotlyJsonToHeatmapProps = function (input) {
|
|
605
|
+
var transformPlotlyJsonToHeatmapProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
604
606
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8;
|
|
605
607
|
var firstData = input.data[0];
|
|
606
608
|
var heatmapDataPoints = [];
|
|
@@ -620,8 +622,8 @@ var transformPlotlyJsonToHeatmapProps = function (input) {
|
|
|
620
622
|
yValues_1.push(firstData.y[index]);
|
|
621
623
|
zValues_1.push(zVal);
|
|
622
624
|
});
|
|
623
|
-
var isXString_1 = (0,
|
|
624
|
-
var isYString_1 = (0,
|
|
625
|
+
var isXString_1 = (0, chart_utilities_1.isStringArray)(xValues_1);
|
|
626
|
+
var isYString_1 = (0, chart_utilities_1.isStringArray)(yValues_1);
|
|
625
627
|
var xBins_1 = createBins(xValues_1, (_b = firstData.xbins) === null || _b === void 0 ? void 0 : _b.start, (_c = firstData.xbins) === null || _c === void 0 ? void 0 : _c.end, (_d = firstData.xbins) === null || _d === void 0 ? void 0 : _d.size);
|
|
626
628
|
var yBins_1 = createBins(yValues_1, (_e = firstData.ybins) === null || _e === void 0 ? void 0 : _e.start, (_f = firstData.ybins) === null || _f === void 0 ? void 0 : _f.end, (_g = firstData.ybins) === null || _g === void 0 ? void 0 : _g.size);
|
|
627
629
|
var zBins_1 = yBins_1.map(function () { return xBins_1.map(function () { return []; }); });
|
|
@@ -731,7 +733,7 @@ var transformPlotlyJsonToHeatmapProps = function (input) {
|
|
|
731
733
|
};
|
|
732
734
|
};
|
|
733
735
|
exports.transformPlotlyJsonToHeatmapProps = transformPlotlyJsonToHeatmapProps;
|
|
734
|
-
var transformPlotlyJsonToSankeyProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
736
|
+
var transformPlotlyJsonToSankeyProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
735
737
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
736
738
|
var _m = input.data[0], link = _m.link, node = _m.node;
|
|
737
739
|
var validLinks = ((_a = link === null || link === void 0 ? void 0 : link.value) !== null && _a !== void 0 ? _a : [])
|
|
@@ -779,7 +781,7 @@ var transformPlotlyJsonToSankeyProps = function (input, colorMap, colorwayType,
|
|
|
779
781
|
};
|
|
780
782
|
};
|
|
781
783
|
exports.transformPlotlyJsonToSankeyProps = transformPlotlyJsonToSankeyProps;
|
|
782
|
-
var transformPlotlyJsonToGaugeProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
784
|
+
var transformPlotlyJsonToGaugeProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
783
785
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25;
|
|
784
786
|
var firstData = input.data[0];
|
|
785
787
|
var stepsColors = ((_a = firstData.gauge) === null || _a === void 0 ? void 0 : _a.steps) ? firstData.gauge.steps.map(function (step) { return step.color; }) : undefined;
|
|
@@ -879,7 +881,7 @@ var formatValue = function (value, colIndex, cells) {
|
|
|
879
881
|
}
|
|
880
882
|
return "".concat(prefix !== null && prefix !== void 0 ? prefix : '').concat(formatted).concat(suffix !== null && suffix !== void 0 ? suffix : '');
|
|
881
883
|
};
|
|
882
|
-
var transformPlotlyJsonToChartTableProps = function (input, colorMap, isDarkTheme) {
|
|
884
|
+
var transformPlotlyJsonToChartTableProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
883
885
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
884
886
|
var tableData = input.data[0];
|
|
885
887
|
var normalizeHeaders = function (values, header) {
|
|
@@ -1085,12 +1087,6 @@ function getLineOptions(line) {
|
|
|
1085
1087
|
}
|
|
1086
1088
|
return Object.keys(lineOptions).length > 0 ? lineOptions : undefined;
|
|
1087
1089
|
}
|
|
1088
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1089
|
-
var isStringArray = function (arr) {
|
|
1090
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1091
|
-
return (0, chart_utilities_1.isArrayOfType)(arr, function (value) { return typeof value === 'string' || value === null; });
|
|
1092
|
-
};
|
|
1093
|
-
exports.isStringArray = isStringArray;
|
|
1094
1090
|
// TODO: Use binary search to find the appropriate bin for numeric value.
|
|
1095
1091
|
var findBinIndex = function (bins, value, isString) {
|
|
1096
1092
|
if (typeof value === 'undefined' || value === null) {
|
|
@@ -1114,7 +1110,7 @@ var createBins = function (data, binStart, binEnd, binSize) {
|
|
|
1114
1110
|
if (!data || data.length === 0) {
|
|
1115
1111
|
return [];
|
|
1116
1112
|
}
|
|
1117
|
-
if ((0,
|
|
1113
|
+
if ((0, chart_utilities_1.isStringArray)(data)) {
|
|
1118
1114
|
var categories_1 = Array.from(new Set(data));
|
|
1119
1115
|
var start = typeof binStart === 'number' ? Math.ceil(binStart) : 0;
|
|
1120
1116
|
var stop_1 = typeof binEnd === 'number' ? Math.floor(binEnd) + 1 : categories_1.length;
|
|
@@ -1185,7 +1181,48 @@ var precisionRound = function (value, precision) {
|
|
|
1185
1181
|
var factor = Math.pow(10, precision);
|
|
1186
1182
|
return Math.round(value * factor) / factor;
|
|
1187
1183
|
};
|
|
1188
|
-
var
|
|
1184
|
+
var getLegendShape = function (series) {
|
|
1185
|
+
var _a, _b;
|
|
1186
|
+
var dashType = ((_a = series.line) === null || _a === void 0 ? void 0 : _a.dash) || 'solid';
|
|
1187
|
+
if (dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot') {
|
|
1188
|
+
return 'dottedLine';
|
|
1189
|
+
}
|
|
1190
|
+
else if ((_b = series.mode) === null || _b === void 0 ? void 0 : _b.includes('markers')) {
|
|
1191
|
+
return 'circle';
|
|
1192
|
+
}
|
|
1193
|
+
return 'default';
|
|
1194
|
+
};
|
|
1195
|
+
var getAllupLegendsProps = function (input, colorMap, colorwayType, isDarkTheme) {
|
|
1196
|
+
var allupLegends = [];
|
|
1197
|
+
// reduce on showlegend boolean propperty. reduce should return true if at least one series has showlegend true
|
|
1198
|
+
var toShowLegend = input.data.reduce(function (acc, series) {
|
|
1199
|
+
return acc || series.showlegend === true;
|
|
1200
|
+
}, false);
|
|
1201
|
+
if (toShowLegend) {
|
|
1202
|
+
input.data.forEach(function (series, index) {
|
|
1203
|
+
var _a, _b, _c, _d, _e;
|
|
1204
|
+
var name = series.legendgroup;
|
|
1205
|
+
var color = ((_a = series.line) === null || _a === void 0 ? void 0 : _a.color) || ((_b = series.marker) === null || _b === void 0 ? void 0 : _b.color);
|
|
1206
|
+
var legendShape = getLegendShape(series);
|
|
1207
|
+
var resolvedColor = (0, PlotlyColorAdapter_1.extractColor)((_e = (_d = (_c = input.layout) === null || _c === void 0 ? void 0 : _c.template) === null || _d === void 0 ? void 0 : _d.layout) === null || _e === void 0 ? void 0 : _e.colorway, colorwayType, color, colorMap, isDarkTheme);
|
|
1208
|
+
if (name !== undefined && allupLegends.some(function (group) { return group.title === name; }) === false) {
|
|
1209
|
+
allupLegends.push({
|
|
1210
|
+
title: name,
|
|
1211
|
+
color: resolvedColor,
|
|
1212
|
+
shape: legendShape,
|
|
1213
|
+
});
|
|
1214
|
+
}
|
|
1215
|
+
});
|
|
1216
|
+
}
|
|
1217
|
+
return {
|
|
1218
|
+
legends: allupLegends,
|
|
1219
|
+
centerLegends: true,
|
|
1220
|
+
enabledWrapLines: true,
|
|
1221
|
+
canSelectMultipleLegends: true,
|
|
1222
|
+
};
|
|
1223
|
+
};
|
|
1224
|
+
exports.getAllupLegendsProps = getAllupLegendsProps;
|
|
1225
|
+
var getLegendProps = function (data, layout, isMultiPlot) {
|
|
1189
1226
|
var legends = [];
|
|
1190
1227
|
if (data.length === 1) {
|
|
1191
1228
|
legends.push(data[0].name || '');
|
|
@@ -1195,10 +1232,11 @@ var getLegendProps = function (data, layout) {
|
|
|
1195
1232
|
legends.push(series.name || "Series ".concat(index + 1));
|
|
1196
1233
|
});
|
|
1197
1234
|
}
|
|
1198
|
-
var
|
|
1235
|
+
var hideLegendsData = data.every(function (series) { return series.showlegend === false; });
|
|
1236
|
+
var hideLegendsInferred = (layout === null || layout === void 0 ? void 0 : layout.showlegend) === false || ((layout === null || layout === void 0 ? void 0 : layout.showlegend) !== true && legends.length < 2);
|
|
1199
1237
|
return {
|
|
1200
1238
|
legends: legends,
|
|
1201
|
-
hideLegend:
|
|
1239
|
+
hideLegend: isMultiPlot || hideLegendsInferred || hideLegendsData,
|
|
1202
1240
|
};
|
|
1203
1241
|
};
|
|
1204
1242
|
var getNumberAtIndexOrDefault = function (data, index) {
|
|
@@ -1232,4 +1270,158 @@ var getValidXYRanges = function (series) {
|
|
|
1232
1270
|
return ranges;
|
|
1233
1271
|
};
|
|
1234
1272
|
exports.getValidXYRanges = getValidXYRanges;
|
|
1273
|
+
var getIndexFromKey = function (key, pattern) {
|
|
1274
|
+
var normalizedKey = key.replace(pattern, '') === '' ? '1' : key.replace(pattern, '');
|
|
1275
|
+
return parseInt(normalizedKey, 10) - 1;
|
|
1276
|
+
};
|
|
1277
|
+
var getGridProperties = function (layout, isMultiPlot) {
|
|
1278
|
+
var _a;
|
|
1279
|
+
var gridX = [];
|
|
1280
|
+
var gridY = [];
|
|
1281
|
+
var annotations = {};
|
|
1282
|
+
var templateRows = '1fr';
|
|
1283
|
+
var templateColumns = '1fr';
|
|
1284
|
+
var gridLayout = {};
|
|
1285
|
+
if (layout === undefined || layout === null || Object.keys(layout).length === 0) {
|
|
1286
|
+
return { templateRows: templateRows, templateColumns: templateColumns, layout: gridLayout };
|
|
1287
|
+
}
|
|
1288
|
+
if (!layout.xaxis || !layout.yaxis) {
|
|
1289
|
+
return { templateRows: templateRows, templateColumns: templateColumns, layout: gridLayout };
|
|
1290
|
+
}
|
|
1291
|
+
if (!isMultiPlot) {
|
|
1292
|
+
return { templateRows: templateRows, templateColumns: templateColumns, layout: gridLayout };
|
|
1293
|
+
}
|
|
1294
|
+
Object.keys(layout).forEach(function (key) {
|
|
1295
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
1296
|
+
if (key.startsWith('xaxis')) {
|
|
1297
|
+
var index = getIndexFromKey(key, 'xaxis');
|
|
1298
|
+
var anchor = (_b = (_a = layout[key]) === null || _a === void 0 ? void 0 : _a.anchor) !== null && _b !== void 0 ? _b : 'y';
|
|
1299
|
+
var anchorIndex = getIndexFromKey(anchor, 'y');
|
|
1300
|
+
if (index !== anchorIndex) {
|
|
1301
|
+
throw new Error("Invalid layout: xaxis ".concat(index + 1, " anchor should be y").concat(anchorIndex + 1));
|
|
1302
|
+
}
|
|
1303
|
+
gridX[index] = (_d = (_c = layout[key]) === null || _c === void 0 ? void 0 : _c.domain) !== null && _d !== void 0 ? _d : [];
|
|
1304
|
+
}
|
|
1305
|
+
else if (key.startsWith('yaxis')) {
|
|
1306
|
+
var index = getIndexFromKey(key, 'yaxis');
|
|
1307
|
+
var anchor = (_f = (_e = layout[key]) === null || _e === void 0 ? void 0 : _e.anchor) !== null && _f !== void 0 ? _f : 'x';
|
|
1308
|
+
var anchorIndex = getIndexFromKey(anchor, 'x');
|
|
1309
|
+
if (index !== anchorIndex) {
|
|
1310
|
+
if ((index === 1 && anchorIndex === 0) || ((_g = layout.yaxis2) === null || _g === void 0 ? void 0 : _g.side) === 'right') {
|
|
1311
|
+
// Special case for secondary y axis where yaxis2 can anchor to x1
|
|
1312
|
+
return { templateRows: templateRows, templateColumns: templateColumns };
|
|
1313
|
+
}
|
|
1314
|
+
throw new Error("Invalid layout: yaxis ".concat(index + 1, " anchor should be x").concat(anchorIndex + 1));
|
|
1315
|
+
}
|
|
1316
|
+
gridY[index] = (_j = (_h = layout[key]) === null || _h === void 0 ? void 0 : _h.domain) !== null && _j !== void 0 ? _j : [];
|
|
1317
|
+
}
|
|
1318
|
+
});
|
|
1319
|
+
(_a = layout.annotations) === null || _a === void 0 ? void 0 : _a.forEach(function (annotation) {
|
|
1320
|
+
var xMatches = gridX.flatMap(function (interval, idx) {
|
|
1321
|
+
return (annotation === null || annotation === void 0 ? void 0 : annotation.x) >= interval[0] && (annotation === null || annotation === void 0 ? void 0 : annotation.x) <= interval[1] ? [idx] : [];
|
|
1322
|
+
});
|
|
1323
|
+
var yMatch = gridY.findIndex(function (interval, yIndex) {
|
|
1324
|
+
return xMatches.includes(yIndex) &&
|
|
1325
|
+
(annotation === null || annotation === void 0 ? void 0 : annotation.y) >= interval[0] &&
|
|
1326
|
+
(annotation === null || annotation === void 0 ? void 0 : annotation.y) <= interval[1];
|
|
1327
|
+
});
|
|
1328
|
+
if (yMatch !== -1) {
|
|
1329
|
+
if (annotations[yMatch] === undefined) {
|
|
1330
|
+
annotations[yMatch] = {};
|
|
1331
|
+
}
|
|
1332
|
+
if ((annotation === null || annotation === void 0 ? void 0 : annotation.textangle) === 90) {
|
|
1333
|
+
annotations[yMatch].yAnnotation = annotation.text;
|
|
1334
|
+
}
|
|
1335
|
+
else {
|
|
1336
|
+
annotations[yMatch].xAnnotation = annotation.text;
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
});
|
|
1340
|
+
if (gridX.length > 0) {
|
|
1341
|
+
var uniqueXIntervals_1 = new Map();
|
|
1342
|
+
gridX.forEach(function (interval) {
|
|
1343
|
+
var key = "".concat(interval[0], "-").concat(interval[1]);
|
|
1344
|
+
if (!uniqueXIntervals_1.has(key)) {
|
|
1345
|
+
uniqueXIntervals_1.set(key, interval);
|
|
1346
|
+
}
|
|
1347
|
+
});
|
|
1348
|
+
var minXInterval_1 = Math.min.apply(Math, Array.from(uniqueXIntervals_1.values()).map(function (interval) { return interval[1] - interval[0]; }));
|
|
1349
|
+
templateColumns = Array.from(uniqueXIntervals_1.values())
|
|
1350
|
+
.map(function (interval) { return "".concat((interval[1] - interval[0]) / minXInterval_1, "fr"); })
|
|
1351
|
+
.join(' ');
|
|
1352
|
+
var columnNumber_1 = 1;
|
|
1353
|
+
var lastIntervalEnd_1 = 0;
|
|
1354
|
+
gridX.forEach(function (interval, index) {
|
|
1355
|
+
if (interval.length === 0) {
|
|
1356
|
+
return;
|
|
1357
|
+
}
|
|
1358
|
+
var cellName = "x".concat(index === 0 ? '' : index + 1);
|
|
1359
|
+
var annotationProps = annotations[index];
|
|
1360
|
+
var xAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.xAnnotation;
|
|
1361
|
+
if (interval[0] < lastIntervalEnd_1) {
|
|
1362
|
+
columnNumber_1 = 1;
|
|
1363
|
+
}
|
|
1364
|
+
lastIntervalEnd_1 = interval[1];
|
|
1365
|
+
var row = {
|
|
1366
|
+
row: -1,
|
|
1367
|
+
column: columnNumber_1,
|
|
1368
|
+
xAnnotation: xAnnotation,
|
|
1369
|
+
};
|
|
1370
|
+
gridLayout[cellName] = row;
|
|
1371
|
+
columnNumber_1 += 1;
|
|
1372
|
+
});
|
|
1373
|
+
}
|
|
1374
|
+
var numColumns = Math.max.apply(Math, Object.values(gridLayout).map(function (cell) { var _a; return (_a = cell.column) !== null && _a !== void 0 ? _a : 0; }));
|
|
1375
|
+
var columnFill = {};
|
|
1376
|
+
for (var i = 1; i <= numColumns; i++) {
|
|
1377
|
+
columnFill[i] = { row: 1, fillDomain: 0 };
|
|
1378
|
+
}
|
|
1379
|
+
if (gridY.length > 0) {
|
|
1380
|
+
var uniqueYIntervals_1 = new Map();
|
|
1381
|
+
gridY.forEach(function (interval) {
|
|
1382
|
+
var key = "".concat(interval[0], "-").concat(interval[1]);
|
|
1383
|
+
if (!uniqueYIntervals_1.has(key)) {
|
|
1384
|
+
uniqueYIntervals_1.set(key, interval);
|
|
1385
|
+
}
|
|
1386
|
+
});
|
|
1387
|
+
var minYInterval_1 = Math.min.apply(Math, Array.from(uniqueYIntervals_1.values()).map(function (interval) { return interval[1] - interval[0]; }));
|
|
1388
|
+
templateRows = Array.from(uniqueYIntervals_1.values())
|
|
1389
|
+
.map(function (interval) { return "".concat((interval[1] - interval[0]) / minYInterval_1, "fr"); })
|
|
1390
|
+
.join(' ');
|
|
1391
|
+
gridY.forEach(function (interval, index) {
|
|
1392
|
+
if (interval.length === 0) {
|
|
1393
|
+
return;
|
|
1394
|
+
}
|
|
1395
|
+
var cellName = "x".concat(index === 0 ? '' : index + 1);
|
|
1396
|
+
var annotationProps = annotations[index];
|
|
1397
|
+
var yAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.yAnnotation;
|
|
1398
|
+
var cell = gridLayout[cellName];
|
|
1399
|
+
if (cell !== undefined) {
|
|
1400
|
+
cell.row = columnFill[cell.column].row;
|
|
1401
|
+
cell.yAnnotation = yAnnotation;
|
|
1402
|
+
}
|
|
1403
|
+
columnFill[cell.column].fillDomain = interval[1];
|
|
1404
|
+
columnFill[cell.column].row += 1;
|
|
1405
|
+
});
|
|
1406
|
+
}
|
|
1407
|
+
// reverse the order of rows in grid layout from bottom-top to top-bottom as required by CSS grid
|
|
1408
|
+
var reversedGridLayout = {};
|
|
1409
|
+
// find the maximum row number
|
|
1410
|
+
var maxRowNumber = Math.max.apply(Math, Object.values(gridLayout).map(function (cell) { var _a; return (_a = cell.row) !== null && _a !== void 0 ? _a : 0; }));
|
|
1411
|
+
// iterate over the gridLayout and reverse the row numbers
|
|
1412
|
+
Object.keys(gridLayout).forEach(function (key) {
|
|
1413
|
+
var cell = gridLayout[key];
|
|
1414
|
+
if (cell.row !== undefined) {
|
|
1415
|
+
// reverse the row number
|
|
1416
|
+
cell.row = maxRowNumber - cell.row + 1;
|
|
1417
|
+
}
|
|
1418
|
+
reversedGridLayout[key] = cell;
|
|
1419
|
+
});
|
|
1420
|
+
return {
|
|
1421
|
+
templateRows: templateRows,
|
|
1422
|
+
templateColumns: templateColumns,
|
|
1423
|
+
layout: reversedGridLayout,
|
|
1424
|
+
};
|
|
1425
|
+
};
|
|
1426
|
+
exports.getGridProperties = getGridProperties;
|
|
1235
1427
|
//# sourceMappingURL=PlotlySchemaAdapter.js.map
|