@gravity-ui/chartkit 3.0.0-beta.zefirka.9 → 3.1.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/components/ChartKit.d.ts +1 -2
- package/build/plugins/highcharts/renderer/HighchartsWidget.d.ts +0 -1
- package/build/plugins/indicator/renderer/IndicatorWidget.d.ts +0 -1
- package/build/plugins/yagr/__stories__/Yagr.stories.d.ts +1 -0
- package/build/plugins/yagr/__stories__/Yagr.stories.js +51 -4
- package/build/plugins/yagr/__stories__/mocks/line10.d.ts +1 -1
- package/build/plugins/yagr/renderer/YagrWidget.d.ts +3 -3
- package/build/plugins/yagr/renderer/YagrWidget.js +22 -25
- package/build/plugins/yagr/renderer/useWidgetData.d.ts +2 -4
- package/build/plugins/yagr/renderer/useWidgetData.js +8 -3
- package/build/plugins/yagr/renderer/utils.d.ts +1 -0
- package/build/plugins/yagr/renderer/utils.js +3 -0
- package/build/plugins/yagr/types.d.ts +9 -1
- package/build/types/index.d.ts +1 -3
- package/build/types/widget.d.ts +2 -4
- package/package.json +8 -6
|
@@ -8,7 +8,6 @@ declare const ChartKitComponent: <T extends keyof import("../types").ChartKitWid
|
|
|
8
8
|
export declare const ChartKit: <T extends keyof import("../types").ChartKitWidget>(props: {
|
|
9
9
|
type: T;
|
|
10
10
|
data: import("../types").ChartKitWidget[T]["data"];
|
|
11
|
-
pluginRef?: import("../types").ChartKitWidget[T]["pluginRef"] | undefined;
|
|
12
11
|
id?: string | undefined;
|
|
13
12
|
isMobile?: boolean | undefined;
|
|
14
13
|
onLoad?: ((data?: import("../types").ChartKitOnLoadData<T> | undefined) => void) | undefined;
|
|
@@ -17,7 +16,7 @@ export declare const ChartKit: <T extends keyof import("../types").ChartKitWidge
|
|
|
17
16
|
onError?: import("../types").ChartKitOnError | undefined;
|
|
18
17
|
renderError?: import("../types").RenderError | undefined;
|
|
19
18
|
renderPluginLoader?: (() => React.ReactNode) | undefined;
|
|
20
|
-
} & (Omit<import("../types").ChartKitWidget[T], "
|
|
19
|
+
} & (Omit<import("../types").ChartKitWidget[T], "data" | "widget"> extends infer T_1 ? { [key in keyof T_1]: import("../types").ChartKitWidget[T][key]; } : never) & {
|
|
21
20
|
ref?: React.ForwardedRef<ChartKitRef | undefined> | undefined;
|
|
22
21
|
}) => ReturnType<typeof ChartKitComponent>;
|
|
23
22
|
export {};
|
|
@@ -3,7 +3,6 @@ import type { ChartKitWidgetRef } from '../../../types';
|
|
|
3
3
|
declare const HighchartsWidget: React.ForwardRefExoticComponent<{
|
|
4
4
|
type: "highcharts";
|
|
5
5
|
data: import("../types").HighchartsWidgetData;
|
|
6
|
-
pluginRef?: undefined;
|
|
7
6
|
id?: string | undefined;
|
|
8
7
|
isMobile?: boolean | undefined;
|
|
9
8
|
onLoad?: ((data?: import("../../../types").ChartKitOnLoadData<"highcharts"> | undefined) => void) | undefined;
|
|
@@ -4,7 +4,6 @@ import './IndicatorWidget.css';
|
|
|
4
4
|
declare const IndicatorWidget: React.ForwardRefExoticComponent<{
|
|
5
5
|
type: "indicator";
|
|
6
6
|
data: import("../types").IndicatorWidgetData;
|
|
7
|
-
pluginRef?: undefined;
|
|
8
7
|
id?: string | undefined;
|
|
9
8
|
isMobile?: boolean | undefined;
|
|
10
9
|
onLoad?: ((data?: import("../../../types").ChartKitOnLoadData<"indicator"> | undefined) => void) | undefined;
|
|
@@ -3,3 +3,4 @@ declare const _default: import("@storybook/types").ComponentAnnotations<import("
|
|
|
3
3
|
export default _default;
|
|
4
4
|
export declare const Line: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, any>;
|
|
5
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,10 +1,12 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import { Button } from '@gravity-ui/uikit';
|
|
3
3
|
import { settings } from '../../../libs';
|
|
4
4
|
import { YagrPlugin } from '../../../plugins';
|
|
5
5
|
import { ChartKit } from '../../../components/ChartKit';
|
|
6
6
|
import { getNewConfig, line10 } from './mocks/line10';
|
|
7
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';
|
|
8
10
|
export default {
|
|
9
11
|
title: 'Plugins/Yagr',
|
|
10
12
|
component: ChartKit,
|
|
@@ -12,14 +14,12 @@ export default {
|
|
|
12
14
|
const LineTemplate = () => {
|
|
13
15
|
const [shown, setShown] = React.useState(false);
|
|
14
16
|
const chartkitRef = React.useRef();
|
|
15
|
-
// Example of usage pluginRef property
|
|
16
|
-
const yagrPluginRef = React.useRef(null);
|
|
17
17
|
if (!shown) {
|
|
18
18
|
settings.set({ plugins: [YagrPlugin] });
|
|
19
19
|
return React.createElement(Button, { onClick: () => setShown(true) }, "Show chart");
|
|
20
20
|
}
|
|
21
21
|
return (React.createElement("div", { style: { height: 300, width: '100%' } },
|
|
22
|
-
React.createElement(ChartKit, { ref: chartkitRef, id: "1", type: "yagr", data: line10
|
|
22
|
+
React.createElement(ChartKit, { ref: chartkitRef, id: "1", type: "yagr", data: line10 })));
|
|
23
23
|
};
|
|
24
24
|
const UpdatesTemplate = () => {
|
|
25
25
|
const [shown, setShown] = React.useState(false);
|
|
@@ -39,5 +39,52 @@ const UpdatesTemplate = () => {
|
|
|
39
39
|
React.createElement(Button, { onClick: onStartUpdates }, "Start Updates"),
|
|
40
40
|
React.createElement(Button, { onClick: () => setState(getNewConfig()) }, "Once")));
|
|
41
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
|
+
};
|
|
42
88
|
export const Line = LineTemplate.bind({});
|
|
43
89
|
export const Updates = UpdatesTemplate.bind({});
|
|
90
|
+
export const CustomTooltip = CustomTooltipImpl.bind({});
|
|
@@ -30,6 +30,7 @@ export declare const getNewConfig: () => {
|
|
|
30
30
|
id?: string | undefined;
|
|
31
31
|
scale?: string | undefined;
|
|
32
32
|
focus?: boolean | undefined;
|
|
33
|
+
title?: string | ((sIdx: number) => string) | undefined;
|
|
33
34
|
show?: boolean | undefined;
|
|
34
35
|
color?: string | undefined;
|
|
35
36
|
spanGaps?: boolean | undefined;
|
|
@@ -38,7 +39,6 @@ export declare const getNewConfig: () => {
|
|
|
38
39
|
precision?: number | undefined;
|
|
39
40
|
snapToValues?: false | import("@gravity-ui/yagr/dist/YagrCore/types").SnapToValue | undefined;
|
|
40
41
|
stackGroup?: number | undefined;
|
|
41
|
-
title?: string | ((sIdx: number) => string) | undefined;
|
|
42
42
|
transform?: ((val: string | number | null, series: import("@gravity-ui/yagr/dist/YagrCore/types").DataSeries[], idx: number) => number | null) | undefined;
|
|
43
43
|
showInTooltip?: boolean | undefined;
|
|
44
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;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { YagrReactRef } from '@gravity-ui/yagr/dist/react';
|
|
3
2
|
import type { ChartKitWidgetRef } from '../../../types';
|
|
4
3
|
import './polyfills';
|
|
5
4
|
import '@gravity-ui/yagr/dist/index.css';
|
|
@@ -7,7 +6,6 @@ import './YagrWidget.css';
|
|
|
7
6
|
declare const YagrWidget: React.ForwardRefExoticComponent<{
|
|
8
7
|
type: "yagr";
|
|
9
8
|
data: import("../types").YagrWidgetData;
|
|
10
|
-
pluginRef?: React.MutableRefObject<YagrReactRef | null> | undefined;
|
|
11
9
|
id?: string | undefined;
|
|
12
10
|
isMobile?: boolean | undefined;
|
|
13
11
|
onLoad?: ((data?: import("../../../types").ChartKitOnLoadData<"yagr"> | undefined) => void) | undefined;
|
|
@@ -16,7 +14,9 @@ declare const YagrWidget: React.ForwardRefExoticComponent<{
|
|
|
16
14
|
onError?: import("../../../types").ChartKitOnError | undefined;
|
|
17
15
|
renderError?: import("../../../types").RenderError | undefined;
|
|
18
16
|
renderPluginLoader?: (() => React.ReactNode) | undefined;
|
|
19
|
-
} & {
|
|
17
|
+
} & {
|
|
18
|
+
tooltip?: (<T extends import("../types").CustomTooltipProps = import("../types").CustomTooltipProps>(props: T) => React.ReactNode) | undefined;
|
|
19
|
+
} & {
|
|
20
20
|
id: string;
|
|
21
21
|
} & React.RefAttributes<ChartKitWidgetRef | undefined>>;
|
|
22
22
|
export default YagrWidget;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import isEmpty from 'lodash/isEmpty';
|
|
3
|
-
import { useForkRef } from '@gravity-ui/uikit';
|
|
4
3
|
import YagrComponent from '@gravity-ui/yagr/dist/react';
|
|
5
4
|
import { i18n } from '../../../i18n';
|
|
6
5
|
import { CHARTKIT_ERROR_CODE, ChartKitError } from '../../../libs';
|
|
@@ -10,27 +9,24 @@ import './polyfills';
|
|
|
10
9
|
import '@gravity-ui/yagr/dist/index.css';
|
|
11
10
|
import './YagrWidget.css';
|
|
12
11
|
const YagrWidget = React.forwardRef((props, forwardedRef) => {
|
|
13
|
-
const { id, data: { data },
|
|
12
|
+
const { id, data: { data }, onLoad, onRender, onChartLoad, tooltip, } = props;
|
|
14
13
|
const yagrRef = React.useRef(null);
|
|
15
|
-
const
|
|
14
|
+
const [yagr, setYagr] = React.useState();
|
|
16
15
|
if (!data || isEmpty(data)) {
|
|
17
16
|
throw new ChartKitError({
|
|
18
17
|
code: CHARTKIT_ERROR_CODE.NO_DATA,
|
|
19
18
|
message: i18n('error', 'label_no-data'),
|
|
20
19
|
});
|
|
21
20
|
}
|
|
22
|
-
const { config, debug } = useWidgetData(
|
|
21
|
+
const { config, debug } = useWidgetData(props, id);
|
|
23
22
|
const handleChartLoading = React.useCallback((chart, { renderTime }) => {
|
|
24
23
|
onLoad === null || onLoad === void 0 ? void 0 : onLoad(Object.assign(Object.assign({}, data), { widget: chart, widgetRendering: renderTime }));
|
|
25
24
|
onRender === null || onRender === void 0 ? void 0 : onRender({ renderTime });
|
|
26
|
-
|
|
25
|
+
setYagr(chart);
|
|
26
|
+
}, [onLoad, onRender, data, setYagr]);
|
|
27
27
|
const onWindowResize = React.useCallback(() => {
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
if (!chart) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
chart.reflow();
|
|
28
|
+
if (yagr) {
|
|
29
|
+
yagr.reflow();
|
|
34
30
|
}
|
|
35
31
|
}, []);
|
|
36
32
|
React.useImperativeHandle(forwardedRef, () => ({
|
|
@@ -39,28 +35,24 @@ const YagrWidget = React.forwardRef((props, forwardedRef) => {
|
|
|
39
35
|
},
|
|
40
36
|
}), [onWindowResize]);
|
|
41
37
|
React.useEffect(() => {
|
|
42
|
-
var _a, _b, _c, _d, _e
|
|
43
|
-
|
|
44
|
-
if (!yagr) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
if ((_c = (_b = yagr.config) === null || _b === void 0 ? void 0 : _b.tooltip) === null || _c === void 0 ? void 0 : _c.virtual) {
|
|
38
|
+
var _a, _b, _c, _d, _e;
|
|
39
|
+
if (!yagr || ((_b = (_a = yagr.config) === null || _a === void 0 ? void 0 : _a.tooltip) === null || _b === void 0 ? void 0 : _b.virtual)) {
|
|
48
40
|
return;
|
|
49
41
|
}
|
|
50
42
|
const handlers = {
|
|
51
43
|
mouseMove: null,
|
|
52
44
|
mouseDown: null,
|
|
53
45
|
};
|
|
54
|
-
(
|
|
46
|
+
(_c = yagr.plugins.tooltip) === null || _c === void 0 ? void 0 : _c.on('render', (tooltip) => {
|
|
55
47
|
synchronizeTooltipTablesCellsWidth(tooltip);
|
|
56
48
|
});
|
|
57
|
-
(
|
|
49
|
+
(_d = yagr.plugins.tooltip) === null || _d === void 0 ? void 0 : _d.on('pin', (tooltip, { actions }) => {
|
|
58
50
|
handlers.mouseMove = checkFocus({ tooltip, yagr });
|
|
59
51
|
handlers.mouseDown = detectClickOutside({ tooltip, actions, yagr });
|
|
60
52
|
document.addEventListener('mousemove', handlers.mouseMove);
|
|
61
53
|
document.addEventListener('mousedown', handlers.mouseDown);
|
|
62
54
|
});
|
|
63
|
-
(
|
|
55
|
+
(_e = yagr.plugins.tooltip) === null || _e === void 0 ? void 0 : _e.on('unpin', () => {
|
|
64
56
|
if (handlers.mouseMove) {
|
|
65
57
|
document.removeEventListener('mousemove', handlers.mouseMove);
|
|
66
58
|
handlers.mouseMove = null;
|
|
@@ -70,11 +62,16 @@ const YagrWidget = React.forwardRef((props, forwardedRef) => {
|
|
|
70
62
|
handlers.mouseDown = null;
|
|
71
63
|
}
|
|
72
64
|
});
|
|
73
|
-
}, []);
|
|
65
|
+
}, [yagr]);
|
|
74
66
|
React.useLayoutEffect(() => {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
67
|
+
onChartLoad === null || onChartLoad === void 0 ? void 0 : onChartLoad({ widget: yagr });
|
|
68
|
+
}, [yagr, onChartLoad]);
|
|
69
|
+
return (React.createElement(React.Fragment, null,
|
|
70
|
+
tooltip &&
|
|
71
|
+
yagr &&
|
|
72
|
+
tooltip({
|
|
73
|
+
yagr,
|
|
74
|
+
}),
|
|
75
|
+
React.createElement(YagrComponent, { ref: yagrRef, id: id, config: config, debug: debug, onChartLoad: handleChartLoading })));
|
|
79
76
|
});
|
|
80
77
|
export default YagrWidget;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { YagrChartProps } from '@gravity-ui/yagr/dist/react';
|
|
2
|
-
import type {
|
|
3
|
-
export declare const useWidgetData: (
|
|
4
|
-
id: string;
|
|
5
|
-
}) => {
|
|
2
|
+
import type { MinimalValidConfig, YagrWidgetProps } from '../types';
|
|
3
|
+
export declare const useWidgetData: (props: YagrWidgetProps, id: string) => {
|
|
6
4
|
config: MinimalValidConfig;
|
|
7
5
|
debug: YagrChartProps['debug'];
|
|
8
6
|
};
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useThemeValue } from '@gravity-ui/uikit';
|
|
3
3
|
import { shapeYagrConfig } from './utils';
|
|
4
|
-
export const useWidgetData = (
|
|
5
|
-
const {
|
|
4
|
+
export const useWidgetData = (props, id) => {
|
|
5
|
+
const { data, sources, libraryConfig } = props.data;
|
|
6
6
|
const theme = useThemeValue();
|
|
7
|
-
const config = React.useMemo(() => shapeYagrConfig({
|
|
7
|
+
const config = React.useMemo(() => shapeYagrConfig({
|
|
8
|
+
data,
|
|
9
|
+
libraryConfig,
|
|
10
|
+
theme,
|
|
11
|
+
customTooltip: Boolean(props.tooltip),
|
|
12
|
+
}), [data, libraryConfig, theme, props.tooltip]);
|
|
8
13
|
const debug = React.useMemo(() => {
|
|
9
14
|
const filename = sources
|
|
10
15
|
? Object.values(sources)
|
|
@@ -3,6 +3,7 @@ type ShapeYagrConfigArgs = {
|
|
|
3
3
|
data: YagrWidgetData['data'];
|
|
4
4
|
libraryConfig: YagrWidgetData['libraryConfig'];
|
|
5
5
|
theme: YagrTheme;
|
|
6
|
+
customTooltip?: boolean;
|
|
6
7
|
};
|
|
7
8
|
export declare const synchronizeTooltipTablesCellsWidth: (tooltipContainer: HTMLElement) => void;
|
|
8
9
|
export declare const checkFocus: (args: {
|
|
@@ -101,6 +101,9 @@ export const shapeYagrConfig = (args) => {
|
|
|
101
101
|
// "className" property prevent default yagr styles adding
|
|
102
102
|
config.tooltip.className = 'chartkit-yagr-tooltip';
|
|
103
103
|
}
|
|
104
|
+
if (args.customTooltip) {
|
|
105
|
+
config.tooltip.virtual = true;
|
|
106
|
+
}
|
|
104
107
|
}
|
|
105
108
|
config.axes = config.axes || {};
|
|
106
109
|
const xAxis = config.axes[defaults.DEFAULT_X_SCALE];
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
import type { RawSerieData, YagrConfig } from '@gravity-ui/yagr';
|
|
1
|
+
import type { MinimalValidConfig, RawSerieData, YagrConfig } from '@gravity-ui/yagr';
|
|
2
|
+
import type Yagr from '@gravity-ui/yagr';
|
|
3
|
+
import { ChartKitProps } from 'src/types';
|
|
2
4
|
export type { default as Yagr } from '@gravity-ui/yagr';
|
|
3
5
|
export type { YagrReactRef } from '@gravity-ui/yagr/dist/react';
|
|
4
6
|
export * from '@gravity-ui/yagr/dist/types';
|
|
7
|
+
export interface CustomTooltipProps {
|
|
8
|
+
yagr: Yagr<MinimalValidConfig> | undefined;
|
|
9
|
+
}
|
|
10
|
+
export type YagrWidgetProps = ChartKitProps<'yagr'> & {
|
|
11
|
+
id: string;
|
|
12
|
+
};
|
|
5
13
|
export type YagrWidgetData = {
|
|
6
14
|
data: {
|
|
7
15
|
graphs: RawSerieData[];
|
package/build/types/index.d.ts
CHANGED
|
@@ -26,8 +26,6 @@ export type ChartKitOnError = (data: {
|
|
|
26
26
|
export type ChartKitProps<T extends ChartKitType> = {
|
|
27
27
|
type: T;
|
|
28
28
|
data: ChartKitWidget[T]['data'];
|
|
29
|
-
/** Plugin component's react ref */
|
|
30
|
-
pluginRef?: ChartKitWidget[T]['pluginRef'];
|
|
31
29
|
id?: string;
|
|
32
30
|
isMobile?: boolean;
|
|
33
31
|
onLoad?: (data?: ChartKitOnLoadData<T>) => void;
|
|
@@ -42,7 +40,7 @@ export type ChartKitProps<T extends ChartKitType> = {
|
|
|
42
40
|
/** Used to render user's plugin loader component */
|
|
43
41
|
renderPluginLoader?: () => React.ReactNode;
|
|
44
42
|
} & {
|
|
45
|
-
[key in keyof Omit<ChartKitWidget[T], 'data' | 'widget'
|
|
43
|
+
[key in keyof Omit<ChartKitWidget[T], 'data' | 'widget'>]: ChartKitWidget[T][key];
|
|
46
44
|
};
|
|
47
45
|
export type ChartKitPlugin = {
|
|
48
46
|
type: ChartKitType;
|
package/build/types/widget.d.ts
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type {
|
|
2
|
+
import type { CustomTooltipProps, Yagr, YagrWidgetData } from '../plugins/yagr/types';
|
|
3
3
|
import type { IndicatorWidgetData } from '../plugins/indicator/types';
|
|
4
4
|
import type { Highcharts, HighchartsWidgetData, StringParams } from '../plugins/highcharts/types';
|
|
5
5
|
export interface ChartKitWidget {
|
|
6
6
|
yagr: {
|
|
7
7
|
data: YagrWidgetData;
|
|
8
8
|
widget: Yagr;
|
|
9
|
-
|
|
9
|
+
tooltip?: <T extends CustomTooltipProps = CustomTooltipProps>(props: T) => React.ReactNode;
|
|
10
10
|
};
|
|
11
11
|
indicator: {
|
|
12
12
|
data: IndicatorWidgetData;
|
|
13
13
|
widget: never;
|
|
14
|
-
pluginRef: never;
|
|
15
14
|
formatNumber?: <T = any>(value: number, options?: T) => string;
|
|
16
15
|
};
|
|
17
16
|
highcharts: {
|
|
18
17
|
data: HighchartsWidgetData;
|
|
19
18
|
widget: Highcharts.Chart | null;
|
|
20
|
-
pluginRef: never;
|
|
21
19
|
hoistConfigError?: boolean;
|
|
22
20
|
nonBodyScroll?: boolean;
|
|
23
21
|
splitTooltip?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravity-ui/chartkit",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.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",
|
|
@@ -14,10 +14,8 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@gravity-ui/date-utils": "^1.4.1",
|
|
17
|
-
"@gravity-ui/yagr": "^3.
|
|
17
|
+
"@gravity-ui/yagr": "^3.7.0",
|
|
18
18
|
"bem-cn-lite": "^4.1.0",
|
|
19
|
-
"highcharts": "^8.2.2",
|
|
20
|
-
"highcharts-react-official": "^3.0.0",
|
|
21
19
|
"lodash": "^4.17.21",
|
|
22
20
|
"react-split-pane": "^0.1.92"
|
|
23
21
|
},
|
|
@@ -30,7 +28,7 @@
|
|
|
30
28
|
"@gravity-ui/prettier-config": "^1.0.1",
|
|
31
29
|
"@gravity-ui/stylelint-config": "^1.0.1",
|
|
32
30
|
"@gravity-ui/tsconfig": "^1.0.0",
|
|
33
|
-
"@gravity-ui/uikit": "^
|
|
31
|
+
"@gravity-ui/uikit": "^5.0.0",
|
|
34
32
|
"@storybook/addon-essentials": "^7.0.26",
|
|
35
33
|
"@storybook/addon-knobs": "^7.0.2",
|
|
36
34
|
"@storybook/cli": "^7.0.26",
|
|
@@ -51,6 +49,8 @@
|
|
|
51
49
|
"gulp-dart-sass": "^1.0.2",
|
|
52
50
|
"gulp-replace": "^1.1.3",
|
|
53
51
|
"gulp-typescript": "^5.0.1",
|
|
52
|
+
"highcharts": "^8.2.2",
|
|
53
|
+
"highcharts-react-official": "^3.2.0",
|
|
54
54
|
"husky": "^4.2.5",
|
|
55
55
|
"jest": "^28.1.3",
|
|
56
56
|
"jest-environment-jsdom": "^28.1.2",
|
|
@@ -71,7 +71,9 @@
|
|
|
71
71
|
"typescript": "^4.9.5"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
|
-
"@gravity-ui/uikit": "^
|
|
74
|
+
"@gravity-ui/uikit": "^5.0.0",
|
|
75
|
+
"highcharts": "^8.2.2",
|
|
76
|
+
"highcharts-react-official": "^3.2.0",
|
|
75
77
|
"react": "^16.0.0 || ^17.0.0 || ^18.0.0"
|
|
76
78
|
},
|
|
77
79
|
"scripts": {
|