@gravity-ui/chartkit 3.3.0 → 3.4.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/build/plugins/highcharts/renderer/helpers/config/utils/index.js +1 -1
- package/package.json +7 -2
- package/build/libs/chartkit-error/__tests__/chartkit-error.d.ts +0 -1
- package/build/libs/chartkit-error/__tests__/chartkit-error.js +0 -27
- package/build/libs/settings/__tests__/settings.test.d.ts +0 -1
- package/build/libs/settings/__tests__/settings.test.js +0 -17
- package/build/plugins/d3/__stories__/bar-x/category.stories.d.ts +0 -4
- package/build/plugins/d3/__stories__/bar-x/category.stories.js +0 -75
- package/build/plugins/d3/__stories__/bar-x/datetime.stories.d.ts +0 -4
- package/build/plugins/d3/__stories__/bar-x/datetime.stories.js +0 -71
- package/build/plugins/d3/__stories__/bar-x/linear.stories.d.ts +0 -4
- package/build/plugins/d3/__stories__/bar-x/linear.stories.js +0 -78
- package/build/plugins/d3/__stories__/penguins.json +0 -3098
- package/build/plugins/d3/__stories__/scatter/LinearCategories.stories.d.ts +0 -4
- package/build/plugins/d3/__stories__/scatter/LinearCategories.stories.js +0 -100
- package/build/plugins/d3/__stories__/scatter/Timestamp.stories.d.ts +0 -4
- package/build/plugins/d3/__stories__/scatter/Timestamp.stories.js +0 -108
- package/build/plugins/highcharts/__stories__/Line.stories.d.ts +0 -3
- package/build/plugins/highcharts/__stories__/Line.stories.js +0 -12
- package/build/plugins/highcharts/__stories__/Pie.stories.d.ts +0 -3
- package/build/plugins/highcharts/__stories__/Pie.stories.js +0 -12
- package/build/plugins/highcharts/__stories__/area/Range.stories.d.ts +0 -3
- package/build/plugins/highcharts/__stories__/area/Range.stories.js +0 -12
- package/build/plugins/highcharts/__stories__/area/Stacked.stories.d.ts +0 -3
- package/build/plugins/highcharts/__stories__/area/Stacked.stories.js +0 -12
- package/build/plugins/highcharts/__stories__/column/HorizontalStacked.stories.d.ts +0 -3
- package/build/plugins/highcharts/__stories__/column/HorizontalStacked.stories.js +0 -12
- package/build/plugins/highcharts/__stories__/column/Vertical.stories.d.ts +0 -3
- package/build/plugins/highcharts/__stories__/column/Vertical.stories.js +0 -12
- package/build/plugins/highcharts/__stories__/column/VerticalStacked.stories.d.ts +0 -3
- package/build/plugins/highcharts/__stories__/column/VerticalStacked.stories.js +0 -12
- package/build/plugins/highcharts/__stories__/combined/ComboChartWithSameLegendValues.stories.d.ts +0 -3
- package/build/plugins/highcharts/__stories__/combined/ComboChartWithSameLegendValues.stories.js +0 -12
- package/build/plugins/highcharts/__stories__/complex/TwoAxis.stories.d.ts +0 -3
- package/build/plugins/highcharts/__stories__/complex/TwoAxis.stories.js +0 -12
- package/build/plugins/highcharts/__stories__/components/ChartStory.d.ts +0 -12
- package/build/plugins/highcharts/__stories__/components/ChartStory.js +0 -28
- package/build/plugins/highcharts/__stories__/constants/story-settings.d.ts +0 -42
- package/build/plugins/highcharts/__stories__/constants/story-settings.js +0 -42
- package/build/plugins/highcharts/__stories__/custom-error-render/custom-error-render.stories.d.ts +0 -3
- package/build/plugins/highcharts/__stories__/custom-error-render/custom-error-render.stories.js +0 -41
- package/build/plugins/highcharts/__stories__/no-data/no-data.stories.d.ts +0 -3
- package/build/plugins/highcharts/__stories__/no-data/no-data.stories.js +0 -20
- package/build/plugins/highcharts/__stories__/pie/WithTotals.stories.d.ts +0 -3
- package/build/plugins/highcharts/__stories__/pie/WithTotals.stories.js +0 -12
- package/build/plugins/highcharts/__tests__/prepare-data.test.d.ts +0 -1
- package/build/plugins/highcharts/__tests__/prepare-data.test.js +0 -13
- package/build/plugins/indicator/__stories__/Indicator.stories.d.ts +0 -4
- package/build/plugins/indicator/__stories__/Indicator.stories.js +0 -45
- package/build/plugins/yagr/__stories__/Yagr.stories.d.ts +0 -6
- package/build/plugins/yagr/__stories__/Yagr.stories.js +0 -90
- package/build/plugins/yagr/__stories__/mocks/line10.d.ts +0 -53
- package/build/plugins/yagr/__stories__/mocks/line10.js +0 -78
- package/build/plugins/yagr/__tests__/utils.test.d.ts +0 -1
- package/build/plugins/yagr/__tests__/utils.test.js +0 -26
- package/build/utils/__tests__/common.test.d.ts +0 -1
- package/build/utils/__tests__/common.test.js +0 -9
|
@@ -13,7 +13,7 @@ export { mergeArrayWithObject } from './mergeArrayWithObject';
|
|
|
13
13
|
export { numberFormat } from './numberFormat';
|
|
14
14
|
export { setNavigatorDefaultPeriod } from './setNavigatorDefaultPeriod';
|
|
15
15
|
export const getSortedData = (data, sort = {}) => {
|
|
16
|
-
const { enabled =
|
|
16
|
+
const { enabled = false, order = 'desc', iteratee = 'y' } = sort;
|
|
17
17
|
if (!enabled) {
|
|
18
18
|
return [...data];
|
|
19
19
|
}
|
package/package.json
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravity-ui/chartkit",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "React component used to render charts based on any sources you need",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "git@github.com:gravity-ui/ChartKit.git",
|
|
7
7
|
"main": "build/index.js",
|
|
8
8
|
"typings": "build/index.d.ts",
|
|
9
9
|
"files": [
|
|
10
|
-
"build"
|
|
10
|
+
"build",
|
|
11
|
+
"!**/__tests__/**",
|
|
12
|
+
"!**/__stories__/**"
|
|
11
13
|
],
|
|
12
14
|
"publishConfig": {
|
|
13
15
|
"access": "public"
|
|
14
16
|
},
|
|
17
|
+
"sideEffects": [
|
|
18
|
+
"*.css"
|
|
19
|
+
],
|
|
15
20
|
"dependencies": {
|
|
16
21
|
"@gravity-ui/date-utils": "^1.4.1",
|
|
17
22
|
"@gravity-ui/yagr": "^3.7.8",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { CHARTKIT_ERROR_CODE, ChartKitError, isChartKitError } from '../chartkit-error';
|
|
2
|
-
describe('libs/chartkit-error', () => {
|
|
3
|
-
test.each([
|
|
4
|
-
[new ChartKitError(), true],
|
|
5
|
-
[new Error(), false],
|
|
6
|
-
[null, false],
|
|
7
|
-
[undefined, false],
|
|
8
|
-
])('isChartKitError (args: %j)', (error, expected) => {
|
|
9
|
-
const result = isChartKitError(error);
|
|
10
|
-
expect(result).toEqual(expected);
|
|
11
|
-
});
|
|
12
|
-
test.each([
|
|
13
|
-
[undefined, CHARTKIT_ERROR_CODE.UNKNOWN],
|
|
14
|
-
[{ code: CHARTKIT_ERROR_CODE.NO_DATA }, CHARTKIT_ERROR_CODE.NO_DATA],
|
|
15
|
-
])('check ChartKitError code (args: %j)', (args, expected) => {
|
|
16
|
-
let result = '';
|
|
17
|
-
try {
|
|
18
|
-
throw new ChartKitError(args);
|
|
19
|
-
}
|
|
20
|
-
catch (error) {
|
|
21
|
-
if (isChartKitError(error)) {
|
|
22
|
-
result = error.code;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
expect(result).toEqual(expected);
|
|
26
|
-
});
|
|
27
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { settings } from '../settings';
|
|
2
|
-
const resetSettings = () => settings.set({ lang: 'en' });
|
|
3
|
-
describe('libs/settings', () => {
|
|
4
|
-
it('Default lang should be equal to en', () => {
|
|
5
|
-
const result = settings.get('lang');
|
|
6
|
-
expect(result).toBe('en');
|
|
7
|
-
});
|
|
8
|
-
it('Changed lang should be equal to ru', () => {
|
|
9
|
-
settings.set({
|
|
10
|
-
lang: 'ru',
|
|
11
|
-
});
|
|
12
|
-
const result = settings.get('lang');
|
|
13
|
-
expect(result).toBe('ru');
|
|
14
|
-
});
|
|
15
|
-
beforeAll(resetSettings);
|
|
16
|
-
afterEach(resetSettings);
|
|
17
|
-
});
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { object, withKnobs } from '@storybook/addon-knobs';
|
|
3
|
-
import { Button } from '@gravity-ui/uikit';
|
|
4
|
-
import { settings } from '../../../../libs';
|
|
5
|
-
import { ChartKit } from '../../../../components/ChartKit';
|
|
6
|
-
import { D3Plugin } from '../..';
|
|
7
|
-
const Template = () => {
|
|
8
|
-
const [shown, setShown] = React.useState(false);
|
|
9
|
-
const chartkitRef = React.useRef();
|
|
10
|
-
const data = {
|
|
11
|
-
legend: { enabled: true },
|
|
12
|
-
tooltip: { enabled: false },
|
|
13
|
-
yAxis: [
|
|
14
|
-
{
|
|
15
|
-
type: 'linear',
|
|
16
|
-
labels: { enabled: true },
|
|
17
|
-
min: 0,
|
|
18
|
-
},
|
|
19
|
-
],
|
|
20
|
-
series: {
|
|
21
|
-
data: [
|
|
22
|
-
{
|
|
23
|
-
type: 'bar-x',
|
|
24
|
-
visible: true,
|
|
25
|
-
data: [
|
|
26
|
-
{
|
|
27
|
-
category: 'A',
|
|
28
|
-
x: 10,
|
|
29
|
-
y: 100,
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
category: 'B',
|
|
33
|
-
x: 12,
|
|
34
|
-
y: 80,
|
|
35
|
-
},
|
|
36
|
-
],
|
|
37
|
-
name: 'AB',
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
type: 'bar-x',
|
|
41
|
-
visible: true,
|
|
42
|
-
data: [
|
|
43
|
-
{
|
|
44
|
-
category: 'C',
|
|
45
|
-
x: 95.5,
|
|
46
|
-
y: 120,
|
|
47
|
-
},
|
|
48
|
-
],
|
|
49
|
-
name: 'C',
|
|
50
|
-
},
|
|
51
|
-
],
|
|
52
|
-
},
|
|
53
|
-
title: { text: 'Category axis' },
|
|
54
|
-
xAxis: {
|
|
55
|
-
type: 'category',
|
|
56
|
-
categories: ['A', 'B', 'C'],
|
|
57
|
-
labels: { enabled: true },
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
if (!shown) {
|
|
61
|
-
settings.set({ plugins: [D3Plugin] });
|
|
62
|
-
return React.createElement(Button, { onClick: () => setShown(true) }, "Show chart");
|
|
63
|
-
}
|
|
64
|
-
return (React.createElement("div", { style: {
|
|
65
|
-
height: '80vh',
|
|
66
|
-
width: '100%',
|
|
67
|
-
} },
|
|
68
|
-
React.createElement(ChartKit, { ref: chartkitRef, type: "d3", data: object('data', data) })));
|
|
69
|
-
};
|
|
70
|
-
export const CategoryXAxis = Template.bind({});
|
|
71
|
-
const meta = {
|
|
72
|
-
title: 'Plugins/D3/Bar-X',
|
|
73
|
-
decorators: [withKnobs],
|
|
74
|
-
};
|
|
75
|
-
export default meta;
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { object, withKnobs } from '@storybook/addon-knobs';
|
|
3
|
-
import { Button } from '@gravity-ui/uikit';
|
|
4
|
-
import { settings } from '../../../../libs';
|
|
5
|
-
import { ChartKit } from '../../../../components/ChartKit';
|
|
6
|
-
import { D3Plugin } from '../..';
|
|
7
|
-
const Template = () => {
|
|
8
|
-
const [shown, setShown] = React.useState(false);
|
|
9
|
-
const chartkitRef = React.useRef();
|
|
10
|
-
const data = {
|
|
11
|
-
title: { text: 'DateTime axis' },
|
|
12
|
-
xAxis: {
|
|
13
|
-
type: 'datetime',
|
|
14
|
-
labels: { enabled: true },
|
|
15
|
-
},
|
|
16
|
-
legend: { enabled: true },
|
|
17
|
-
tooltip: { enabled: false },
|
|
18
|
-
yAxis: [
|
|
19
|
-
{
|
|
20
|
-
type: 'linear',
|
|
21
|
-
labels: { enabled: true },
|
|
22
|
-
min: 0,
|
|
23
|
-
},
|
|
24
|
-
],
|
|
25
|
-
series: {
|
|
26
|
-
data: [
|
|
27
|
-
{
|
|
28
|
-
type: 'bar-x',
|
|
29
|
-
visible: true,
|
|
30
|
-
data: [
|
|
31
|
-
{
|
|
32
|
-
x: Number(new Date(2022, 10, 10)),
|
|
33
|
-
y: 100,
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
x: Number(new Date(2023, 2, 5)),
|
|
37
|
-
y: 80,
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
name: 'AB',
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
type: 'bar-x',
|
|
44
|
-
visible: true,
|
|
45
|
-
data: [
|
|
46
|
-
{
|
|
47
|
-
x: Number(new Date(2022, 11, 25)),
|
|
48
|
-
y: 120,
|
|
49
|
-
},
|
|
50
|
-
],
|
|
51
|
-
name: 'C',
|
|
52
|
-
},
|
|
53
|
-
],
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
if (!shown) {
|
|
57
|
-
settings.set({ plugins: [D3Plugin] });
|
|
58
|
-
return React.createElement(Button, { onClick: () => setShown(true) }, "Show chart");
|
|
59
|
-
}
|
|
60
|
-
return (React.createElement("div", { style: {
|
|
61
|
-
height: '80vh',
|
|
62
|
-
width: '100%',
|
|
63
|
-
} },
|
|
64
|
-
React.createElement(ChartKit, { ref: chartkitRef, type: "d3", data: object('data', data) })));
|
|
65
|
-
};
|
|
66
|
-
export const DatetimeXAxis = Template.bind({});
|
|
67
|
-
const meta = {
|
|
68
|
-
title: 'Plugins/D3/Bar-X',
|
|
69
|
-
decorators: [withKnobs],
|
|
70
|
-
};
|
|
71
|
-
export default meta;
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { withKnobs, object } from '@storybook/addon-knobs';
|
|
3
|
-
import { Button } from '@gravity-ui/uikit';
|
|
4
|
-
import { settings } from '../../../../libs';
|
|
5
|
-
import { ChartKit } from '../../../../components/ChartKit';
|
|
6
|
-
import { D3Plugin } from '../..';
|
|
7
|
-
const Template = () => {
|
|
8
|
-
const [shown, setShown] = React.useState(false);
|
|
9
|
-
const chartkitRef = React.useRef();
|
|
10
|
-
const data = {
|
|
11
|
-
series: {
|
|
12
|
-
data: [
|
|
13
|
-
{
|
|
14
|
-
type: 'bar-x',
|
|
15
|
-
visible: true,
|
|
16
|
-
data: [
|
|
17
|
-
{
|
|
18
|
-
category: 'A',
|
|
19
|
-
x: 10,
|
|
20
|
-
y: 100,
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
category: 'B',
|
|
24
|
-
x: 12,
|
|
25
|
-
y: 80,
|
|
26
|
-
},
|
|
27
|
-
],
|
|
28
|
-
name: 'AB',
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
type: 'bar-x',
|
|
32
|
-
visible: true,
|
|
33
|
-
data: [
|
|
34
|
-
{
|
|
35
|
-
category: 'C',
|
|
36
|
-
x: 95.5,
|
|
37
|
-
y: 120,
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
name: 'C',
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
},
|
|
44
|
-
title: { text: 'Linear axis' },
|
|
45
|
-
xAxis: {
|
|
46
|
-
min: 0,
|
|
47
|
-
type: 'linear',
|
|
48
|
-
labels: { enabled: true },
|
|
49
|
-
},
|
|
50
|
-
yAxis: [
|
|
51
|
-
{
|
|
52
|
-
type: 'linear',
|
|
53
|
-
labels: { enabled: true },
|
|
54
|
-
min: 0,
|
|
55
|
-
ticks: {
|
|
56
|
-
pixelInterval: 100,
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
],
|
|
60
|
-
legend: { enabled: true },
|
|
61
|
-
tooltip: { enabled: false },
|
|
62
|
-
};
|
|
63
|
-
if (!shown) {
|
|
64
|
-
settings.set({ plugins: [D3Plugin] });
|
|
65
|
-
return React.createElement(Button, { onClick: () => setShown(true) }, "Show chart");
|
|
66
|
-
}
|
|
67
|
-
return (React.createElement("div", { style: {
|
|
68
|
-
height: '80vh',
|
|
69
|
-
width: '100%',
|
|
70
|
-
} },
|
|
71
|
-
React.createElement(ChartKit, { ref: chartkitRef, type: "d3", data: object('data', data) })));
|
|
72
|
-
};
|
|
73
|
-
export const LinearXAxis = Template.bind({});
|
|
74
|
-
const meta = {
|
|
75
|
-
title: 'Plugins/D3/Bar-X',
|
|
76
|
-
decorators: [withKnobs],
|
|
77
|
-
};
|
|
78
|
-
export default meta;
|