@gravity-ui/chartkit 3.3.0 → 3.4.1

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 (57) hide show
  1. package/build/plugins/highcharts/renderer/helpers/config/utils/index.js +1 -1
  2. package/package.json +8 -3
  3. package/build/libs/chartkit-error/__tests__/chartkit-error.d.ts +0 -1
  4. package/build/libs/chartkit-error/__tests__/chartkit-error.js +0 -27
  5. package/build/libs/settings/__tests__/settings.test.d.ts +0 -1
  6. package/build/libs/settings/__tests__/settings.test.js +0 -17
  7. package/build/plugins/d3/__stories__/bar-x/category.stories.d.ts +0 -4
  8. package/build/plugins/d3/__stories__/bar-x/category.stories.js +0 -75
  9. package/build/plugins/d3/__stories__/bar-x/datetime.stories.d.ts +0 -4
  10. package/build/plugins/d3/__stories__/bar-x/datetime.stories.js +0 -71
  11. package/build/plugins/d3/__stories__/bar-x/linear.stories.d.ts +0 -4
  12. package/build/plugins/d3/__stories__/bar-x/linear.stories.js +0 -78
  13. package/build/plugins/d3/__stories__/penguins.json +0 -3098
  14. package/build/plugins/d3/__stories__/scatter/LinearCategories.stories.d.ts +0 -4
  15. package/build/plugins/d3/__stories__/scatter/LinearCategories.stories.js +0 -100
  16. package/build/plugins/d3/__stories__/scatter/Timestamp.stories.d.ts +0 -4
  17. package/build/plugins/d3/__stories__/scatter/Timestamp.stories.js +0 -108
  18. package/build/plugins/highcharts/__stories__/Line.stories.d.ts +0 -3
  19. package/build/plugins/highcharts/__stories__/Line.stories.js +0 -12
  20. package/build/plugins/highcharts/__stories__/Pie.stories.d.ts +0 -3
  21. package/build/plugins/highcharts/__stories__/Pie.stories.js +0 -12
  22. package/build/plugins/highcharts/__stories__/area/Range.stories.d.ts +0 -3
  23. package/build/plugins/highcharts/__stories__/area/Range.stories.js +0 -12
  24. package/build/plugins/highcharts/__stories__/area/Stacked.stories.d.ts +0 -3
  25. package/build/plugins/highcharts/__stories__/area/Stacked.stories.js +0 -12
  26. package/build/plugins/highcharts/__stories__/column/HorizontalStacked.stories.d.ts +0 -3
  27. package/build/plugins/highcharts/__stories__/column/HorizontalStacked.stories.js +0 -12
  28. package/build/plugins/highcharts/__stories__/column/Vertical.stories.d.ts +0 -3
  29. package/build/plugins/highcharts/__stories__/column/Vertical.stories.js +0 -12
  30. package/build/plugins/highcharts/__stories__/column/VerticalStacked.stories.d.ts +0 -3
  31. package/build/plugins/highcharts/__stories__/column/VerticalStacked.stories.js +0 -12
  32. package/build/plugins/highcharts/__stories__/combined/ComboChartWithSameLegendValues.stories.d.ts +0 -3
  33. package/build/plugins/highcharts/__stories__/combined/ComboChartWithSameLegendValues.stories.js +0 -12
  34. package/build/plugins/highcharts/__stories__/complex/TwoAxis.stories.d.ts +0 -3
  35. package/build/plugins/highcharts/__stories__/complex/TwoAxis.stories.js +0 -12
  36. package/build/plugins/highcharts/__stories__/components/ChartStory.d.ts +0 -12
  37. package/build/plugins/highcharts/__stories__/components/ChartStory.js +0 -28
  38. package/build/plugins/highcharts/__stories__/constants/story-settings.d.ts +0 -42
  39. package/build/plugins/highcharts/__stories__/constants/story-settings.js +0 -42
  40. package/build/plugins/highcharts/__stories__/custom-error-render/custom-error-render.stories.d.ts +0 -3
  41. package/build/plugins/highcharts/__stories__/custom-error-render/custom-error-render.stories.js +0 -41
  42. package/build/plugins/highcharts/__stories__/no-data/no-data.stories.d.ts +0 -3
  43. package/build/plugins/highcharts/__stories__/no-data/no-data.stories.js +0 -20
  44. package/build/plugins/highcharts/__stories__/pie/WithTotals.stories.d.ts +0 -3
  45. package/build/plugins/highcharts/__stories__/pie/WithTotals.stories.js +0 -12
  46. package/build/plugins/highcharts/__tests__/prepare-data.test.d.ts +0 -1
  47. package/build/plugins/highcharts/__tests__/prepare-data.test.js +0 -13
  48. package/build/plugins/indicator/__stories__/Indicator.stories.d.ts +0 -4
  49. package/build/plugins/indicator/__stories__/Indicator.stories.js +0 -45
  50. package/build/plugins/yagr/__stories__/Yagr.stories.d.ts +0 -6
  51. package/build/plugins/yagr/__stories__/Yagr.stories.js +0 -90
  52. package/build/plugins/yagr/__stories__/mocks/line10.d.ts +0 -53
  53. package/build/plugins/yagr/__stories__/mocks/line10.js +0 -78
  54. package/build/plugins/yagr/__tests__/utils.test.d.ts +0 -1
  55. package/build/plugins/yagr/__tests__/utils.test.js +0 -26
  56. package/build/utils/__tests__/common.test.d.ts +0 -1
  57. package/build/utils/__tests__/common.test.js +0 -9
@@ -1,45 +0,0 @@
1
- import React from 'react';
2
- import { withKnobs, boolean, color as colorKnob, radios, text } from '@storybook/addon-knobs';
3
- import { cloneDeep } from 'lodash';
4
- import { Button } from '@gravity-ui/uikit';
5
- import { settings } from '../../../libs';
6
- import { ChartKit } from '../../../components/ChartKit';
7
- import { IndicatorPlugin } from '../';
8
- const data = {
9
- data: [
10
- {
11
- content: {
12
- current: {
13
- value: 1539577973,
14
- },
15
- },
16
- },
17
- ],
18
- };
19
- const Template = () => {
20
- const [shown, setShown] = React.useState(false);
21
- const chartkitRef = React.useRef();
22
- const color = colorKnob('color', '#4da2f1');
23
- const size = radios('size', { s: 's', m: 'm', l: 'l', xl: 'xl' }, 'm');
24
- const title = text('title', 'Value title');
25
- const nowrap = boolean('nowrap', false);
26
- const resultData = cloneDeep(data);
27
- if (resultData.data) {
28
- resultData.data[0].size = size;
29
- resultData.data[0].color = color;
30
- resultData.data[0].title = title;
31
- resultData.data[0].nowrap = nowrap;
32
- }
33
- if (!shown) {
34
- settings.set({ plugins: [IndicatorPlugin] });
35
- return React.createElement(Button, { onClick: () => setShown(true) }, "Show chart");
36
- }
37
- return (React.createElement("div", { style: { height: 300, width: '100%' } },
38
- React.createElement(ChartKit, { ref: chartkitRef, id: "1", type: "indicator", data: resultData })));
39
- };
40
- export const Showcase = Template.bind({});
41
- const meta = {
42
- title: 'Plugins/Indicator',
43
- decorators: [withKnobs],
44
- };
45
- export default meta;
@@ -1,6 +0,0 @@
1
- import '@gravity-ui/yagr/dist/index.css';
2
- declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
3
- export default _default;
4
- export declare const Line: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, any>;
5
- export declare const Updates: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, any>;
6
- export declare const CustomTooltip: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, any>;
@@ -1,90 +0,0 @@
1
- import React, { useEffect, useState } from 'react';
2
- import { Button } from '@gravity-ui/uikit';
3
- import { settings } from '../../../libs';
4
- import { YagrPlugin } from '../../../plugins';
5
- import { ChartKit } from '../../../components/ChartKit';
6
- import { getNewConfig, line10 } from './mocks/line10';
7
- import '@gravity-ui/yagr/dist/index.css';
8
- import placement from '@gravity-ui/yagr/dist/YagrCore/plugins/tooltip/placement';
9
- import { dateTime } from '@gravity-ui/date-utils';
10
- export default {
11
- title: 'Plugins/Yagr',
12
- component: ChartKit,
13
- };
14
- const LineTemplate = () => {
15
- const [shown, setShown] = React.useState(false);
16
- const chartkitRef = React.useRef();
17
- if (!shown) {
18
- settings.set({ plugins: [YagrPlugin] });
19
- return React.createElement(Button, { onClick: () => setShown(true) }, "Show chart");
20
- }
21
- return (React.createElement("div", { style: { height: 300, width: '100%' } },
22
- React.createElement(ChartKit, { ref: chartkitRef, id: "1", type: "yagr", data: line10 })));
23
- };
24
- const UpdatesTemplate = () => {
25
- const [shown, setShown] = React.useState(false);
26
- const chartkitRef = React.useRef();
27
- const [state, setState] = React.useState(line10);
28
- const onStartUpdates = React.useCallback(() => {
29
- setInterval(() => {
30
- setState(getNewConfig());
31
- }, 1000);
32
- }, []);
33
- if (!shown) {
34
- settings.set({ plugins: [YagrPlugin] });
35
- return React.createElement(Button, { onClick: () => setShown(true) }, "Show chart");
36
- }
37
- return (React.createElement("div", { style: { height: 300, width: '100%' } },
38
- React.createElement(ChartKit, { ref: chartkitRef, id: "1", type: "yagr", data: state }),
39
- React.createElement(Button, { onClick: onStartUpdates }, "Start Updates"),
40
- React.createElement(Button, { onClick: () => setState(getNewConfig()) }, "Once")));
41
- };
42
- function Tooltip({ yagr }) {
43
- const [x, setX] = useState(null);
44
- const [visible, setVisible] = useState(false);
45
- const tooltipRef = React.useRef(null);
46
- useEffect(() => {
47
- var _a, _b, _c;
48
- if (!yagr) {
49
- return;
50
- }
51
- const onChange = (_, data) => {
52
- var _a, _b;
53
- setX((_a = data.data) === null || _a === void 0 ? void 0 : _a.x);
54
- setVisible(data.state.visible);
55
- if (data.state.visible && tooltipRef.current && ((_b = data.data) === null || _b === void 0 ? void 0 : _b.anchor)) {
56
- placement(tooltipRef.current, data.data.anchor, 'right', {
57
- xOffset: 24,
58
- yOffset: 24,
59
- });
60
- }
61
- };
62
- (_a = yagr.plugins.tooltip) === null || _a === void 0 ? void 0 : _a.on('render', onChange);
63
- (_b = yagr.plugins.tooltip) === null || _b === void 0 ? void 0 : _b.on('show', onChange);
64
- (_c = yagr.plugins.tooltip) === null || _c === void 0 ? void 0 : _c.on('hide', onChange);
65
- }, [yagr]);
66
- if (!visible) {
67
- return null;
68
- }
69
- return (React.createElement("div", { style: {
70
- zIndex: 1000,
71
- backgroundColor: 'white',
72
- padding: 8,
73
- pointerEvents: 'none',
74
- }, ref: tooltipRef }, dateTime({ input: x !== null && x !== void 0 ? x : 0 }).format('DD MMMM YYYY HH:mm:ss')));
75
- }
76
- const CustomTooltipImpl = () => {
77
- const [shown, setShown] = React.useState(false);
78
- const chartkitRef = React.useRef();
79
- const [state, setState] = React.useState(line10);
80
- if (!shown) {
81
- settings.set({ plugins: [YagrPlugin] });
82
- return React.createElement(Button, { onClick: () => setShown(true) }, "Show chart");
83
- }
84
- return (React.createElement("div", { style: { height: 300, width: '100%' } },
85
- React.createElement(ChartKit, { ref: chartkitRef, id: "1", type: "yagr", data: state, tooltip: (props) => React.createElement(Tooltip, Object.assign({}, props)) }),
86
- React.createElement(Button, { onClick: () => setState(getNewConfig()) }, "Change data")));
87
- };
88
- export const Line = LineTemplate.bind({});
89
- export const Updates = UpdatesTemplate.bind({});
90
- export const CustomTooltip = CustomTooltipImpl.bind({});
@@ -1,53 +0,0 @@
1
- import type { YagrWidgetData } from '../../types';
2
- export declare const line10: YagrWidgetData;
3
- export declare const getNewConfig: () => {
4
- libraryConfig: {
5
- title: {
6
- text: string;
7
- };
8
- chart?: import("@gravity-ui/yagr/dist/YagrCore/types").YagrChartOptions | undefined;
9
- legend?: import("@gravity-ui/yagr/dist/YagrCore/plugins/legend/legend").LegendOptions | undefined;
10
- axes?: Record<string, import("@gravity-ui/yagr/dist/YagrCore/types").AxisOptions> | undefined;
11
- cursor?: import("@gravity-ui/yagr/dist/YagrCore/plugins/cursor/cursor").CursorOptions | undefined;
12
- timeline?: number[] | undefined;
13
- tooltip?: Partial<import("@gravity-ui/yagr/dist/YagrCore/plugins/tooltip/types").TooltipOptions> | undefined;
14
- grid?: import("uplot").Axis.Grid | undefined;
15
- markers?: import("@gravity-ui/yagr/dist/YagrCore/types").MarkersOptions | undefined;
16
- scales?: Record<string, import("@gravity-ui/yagr/dist/YagrCore/types").Scale> | undefined;
17
- series?: import("@gravity-ui/yagr/dist/YagrCore/types").RawSerieData<Omit<import("@gravity-ui/yagr/dist/YagrCore/types").SeriesOptions, "type"> & {
18
- type?: import("@gravity-ui/yagr/dist/YagrCore/types").ChartType | undefined;
19
- }>[] | undefined;
20
- hooks?: import("@gravity-ui/yagr/dist/YagrCore/types").YagrHooks | undefined;
21
- processing?: import("@gravity-ui/yagr/dist/YagrCore/types").ProcessingSettings | undefined;
22
- editUplotOptions?: ((opts: import("uplot").Options) => import("uplot").Options) | undefined;
23
- plugins?: Record<string, import("@gravity-ui/yagr/dist/YagrCore/types").YagrPlugin<{}, []>> | undefined;
24
- };
25
- data: {
26
- timeline: number[];
27
- graphs: {
28
- data: number[];
29
- name?: string | undefined;
30
- id?: string | undefined;
31
- scale?: string | undefined;
32
- focus?: boolean | undefined;
33
- title?: string | ((sIdx: number) => string) | undefined;
34
- show?: boolean | undefined;
35
- color?: string | undefined;
36
- spanGaps?: boolean | undefined;
37
- cursorOptions?: Pick<import("@gravity-ui/yagr/dist/YagrCore/plugins/cursor/cursor").CursorOptions, "snapToValues" | "markersSize"> | undefined;
38
- formatter?: ((value: string | number | null, serie: import("uplot").Series) => string) | undefined;
39
- precision?: number | undefined;
40
- snapToValues?: false | import("@gravity-ui/yagr/dist/YagrCore/types").SnapToValue | undefined;
41
- stackGroup?: number | undefined;
42
- transform?: ((val: string | number | null, series: import("@gravity-ui/yagr/dist/YagrCore/types").DataSeries[], idx: number) => number | null) | undefined;
43
- showInTooltip?: boolean | undefined;
44
- postProcess?: ((data: (number | null)[], idx: number, y: import("@gravity-ui/yagr/dist/YagrCore").default<import("@gravity-ui/yagr/dist/YagrCore/types").MinimalValidConfig>) => (number | null)[]) | undefined;
45
- type?: import("@gravity-ui/yagr/dist/YagrCore/types").ChartType | undefined;
46
- }[];
47
- };
48
- sources?: Record<number, {
49
- data: {
50
- program: string;
51
- };
52
- }> | undefined;
53
- };
@@ -1,78 +0,0 @@
1
- export const line10 = {
2
- data: {
3
- timeline: [
4
- 1636838612441, 1636925012441, 1637011412441, 1637097812441, 1637184212441,
5
- 1637270612441, 1637357012441, 1637443412441, 1637529812441, 1637616212441,
6
- ],
7
- graphs: [
8
- {
9
- id: '0',
10
- name: 'Serie 1',
11
- color: '#6c59c2',
12
- data: [45, 52, 89, 72, 39, 49, 82, 59, 36, 5],
13
- },
14
- {
15
- id: '1',
16
- name: 'Serie 2',
17
- color: '#6e8188',
18
- data: [37, 6, 51, 10, 65, 35, 72, 0, 94, 54],
19
- },
20
- {
21
- id: '2',
22
- name: 'Serie 3',
23
- color: '#e21576',
24
- data: [26, 54, 15, 40, 43, 18, 65, 46, 51, 33],
25
- },
26
- ],
27
- },
28
- libraryConfig: {
29
- chart: {
30
- series: {
31
- type: 'line',
32
- },
33
- select: {
34
- zoom: false,
35
- },
36
- },
37
- title: {
38
- text: 'line: random 10 pts',
39
- },
40
- axes: {
41
- x: {},
42
- },
43
- scales: {
44
- x: {},
45
- y: {
46
- type: 'linear',
47
- range: 'nice',
48
- },
49
- },
50
- cursor: {
51
- x: {
52
- visible: true,
53
- style: 'solid 2px rgba(230, 2, 7, 0.3)',
54
- },
55
- },
56
- tooltip: {
57
- show: true,
58
- tracking: 'sticky',
59
- },
60
- legend: {},
61
- processing: {},
62
- },
63
- };
64
- export const getNewConfig = () => {
65
- const startPoint = (Math.random() * 10 ** 5) >> 0; // eslint-disable-line no-bitwise
66
- return Object.assign(Object.assign({}, line10), { libraryConfig: Object.assign(Object.assign({}, line10.libraryConfig), { title: {
67
- text: 'line: random 100 pts',
68
- } }), data: {
69
- timeline: new Array(100).fill(0).map((_, i) => {
70
- return startPoint + i * 1000;
71
- }),
72
- graphs: line10.data.graphs.map((graph) => {
73
- return Object.assign(Object.assign({}, graph), { data: new Array(100).fill(0).map(() => {
74
- return (Math.random() * 100) >> 0; // eslint-disable-line no-bitwise
75
- }) });
76
- }),
77
- } });
78
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,26 +0,0 @@
1
- import { shapeYagrConfig } from '../renderer/utils';
2
- const DATA = {
3
- timeline: [1],
4
- graphs: [{ data: [45] }],
5
- };
6
- describe('plugins/yagr/utils', () => {
7
- describe('shapeYagrConfig > check chart property', () => {
8
- test.each([
9
- [{}, { appearance: { locale: 'en', theme: 'dark' } }],
10
- [{ appearance: { locale: 'ru' } }, { appearance: { locale: 'ru', theme: 'dark' } }],
11
- [{ appearance: { theme: 'light' } }, { appearance: { locale: 'en', theme: 'light' } }],
12
- [
13
- { series: { type: 'dots' }, select: { zoom: false }, timeMultiplier: 1 },
14
- {
15
- appearance: { locale: 'en', theme: 'dark' },
16
- series: { type: 'dots' },
17
- select: { zoom: false },
18
- timeMultiplier: 1,
19
- },
20
- ],
21
- ])('(args: %j)', (chart, expected) => {
22
- const config = shapeYagrConfig({ data: DATA, libraryConfig: { chart }, theme: 'dark' });
23
- expect(config.chart).toEqual(expected);
24
- });
25
- });
26
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,9 +0,0 @@
1
- import { getRandomCKId } from '../common';
2
- // length of "ck." + 10 random symbols
3
- const ID_LENGTH = 13;
4
- describe('utils/getRandomCKId', () => {
5
- it('Id should have 13 symbols', () => {
6
- const result = getRandomCKId();
7
- expect(result.length).toBe(ID_LENGTH);
8
- });
9
- });