@wonderflow/charts 12.10.0 → 13.0.0
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/dist/components/bar-chart/bar-chart.d.ts +33 -5
- package/dist/components/bar-chart/bar-chart.d.ts.map +1 -1
- package/dist/components/bar-chart/bar-chart.js +20 -45
- package/dist/components/bar-chart/bar-chart.test.js +7 -1
- package/dist/components/cartesian-base/cartesian-base-axis.d.ts.map +1 -1
- package/dist/components/cartesian-base/cartesian-base-axis.js +10 -11
- package/dist/components/cartesian-base/cartesian-base-legend.d.ts.map +1 -1
- package/dist/components/cartesian-base/cartesian-base-legend.js +3 -3
- package/dist/components/cartesian-base/cartesian-base.d.ts +27 -0
- package/dist/components/cartesian-base/cartesian-base.d.ts.map +1 -1
- package/dist/components/cartesian-base/cartesian-base.js +7 -3
- package/dist/components/cartesian-base/cartesian-base.module.css +1 -1
- package/dist/components/headings/headings.d.ts +19 -2
- package/dist/components/headings/headings.d.ts.map +1 -1
- package/dist/components/headings/headings.js +72 -6
- package/dist/components/headings/headings.module.css +1 -0
- package/dist/components/headings/headings.test.d.ts +1 -1
- package/dist/components/headings/headings.test.d.ts.map +1 -1
- package/dist/components/headings/headings.test.js +37 -3
- package/dist/components/line-chart/line-chart.d.ts +29 -13
- package/dist/components/line-chart/line-chart.d.ts.map +1 -1
- package/dist/components/line-chart/line-chart.js +4 -2
- package/dist/components/line-chart/line-chart.test.js +2 -2
- package/dist/components/loader/bar-chart-loader.d.ts.map +1 -1
- package/dist/components/loader/bar-chart-loader.js +1 -1
- package/dist/components/loader/loader.js +2 -2
- package/dist/components/loader/loader.test.js +4 -2
- package/dist/components/shapes/bars/bars-average.d.ts +3 -0
- package/dist/components/shapes/bars/bars-average.d.ts.map +1 -0
- package/dist/components/shapes/bars/bars-average.js +30 -0
- package/dist/components/shapes/bars/bars-overlay.d.ts +6 -0
- package/dist/components/shapes/bars/bars-overlay.d.ts.map +1 -0
- package/dist/components/shapes/bars/bars-overlay.js +59 -0
- package/dist/components/shapes/bars/bars-series.d.ts +6 -0
- package/dist/components/shapes/bars/bars-series.d.ts.map +1 -0
- package/dist/components/shapes/bars/bars-series.js +56 -0
- package/dist/components/shapes/bars/bars-tooltip.d.ts +3 -0
- package/dist/components/shapes/bars/bars-tooltip.d.ts.map +1 -0
- package/dist/components/shapes/bars/bars-tooltip.js +85 -0
- package/dist/components/shapes/bars/bars-trendline.d.ts +3 -0
- package/dist/components/shapes/bars/bars-trendline.d.ts.map +1 -0
- package/dist/components/shapes/bars/bars-trendline.js +43 -0
- package/dist/components/shapes/bars/bars.d.ts.map +1 -1
- package/dist/components/shapes/bars/bars.js +25 -18
- package/dist/components/shapes/bars/bars.module.css +1 -1
- package/dist/components/shapes/bars/bars.test.js +39 -8
- package/dist/components/shapes/bars/index.d.ts +5 -0
- package/dist/components/shapes/bars/index.d.ts.map +1 -1
- package/dist/components/shapes/bars/index.js +6 -1
- package/dist/components/shapes/lines/lines-average.d.ts.map +1 -1
- package/dist/components/shapes/lines/lines-average.js +8 -46
- package/dist/components/shapes/lines/lines-marker-labels.d.ts.map +1 -1
- package/dist/components/shapes/lines/lines-marker-labels.js +10 -10
- package/dist/components/shapes/lines/lines-overlay.d.ts.map +1 -1
- package/dist/components/shapes/lines/lines-overlay.js +21 -26
- package/dist/components/shapes/lines/lines-series.d.ts.map +1 -1
- package/dist/components/shapes/lines/lines-series.js +6 -19
- package/dist/components/shapes/lines/lines-tooltip.d.ts.map +1 -1
- package/dist/components/shapes/lines/lines-tooltip.js +20 -27
- package/dist/components/shapes/lines/lines-trendline.d.ts +3 -0
- package/dist/components/shapes/lines/lines-trendline.d.ts.map +1 -0
- package/dist/components/shapes/lines/lines-trendline.js +43 -0
- package/dist/components/shapes/lines/lines.d.ts.map +1 -1
- package/dist/components/shapes/lines/lines.js +2 -1
- package/dist/components/shapes/lines/lines.test.js +29 -8
- package/dist/hooks/hooks.test.d.ts.map +1 -1
- package/dist/hooks/hooks.test.js +157 -5
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +4 -0
- package/dist/hooks/useAverage.d.ts +82 -0
- package/dist/hooks/useAverage.d.ts.map +1 -0
- package/dist/hooks/useAverage.js +83 -0
- package/dist/hooks/useBarChart.d.ts +16 -0
- package/dist/hooks/useBarChart.d.ts.map +1 -0
- package/dist/hooks/useBarChart.js +104 -0
- package/dist/hooks/useBars.d.ts +52 -0
- package/dist/hooks/useBars.d.ts.map +1 -0
- package/dist/hooks/useBars.js +82 -0
- package/dist/hooks/useCartesian.d.ts +11 -2
- package/dist/hooks/useCartesian.d.ts.map +1 -1
- package/dist/hooks/useCartesian.js +16 -5
- package/dist/hooks/useLineChart.d.ts +3 -27
- package/dist/hooks/useLineChart.d.ts.map +1 -1
- package/dist/hooks/useLineChart.js +22 -13
- package/dist/hooks/useLines.d.ts +48 -0
- package/dist/hooks/useLines.d.ts.map +1 -0
- package/dist/hooks/useLines.js +70 -0
- package/dist/hooks/useTrendline.d.ts +56 -0
- package/dist/hooks/useTrendline.d.ts.map +1 -0
- package/dist/hooks/useTrendline.js +84 -0
- package/dist/providers/cartesian.d.ts +5 -1
- package/dist/providers/cartesian.d.ts.map +1 -1
- package/dist/providers/cartesian.js +19 -3
- package/dist/providers/data.d.ts +6 -7
- package/dist/providers/data.d.ts.map +1 -1
- package/dist/providers/data.js +4 -3
- package/dist/style-config/axis.js +3 -3
- package/dist/style-config/bars.d.ts +3 -0
- package/dist/style-config/bars.d.ts.map +1 -0
- package/dist/style-config/bars.js +33 -0
- package/dist/style-config/cartesian.d.ts.map +1 -1
- package/dist/style-config/cartesian.js +2 -0
- package/dist/style-config/colors.d.ts +1 -4
- package/dist/style-config/colors.d.ts.map +1 -1
- package/dist/style-config/colors.js +30 -36
- package/dist/style-config/headings.d.ts.map +1 -1
- package/dist/style-config/headings.js +16 -1
- package/dist/style-config/lines.d.ts.map +1 -1
- package/dist/style-config/lines.js +6 -0
- package/dist/style-config/themes.d.ts.map +1 -1
- package/dist/style-config/themes.js +18 -0
- package/dist/types/bar-chart.d.ts +20 -15
- package/dist/types/bar-chart.d.ts.map +1 -1
- package/dist/types/bar-chart.js +1 -39
- package/dist/types/bars.d.ts +29 -0
- package/dist/types/bars.d.ts.map +1 -0
- package/dist/types/bars.js +16 -0
- package/dist/types/cartesian.d.ts +3 -0
- package/dist/types/cartesian.d.ts.map +1 -1
- package/dist/types/headings.d.ts +15 -0
- package/dist/types/headings.d.ts.map +1 -1
- package/dist/types/headings.js +1 -1
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +4 -1
- package/dist/types/line-chart.d.ts +12 -12
- package/dist/types/line-chart.d.ts.map +1 -1
- package/dist/types/lines.d.ts +6 -0
- package/dist/types/lines.d.ts.map +1 -1
- package/dist/types/main.d.ts +14 -1
- package/dist/types/main.d.ts.map +1 -1
- package/dist/types/themes.d.ts +9 -0
- package/dist/types/themes.d.ts.map +1 -1
- package/dist/utils/axis.d.ts +12 -2
- package/dist/utils/axis.d.ts.map +1 -1
- package/dist/utils/axis.js +52 -15
- package/dist/utils/axis.test.js +72 -8
- package/dist/utils/bars.d.ts +15 -0
- package/dist/utils/bars.d.ts.map +1 -0
- package/dist/utils/bars.js +71 -0
- package/dist/utils/bars.test.d.ts +2 -0
- package/dist/utils/bars.test.d.ts.map +1 -0
- package/dist/utils/bars.test.js +95 -0
- package/dist/utils/data.d.ts +9 -6
- package/dist/utils/data.d.ts.map +1 -1
- package/dist/utils/data.js +87 -15
- package/dist/utils/data.test.js +173 -80
- package/dist/utils/format.d.ts +1 -0
- package/dist/utils/format.d.ts.map +1 -1
- package/dist/utils/format.js +2 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -1
- package/dist/utils/lines.test.js +25 -0
- package/dist/utils/metadata.d.ts +7 -8
- package/dist/utils/metadata.d.ts.map +1 -1
- package/dist/utils/metadata.js +3 -20
- package/dist/utils/metadata.test.js +3 -56
- package/dist/utils/viewport.test.js +8 -0
- package/package.json +4 -2
package/dist/utils/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAgBA,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAgBA,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC"}
|
package/dist/utils/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright 2023 Wonderflow Design Team
|
|
2
|
+
* Copyright 2023-2024 Wonderflow Design Team
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
export * from './axis';
|
|
17
|
+
export * from './bars';
|
|
17
18
|
export * from './colors';
|
|
18
19
|
export * from './data';
|
|
19
20
|
export * from './format';
|
package/dist/utils/lines.test.js
CHANGED
|
@@ -3,6 +3,11 @@ import { themes } from '../style-config';
|
|
|
3
3
|
import { computeAxisProperties } from './axis';
|
|
4
4
|
import { accessor, accessorInvert, bisectIndex, createSubArrays, createSubPaths, getCoordinates, getLinesRenderer, getMarkerLabelProps, isMarkerLabelVisible, } from './lines';
|
|
5
5
|
describe('accessor()', () => {
|
|
6
|
+
const config = {
|
|
7
|
+
hasReversedIndex: false,
|
|
8
|
+
hasMirroredDomainsHorizontal: false,
|
|
9
|
+
hasMirroredDomainsVertical: false,
|
|
10
|
+
};
|
|
6
11
|
it('should return an integer for linear scale', () => {
|
|
7
12
|
const axis = {
|
|
8
13
|
domain: [0, 100],
|
|
@@ -19,6 +24,7 @@ describe('accessor()', () => {
|
|
|
19
24
|
positionRight: 2,
|
|
20
25
|
positionBottom: 3,
|
|
21
26
|
positionLeft: 4,
|
|
27
|
+
config,
|
|
22
28
|
});
|
|
23
29
|
const res = accessor(cartesian, 'value', { value: 50 });
|
|
24
30
|
const exp = 400;
|
|
@@ -40,6 +46,7 @@ describe('accessor()', () => {
|
|
|
40
46
|
positionRight: 2,
|
|
41
47
|
positionBottom: 3,
|
|
42
48
|
positionLeft: 4,
|
|
49
|
+
config,
|
|
43
50
|
});
|
|
44
51
|
const res = accessor(cartesian, 'date', { date: '01-01-2021' });
|
|
45
52
|
const exp = 401;
|
|
@@ -61,6 +68,7 @@ describe('accessor()', () => {
|
|
|
61
68
|
positionRight: 2,
|
|
62
69
|
positionBottom: 3,
|
|
63
70
|
positionLeft: 4,
|
|
71
|
+
config,
|
|
64
72
|
});
|
|
65
73
|
const res = accessor(cartesian, 'date', { date: '01-01-2021' });
|
|
66
74
|
const exp = 400;
|
|
@@ -82,6 +90,7 @@ describe('accessor()', () => {
|
|
|
82
90
|
positionRight: 2,
|
|
83
91
|
positionBottom: 3,
|
|
84
92
|
positionLeft: 4,
|
|
93
|
+
config,
|
|
85
94
|
});
|
|
86
95
|
const res = accessor(cartesian, 'date', { date: undefined });
|
|
87
96
|
const exp = undefined;
|
|
@@ -89,6 +98,11 @@ describe('accessor()', () => {
|
|
|
89
98
|
});
|
|
90
99
|
});
|
|
91
100
|
describe('accessorInvert()', () => {
|
|
101
|
+
const config = {
|
|
102
|
+
hasReversedIndex: false,
|
|
103
|
+
hasMirroredDomainsHorizontal: false,
|
|
104
|
+
hasMirroredDomainsVertical: false,
|
|
105
|
+
};
|
|
92
106
|
it('should return the correct value from domain - top axis', () => {
|
|
93
107
|
const axis = {
|
|
94
108
|
domain: [0, 100],
|
|
@@ -105,6 +119,7 @@ describe('accessorInvert()', () => {
|
|
|
105
119
|
positionRight: 2,
|
|
106
120
|
positionBottom: 3,
|
|
107
121
|
positionLeft: 4,
|
|
122
|
+
config,
|
|
108
123
|
});
|
|
109
124
|
const res = accessorInvert(cartesian, 400);
|
|
110
125
|
const exp = 49.5;
|
|
@@ -126,6 +141,7 @@ describe('accessorInvert()', () => {
|
|
|
126
141
|
positionRight: 2,
|
|
127
142
|
positionBottom: 3,
|
|
128
143
|
positionLeft: 4,
|
|
144
|
+
config,
|
|
129
145
|
});
|
|
130
146
|
const res = accessorInvert(cartesian, 300);
|
|
131
147
|
const exp = 50;
|
|
@@ -147,6 +163,7 @@ describe('accessorInvert()', () => {
|
|
|
147
163
|
positionRight: 2,
|
|
148
164
|
positionBottom: 3,
|
|
149
165
|
positionLeft: 4,
|
|
166
|
+
config,
|
|
150
167
|
});
|
|
151
168
|
const res = accessorInvert(cartesian, 400);
|
|
152
169
|
const exp = 'c';
|
|
@@ -168,6 +185,7 @@ describe('accessorInvert()', () => {
|
|
|
168
185
|
positionRight: 2,
|
|
169
186
|
positionBottom: 3,
|
|
170
187
|
positionLeft: 4,
|
|
188
|
+
config,
|
|
171
189
|
});
|
|
172
190
|
const res = accessorInvert(cartesian, 350);
|
|
173
191
|
const exp = 'b';
|
|
@@ -197,6 +215,11 @@ describe('getCoordinates()', () => {
|
|
|
197
215
|
scaleType: 'linear',
|
|
198
216
|
orientation: 'left',
|
|
199
217
|
};
|
|
218
|
+
const config = {
|
|
219
|
+
hasReversedIndex: false,
|
|
220
|
+
hasMirroredDomainsHorizontal: false,
|
|
221
|
+
hasMirroredDomainsVertical: false,
|
|
222
|
+
};
|
|
200
223
|
const i = computeAxisProperties({
|
|
201
224
|
axis: indexAxis,
|
|
202
225
|
maxRangeX: 800,
|
|
@@ -205,6 +228,7 @@ describe('getCoordinates()', () => {
|
|
|
205
228
|
positionRight: 2,
|
|
206
229
|
positionBottom: 3,
|
|
207
230
|
positionLeft: 4,
|
|
231
|
+
config,
|
|
208
232
|
});
|
|
209
233
|
const s = computeAxisProperties({
|
|
210
234
|
axis: seriesAxis,
|
|
@@ -214,6 +238,7 @@ describe('getCoordinates()', () => {
|
|
|
214
238
|
positionRight: 2,
|
|
215
239
|
positionBottom: 3,
|
|
216
240
|
positionLeft: 4,
|
|
241
|
+
config,
|
|
217
242
|
});
|
|
218
243
|
it('should return data - horizontal', () => {
|
|
219
244
|
const res = getCoordinates({
|
package/dist/utils/metadata.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
7
|
-
export
|
|
8
|
-
export declare const handleBarChartOverlayColor: (overlay: BarChartOverlay | undefined, palette: string) => string;
|
|
1
|
+
import { LineChartSeries } from '../types';
|
|
2
|
+
import { BarChartSeries } from '../types/bar-chart';
|
|
3
|
+
declare type ChartSeries = LineChartSeries | BarChartSeries;
|
|
4
|
+
export declare const handleSeriesNames: (series: ChartSeries) => string[];
|
|
5
|
+
export declare const handleLineChartSeriesColors: (series: LineChartSeries, palette: string[]) => string[];
|
|
6
|
+
export declare const handleBarChartSeriesColors: (series: BarChartSeries, palette: string[]) => string[];
|
|
7
|
+
export {};
|
|
9
8
|
//# sourceMappingURL=metadata.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/utils/metadata.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/utils/metadata.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGpD,aAAK,WAAW,GAAG,eAAe,GAAG,cAAc,CAAC;AAEpD,eAAO,MAAM,iBAAiB,WACpB,WAAW,aAInB,CAAC;AAEH,eAAO,MAAM,2BAA2B,WAC9B,eAAe,WACd,MAAM,EAAE,aAGjB,CAAC;AAEH,eAAO,MAAM,0BAA0B,WAC7B,cAAc,WACb,MAAM,EAAE,aAGjB,CAAC"}
|
package/dist/utils/metadata.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright 2023 Wonderflow Design Team
|
|
2
|
+
* Copyright 2023-2024 Wonderflow Design Team
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -19,22 +19,5 @@ export const handleSeriesNames = (series) => series.dataKey.map((s, i) => {
|
|
|
19
19
|
const renamed = series.rename ? series.rename(s, i) : getLabelFromPath(s);
|
|
20
20
|
return _.startCase(renamed);
|
|
21
21
|
});
|
|
22
|
-
export const handleLineChartSeriesColors = (series, palette) => series.dataKey.map((_, i) => (series.style?.[i]
|
|
23
|
-
|
|
24
|
-
: palette[i % palette.length]));
|
|
25
|
-
export const handleBarChartSeriesColors = (series, palette) => series.dataKey.map((_, i) => (series.style?.[i]
|
|
26
|
-
? series.style[i]?.fill
|
|
27
|
-
: palette[i % palette.length]));
|
|
28
|
-
export const handleOverlayName = (overlay) => {
|
|
29
|
-
if (overlay) {
|
|
30
|
-
const { rename, label, dataKey } = overlay;
|
|
31
|
-
if (rename)
|
|
32
|
-
return rename;
|
|
33
|
-
if (label)
|
|
34
|
-
return _.startCase(label);
|
|
35
|
-
return _.startCase(dataKey);
|
|
36
|
-
}
|
|
37
|
-
return '';
|
|
38
|
-
};
|
|
39
|
-
export const handleLineChartOverlayColor = (overlay, palette) => overlay?.style?.stroke ?? palette;
|
|
40
|
-
export const handleBarChartOverlayColor = (overlay, palette) => overlay?.style?.fill ?? palette;
|
|
22
|
+
export const handleLineChartSeriesColors = (series, palette) => series.dataKey.map((_, i) => (series.style?.[i]?.stroke ?? palette[i % palette.length]));
|
|
23
|
+
export const handleBarChartSeriesColors = (series, palette) => series.dataKey.map((_, i) => (series.style?.[i]?.fill ?? palette[i % palette.length]));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { colorPaletteDefault } from '../style-config/colors';
|
|
2
|
+
import { handleLineChartSeriesColors, handleSeriesNames, } from './metadata';
|
|
3
3
|
describe('handleSeriesNames()', () => {
|
|
4
4
|
it('should return formatted labels', () => {
|
|
5
5
|
const series = {
|
|
@@ -20,7 +20,7 @@ describe('handleSeriesNames()', () => {
|
|
|
20
20
|
});
|
|
21
21
|
});
|
|
22
22
|
describe('handleLineChartSeriesColors()', () => {
|
|
23
|
-
const colors =
|
|
23
|
+
const colors = colorPaletteDefault.light;
|
|
24
24
|
it('should return custom styled color', () => {
|
|
25
25
|
const series = {
|
|
26
26
|
dataKey: ['test1', 'test2'],
|
|
@@ -47,56 +47,3 @@ describe('handleLineChartSeriesColors()', () => {
|
|
|
47
47
|
expect(res).toStrictEqual(exp);
|
|
48
48
|
});
|
|
49
49
|
});
|
|
50
|
-
describe('handleOverlayName()', () => {
|
|
51
|
-
it('should return default formatted datakey', () => {
|
|
52
|
-
const overlay = {
|
|
53
|
-
dataKey: 'test',
|
|
54
|
-
};
|
|
55
|
-
const res = handleOverlayName(overlay);
|
|
56
|
-
const exp = 'Test';
|
|
57
|
-
expect(res).toStrictEqual(exp);
|
|
58
|
-
});
|
|
59
|
-
it('should return preferred formatted labels', () => {
|
|
60
|
-
const overlay = {
|
|
61
|
-
dataKey: 'test',
|
|
62
|
-
label: 'best',
|
|
63
|
-
};
|
|
64
|
-
const res = handleOverlayName(overlay);
|
|
65
|
-
const exp = 'Best';
|
|
66
|
-
expect(res).toStrictEqual(exp);
|
|
67
|
-
});
|
|
68
|
-
it('should return renamed labels', () => {
|
|
69
|
-
const overlay = {
|
|
70
|
-
dataKey: 'test',
|
|
71
|
-
rename: 'fest',
|
|
72
|
-
};
|
|
73
|
-
const res = handleOverlayName(overlay);
|
|
74
|
-
const exp = 'fest';
|
|
75
|
-
expect(res).toStrictEqual(exp);
|
|
76
|
-
});
|
|
77
|
-
it('should return empty string w/o overlay', () => {
|
|
78
|
-
const res = handleOverlayName(undefined);
|
|
79
|
-
const exp = '';
|
|
80
|
-
expect(res).toStrictEqual(exp);
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
describe('handleLineChartOverlayColor()', () => {
|
|
84
|
-
const colors = defaultLineChartPalette.light.overlay;
|
|
85
|
-
it('should return the default color', () => {
|
|
86
|
-
const overlay = {
|
|
87
|
-
dataKey: 'test',
|
|
88
|
-
};
|
|
89
|
-
const res = handleLineChartOverlayColor(overlay, colors);
|
|
90
|
-
const exp = 'hsl(14 63% 53%)';
|
|
91
|
-
expect(res).toStrictEqual(exp);
|
|
92
|
-
});
|
|
93
|
-
it('should return a custom styled color', () => {
|
|
94
|
-
const overlay = {
|
|
95
|
-
dataKey: 'test',
|
|
96
|
-
style: { stroke: 'salmon' },
|
|
97
|
-
};
|
|
98
|
-
const res = handleLineChartOverlayColor(overlay, colors);
|
|
99
|
-
const exp = 'salmon';
|
|
100
|
-
expect(res).toStrictEqual(exp);
|
|
101
|
-
});
|
|
102
|
-
});
|
|
@@ -2,6 +2,11 @@ import { viewportStyleConfig } from '../style-config';
|
|
|
2
2
|
import { computeAxisProperties } from './axis';
|
|
3
3
|
import { manageViewport } from './viewport';
|
|
4
4
|
describe('manageViewport()', () => {
|
|
5
|
+
const config = {
|
|
6
|
+
hasReversedIndex: false,
|
|
7
|
+
hasMirroredDomainsHorizontal: false,
|
|
8
|
+
hasMirroredDomainsVertical: false,
|
|
9
|
+
};
|
|
5
10
|
it('should return correct number of ticks - horizontal/linear', () => {
|
|
6
11
|
const axis = {
|
|
7
12
|
domain: [0, 1],
|
|
@@ -16,6 +21,7 @@ describe('manageViewport()', () => {
|
|
|
16
21
|
positionRight: 2,
|
|
17
22
|
positionBottom: 3,
|
|
18
23
|
positionLeft: 4,
|
|
24
|
+
config,
|
|
19
25
|
});
|
|
20
26
|
const res = manageViewport(800, 600, cartesian, viewportStyleConfig);
|
|
21
27
|
const exp = { numTicks: 10 };
|
|
@@ -35,6 +41,7 @@ describe('manageViewport()', () => {
|
|
|
35
41
|
positionRight: 2,
|
|
36
42
|
positionBottom: 3,
|
|
37
43
|
positionLeft: 4,
|
|
44
|
+
config,
|
|
38
45
|
});
|
|
39
46
|
const res = manageViewport(800, 600, cartesian, viewportStyleConfig);
|
|
40
47
|
const exp = { numTicks: 2 };
|
|
@@ -55,6 +62,7 @@ describe('manageViewport()', () => {
|
|
|
55
62
|
positionRight: 2,
|
|
56
63
|
positionBottom: 3,
|
|
57
64
|
positionLeft: 4,
|
|
65
|
+
config,
|
|
58
66
|
});
|
|
59
67
|
const res = manageViewport(800, 600, cartesian, viewportStyleConfig);
|
|
60
68
|
const exp = { numTicks: 10 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wonderflow/charts",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.0",
|
|
4
4
|
"description": "Wonderflow's Wanda Design System Charting Library",
|
|
5
5
|
"author": "Wonderflow Design Team",
|
|
6
6
|
"contributors": [
|
|
@@ -62,11 +62,12 @@
|
|
|
62
62
|
"@babel/core": "7.19.3",
|
|
63
63
|
"@babel/preset-typescript": "7.18.6",
|
|
64
64
|
"@types/d3": "7.4.3",
|
|
65
|
+
"@types/lodash": "4.14.202",
|
|
65
66
|
"@types/react": "17.0.43",
|
|
66
67
|
"@types/react-dom": "17.0.14",
|
|
67
68
|
"@types/react-test-renderer": "18.0.7",
|
|
68
69
|
"@types/uuid": "9.0.7",
|
|
69
|
-
"@wonderflow/config": "
|
|
70
|
+
"@wonderflow/config": "13.0.0",
|
|
70
71
|
"babel-loader": "8.2.5",
|
|
71
72
|
"cpy-cli": "3.1.1",
|
|
72
73
|
"postcss": "8.4.32",
|
|
@@ -100,6 +101,7 @@
|
|
|
100
101
|
"d3": "7.8.5",
|
|
101
102
|
"framer-motion": "6.5.1",
|
|
102
103
|
"lodash": "4.17.21",
|
|
104
|
+
"ml-regression-simple-linear": "3.0.0",
|
|
103
105
|
"react-merge-refs": "2.1.1",
|
|
104
106
|
"type-fest": "3.0.0",
|
|
105
107
|
"uuid": "9.0.1"
|