@gravity-ui/chartkit 3.0.0-beta.11 → 3.0.0-beta.16
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.css +19 -19
- package/build/components/ChartKit.d.ts +1 -2
- package/build/plugins/highcharts/mocks/complex.js +1 -1
- package/build/plugins/highcharts/renderer/HighchartsWidget.d.ts +0 -1
- package/build/plugins/highcharts/renderer/components/StyledSplitPane/StyledSplitPane.css +1 -1
- package/build/plugins/highcharts/renderer/helpers/config/config.js +4 -4
- package/build/plugins/highcharts/renderer/helpers/config/options.js +1 -1
- package/build/plugins/highcharts/renderer/helpers/graph.css +4 -4
- package/build/plugins/highcharts/renderer/helpers/tooltip/tooltip.css +5 -5
- package/build/plugins/indicator/renderer/IndicatorWidget.css +1 -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 +50 -4
- package/build/plugins/yagr/__stories__/mocks/line10.d.ts +1 -1
- package/build/plugins/yagr/renderer/YagrWidget.css +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/tooltip/tooltip.css +14 -14
- 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 +4 -4
|
@@ -8,24 +8,24 @@
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
.chartkit-theme_common {
|
|
11
|
-
--highcarts-navigator-border: var(--
|
|
12
|
-
--highcarts-navigator-track: var(--
|
|
13
|
-
--highcarts-navigator-body: var(--
|
|
14
|
-
--highcharts-series-border: var(--
|
|
15
|
-
--highcharts-grid-line: var(--
|
|
16
|
-
--highcharts-axis-line: var(--
|
|
17
|
-
--highcharts-tick: var(--
|
|
18
|
-
--highcharts-title: var(--
|
|
19
|
-
--highcharts-axis-labels: var(--
|
|
20
|
-
--highcharts-data-labels: var(--
|
|
21
|
-
--highcharts-plot-line-label: var(--
|
|
22
|
-
--highcharts-legend-item: var(--
|
|
23
|
-
--highcharts-legend-item-hover: var(--
|
|
24
|
-
--highcharts-legend-item-hidden: var(--
|
|
25
|
-
--highcharts-floating-bg: var(--
|
|
26
|
-
--highcharts-tooltip-text: var(--
|
|
11
|
+
--highcarts-navigator-border: var(--yc-color-line-generic);
|
|
12
|
+
--highcarts-navigator-track: var(--yc-color-base-generic);
|
|
13
|
+
--highcarts-navigator-body: var(--yc-color-scroll-handle);
|
|
14
|
+
--highcharts-series-border: var(--yc-color-base-background);
|
|
15
|
+
--highcharts-grid-line: var(--yc-color-line-generic);
|
|
16
|
+
--highcharts-axis-line: var(--yc-color-line-generic);
|
|
17
|
+
--highcharts-tick: var(--yc-color-line-generic);
|
|
18
|
+
--highcharts-title: var(--yc-color-text-primary);
|
|
19
|
+
--highcharts-axis-labels: var(--yc-color-text-secondary);
|
|
20
|
+
--highcharts-data-labels: var(--yc-color-text-complementary);
|
|
21
|
+
--highcharts-plot-line-label: var(--yc-color-text-complementary);
|
|
22
|
+
--highcharts-legend-item: var(--yc-color-text-secondary);
|
|
23
|
+
--highcharts-legend-item-hover: var(--yc-color-text-primary);
|
|
24
|
+
--highcharts-legend-item-hidden: var(--yc-color-text-hint);
|
|
25
|
+
--highcharts-floating-bg: var(--yc-color-infographics-tooltip-bg);
|
|
26
|
+
--highcharts-tooltip-text: var(--yc-color-text-primary);
|
|
27
27
|
--highcharts-tooltip-bg: var(--highcharts-floating-bg);
|
|
28
|
-
--highcharts-tooltip-alternate-bg: var(--
|
|
29
|
-
--highcharts-tooltip-text-complementary: var(--
|
|
30
|
-
--highcharts-holiday-band: var(--
|
|
28
|
+
--highcharts-tooltip-alternate-bg: var(--yc-color-base-generic);
|
|
29
|
+
--highcharts-tooltip-text-complementary: var(--yc-color-text-complementary);
|
|
30
|
+
--highcharts-holiday-band: var(--yc-color-base-generic);
|
|
31
31
|
}
|
|
@@ -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 {};
|
|
@@ -244,7 +244,7 @@ export const data = {
|
|
|
244
244
|
.rect(rect.x, rect.y, rect.width, rect.height)
|
|
245
245
|
.addClass('highcharts-axis-grid-divider')
|
|
246
246
|
.attr({
|
|
247
|
-
fill: 'var(--
|
|
247
|
+
fill: 'var(--yc-color-base-background)',
|
|
248
248
|
zIndex: 8,
|
|
249
249
|
})
|
|
250
250
|
.add();
|
|
@@ -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;
|
|
@@ -159,12 +159,12 @@ export function buildLegend(options) {
|
|
|
159
159
|
}
|
|
160
160
|
},
|
|
161
161
|
navigation: {
|
|
162
|
-
activeColor: 'var(--
|
|
163
|
-
inactiveColor: 'var(--
|
|
164
|
-
style: { color: 'var(--
|
|
162
|
+
activeColor: 'var(--yc-color-base-special)',
|
|
163
|
+
inactiveColor: 'var(--yc-color-base-generic-accent-disabled)',
|
|
164
|
+
style: { color: 'var(--yc-color-text-primary)' },
|
|
165
165
|
},
|
|
166
166
|
title: {
|
|
167
|
-
style: { color: 'var(--
|
|
167
|
+
style: { color: 'var(--yc-color-text-secondary)' },
|
|
168
168
|
},
|
|
169
169
|
};
|
|
170
170
|
if (options.outsideLegend) {
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
.chartkit-graph .highcharts-legend .highcharts-coloraxis-labels text {
|
|
11
|
-
fill: var(--
|
|
12
|
-
color: var(--
|
|
11
|
+
fill: var(--yc-color-text-secondary) !important;
|
|
12
|
+
color: var(--yc-color-text-secondary) !important;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
.chartkit-graph .highcharts-legend .highcharts-coloraxis-grid path {
|
|
16
|
-
stroke: var(--
|
|
16
|
+
stroke: var(--yc-color-base-background);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
.chartkit-tooltip {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
border: none;
|
|
32
32
|
border-radius: 0;
|
|
33
33
|
box-shadow: none;
|
|
34
|
-
border-bottom: 1px solid var(--
|
|
34
|
+
border-bottom: 1px solid var(--yc-color-line-generic);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
.chartkit-tooltip_yandex-map {
|
|
@@ -4,19 +4,19 @@
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
.chartkit-highcharts-tooltip-container._tooltip-with-scroll ._tooltip-header td:last-child {
|
|
7
|
-
padding-right: calc(18px + var(--
|
|
7
|
+
padding-right: calc(18px + var(--yc-scrollbar-width, 15px));
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
.chartkit-highcharts-tooltip-container._tooltip-with-scroll ._tooltip-footer td:last-child {
|
|
11
|
-
padding-right: calc(18px + var(--
|
|
11
|
+
padding-right: calc(18px + var(--yc-scrollbar-width, 15px));
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
.chartkit-highcharts-tooltip-container._tooltip-with-scroll-in-safari ._tooltip-row td:last-child {
|
|
15
|
-
padding-right: calc(18px + var(--
|
|
15
|
+
padding-right: calc(18px + var(--yc-scrollbar-width, 15px));
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
.chartkit-highcharts-tooltip-container._tooltip-with-scroll-in-safari ._tooltip-rows__summ-tr td:last-child {
|
|
19
|
-
padding-right: calc(18px + var(--
|
|
19
|
+
padding-right: calc(18px + var(--yc-scrollbar-width, 15px));
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
._tooltip {
|
|
@@ -347,7 +347,7 @@
|
|
|
347
347
|
}
|
|
348
348
|
|
|
349
349
|
._tooltip-right__traf-div_for-split-tooltip {
|
|
350
|
-
color: var(--
|
|
350
|
+
color: var(--yc-color-text-secondary);
|
|
351
351
|
padding-left: 8px;
|
|
352
352
|
border-top: none;
|
|
353
353
|
border-left: 2px solid;
|
|
@@ -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,11 @@
|
|
|
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';
|
|
8
9
|
export default {
|
|
9
10
|
title: 'Plugins/Yagr',
|
|
10
11
|
component: ChartKit,
|
|
@@ -12,14 +13,12 @@ export default {
|
|
|
12
13
|
const LineTemplate = () => {
|
|
13
14
|
const [shown, setShown] = React.useState(false);
|
|
14
15
|
const chartkitRef = React.useRef();
|
|
15
|
-
// Example of usage pluginRef property
|
|
16
|
-
const yagrPluginRef = React.useRef(null);
|
|
17
16
|
if (!shown) {
|
|
18
17
|
settings.set({ plugins: [YagrPlugin] });
|
|
19
18
|
return React.createElement(Button, { onClick: () => setShown(true) }, "Show chart");
|
|
20
19
|
}
|
|
21
20
|
return (React.createElement("div", { style: { height: 300, width: '100%' } },
|
|
22
|
-
React.createElement(ChartKit, { ref: chartkitRef, id: "1", type: "yagr", data: line10
|
|
21
|
+
React.createElement(ChartKit, { ref: chartkitRef, id: "1", type: "yagr", data: line10 })));
|
|
23
22
|
};
|
|
24
23
|
const UpdatesTemplate = () => {
|
|
25
24
|
const [shown, setShown] = React.useState(false);
|
|
@@ -39,5 +38,52 @@ const UpdatesTemplate = () => {
|
|
|
39
38
|
React.createElement(Button, { onClick: onStartUpdates }, "Start Updates"),
|
|
40
39
|
React.createElement(Button, { onClick: () => setState(getNewConfig()) }, "Once")));
|
|
41
40
|
};
|
|
41
|
+
function Tooltip({ yagr }) {
|
|
42
|
+
const [x, setX] = useState(null);
|
|
43
|
+
const [visible, setVisible] = useState(false);
|
|
44
|
+
const tooltipRef = React.useRef(null);
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
var _a, _b, _c;
|
|
47
|
+
if (!yagr) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const onChange = (_, data) => {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
setX((_a = data.data) === null || _a === void 0 ? void 0 : _a.x);
|
|
53
|
+
setVisible(data.state.visible);
|
|
54
|
+
if (data.state.visible && tooltipRef.current && ((_b = data.data) === null || _b === void 0 ? void 0 : _b.anchor)) {
|
|
55
|
+
placement(tooltipRef.current, data.data.anchor, 'right', {
|
|
56
|
+
xOffset: 24,
|
|
57
|
+
yOffset: 24,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
(_a = yagr.plugins.tooltip) === null || _a === void 0 ? void 0 : _a.on('render', onChange);
|
|
62
|
+
(_b = yagr.plugins.tooltip) === null || _b === void 0 ? void 0 : _b.on('show', onChange);
|
|
63
|
+
(_c = yagr.plugins.tooltip) === null || _c === void 0 ? void 0 : _c.on('hide', onChange);
|
|
64
|
+
}, [yagr]);
|
|
65
|
+
if (!visible) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
return (React.createElement("div", { style: {
|
|
69
|
+
zIndex: 1000,
|
|
70
|
+
backgroundColor: 'white',
|
|
71
|
+
padding: 8,
|
|
72
|
+
pointerEvents: 'none',
|
|
73
|
+
}, ref: tooltipRef }, x));
|
|
74
|
+
}
|
|
75
|
+
const CustomTooltipImpl = () => {
|
|
76
|
+
const [shown, setShown] = React.useState(false);
|
|
77
|
+
const chartkitRef = React.useRef();
|
|
78
|
+
const [state, setState] = React.useState(line10);
|
|
79
|
+
if (!shown) {
|
|
80
|
+
settings.set({ plugins: [YagrPlugin] });
|
|
81
|
+
return React.createElement(Button, { onClick: () => setShown(true) }, "Show chart");
|
|
82
|
+
}
|
|
83
|
+
return (React.createElement("div", { style: { height: 300, width: '100%' } },
|
|
84
|
+
React.createElement(ChartKit, { ref: chartkitRef, id: "1", type: "yagr", data: state, tooltip: (props) => React.createElement(Tooltip, Object.assign({}, props)) }),
|
|
85
|
+
React.createElement(Button, { onClick: () => setState(getNewConfig()) }, "Change data")));
|
|
86
|
+
};
|
|
42
87
|
export const Line = LineTemplate.bind({});
|
|
43
88
|
export const Updates = UpdatesTemplate.bind({});
|
|
89
|
+
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;
|
|
@@ -4,26 +4,26 @@
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
.chartkit-highcharts-tooltip-container._tooltip-with-scroll ._tooltip-header td:last-child {
|
|
7
|
-
padding-right: calc(18px + var(--
|
|
7
|
+
padding-right: calc(18px + var(--yc-scrollbar-width, 15px));
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
.chartkit-highcharts-tooltip-container._tooltip-with-scroll ._tooltip-footer td:last-child {
|
|
11
|
-
padding-right: calc(18px + var(--
|
|
11
|
+
padding-right: calc(18px + var(--yc-scrollbar-width, 15px));
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
.chartkit-highcharts-tooltip-container._tooltip-with-scroll-in-safari ._tooltip-row td:last-child {
|
|
15
|
-
padding-right: calc(18px + var(--
|
|
15
|
+
padding-right: calc(18px + var(--yc-scrollbar-width, 15px));
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
.chartkit-highcharts-tooltip-container._tooltip-with-scroll-in-safari ._tooltip-rows__summ-tr td:last-child {
|
|
19
|
-
padding-right: calc(18px + var(--
|
|
19
|
+
padding-right: calc(18px + var(--yc-scrollbar-width, 15px));
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
._tooltip {
|
|
23
23
|
border-radius: 5px;
|
|
24
|
-
background: var(--
|
|
25
|
-
background-color: var(--
|
|
26
|
-
color: var(--
|
|
24
|
+
background: var(--yc-color-infographics-tooltip-bg);
|
|
25
|
+
background-color: var(--yc-color-infographics-tooltip-bg);
|
|
26
|
+
color: var(--yc-color-text-primary);
|
|
27
27
|
font-size: 12px;
|
|
28
28
|
overflow: hidden;
|
|
29
29
|
box-sizing: border-box;
|
|
@@ -150,7 +150,7 @@
|
|
|
150
150
|
._tooltip-rows__table thead._tooltip-header tr:not(._tooltip-fake-row):first-child td {
|
|
151
151
|
padding-top: 6px;
|
|
152
152
|
padding-bottom: 6px;
|
|
153
|
-
border-bottom: 1px solid var(--
|
|
153
|
+
border-bottom: 1px solid var(--yc-color-line-generic);
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
._tooltip-rows__table tbody {
|
|
@@ -169,11 +169,11 @@
|
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
._tooltip-rows__table tbody._tooltip-list ._tooltip-row-dark-bg {
|
|
172
|
-
background-color: var(--
|
|
172
|
+
background-color: var(--yc-color-base-generic);
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
._tooltip-rows__table tbody ._hidden-rows-sum._hidden-rows-sum-dark-bg {
|
|
176
|
-
background-color: var(--
|
|
176
|
+
background-color: var(--yc-color-base-generic);
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
._tooltip-rows__table tbody ._hidden-rows-sum td {
|
|
@@ -281,9 +281,9 @@
|
|
|
281
281
|
|
|
282
282
|
._tooltip-rows__summ-td {
|
|
283
283
|
padding: 6px 0 6px 3px;
|
|
284
|
-
color: var(--
|
|
284
|
+
color: var(--yc-color-text-complementary);
|
|
285
285
|
font-size: 12px;
|
|
286
|
-
border-top: 1px solid var(--
|
|
286
|
+
border-top: 1px solid var(--yc-color-line-generic);
|
|
287
287
|
}
|
|
288
288
|
|
|
289
289
|
._tooltip-rows__summ-td-value {
|
|
@@ -308,7 +308,7 @@
|
|
|
308
308
|
._tooltip-right__td {
|
|
309
309
|
vertical-align: top;
|
|
310
310
|
opacity: 0.9;
|
|
311
|
-
border-left: 1px solid var(--
|
|
311
|
+
border-left: 1px solid var(--yc-color-line-generic);
|
|
312
312
|
white-space: normal;
|
|
313
313
|
font-size: 8pt;
|
|
314
314
|
position: relative;
|
|
@@ -348,7 +348,7 @@
|
|
|
348
348
|
}
|
|
349
349
|
|
|
350
350
|
._tooltip-right__traf-div_for-split-tooltip {
|
|
351
|
-
color: var(--
|
|
351
|
+
color: var(--yc-color-text-secondary);
|
|
352
352
|
padding-left: 8px;
|
|
353
353
|
border-top: none;
|
|
354
354
|
border-left: 2px solid;
|
|
@@ -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.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.16",
|
|
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.4
|
|
17
|
+
"@gravity-ui/yagr": "^3.7.4",
|
|
18
18
|
"bem-cn-lite": "^4.1.0",
|
|
19
19
|
"highcharts": "^8.2.2",
|
|
20
20
|
"highcharts-react-official": "^3.0.0",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@gravity-ui/prettier-config": "^1.0.1",
|
|
31
31
|
"@gravity-ui/stylelint-config": "^1.0.1",
|
|
32
32
|
"@gravity-ui/tsconfig": "^1.0.0",
|
|
33
|
-
"@gravity-ui/uikit": "^
|
|
33
|
+
"@gravity-ui/uikit": "^4.2.0",
|
|
34
34
|
"@storybook/addon-essentials": "^7.0.26",
|
|
35
35
|
"@storybook/addon-knobs": "^7.0.2",
|
|
36
36
|
"@storybook/cli": "^7.0.26",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"typescript": "^4.9.5"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
|
-
"@gravity-ui/uikit": "^
|
|
74
|
+
"@gravity-ui/uikit": "^4.0.0",
|
|
75
75
|
"react": "^16.0.0 || ^17.0.0 || ^18.0.0"
|
|
76
76
|
},
|
|
77
77
|
"scripts": {
|