@gravity-ui/chartkit 1.4.2 → 1.4.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.
Files changed (34) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/build/plugins/highcharts/__stories__/Line.stories.js +2 -11
  3. package/build/plugins/highcharts/__stories__/Pie.stories.js +2 -11
  4. package/build/plugins/highcharts/__stories__/{AreaRange.stories.d.ts → area/Range.stories.d.ts} +0 -0
  5. package/build/plugins/highcharts/__stories__/area/Range.stories.js +12 -0
  6. package/build/plugins/highcharts/__stories__/area/Stacked.stories.d.ts +4 -0
  7. package/build/plugins/highcharts/__stories__/area/Stacked.stories.js +12 -0
  8. package/build/plugins/highcharts/__stories__/column/HorizontalStacked.stories.d.ts +4 -0
  9. package/build/plugins/highcharts/__stories__/column/HorizontalStacked.stories.js +12 -0
  10. package/build/plugins/highcharts/__stories__/{Column.stories.d.ts → column/Vertical.stories.d.ts} +1 -1
  11. package/build/plugins/highcharts/__stories__/column/Vertical.stories.js +12 -0
  12. package/build/plugins/highcharts/__stories__/{Bar.stories.d.ts → column/VerticalStacked.stories.d.ts} +1 -1
  13. package/build/plugins/highcharts/__stories__/column/VerticalStacked.stories.js +12 -0
  14. package/build/plugins/highcharts/__stories__/components/ChartStory.d.ts +8 -0
  15. package/build/plugins/highcharts/__stories__/components/ChartStory.js +22 -0
  16. package/build/plugins/highcharts/__stories__/mocks/{bar.d.ts → area-stacked.d.ts} +0 -0
  17. package/build/plugins/highcharts/__stories__/mocks/area-stacked.js +104 -0
  18. package/build/plugins/highcharts/__stories__/mocks/{column.d.ts → column-hor-stacked.d.ts} +0 -0
  19. package/build/plugins/highcharts/__stories__/mocks/{bar.js → column-hor-stacked.js} +0 -0
  20. package/build/plugins/highcharts/__stories__/mocks/column-ver-stacked.d.ts +2 -0
  21. package/build/plugins/highcharts/__stories__/mocks/{column.js → column-ver-stacked.js} +0 -0
  22. package/build/plugins/highcharts/__stories__/mocks/column-ver.d.ts +2 -0
  23. package/build/plugins/highcharts/__stories__/mocks/column-ver.js +73 -0
  24. package/build/plugins/highcharts/renderer/components/HighchartsComponent.d.ts +5 -0
  25. package/build/plugins/highcharts/renderer/helpers/config/config.d.ts +10 -0
  26. package/build/plugins/highcharts/renderer/helpers/config/config.js +3 -0
  27. package/build/plugins/highcharts/renderer/helpers/graph.d.ts +5 -0
  28. package/build/plugins/highcharts/renderer/helpers/tooltip/index.js +2 -3
  29. package/build/plugins/yagr/renderer/YagrWidget.d.ts +1 -0
  30. package/build/plugins/yagr/renderer/YagrWidget.js +1 -0
  31. package/package.json +7 -2
  32. package/build/plugins/highcharts/__stories__/AreaRange.stories.js +0 -22
  33. package/build/plugins/highcharts/__stories__/Bar.stories.js +0 -31
  34. package/build/plugins/highcharts/__stories__/Column.stories.js +0 -30
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.4.3](https://github.com/gravity-ui/chartkit/compare/v1.4.2...v1.4.3) (2022-12-14)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **Highcharts plugin:** fix colorAxis legend title color ([#100](https://github.com/gravity-ui/chartkit/issues/100)) ([06c992a](https://github.com/gravity-ui/chartkit/commit/06c992a5a614798a475aa7c3358058ed7080c6c1))
9
+ * **Highcharts plugin:** remove tooltip lines sorting ([#103](https://github.com/gravity-ui/chartkit/issues/103)) ([5e57035](https://github.com/gravity-ui/chartkit/commit/5e57035b7c1d572d66926c48889e8b5905399592))
10
+ * **Yagr plugin:** add core styles import ([#104](https://github.com/gravity-ui/chartkit/issues/104)) ([4de763d](https://github.com/gravity-ui/chartkit/commit/4de763d7f502f4bacf202beddeb0e5ef27381917))
11
+
3
12
  ## [1.4.2](https://github.com/gravity-ui/chartkit/compare/v1.4.1...v1.4.2) (2022-12-13)
4
13
 
5
14
 
@@ -1,21 +1,12 @@
1
1
  import React from 'react';
2
- import { Button } from '@gravity-ui/uikit';
3
- import { settings } from '../../../libs';
4
- import { HighchartsPlugin } from '../../../plugins';
5
2
  import { ChartKit } from '../../../components/ChartKit';
6
3
  import { data } from './mocks/line';
4
+ import { ChartStory } from './components/ChartStory';
7
5
  export default {
8
6
  title: 'Plugins/Highcharts/Line',
9
7
  component: ChartKit,
10
8
  };
11
9
  const Template = () => {
12
- const [shown, setShown] = React.useState(false);
13
- const chartkitRef = React.useRef();
14
- if (!shown) {
15
- settings.set({ plugins: [HighchartsPlugin] });
16
- return React.createElement(Button, { onClick: () => setShown(true) }, "Show chart");
17
- }
18
- return (React.createElement("div", { style: { height: 300, width: '100%' } },
19
- React.createElement(ChartKit, { ref: chartkitRef, type: "highcharts", data: data, splitTooltip: true })));
10
+ return React.createElement(ChartStory, { data: data });
20
11
  };
21
12
  export const Line = Template.bind({});
@@ -1,21 +1,12 @@
1
1
  import React from 'react';
2
- import { Button } from '@gravity-ui/uikit';
3
- import { settings } from '../../../libs';
4
- import { HighchartsPlugin } from '../..';
5
2
  import { ChartKit } from '../../../components/ChartKit';
6
3
  import { data } from './mocks/pie';
4
+ import { ChartStory } from './components/ChartStory';
7
5
  export default {
8
6
  title: 'Plugins/Highcharts/Pie',
9
7
  component: ChartKit,
10
8
  };
11
9
  const Template = () => {
12
- const [shown, setShown] = React.useState(false);
13
- const chartkitRef = React.useRef();
14
- if (!shown) {
15
- settings.set({ plugins: [HighchartsPlugin] });
16
- return React.createElement(Button, { onClick: () => setShown(true) }, "Show chart");
17
- }
18
- return (React.createElement("div", { style: { height: 300, width: '100%' } },
19
- React.createElement(ChartKit, { ref: chartkitRef, type: "highcharts", data: data })));
10
+ return React.createElement(ChartStory, { data: data });
20
11
  };
21
12
  export const Pie = Template.bind({});
@@ -0,0 +1,12 @@
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({});
@@ -0,0 +1,4 @@
1
+ import { Meta, Story } from '@storybook/react';
2
+ declare const _default: Meta<import("@storybook/react").Args>;
3
+ export default _default;
4
+ export declare const AreaStacked: Story<any>;
@@ -0,0 +1,12 @@
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({});
@@ -0,0 +1,4 @@
1
+ import { Story, Meta } from '@storybook/react';
2
+ declare const _default: Meta<import("@storybook/react").Args>;
3
+ export default _default;
4
+ export declare const HorizontalStacked: Story<any>;
@@ -0,0 +1,12 @@
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,4 +1,4 @@
1
1
  import { Story, Meta } from '@storybook/react';
2
2
  declare const _default: Meta<import("@storybook/react").Args>;
3
3
  export default _default;
4
- export declare const Column: Story<any>;
4
+ export declare const Vertical: Story<any>;
@@ -0,0 +1,12 @@
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,4 +1,4 @@
1
1
  import { Story, Meta } from '@storybook/react';
2
2
  declare const _default: Meta<import("@storybook/react").Args>;
3
3
  export default _default;
4
- export declare const Bar: Story<any>;
4
+ export declare const VerticalStacked: Story<any>;
@@ -0,0 +1,12 @@
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({});
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { HighchartsWidgetData } from '../../types';
3
+ export declare type ChartStoryProps = {
4
+ height?: string;
5
+ width?: string;
6
+ data: HighchartsWidgetData;
7
+ };
8
+ export declare const ChartStory: React.FC<ChartStoryProps>;
@@ -0,0 +1,22 @@
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 [visible, setVisible] = React.useState(false);
12
+ const chartKitRef = React.useRef();
13
+ if (!visible) {
14
+ settings.set({ plugins: [HighchartsPlugin], extra: { holidays } });
15
+ return React.createElement(Button, { onClick: () => setVisible(true) }, "Show chart");
16
+ }
17
+ return (React.createElement("div", { style: {
18
+ height: height || DEFAULT_STORY_HEIGHT,
19
+ width: width || DEFAULT_STORY_WIDTH,
20
+ } },
21
+ React.createElement(ChartKit, { ref: chartKitRef, type: "highcharts", data: data })));
22
+ };
@@ -0,0 +1,104 @@
1
+ export const data = {
2
+ data: {
3
+ graphs: [
4
+ {
5
+ title: 'Appliances',
6
+ tooltip: {
7
+ chartKitFormatting: true,
8
+ chartKitPrecision: 0,
9
+ },
10
+ data: [
11
+ {
12
+ y: 2420,
13
+ x: 2014,
14
+ },
15
+ {
16
+ y: 2472,
17
+ x: 2015,
18
+ },
19
+ {
20
+ y: 5248,
21
+ x: 2016,
22
+ },
23
+ {
24
+ y: 7787,
25
+ x: 2017,
26
+ },
27
+ ],
28
+ legendTitle: 'Appliances',
29
+ connectNulls: false,
30
+ yAxis: 0,
31
+ color: '#FF3D64',
32
+ },
33
+ {
34
+ title: 'Bookcases',
35
+ tooltip: {
36
+ chartKitFormatting: true,
37
+ chartKitPrecision: 0,
38
+ },
39
+ data: [
40
+ {
41
+ y: -363,
42
+ x: 2014,
43
+ },
44
+ {
45
+ y: -2777,
46
+ x: 2015,
47
+ },
48
+ {
49
+ y: 1880,
50
+ x: 2016,
51
+ },
52
+ {
53
+ y: -616,
54
+ x: 2017,
55
+ },
56
+ ],
57
+ legendTitle: 'Bookcases',
58
+ connectNulls: false,
59
+ yAxis: 0,
60
+ color: '#8AD554',
61
+ },
62
+ ],
63
+ categories: ['2014', '2015', '2016', '2017'],
64
+ },
65
+ config: {
66
+ withoutLineLimit: true,
67
+ hideHolidaysBands: true,
68
+ enableSum: true,
69
+ },
70
+ libraryConfig: {
71
+ chart: {
72
+ type: 'area',
73
+ zoomType: 'x',
74
+ },
75
+ xAxis: {
76
+ endOnTick: false,
77
+ type: 'linear',
78
+ labels: {
79
+ enabled: true,
80
+ },
81
+ },
82
+ yAxis: {
83
+ opposite: false,
84
+ labels: {
85
+ y: 3,
86
+ enabled: true,
87
+ },
88
+ type: 'linear',
89
+ },
90
+ plotOptions: {
91
+ area: {
92
+ stacking: 'normal',
93
+ },
94
+ series: {
95
+ dataGrouping: {
96
+ enabled: false,
97
+ },
98
+ dataLabels: {
99
+ allowOverlap: false,
100
+ },
101
+ },
102
+ },
103
+ },
104
+ };
@@ -0,0 +1,2 @@
1
+ import { HighchartsWidgetData } from '../../types';
2
+ export declare const data: HighchartsWidgetData;
@@ -0,0 +1,2 @@
1
+ import { HighchartsWidgetData } from '../../types';
2
+ export declare const data: HighchartsWidgetData;
@@ -0,0 +1,73 @@
1
+ export const data = {
2
+ data: {
3
+ graphs: [
4
+ {
5
+ data: [
6
+ {
7
+ y: 50.55,
8
+ color: 'rgb(255, 61, 9)',
9
+ },
10
+ {
11
+ y: 80.45,
12
+ color: 'rgb(255, 65, 9)',
13
+ },
14
+ {
15
+ y: 100.34,
16
+ color: 'rgb(255, 83, 9)',
17
+ },
18
+ ],
19
+ name: 'Profit',
20
+ },
21
+ {
22
+ data: [
23
+ {
24
+ y: 350.65,
25
+ color: 'rgb(208, 189, 48)',
26
+ },
27
+ {
28
+ y: 119.82,
29
+ color: 'rgb(255, 95, 88)',
30
+ },
31
+ {
32
+ y: 452.15,
33
+ color: 'rgb(84, 165, 32)',
34
+ },
35
+ ],
36
+ name: 'Sales',
37
+ },
38
+ ],
39
+ categories: ['Furniture', 'Office Supplies', 'Technology'],
40
+ },
41
+ config: {
42
+ enableSum: true,
43
+ precision: 2,
44
+ },
45
+ libraryConfig: {
46
+ chart: {
47
+ type: 'column',
48
+ },
49
+ legend: {
50
+ title: {
51
+ text: 'Measure Values',
52
+ },
53
+ enabled: true,
54
+ },
55
+ colorAxis: {
56
+ startOnTick: false,
57
+ endOnTick: false,
58
+ min: 50.55,
59
+ max: 452.72057380654326,
60
+ stops: [
61
+ [0, 'rgb(255, 61, 100)'],
62
+ [0.5, 'rgb(255, 198, 54)'],
63
+ [1, 'rgb(84, 165, 32)'],
64
+ ],
65
+ },
66
+ plotOptions: {
67
+ column: {
68
+ maxPointWidth: 50,
69
+ },
70
+ },
71
+ enableSum: true,
72
+ },
73
+ };
@@ -453,6 +453,11 @@ export declare class HighchartsComponent extends React.PureComponent<Props, Stat
453
453
  color: string;
454
454
  };
455
455
  };
456
+ title: {
457
+ style: {
458
+ color: string;
459
+ };
460
+ };
456
461
  } | {
457
462
  enabled: boolean;
458
463
  });
@@ -10,6 +10,11 @@ export function buildLegend(options: any): {
10
10
  color: string;
11
11
  };
12
12
  };
13
+ title: {
14
+ style: {
15
+ color: string;
16
+ };
17
+ };
13
18
  };
14
19
  export function hasChartVisibleSeries(chart: any): any;
15
20
  export function handleScroll(): false | undefined;
@@ -486,6 +491,11 @@ export function prepareConfig(data: any, options: any, isMobile: any, holidays:
486
491
  color: string;
487
492
  };
488
493
  };
494
+ title: {
495
+ style: {
496
+ color: string;
497
+ };
498
+ };
489
499
  } | {
490
500
  enabled: boolean;
491
501
  };
@@ -162,6 +162,9 @@ export function buildLegend(options) {
162
162
  inactiveColor: 'var(--yc-color-base-generic-accent-disabled)',
163
163
  style: { color: 'var(--yc-color-text-primary)' },
164
164
  },
165
+ title: {
166
+ style: { color: 'var(--yc-color-text-secondary)' },
167
+ },
165
168
  };
166
169
  if (options.outsideLegend) {
167
170
  options.legendPosition = null;
@@ -447,6 +447,11 @@ declare function getGraph({ options, data, comments, isMobile, holidays }: GetGr
447
447
  color: string;
448
448
  };
449
449
  };
450
+ title: {
451
+ style: {
452
+ color: string;
453
+ };
454
+ };
450
455
  } | {
451
456
  enabled: boolean;
452
457
  });
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable complexity */
2
- import { escape as _escape, orderBy as _orderBy } from 'lodash';
2
+ import _escape from 'lodash/escape';
3
3
  import { i18n } from '../../../../../i18n';
4
4
  import { renderShapeIcon } from './render-shape-icon';
5
5
  import { escapeHTML } from './helpers';
@@ -131,7 +131,6 @@ export const formatTooltip = (data, tooltip, isMobile) => {
131
131
  const selectedLineIndex = data.lines.findIndex(({ selectedSeries }) => selectedSeries);
132
132
  const selectedLine = data.lines[selectedLineIndex];
133
133
  const lines = data.lines.slice(0, (tooltip.lastVisibleRowIndex || data.lines.length) + 1);
134
- const sortedLines = _orderBy(lines, ['originalValue'], ['desc']);
135
134
  const withShapes = lines.every((line) => line.seriesShape);
136
135
  const unsafe = data.unsafe;
137
136
  const tooltipHeaderRaw = (_a = data.tooltipHeader) === null || _a === void 0 ? void 0 : _a.trim();
@@ -212,7 +211,7 @@ export const formatTooltip = (data, tooltip, isMobile) => {
212
211
  .join('')}</tr>
213
212
  </thead>`}
214
213
  <tbody class="${TOOLTIP_LIST_CLASS_NAME}">
215
- ${sortedLines
214
+ ${lines
216
215
  .map((line, index) => renderRow(line, getRowRenderConfig(index)))
217
216
  .join('')}
218
217
  </tbody>
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import type { ChartKitWidgetRef } from '../../../types';
3
3
  import './polyfills';
4
+ import '@gravity-ui/yagr/dist/index.css';
4
5
  import './YagrWidget.css';
5
6
  declare const YagrWidget: React.ForwardRefExoticComponent<{
6
7
  type: "yagr";
@@ -6,6 +6,7 @@ import { CHARTKIT_ERROR_CODE, ChartKitError } from '../../../libs';
6
6
  import { useWidgetData } from './useWidgetData';
7
7
  import { checkFocus, detectClickOutside, synchronizeTooltipTablesCellsWidth } from './utils';
8
8
  import './polyfills';
9
+ import '@gravity-ui/yagr/dist/index.css';
9
10
  import './YagrWidget.css';
10
11
  const YagrWidget = React.forwardRef((props, forwardedRef) => {
11
12
  const { id, data: { data }, onLoad, } = props;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/chartkit",
3
- "version": "1.4.2",
3
+ "version": "1.4.3",
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",
@@ -37,6 +37,8 @@
37
37
  "@types/react": "^17.0.48",
38
38
  "@types/react-dom": "^17.0.17",
39
39
  "@typescript-eslint/eslint-plugin": "^5.31.0",
40
+ "cross-env": "^7.0.3",
41
+ "css-loader": "^5.2.7",
40
42
  "eslint": "^8.11.0",
41
43
  "gulp": "^4.0.2",
42
44
  "gulp-cli": "^2.3.0",
@@ -51,9 +53,12 @@
51
53
  "npm-run-all": "^4.1.5",
52
54
  "prettier": "^2.6.0",
53
55
  "react": "^17.0.2",
56
+ "react-docgen-typescript": "^2.2.2",
54
57
  "react-dom": "^17.0.2",
55
58
  "rimraf": "^3.0.2",
59
+ "sass": "^1.56.2",
56
60
  "sass-loader": "^10.2.1",
61
+ "style-loader": "^2.0.0",
57
62
  "stylelint": "^14.6.0",
58
63
  "ts-jest": "^28.0.5",
59
64
  "ts-node": "^10.2.1",
@@ -68,7 +73,7 @@
68
73
  "test": "jest",
69
74
  "test:watch": "jest --watchAll",
70
75
  "clean": "gulp clean",
71
- "start": "start-storybook -p 7007",
76
+ "start": "cross-env TS_NODE_PROJECT=.storybook/tsconfig.json start-storybook -p 7007",
72
77
  "build": "gulp",
73
78
  "lint:js": "eslint --quiet --ext .js,.jsx,.ts,.tsx .",
74
79
  "lint:styles": "stylelint '{styles,src}/**/*.scss' --quiet",
@@ -1,22 +0,0 @@
1
- import React from 'react';
2
- import { Button } from '@gravity-ui/uikit';
3
- import { settings } from '../../../libs';
4
- import { HighchartsPlugin } from '../..';
5
- import { ChartKit } from '../../../components/ChartKit';
6
- import { data } from './mocks/area-range';
7
- import holidays from './mocks/holidays';
8
- export default {
9
- title: 'Plugins/Highcharts/AreaRange',
10
- component: ChartKit,
11
- };
12
- const Template = () => {
13
- const [shown, setShown] = React.useState(false);
14
- const chartkitRef = React.useRef();
15
- if (!shown) {
16
- settings.set({ plugins: [HighchartsPlugin], extra: { holidays } });
17
- return React.createElement(Button, { onClick: () => setShown(true) }, "Show chart");
18
- }
19
- return (React.createElement("div", { style: { height: 300, width: '100%' } },
20
- React.createElement(ChartKit, { ref: chartkitRef, id: "1", type: "highcharts", data: data })));
21
- };
22
- export const AreaRange = Template.bind({});
@@ -1,31 +0,0 @@
1
- import React from 'react';
2
- import { Button, ThemeProvider } from '@gravity-ui/uikit';
3
- import { ChartKit } from '../../../components/ChartKit';
4
- import { settings } from '../../../libs';
5
- import { HighchartsPlugin } from '../index';
6
- import { defaultChartKitPropsControlsState } from './constants/story-settings';
7
- import holidays from './mocks/holidays';
8
- import { data } from './mocks/bar';
9
- export default {
10
- title: 'Plugins/Highcharts/Bar',
11
- component: ChartKit,
12
- args: {
13
- theme: 'light',
14
- },
15
- argTypes: Object.assign({ theme: {
16
- options: ['light', 'light-hc', 'dark', 'dark-hc'],
17
- control: { type: 'radio' },
18
- } }, defaultChartKitPropsControlsState),
19
- };
20
- const Template = (args) => {
21
- const [shown, setShown] = React.useState(false);
22
- const chartkitRef = React.useRef();
23
- if (!shown) {
24
- settings.set({ plugins: [HighchartsPlugin], extra: { holidays } });
25
- return React.createElement(Button, { onClick: () => setShown(true) }, "Show chart");
26
- }
27
- return (React.createElement(ThemeProvider, { theme: args.theme },
28
- React.createElement("div", { style: { height: '600px', width: '100%' } },
29
- React.createElement(ChartKit, { ref: chartkitRef, type: "highcharts", data: data }))));
30
- };
31
- export const Bar = Template.bind({});
@@ -1,30 +0,0 @@
1
- import React from 'react';
2
- import { Button, ThemeProvider } from '@gravity-ui/uikit';
3
- import { ChartKit } from '../../../components/ChartKit';
4
- import { settings } from '../../../libs';
5
- import { HighchartsPlugin } from '../index';
6
- import { defaultChartKitPropsControlsState } from './constants/story-settings';
7
- import holidays from './mocks/holidays';
8
- import { data } from './mocks/column';
9
- export default {
10
- title: 'Plugins/Highcharts/Column',
11
- component: ChartKit,
12
- args: {
13
- theme: 'light',
14
- },
15
- argTypes: Object.assign({ theme: {
16
- options: ['light', 'light-hc', 'dark', 'dark-hc'],
17
- control: { type: 'radio' },
18
- } }, defaultChartKitPropsControlsState),
19
- };
20
- const Template = (args) => {
21
- const [shown, setShown] = React.useState(false);
22
- const chartkitRef = React.useRef();
23
- if (!shown) {
24
- settings.set({ plugins: [HighchartsPlugin], extra: { holidays } });
25
- return React.createElement(Button, { onClick: () => setShown(true) }, "Show chart");
26
- }
27
- return (React.createElement(ThemeProvider, { theme: args.theme },
28
- React.createElement(ChartKit, { ref: chartkitRef, type: "highcharts", data: data })));
29
- };
30
- export const Column = Template.bind({});