@gravity-ui/chartkit 3.2.0-beta.1 → 3.2.0-beta.2

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.
Files changed (56) hide show
  1. package/package.json +4 -2
  2. package/build/libs/chartkit-error/__tests__/chartkit-error.d.ts +0 -1
  3. package/build/libs/chartkit-error/__tests__/chartkit-error.js +0 -27
  4. package/build/libs/settings/__tests__/settings.test.d.ts +0 -1
  5. package/build/libs/settings/__tests__/settings.test.js +0 -17
  6. package/build/plugins/d3/__stories__/bar/category.stories.d.ts +0 -4
  7. package/build/plugins/d3/__stories__/bar/category.stories.js +0 -75
  8. package/build/plugins/d3/__stories__/bar/datetime.stories.d.ts +0 -4
  9. package/build/plugins/d3/__stories__/bar/datetime.stories.js +0 -71
  10. package/build/plugins/d3/__stories__/bar/linear.stories.d.ts +0 -4
  11. package/build/plugins/d3/__stories__/bar/linear.stories.js +0 -74
  12. package/build/plugins/d3/__stories__/penguins.json +0 -3098
  13. package/build/plugins/d3/__stories__/scatter/LinearCategories.stories.d.ts +0 -4
  14. package/build/plugins/d3/__stories__/scatter/LinearCategories.stories.js +0 -103
  15. package/build/plugins/d3/__stories__/scatter/Timestamp.stories.d.ts +0 -4
  16. package/build/plugins/d3/__stories__/scatter/Timestamp.stories.js +0 -91
  17. package/build/plugins/highcharts/__stories__/Line.stories.d.ts +0 -3
  18. package/build/plugins/highcharts/__stories__/Line.stories.js +0 -12
  19. package/build/plugins/highcharts/__stories__/Pie.stories.d.ts +0 -3
  20. package/build/plugins/highcharts/__stories__/Pie.stories.js +0 -12
  21. package/build/plugins/highcharts/__stories__/area/Range.stories.d.ts +0 -3
  22. package/build/plugins/highcharts/__stories__/area/Range.stories.js +0 -12
  23. package/build/plugins/highcharts/__stories__/area/Stacked.stories.d.ts +0 -3
  24. package/build/plugins/highcharts/__stories__/area/Stacked.stories.js +0 -12
  25. package/build/plugins/highcharts/__stories__/column/HorizontalStacked.stories.d.ts +0 -3
  26. package/build/plugins/highcharts/__stories__/column/HorizontalStacked.stories.js +0 -12
  27. package/build/plugins/highcharts/__stories__/column/Vertical.stories.d.ts +0 -3
  28. package/build/plugins/highcharts/__stories__/column/Vertical.stories.js +0 -12
  29. package/build/plugins/highcharts/__stories__/column/VerticalStacked.stories.d.ts +0 -3
  30. package/build/plugins/highcharts/__stories__/column/VerticalStacked.stories.js +0 -12
  31. package/build/plugins/highcharts/__stories__/combined/ComboChartWithSameLegendValues.stories.d.ts +0 -3
  32. package/build/plugins/highcharts/__stories__/combined/ComboChartWithSameLegendValues.stories.js +0 -12
  33. package/build/plugins/highcharts/__stories__/complex/TwoAxis.stories.d.ts +0 -3
  34. package/build/plugins/highcharts/__stories__/complex/TwoAxis.stories.js +0 -12
  35. package/build/plugins/highcharts/__stories__/components/ChartStory.d.ts +0 -12
  36. package/build/plugins/highcharts/__stories__/components/ChartStory.js +0 -28
  37. package/build/plugins/highcharts/__stories__/constants/story-settings.d.ts +0 -42
  38. package/build/plugins/highcharts/__stories__/constants/story-settings.js +0 -42
  39. package/build/plugins/highcharts/__stories__/custom-error-render/custom-error-render.stories.d.ts +0 -3
  40. package/build/plugins/highcharts/__stories__/custom-error-render/custom-error-render.stories.js +0 -41
  41. package/build/plugins/highcharts/__stories__/no-data/no-data.stories.d.ts +0 -3
  42. package/build/plugins/highcharts/__stories__/no-data/no-data.stories.js +0 -20
  43. package/build/plugins/highcharts/__stories__/pie/WithTotals.stories.d.ts +0 -3
  44. package/build/plugins/highcharts/__stories__/pie/WithTotals.stories.js +0 -12
  45. package/build/plugins/highcharts/__tests__/prepare-data.test.d.ts +0 -1
  46. package/build/plugins/highcharts/__tests__/prepare-data.test.js +0 -13
  47. package/build/plugins/indicator/__stories__/Indicator.stories.d.ts +0 -4
  48. package/build/plugins/indicator/__stories__/Indicator.stories.js +0 -45
  49. package/build/plugins/yagr/__stories__/Yagr.stories.d.ts +0 -6
  50. package/build/plugins/yagr/__stories__/Yagr.stories.js +0 -90
  51. package/build/plugins/yagr/__stories__/mocks/line10.d.ts +0 -53
  52. package/build/plugins/yagr/__stories__/mocks/line10.js +0 -78
  53. package/build/plugins/yagr/__tests__/utils.test.d.ts +0 -1
  54. package/build/plugins/yagr/__tests__/utils.test.js +0 -26
  55. package/build/utils/__tests__/common.test.d.ts +0 -1
  56. package/build/utils/__tests__/common.test.js +0 -9
@@ -1,4 +0,0 @@
1
- import { Meta } from '@storybook/react';
2
- export declare const LinearAndCategories: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
3
- declare const meta: Meta;
4
- export default meta;
@@ -1,103 +0,0 @@
1
- import React from 'react';
2
- import random from 'lodash/random';
3
- import { withKnobs, select, radios, text } from '@storybook/addon-knobs';
4
- import { Button } from '@gravity-ui/uikit';
5
- import { settings } from '../../../../libs';
6
- import { ChartKit } from '../../../../components/ChartKit';
7
- import { D3Plugin } from '../..';
8
- import penguins from '../penguins.json';
9
- const shapeScatterSeriesData = (args) => {
10
- const { data, groupBy, map } = args;
11
- return data.reduce((acc, d) => {
12
- const seriesName = d[groupBy];
13
- if (!seriesName) {
14
- return acc;
15
- }
16
- if (!acc[seriesName]) {
17
- acc[seriesName] = [];
18
- }
19
- acc[seriesName].push(Object.assign({ x: d[map.x], y: d[map.y], radius: random(3, 6) }, (map.category && { category: d[map.category] })));
20
- return acc;
21
- }, {});
22
- };
23
- const shapeScatterSeries = (data) => {
24
- return Object.keys(data).reduce((acc, name) => {
25
- acc.push({
26
- type: 'scatter',
27
- data: data[name],
28
- name,
29
- });
30
- return acc;
31
- }, []);
32
- };
33
- const shapeScatterChartData = (series, categoriesType, categories) => {
34
- let xAxis = {
35
- labels: {
36
- enabled: false,
37
- },
38
- title: {
39
- text: text('X axis title', ''),
40
- },
41
- };
42
- let yAxis = {
43
- title: {
44
- text: text('Y axis title', ''),
45
- },
46
- };
47
- if (categories && categoriesType === 'x') {
48
- xAxis = Object.assign(Object.assign({}, xAxis), { type: 'category', categories });
49
- }
50
- if (categories && categoriesType === 'y') {
51
- yAxis = Object.assign(Object.assign({}, yAxis), { type: 'category', categories });
52
- }
53
- return {
54
- series: {
55
- data: series,
56
- },
57
- xAxis,
58
- yAxis: [yAxis],
59
- title: {
60
- text: text('title', 'Chart title'),
61
- },
62
- };
63
- };
64
- const Template = () => {
65
- const [shown, setShown] = React.useState(false);
66
- const chartkitRef = React.useRef();
67
- const x = select('x', ['culmen_length_mm', 'culmen_depth_mm', 'flipper_length_mm', 'body_mass_g'], 'culmen_length_mm');
68
- const y = select('y', ['culmen_length_mm', 'culmen_depth_mm', 'flipper_length_mm', 'body_mass_g'], 'culmen_depth_mm');
69
- const groupBy = select('groupBy', ['species', 'island', 'sex'], 'species');
70
- const categoriesType = radios('categoriesType', { none: 'none', x: 'x', y: 'y' }, 'none');
71
- const category = categoriesType === 'none'
72
- ? undefined
73
- : select('category', ['species', 'island', 'sex'], 'island');
74
- let categories;
75
- if (categoriesType !== 'none' && category) {
76
- categories = penguins.reduce((acc, p) => {
77
- const cerrentCategory = p[category];
78
- if (typeof cerrentCategory === 'string' && !acc.includes(cerrentCategory)) {
79
- acc.push(cerrentCategory);
80
- }
81
- return acc;
82
- }, []);
83
- }
84
- const shapedScatterSeriesData = shapeScatterSeriesData({
85
- data: penguins,
86
- groupBy,
87
- map: { x, y, category },
88
- });
89
- const shapedScatterSeries = shapeScatterSeries(shapedScatterSeriesData);
90
- const data = shapeScatterChartData(shapedScatterSeries, categoriesType, categories);
91
- if (!shown) {
92
- settings.set({ plugins: [D3Plugin] });
93
- return React.createElement(Button, { onClick: () => setShown(true) }, "Show chart");
94
- }
95
- return (React.createElement("div", { style: { height: '80vh', width: '100%' } },
96
- React.createElement(ChartKit, { ref: chartkitRef, type: "d3", data: data })));
97
- };
98
- export const LinearAndCategories = Template.bind({});
99
- const meta = {
100
- title: 'Plugins/D3/Scatter',
101
- decorators: [withKnobs],
102
- };
103
- export default meta;
@@ -1,4 +0,0 @@
1
- import { Meta } from '@storybook/react';
2
- export declare const Timestamp: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
3
- declare const meta: Meta;
4
- export default meta;
@@ -1,91 +0,0 @@
1
- import React from 'react';
2
- import random from 'lodash/random';
3
- import { dateTime } from '@gravity-ui/date-utils';
4
- import { Button } from '@gravity-ui/uikit';
5
- import { settings } from '../../../../libs';
6
- import { ChartKit } from '../../../../components/ChartKit';
7
- import { D3Plugin } from '../..';
8
- const rowData = [
9
- {
10
- x: 1690686000000,
11
- y: 86.71905594602345,
12
- custom: 'green',
13
- },
14
- {
15
- x: 1690426800000,
16
- y: 86.73089353359981,
17
- custom: 'yellow',
18
- },
19
- {
20
- x: 1690254000000,
21
- y: 86.53675705168267,
22
- custom: 'red',
23
- },
24
- {
25
- x: 1690772400000,
26
- y: 86.47880981408552,
27
- custom: 'blue',
28
- },
29
- {
30
- x: 1690340400000,
31
- y: 86.4108836764148,
32
- custom: 'gray',
33
- },
34
- {
35
- x: 1690599600000,
36
- y: 86.73440096266042,
37
- custom: 'pink',
38
- },
39
- {
40
- x: 1690513200000,
41
- y: 86.64935929597681,
42
- custom: 'purple',
43
- },
44
- ];
45
- const shapeData = (data) => {
46
- const scatterData = data.map((d) => ({
47
- x: d.x,
48
- y: d.y,
49
- radius: random(3, 6),
50
- custom: d.custom,
51
- }));
52
- const scatterSeries = {
53
- type: 'scatter',
54
- data: scatterData,
55
- name: 'some-name',
56
- };
57
- return {
58
- series: {
59
- data: [scatterSeries],
60
- },
61
- xAxis: {
62
- type: 'datetime',
63
- timestamps: data.map((d) => d.x),
64
- },
65
- tooltip: {
66
- renderer: ({ hovered }) => {
67
- const d = hovered.data;
68
- return React.createElement("div", { style: { color: d.custom } }, dateTime({ input: d.x }).format('LL'));
69
- },
70
- },
71
- title: {
72
- text: 'Chart title',
73
- },
74
- };
75
- };
76
- const Template = () => {
77
- const [shown, setShown] = React.useState(false);
78
- const chartkitRef = React.useRef();
79
- const data = shapeData(rowData);
80
- if (!shown) {
81
- settings.set({ plugins: [D3Plugin] });
82
- return React.createElement(Button, { onClick: () => setShown(true) }, "Show chart");
83
- }
84
- return (React.createElement("div", { style: { height: '300px', width: '100%' } },
85
- React.createElement(ChartKit, { ref: chartkitRef, type: "d3", data: data })));
86
- };
87
- export const Timestamp = Template.bind({});
88
- const meta = {
89
- title: 'Plugins/D3/Scatter',
90
- };
91
- export default meta;
@@ -1,3 +0,0 @@
1
- declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
2
- export default _default;
3
- export declare const Line: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, any>;
@@ -1,12 +0,0 @@
1
- import React from 'react';
2
- import { ChartKit } from '../../../components/ChartKit';
3
- import { data } from '../mocks/line';
4
- import { ChartStory } from './components/ChartStory';
5
- export default {
6
- title: 'Plugins/Highcharts/Line',
7
- component: ChartKit,
8
- };
9
- const Template = () => {
10
- return React.createElement(ChartStory, { data: data });
11
- };
12
- export const Line = Template.bind({});
@@ -1,3 +0,0 @@
1
- declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
2
- export default _default;
3
- export declare const Pie: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, any>;
@@ -1,12 +0,0 @@
1
- import React from 'react';
2
- import { ChartKit } from '../../../components/ChartKit';
3
- import { data } from '../mocks/pie';
4
- import { ChartStory } from './components/ChartStory';
5
- export default {
6
- title: 'Plugins/Highcharts/Pie',
7
- component: ChartKit,
8
- };
9
- const Template = () => {
10
- return React.createElement(ChartStory, { data: data });
11
- };
12
- export const Pie = Template.bind({});
@@ -1,3 +0,0 @@
1
- declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
2
- export default _default;
3
- export declare const AreaRange: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, any>;
@@ -1,12 +0,0 @@
1
- import React from 'react';
2
- import { ChartKit } from '../../../../components/ChartKit';
3
- import { data } from '../../mocks/area-range';
4
- import { ChartStory } from '../components/ChartStory';
5
- export default {
6
- title: 'Plugins/Highcharts/Area',
7
- component: ChartKit,
8
- };
9
- const Template = () => {
10
- return React.createElement(ChartStory, { data: data });
11
- };
12
- export const AreaRange = Template.bind({});
@@ -1,3 +0,0 @@
1
- declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
2
- export default _default;
3
- export declare const AreaStacked: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, any>;
@@ -1,12 +0,0 @@
1
- import React from 'react';
2
- import { ChartKit } from '../../../../components/ChartKit';
3
- import { data } from '../../mocks/area-stacked';
4
- import { ChartStory } from '../components/ChartStory';
5
- export default {
6
- title: 'Plugins/Highcharts/Area',
7
- component: ChartKit,
8
- };
9
- const Template = () => {
10
- return React.createElement(ChartStory, { data: data, height: "500px" });
11
- };
12
- export const AreaStacked = Template.bind({});
@@ -1,3 +0,0 @@
1
- declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
2
- export default _default;
3
- export declare const HorizontalStacked: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, any>;
@@ -1,12 +0,0 @@
1
- import React from 'react';
2
- import { ChartKit } from '../../../../components/ChartKit';
3
- import { data } from '../../mocks/column-hor-stacked';
4
- import { ChartStory } from '../components/ChartStory';
5
- export default {
6
- title: 'Plugins/Highcharts/Column',
7
- component: ChartKit,
8
- };
9
- const Template = () => {
10
- return React.createElement(ChartStory, { data: data });
11
- };
12
- export const HorizontalStacked = Template.bind({});
@@ -1,3 +0,0 @@
1
- declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
2
- export default _default;
3
- export declare const Vertical: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, any>;
@@ -1,12 +0,0 @@
1
- import React from 'react';
2
- import { ChartKit } from '../../../../components/ChartKit';
3
- import { data } from '../../mocks/column-ver';
4
- import { ChartStory } from '../components/ChartStory';
5
- export default {
6
- title: 'Plugins/Highcharts/Column',
7
- component: ChartKit,
8
- };
9
- const Template = () => {
10
- return React.createElement(ChartStory, { data: data });
11
- };
12
- export const Vertical = Template.bind({});
@@ -1,3 +0,0 @@
1
- declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
2
- export default _default;
3
- export declare const VerticalStacked: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, any>;
@@ -1,12 +0,0 @@
1
- import React from 'react';
2
- import { ChartKit } from '../../../../components/ChartKit';
3
- import { data } from '../../mocks/column-ver-stacked';
4
- import { ChartStory } from '../components/ChartStory';
5
- export default {
6
- title: 'Plugins/Highcharts/Column',
7
- component: ChartKit,
8
- };
9
- const Template = () => {
10
- return React.createElement(ChartStory, { data: data });
11
- };
12
- export const VerticalStacked = Template.bind({});
@@ -1,3 +0,0 @@
1
- declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
2
- export default _default;
3
- export declare const ComboChart: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, any>;
@@ -1,12 +0,0 @@
1
- import React from 'react';
2
- import { ChartKit } from '../../../../components/ChartKit';
3
- import { data } from '../../mocks/combo-chart-with-same-legend-titles';
4
- import { ChartStory } from '../components/ChartStory';
5
- export default {
6
- title: 'Plugins/Highcharts/Combined Charts',
7
- component: ChartKit,
8
- };
9
- const Template = () => {
10
- return React.createElement(ChartStory, { height: "500px", data: data });
11
- };
12
- export const ComboChart = Template.bind({});
@@ -1,3 +0,0 @@
1
- declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
2
- export default _default;
3
- export declare const TwoAxis: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
@@ -1,12 +0,0 @@
1
- import React from 'react';
2
- import { ChartKit } from '../../../../components/ChartKit';
3
- import { ChartStory } from '../components/ChartStory';
4
- import { data } from '../../mocks/complex';
5
- export default {
6
- title: 'Plugins/Highcharts/TwoAxis',
7
- component: ChartKit,
8
- };
9
- const Template = () => {
10
- return React.createElement(ChartStory, { data: data, height: "500px" });
11
- };
12
- export const TwoAxis = Template.bind({});
@@ -1,12 +0,0 @@
1
- import React from 'react';
2
- import { RenderError } from '../../../../types';
3
- import { HighchartsWidgetData } from '../../types';
4
- export type ChartStoryProps = {
5
- data: HighchartsWidgetData;
6
- withoutPlugin?: boolean;
7
- visible?: boolean;
8
- height?: string;
9
- width?: string;
10
- renderError?: RenderError;
11
- };
12
- export declare const ChartStory: React.FC<ChartStoryProps>;
@@ -1,28 +0,0 @@
1
- import React from 'react';
2
- import { Button } from '@gravity-ui/uikit';
3
- import { settings } from '../../../../libs';
4
- import { HighchartsPlugin } from '../../index';
5
- import holidays from '../../mocks/holidays';
6
- import { ChartKit } from '../../../../components/ChartKit';
7
- const DEFAULT_STORY_HEIGHT = '300px';
8
- const DEFAULT_STORY_WIDTH = '100%';
9
- export const ChartStory = (props) => {
10
- const { height, width, data } = props;
11
- const initRef = React.useRef(false);
12
- const [visible, setVisible] = React.useState(Boolean(props.visible));
13
- const chartKitRef = React.useRef();
14
- if (!initRef.current) {
15
- if (!props.withoutPlugin) {
16
- settings.set({ plugins: [HighchartsPlugin], extra: { holidays } });
17
- }
18
- initRef.current = true;
19
- }
20
- if (!visible) {
21
- return React.createElement(Button, { onClick: () => setVisible(true) }, "Show chart");
22
- }
23
- return (React.createElement("div", { style: {
24
- height: height || DEFAULT_STORY_HEIGHT,
25
- width: width || DEFAULT_STORY_WIDTH,
26
- } },
27
- React.createElement(ChartKit, { ref: chartKitRef, type: "highcharts", data: data, renderError: props.renderError })));
28
- };
@@ -1,42 +0,0 @@
1
- export declare const defaultChartKitPropsControlsState: {
2
- ref: {
3
- table: {
4
- disable: boolean;
5
- };
6
- };
7
- hoistConfigError: {
8
- table: {
9
- disable: boolean;
10
- };
11
- };
12
- onError: {
13
- table: {
14
- disable: boolean;
15
- };
16
- };
17
- data: {
18
- table: {
19
- disable: boolean;
20
- };
21
- };
22
- type: {
23
- table: {
24
- disable: boolean;
25
- };
26
- };
27
- id: {
28
- table: {
29
- disable: boolean;
30
- };
31
- };
32
- isMobile: {
33
- table: {
34
- disable: boolean;
35
- };
36
- };
37
- onLoad: {
38
- table: {
39
- disable: boolean;
40
- };
41
- };
42
- };
@@ -1,42 +0,0 @@
1
- export const defaultChartKitPropsControlsState = {
2
- ref: {
3
- table: {
4
- disable: true,
5
- },
6
- },
7
- hoistConfigError: {
8
- table: {
9
- disable: true,
10
- },
11
- },
12
- onError: {
13
- table: {
14
- disable: true,
15
- },
16
- },
17
- data: {
18
- table: {
19
- disable: true,
20
- },
21
- },
22
- type: {
23
- table: {
24
- disable: true,
25
- },
26
- },
27
- id: {
28
- table: {
29
- disable: true,
30
- },
31
- },
32
- isMobile: {
33
- table: {
34
- disable: true,
35
- },
36
- },
37
- onLoad: {
38
- table: {
39
- disable: true,
40
- },
41
- },
42
- };
@@ -1,3 +0,0 @@
1
- declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
2
- export default _default;
3
- export declare const CustomErrorRender: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
@@ -1,41 +0,0 @@
1
- import React from 'react';
2
- import { ChartKit } from '../../../../components/ChartKit';
3
- import { ChartStory } from '../components/ChartStory';
4
- import { Button } from '@gravity-ui/uikit';
5
- import { CHARTKIT_ERROR_CODE, settings } from '../../../../libs';
6
- import { HighchartsPlugin } from '../../index';
7
- import holidays from '../../mocks/holidays';
8
- import { noData, filledData } from '../../mocks/custom-error-render';
9
- export default {
10
- title: 'Plugins/Highcharts/CustomErrorRender',
11
- component: ChartKit,
12
- };
13
- const Template = () => {
14
- const [data, setData] = React.useState(noData);
15
- const renderErrorView = React.useCallback(({ error, message, resetError }) => {
16
- function renderFixButton() {
17
- if (!('code' in error)) {
18
- return null;
19
- }
20
- switch (error.code) {
21
- case CHARTKIT_ERROR_CODE.UNKNOWN_PLUGIN:
22
- return (React.createElement(Button, { onClick: () => {
23
- settings.set({ plugins: [HighchartsPlugin], extra: { holidays } });
24
- resetError();
25
- } }, "Add highcharts plugin"));
26
- case CHARTKIT_ERROR_CODE.NO_DATA:
27
- return (React.createElement(Button, { onClick: () => {
28
- setData(filledData);
29
- } }, "Add data"));
30
- default:
31
- return null;
32
- }
33
- }
34
- return (React.createElement("div", null,
35
- React.createElement("h2", null, message),
36
- renderFixButton()));
37
- }, []);
38
- return (React.createElement("div", null,
39
- React.createElement(ChartStory, { withoutPlugin: true, data: data, visible: true, renderError: renderErrorView })));
40
- };
41
- export const CustomErrorRender = Template.bind({});
@@ -1,3 +0,0 @@
1
- declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
2
- export default _default;
3
- export declare const NoData: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
@@ -1,20 +0,0 @@
1
- import React from 'react';
2
- import { ChartKit } from '../../../../components/ChartKit';
3
- import { noData, filledData } from '../../mocks/no-data';
4
- import { ChartStory } from '../components/ChartStory';
5
- import { Button } from '@gravity-ui/uikit';
6
- export default {
7
- title: 'Plugins/Highcharts/NoData',
8
- component: ChartKit,
9
- };
10
- const Template = () => {
11
- const [data, setData] = React.useState(noData);
12
- const handleUpdateData = React.useCallback(() => {
13
- setData(filledData);
14
- }, []);
15
- return (React.createElement("div", null,
16
- React.createElement("div", { style: { marginBottom: 12 } },
17
- React.createElement(Button, { onClick: handleUpdateData }, "Add data")),
18
- React.createElement(ChartStory, { data: data, visible: true })));
19
- };
20
- export const NoData = Template.bind({});
@@ -1,3 +0,0 @@
1
- declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
2
- export default _default;
3
- export declare const WithTotals: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, any>;
@@ -1,12 +0,0 @@
1
- import React from 'react';
2
- import { ChartKit } from '../../../../components/ChartKit';
3
- import { data } from '../../mocks/pie-with-totals';
4
- import { ChartStory } from '../components/ChartStory';
5
- export default {
6
- title: 'Plugins/Highcharts/Pie',
7
- component: ChartKit,
8
- };
9
- const Template = () => {
10
- return React.createElement(ChartStory, { data: data });
11
- };
12
- export const WithTotals = Template.bind({});
@@ -1,13 +0,0 @@
1
- import { prepareData } from '../renderer/helpers/prepare-data';
2
- import { data } from '../mocks/line';
3
- describe('plugins/highcharts/helpers', () => {
4
- describe('prepareData', () => {
5
- it('should not throw an error', () => {
6
- expect(() => prepareData(data.data, data.config)).not.toThrowError();
7
- });
8
- it('should throw an error', () => {
9
- const configWithLinesLimit = Object.assign(Object.assign({}, data.config), { linesLimit: 1 });
10
- expect(() => prepareData(data.data, configWithLinesLimit)).toThrowError();
11
- });
12
- });
13
- });
@@ -1,4 +0,0 @@
1
- import { Meta } from '@storybook/react';
2
- export declare const Showcase: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
3
- declare const meta: Meta;
4
- export default meta;