@gravity-ui/chartkit 3.0.0-beta.zefirka.11 → 3.0.0-beta.zefirka.12
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.js +2 -4
- package/build/plugins/yagr/renderer/YagrWidget.d.ts +1 -5
- package/build/plugins/yagr/renderer/YagrWidget.js +6 -2
- package/build/plugins/yagr/renderer/useWidgetData.js +2 -2
- package/build/plugins/yagr/types.d.ts +3 -6
- package/build/types/index.d.ts +1 -3
- package/build/types/widget.d.ts +2 -5
- package/package.json +2 -2
|
@@ -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], "data" | "widget"
|
|
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;
|
|
@@ -13,14 +13,12 @@ export default {
|
|
|
13
13
|
const LineTemplate = () => {
|
|
14
14
|
const [shown, setShown] = React.useState(false);
|
|
15
15
|
const chartkitRef = React.useRef();
|
|
16
|
-
// Example of usage pluginRef property
|
|
17
|
-
const yagrPluginRef = React.useRef(null);
|
|
18
16
|
if (!shown) {
|
|
19
17
|
settings.set({ plugins: [YagrPlugin] });
|
|
20
18
|
return React.createElement(Button, { onClick: () => setShown(true) }, "Show chart");
|
|
21
19
|
}
|
|
22
20
|
return (React.createElement("div", { style: { height: 300, width: '100%' } },
|
|
23
|
-
React.createElement(ChartKit, { ref: chartkitRef, id: "1", type: "yagr", data: line10
|
|
21
|
+
React.createElement(ChartKit, { ref: chartkitRef, id: "1", type: "yagr", data: line10 })));
|
|
24
22
|
};
|
|
25
23
|
const UpdatesTemplate = () => {
|
|
26
24
|
const [shown, setShown] = React.useState(false);
|
|
@@ -83,7 +81,7 @@ const CustomTooltipImpl = () => {
|
|
|
83
81
|
return React.createElement(Button, { onClick: () => setShown(true) }, "Show chart");
|
|
84
82
|
}
|
|
85
83
|
return (React.createElement("div", { style: { height: 300, width: '100%' } },
|
|
86
|
-
React.createElement(ChartKit, { ref: chartkitRef, id: "1", type: "yagr", data: state,
|
|
84
|
+
React.createElement(ChartKit, { ref: chartkitRef, id: "1", type: "yagr", data: state, tooltip: (props) => React.createElement(Tooltip, Object.assign({}, props)) }),
|
|
87
85
|
React.createElement(Button, { onClick: () => setState(getNewConfig()) }, "Change data")));
|
|
88
86
|
};
|
|
89
87
|
export const Line = LineTemplate.bind({});
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { YagrReactRef } from '@gravity-ui/yagr/dist/react';
|
|
3
2
|
import type { ChartKitWidgetRef } from '../../../types';
|
|
4
|
-
import { Yagr } from '../types';
|
|
5
3
|
import './polyfills';
|
|
6
4
|
import '@gravity-ui/yagr/dist/index.css';
|
|
7
5
|
import './YagrWidget.css';
|
|
8
6
|
declare const YagrWidget: React.ForwardRefExoticComponent<{
|
|
9
7
|
type: "yagr";
|
|
10
8
|
data: import("../types").YagrWidgetData;
|
|
11
|
-
pluginRef?: React.MutableRefObject<YagrReactRef | null> | undefined;
|
|
12
9
|
id?: string | undefined;
|
|
13
10
|
isMobile?: boolean | undefined;
|
|
14
11
|
onLoad?: ((data?: import("../../../types").ChartKitOnLoadData<"yagr"> | undefined) => void) | undefined;
|
|
@@ -18,9 +15,8 @@ declare const YagrWidget: React.ForwardRefExoticComponent<{
|
|
|
18
15
|
renderError?: import("../../../types").RenderError | undefined;
|
|
19
16
|
renderPluginLoader?: (() => React.ReactNode) | undefined;
|
|
20
17
|
} & {
|
|
21
|
-
|
|
18
|
+
tooltip?: (<T extends import("../types").CustomTooltipProps = import("../types").CustomTooltipProps>(props: T) => React.ReactNode) | undefined;
|
|
22
19
|
} & {
|
|
23
20
|
id: string;
|
|
24
|
-
CustomTooltip?: React.ComponentType<import("../types").CustomTooltipProps<Yagr<import("@gravity-ui/yagr/dist/YagrCore/types").MinimalValidConfig>>> | undefined;
|
|
25
21
|
} & React.RefAttributes<ChartKitWidgetRef | undefined>>;
|
|
26
22
|
export default YagrWidget;
|
|
@@ -9,7 +9,7 @@ import './polyfills';
|
|
|
9
9
|
import '@gravity-ui/yagr/dist/index.css';
|
|
10
10
|
import './YagrWidget.css';
|
|
11
11
|
const YagrWidget = React.forwardRef((props, forwardedRef) => {
|
|
12
|
-
const { id, data: { data }, onLoad, onRender, onChartLoad,
|
|
12
|
+
const { id, data: { data }, onLoad, onRender, onChartLoad, tooltip, } = props;
|
|
13
13
|
const yagrRef = React.useRef(null);
|
|
14
14
|
const [yagr, setYagr] = React.useState();
|
|
15
15
|
if (!data || isEmpty(data)) {
|
|
@@ -67,7 +67,11 @@ const YagrWidget = React.forwardRef((props, forwardedRef) => {
|
|
|
67
67
|
onChartLoad === null || onChartLoad === void 0 ? void 0 : onChartLoad({ widget: yagr });
|
|
68
68
|
}, [yagr, onChartLoad]);
|
|
69
69
|
return (React.createElement(React.Fragment, null,
|
|
70
|
-
|
|
70
|
+
tooltip &&
|
|
71
|
+
yagr &&
|
|
72
|
+
tooltip({
|
|
73
|
+
yagr,
|
|
74
|
+
}),
|
|
71
75
|
React.createElement(YagrComponent, { ref: yagrRef, id: id, config: config, debug: debug, onChartLoad: handleChartLoading })));
|
|
72
76
|
});
|
|
73
77
|
export default YagrWidget;
|
|
@@ -8,8 +8,8 @@ export const useWidgetData = (props, id) => {
|
|
|
8
8
|
data,
|
|
9
9
|
libraryConfig,
|
|
10
10
|
theme,
|
|
11
|
-
customTooltip: Boolean(props.
|
|
12
|
-
}), [data, libraryConfig, theme, props.
|
|
11
|
+
customTooltip: Boolean(props.tooltip),
|
|
12
|
+
}), [data, libraryConfig, theme, props.tooltip]);
|
|
13
13
|
const debug = React.useMemo(() => {
|
|
14
14
|
const filename = sources
|
|
15
15
|
? Object.values(sources)
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
import type { MinimalValidConfig, RawSerieData, TooltipOptions, YagrConfig } from '@gravity-ui/yagr';
|
|
1
|
+
import type { MinimalValidConfig, RawSerieData, YagrConfig } from '@gravity-ui/yagr';
|
|
3
2
|
import type Yagr from '@gravity-ui/yagr';
|
|
4
3
|
import { ChartKitProps } from 'src/types';
|
|
5
4
|
export type { default as Yagr } from '@gravity-ui/yagr';
|
|
6
5
|
export type { YagrReactRef } from '@gravity-ui/yagr/dist/react';
|
|
7
6
|
export * from '@gravity-ui/yagr/dist/types';
|
|
8
|
-
export interface CustomTooltipProps
|
|
9
|
-
|
|
10
|
-
yagr: T | undefined;
|
|
7
|
+
export interface CustomTooltipProps {
|
|
8
|
+
yagr: Yagr<MinimalValidConfig> | undefined;
|
|
11
9
|
}
|
|
12
10
|
export type YagrWidgetProps = ChartKitProps<'yagr'> & {
|
|
13
11
|
id: string;
|
|
14
|
-
CustomTooltip?: React.ComponentType<CustomTooltipProps>;
|
|
15
12
|
};
|
|
16
13
|
export type YagrWidgetData = {
|
|
17
14
|
data: {
|
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,24 +1,21 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { CustomTooltipProps, Yagr,
|
|
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
|
-
|
|
10
|
-
CustomTooltip?: React.ComponentType<CustomTooltipProps>;
|
|
9
|
+
tooltip?: <T extends CustomTooltipProps = CustomTooltipProps>(props: T) => React.ReactNode;
|
|
11
10
|
};
|
|
12
11
|
indicator: {
|
|
13
12
|
data: IndicatorWidgetData;
|
|
14
13
|
widget: never;
|
|
15
|
-
pluginRef: never;
|
|
16
14
|
formatNumber?: <T = any>(value: number, options?: T) => string;
|
|
17
15
|
};
|
|
18
16
|
highcharts: {
|
|
19
17
|
data: HighchartsWidgetData;
|
|
20
18
|
widget: Highcharts.Chart | null;
|
|
21
|
-
pluginRef: never;
|
|
22
19
|
hoistConfigError?: boolean;
|
|
23
20
|
nonBodyScroll?: boolean;
|
|
24
21
|
splitTooltip?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravity-ui/chartkit",
|
|
3
|
-
"version": "3.0.0-beta.zefirka.
|
|
3
|
+
"version": "3.0.0-beta.zefirka.12",
|
|
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,7 +14,7 @@
|
|
|
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
19
|
"highcharts": "^8.2.2",
|
|
20
20
|
"highcharts-react-official": "^3.0.0",
|