@gravity-ui/charts 0.6.0 → 0.7.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/README.md +1 -1
- package/dist/cjs/components/Tooltip/ChartTooltipContent.d.ts +2 -2
- package/dist/cjs/components/Tooltip/index.js +6 -6
- package/dist/cjs/components/Tooltip/styles.css +7 -18
- package/dist/cjs/components/index.d.ts +10 -9
- package/dist/cjs/hooks/useSeries/prepare-area.d.ts +1 -1
- package/dist/cjs/hooks/useSeries/prepare-line.d.ts +1 -1
- package/dist/cjs/hooks/useShapes/area/prepare-data.js +4 -0
- package/dist/cjs/hooks/useShapes/bar-x/prepare-data.js +1 -0
- package/dist/cjs/hooks/useShapes/bar-y/prepare-data.js +1 -0
- package/dist/cjs/hooks/useShapes/line/prepare-data.js +1 -0
- package/dist/cjs/hooks/useShapes/pie/index.js +2 -1
- package/dist/cjs/hooks/useShapes/pie/prepare-data.js +159 -111
- package/dist/cjs/hooks/useShapes/pie/types.d.ts +1 -1
- package/dist/cjs/hooks/useShapes/treemap/prepare-data.js +1 -0
- package/dist/cjs/types/chart/area.d.ts +6 -6
- package/dist/cjs/types/chart/axis.d.ts +8 -7
- package/dist/cjs/types/chart/bar-x.d.ts +4 -4
- package/dist/cjs/types/chart/bar-y.d.ts +5 -6
- package/dist/cjs/types/chart/base.d.ts +6 -6
- package/dist/cjs/types/chart/chart.d.ts +4 -4
- package/dist/cjs/types/chart/halo.d.ts +2 -2
- package/dist/cjs/types/chart/legend.d.ts +10 -10
- package/dist/cjs/types/chart/line.d.ts +4 -4
- package/dist/cjs/types/chart/marker.d.ts +2 -2
- package/dist/cjs/types/chart/pie.d.ts +4 -4
- package/dist/cjs/types/chart/scatter.d.ts +4 -4
- package/dist/cjs/types/chart/series.d.ts +8 -8
- package/dist/cjs/types/chart/split.d.ts +4 -4
- package/dist/cjs/types/chart/title.d.ts +2 -2
- package/dist/cjs/types/chart/tooltip.d.ts +20 -20
- package/dist/cjs/types/chart/treemap.d.ts +4 -4
- package/dist/cjs/types/chart/waterfall.d.ts +4 -4
- package/dist/cjs/types/chart-ui.d.ts +10 -6
- package/dist/cjs/types/formatter.d.ts +4 -4
- package/dist/cjs/types/index.d.ts +34 -4
- package/dist/esm/components/Tooltip/ChartTooltipContent.d.ts +2 -2
- package/dist/esm/components/Tooltip/index.js +6 -6
- package/dist/esm/components/Tooltip/styles.css +7 -18
- package/dist/esm/components/index.d.ts +10 -9
- package/dist/esm/hooks/useSeries/prepare-area.d.ts +1 -1
- package/dist/esm/hooks/useSeries/prepare-line.d.ts +1 -1
- package/dist/esm/hooks/useShapes/area/prepare-data.js +4 -0
- package/dist/esm/hooks/useShapes/bar-x/prepare-data.js +1 -0
- package/dist/esm/hooks/useShapes/bar-y/prepare-data.js +1 -0
- package/dist/esm/hooks/useShapes/line/prepare-data.js +1 -0
- package/dist/esm/hooks/useShapes/pie/index.js +2 -1
- package/dist/esm/hooks/useShapes/pie/prepare-data.js +159 -111
- package/dist/esm/hooks/useShapes/pie/types.d.ts +1 -1
- package/dist/esm/hooks/useShapes/treemap/prepare-data.js +1 -0
- package/dist/esm/types/chart/area.d.ts +6 -6
- package/dist/esm/types/chart/axis.d.ts +8 -7
- package/dist/esm/types/chart/bar-x.d.ts +4 -4
- package/dist/esm/types/chart/bar-y.d.ts +5 -6
- package/dist/esm/types/chart/base.d.ts +6 -6
- package/dist/esm/types/chart/chart.d.ts +4 -4
- package/dist/esm/types/chart/halo.d.ts +2 -2
- package/dist/esm/types/chart/legend.d.ts +10 -10
- package/dist/esm/types/chart/line.d.ts +4 -4
- package/dist/esm/types/chart/marker.d.ts +2 -2
- package/dist/esm/types/chart/pie.d.ts +4 -4
- package/dist/esm/types/chart/scatter.d.ts +4 -4
- package/dist/esm/types/chart/series.d.ts +8 -8
- package/dist/esm/types/chart/split.d.ts +4 -4
- package/dist/esm/types/chart/title.d.ts +2 -2
- package/dist/esm/types/chart/tooltip.d.ts +20 -20
- package/dist/esm/types/chart/treemap.d.ts +4 -4
- package/dist/esm/types/chart/waterfall.d.ts +4 -4
- package/dist/esm/types/chart-ui.d.ts +10 -6
- package/dist/esm/types/formatter.d.ts +4 -4
- package/dist/esm/types/index.d.ts +34 -4
- package/package.json +7 -4
|
@@ -2,8 +2,7 @@ import type { SeriesType } from '../../constants';
|
|
|
2
2
|
import type { MeaningfulAny } from '../misc';
|
|
3
3
|
import type { BaseSeries, BaseSeriesData } from './base';
|
|
4
4
|
import type { ChartLegend, RectLegendSymbolOptions } from './legend';
|
|
5
|
-
|
|
6
|
-
export type BarYSeriesData<T = MeaningfulAny> = BaseSeriesData<T> & {
|
|
5
|
+
export interface BarYSeriesData<T = MeaningfulAny> extends BaseSeriesData<T> {
|
|
7
6
|
/**
|
|
8
7
|
* The `x` value of the bar. Depending on the context , it may represents:
|
|
9
8
|
* - numeric value (for `linear` x axis)
|
|
@@ -22,8 +21,8 @@ export type BarYSeriesData<T = MeaningfulAny> = BaseSeriesData<T> & {
|
|
|
22
21
|
label?: string | number;
|
|
23
22
|
/** Individual opacity for the bar. */
|
|
24
23
|
opacity?: number;
|
|
25
|
-
}
|
|
26
|
-
export
|
|
24
|
+
}
|
|
25
|
+
export interface BarYSeries<T = MeaningfulAny> extends BaseSeries {
|
|
27
26
|
type: typeof SeriesType.BarY;
|
|
28
27
|
data: BarYSeriesData<T>[];
|
|
29
28
|
/** The name of the series (used in legend, tooltip etc) */
|
|
@@ -44,7 +43,7 @@ export type BarYSeries<T = MeaningfulAny> = BaseSeries & {
|
|
|
44
43
|
* @default true
|
|
45
44
|
* */
|
|
46
45
|
grouping?: boolean;
|
|
47
|
-
dataLabels?:
|
|
46
|
+
dataLabels?: BaseSeries['dataLabels'] & {
|
|
48
47
|
/**
|
|
49
48
|
* Whether to align the data label inside or outside the box.
|
|
50
49
|
* For charts with a percentage stack, it is always true.
|
|
@@ -57,4 +56,4 @@ export type BarYSeries<T = MeaningfulAny> = BaseSeries & {
|
|
|
57
56
|
legend?: ChartLegend & {
|
|
58
57
|
symbol?: RectLegendSymbolOptions;
|
|
59
58
|
};
|
|
60
|
-
}
|
|
59
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MeaningfulAny } from '../misc';
|
|
2
|
-
export
|
|
2
|
+
export interface BaseSeries {
|
|
3
3
|
/** Initial visibility of the series */
|
|
4
4
|
visible?: boolean;
|
|
5
5
|
/**
|
|
@@ -30,8 +30,8 @@ export type BaseSeries = {
|
|
|
30
30
|
};
|
|
31
31
|
/** You can set the cursor to "pointer" if you have click events attached to the series, to signal to the user that the points and lines can be clicked. */
|
|
32
32
|
cursor?: string;
|
|
33
|
-
}
|
|
34
|
-
export
|
|
33
|
+
}
|
|
34
|
+
export interface BaseSeriesData<T = MeaningfulAny> {
|
|
35
35
|
/**
|
|
36
36
|
* A reserved subspace to store options and values for customized functionality
|
|
37
37
|
*
|
|
@@ -40,9 +40,9 @@ export type BaseSeriesData<T = MeaningfulAny> = {
|
|
|
40
40
|
custom?: T;
|
|
41
41
|
/** Individual color for the data chunk (point in scatter, segment in pie, bar etc) */
|
|
42
42
|
color?: string;
|
|
43
|
-
}
|
|
44
|
-
export
|
|
43
|
+
}
|
|
44
|
+
export interface BaseTextStyle {
|
|
45
45
|
fontSize: string;
|
|
46
46
|
fontWeight?: string;
|
|
47
47
|
fontColor?: string;
|
|
48
|
-
}
|
|
48
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { MeaningfulAny } from '../misc';
|
|
2
2
|
import type { ChartTooltipRendererArgs } from './tooltip';
|
|
3
|
-
export
|
|
3
|
+
export interface ChartMargin {
|
|
4
4
|
top: number;
|
|
5
5
|
right: number;
|
|
6
6
|
bottom: number;
|
|
7
7
|
left: number;
|
|
8
|
-
}
|
|
9
|
-
export
|
|
8
|
+
}
|
|
9
|
+
export interface ChartOptions {
|
|
10
10
|
margin?: Partial<ChartMargin>;
|
|
11
11
|
events?: {
|
|
12
12
|
click?: (data: {
|
|
@@ -15,4 +15,4 @@ export type ChartOptions = {
|
|
|
15
15
|
}, event: PointerEvent) => void;
|
|
16
16
|
pointermove?: (data: ChartTooltipRendererArgs | undefined, event: PointerEvent) => void;
|
|
17
17
|
};
|
|
18
|
-
}
|
|
18
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/** The halo appearing around the hovered part of series(point in line-type series or slice in pie charts) */
|
|
2
|
-
export
|
|
2
|
+
export interface Halo {
|
|
3
3
|
/** Enable or disable the halo */
|
|
4
4
|
enabled?: boolean;
|
|
5
5
|
/** The opacity of halo */
|
|
6
6
|
opacity?: number;
|
|
7
7
|
/** The pixel size of the halo. Radius for point markers or width of the outside slice in pie charts. */
|
|
8
8
|
size?: number;
|
|
9
|
-
}
|
|
9
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BaseTextStyle } from './base';
|
|
2
|
-
export
|
|
2
|
+
export interface ChartLegend {
|
|
3
3
|
enabled?: boolean;
|
|
4
4
|
/**
|
|
5
5
|
* Different types for different color schemes.
|
|
@@ -47,16 +47,16 @@ export type ChartLegend = {
|
|
|
47
47
|
domain?: number[];
|
|
48
48
|
};
|
|
49
49
|
width?: number;
|
|
50
|
-
}
|
|
51
|
-
export
|
|
50
|
+
}
|
|
51
|
+
export interface BaseLegendSymbol {
|
|
52
52
|
/**
|
|
53
53
|
* The pixel padding between the legend item symbol and the legend item text.
|
|
54
54
|
*
|
|
55
55
|
* @default 5
|
|
56
56
|
* */
|
|
57
57
|
padding?: number;
|
|
58
|
-
}
|
|
59
|
-
export
|
|
58
|
+
}
|
|
59
|
+
export interface RectLegendSymbolOptions extends BaseLegendSymbol {
|
|
60
60
|
/**
|
|
61
61
|
* The pixel width of the symbol for series types that use a rectangle in the legend
|
|
62
62
|
*
|
|
@@ -75,20 +75,20 @@ export type RectLegendSymbolOptions = BaseLegendSymbol & {
|
|
|
75
75
|
* Defaults to half the symbolHeight, effectively creating a circle.
|
|
76
76
|
*/
|
|
77
77
|
radius?: number;
|
|
78
|
-
}
|
|
79
|
-
export
|
|
78
|
+
}
|
|
79
|
+
export interface PathLegendSymbolOptions extends BaseLegendSymbol {
|
|
80
80
|
/**
|
|
81
81
|
* The pixel width of the symbol for series types that use a path in the legend
|
|
82
82
|
*
|
|
83
83
|
* @default 16
|
|
84
84
|
* */
|
|
85
85
|
width?: number;
|
|
86
|
-
}
|
|
87
|
-
export
|
|
86
|
+
}
|
|
87
|
+
export interface SymbolLegendSymbolOptions extends BaseLegendSymbol {
|
|
88
88
|
/**
|
|
89
89
|
* The pixel width of the symbol for series types that use a symbol in the legend
|
|
90
90
|
*
|
|
91
91
|
* @default 8
|
|
92
92
|
* */
|
|
93
93
|
width?: number;
|
|
94
|
-
}
|
|
94
|
+
}
|
|
@@ -3,7 +3,7 @@ import type { MeaningfulAny } from '../misc';
|
|
|
3
3
|
import type { BaseSeries, BaseSeriesData } from './base';
|
|
4
4
|
import type { ChartLegend, RectLegendSymbolOptions } from './legend';
|
|
5
5
|
import type { PointMarkerOptions } from './marker';
|
|
6
|
-
export
|
|
6
|
+
export interface LineSeriesData<T = MeaningfulAny> extends BaseSeriesData<T> {
|
|
7
7
|
/**
|
|
8
8
|
* The `x` value of the point. Depending on the context , it may represents:
|
|
9
9
|
* - numeric value (for `linear` x axis)
|
|
@@ -27,8 +27,8 @@ export type LineSeriesData<T = MeaningfulAny> = BaseSeriesData<T> & {
|
|
|
27
27
|
};
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
|
-
}
|
|
31
|
-
export
|
|
30
|
+
}
|
|
31
|
+
export interface LineSeries<T = MeaningfulAny> extends BaseSeries {
|
|
32
32
|
type: typeof SeriesType.Line;
|
|
33
33
|
data: LineSeriesData<T>[];
|
|
34
34
|
/** The name of the series (used in legend, tooltip etc) */
|
|
@@ -54,4 +54,4 @@ export type LineSeries<T = MeaningfulAny> = BaseSeries & {
|
|
|
54
54
|
opacity?: number;
|
|
55
55
|
/** Y-axis index (when using two axes) */
|
|
56
56
|
yAxis?: number;
|
|
57
|
-
}
|
|
57
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SymbolType } from '../../constants';
|
|
2
|
-
export
|
|
2
|
+
export interface PointMarkerOptions {
|
|
3
3
|
/** Enable or disable the point marker */
|
|
4
4
|
enabled?: boolean;
|
|
5
5
|
/** The radius of the point marker */
|
|
@@ -9,4 +9,4 @@ export type PointMarkerOptions = {
|
|
|
9
9
|
/** The width of the point marker's border */
|
|
10
10
|
borderWidth?: number;
|
|
11
11
|
symbol?: `${SymbolType}`;
|
|
12
|
-
}
|
|
12
|
+
}
|
|
@@ -3,7 +3,7 @@ import type { SeriesType } from '../../constants';
|
|
|
3
3
|
import type { MeaningfulAny } from '../misc';
|
|
4
4
|
import type { BaseSeries, BaseSeriesData } from './base';
|
|
5
5
|
import type { ChartLegend, RectLegendSymbolOptions } from './legend';
|
|
6
|
-
export
|
|
6
|
+
export interface PieSeriesData<T = MeaningfulAny> extends BaseSeriesData<T> {
|
|
7
7
|
/** The value of the pie segment. */
|
|
8
8
|
value: number;
|
|
9
9
|
/** The name of the pie segment (used in legend, tooltip etc). */
|
|
@@ -14,10 +14,10 @@ export type PieSeriesData<T = MeaningfulAny> = BaseSeriesData<T> & {
|
|
|
14
14
|
label?: string;
|
|
15
15
|
/** Individual opacity for the pie segment. */
|
|
16
16
|
opacity?: number;
|
|
17
|
-
}
|
|
17
|
+
}
|
|
18
18
|
export type ConnectorShape = 'straight-line' | 'polyline';
|
|
19
19
|
export type ConnectorCurve = 'linear' | 'basic';
|
|
20
|
-
export
|
|
20
|
+
export interface PieSeries<T = MeaningfulAny> extends BaseSeries {
|
|
21
21
|
type: typeof SeriesType.Pie;
|
|
22
22
|
data: PieSeriesData<T>[];
|
|
23
23
|
/**
|
|
@@ -85,4 +85,4 @@ export type PieSeries<T = MeaningfulAny> = BaseSeries & {
|
|
|
85
85
|
innerRadius: number;
|
|
86
86
|
};
|
|
87
87
|
}) => BaseType;
|
|
88
|
-
}
|
|
88
|
+
}
|
|
@@ -2,7 +2,7 @@ import type { SeriesType, SymbolType } from '../../constants';
|
|
|
2
2
|
import type { MeaningfulAny } from '../misc';
|
|
3
3
|
import type { BaseSeries, BaseSeriesData } from './base';
|
|
4
4
|
import type { ChartLegend, RectLegendSymbolOptions } from './legend';
|
|
5
|
-
export
|
|
5
|
+
export interface ScatterSeriesData<T = MeaningfulAny> extends BaseSeriesData<T> {
|
|
6
6
|
/**
|
|
7
7
|
* The `x` value of the point. Depending on the context , it may represents:
|
|
8
8
|
* - numeric value (for `linear` x axis)
|
|
@@ -27,8 +27,8 @@ export type ScatterSeriesData<T = MeaningfulAny> = BaseSeriesData<T> & {
|
|
|
27
27
|
radius?: number;
|
|
28
28
|
/** Individual opacity for the point. */
|
|
29
29
|
opacity?: number;
|
|
30
|
-
}
|
|
31
|
-
export
|
|
30
|
+
}
|
|
31
|
+
export interface ScatterSeries<T = MeaningfulAny> extends BaseSeries {
|
|
32
32
|
type: typeof SeriesType.Scatter;
|
|
33
33
|
data: ScatterSeriesData<T>[];
|
|
34
34
|
/** The name of the series (used in legend, tooltip etc) */
|
|
@@ -43,4 +43,4 @@ export type ScatterSeries<T = MeaningfulAny> = BaseSeries & {
|
|
|
43
43
|
};
|
|
44
44
|
/** Y-axis index (when using two axes) */
|
|
45
45
|
yAxis?: number;
|
|
46
|
-
}
|
|
46
|
+
}
|
|
@@ -13,10 +13,10 @@ import type { TreemapSeries, TreemapSeriesData } from './treemap';
|
|
|
13
13
|
import type { WaterfallSeries, WaterfallSeriesData } from './waterfall';
|
|
14
14
|
export type ChartSeries<T = MeaningfulAny> = ScatterSeries<T> | PieSeries<T> | BarXSeries<T> | BarYSeries<T> | LineSeries<T> | AreaSeries<T> | TreemapSeries<T> | WaterfallSeries<T>;
|
|
15
15
|
export type ChartSeriesData<T = MeaningfulAny> = ScatterSeriesData<T> | PieSeriesData<T> | BarXSeriesData<T> | BarYSeriesData<T> | LineSeriesData<T> | AreaSeriesData<T> | TreemapSeriesData<T> | WaterfallSeriesData<T>;
|
|
16
|
-
export
|
|
16
|
+
export interface DataLabelRendererData<T = MeaningfulAny> {
|
|
17
17
|
data: ChartSeriesData<T>;
|
|
18
|
-
}
|
|
19
|
-
export
|
|
18
|
+
}
|
|
19
|
+
export interface BasicHoverState {
|
|
20
20
|
/**
|
|
21
21
|
* Enable separate styles for the hovered series.
|
|
22
22
|
*
|
|
@@ -32,8 +32,8 @@ export type BasicHoverState = {
|
|
|
32
32
|
* @default 0.3
|
|
33
33
|
*/
|
|
34
34
|
brightness?: number;
|
|
35
|
-
}
|
|
36
|
-
export
|
|
35
|
+
}
|
|
36
|
+
export interface BasicInactiveState {
|
|
37
37
|
/**
|
|
38
38
|
* Enable separate styles for the inactive series.
|
|
39
39
|
*
|
|
@@ -46,8 +46,8 @@ export type BasicInactiveState = {
|
|
|
46
46
|
* @default 0.5
|
|
47
47
|
* */
|
|
48
48
|
opacity?: number;
|
|
49
|
-
}
|
|
50
|
-
export
|
|
49
|
+
}
|
|
50
|
+
export interface ChartSeriesOptions {
|
|
51
51
|
/** Individual data label for each point. */
|
|
52
52
|
dataLabels?: {
|
|
53
53
|
/** Enable or disable the data labels */
|
|
@@ -222,4 +222,4 @@ export type ChartSeriesOptions = {
|
|
|
222
222
|
inactive?: BasicInactiveState;
|
|
223
223
|
};
|
|
224
224
|
};
|
|
225
|
-
}
|
|
225
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { BaseTextStyle } from './base';
|
|
2
|
-
export
|
|
2
|
+
export interface SplitPlotOptions {
|
|
3
3
|
title?: {
|
|
4
4
|
text: string;
|
|
5
5
|
style?: Partial<BaseTextStyle>;
|
|
6
6
|
};
|
|
7
|
-
}
|
|
8
|
-
export
|
|
7
|
+
}
|
|
8
|
+
export interface ChartSplit {
|
|
9
9
|
enable: boolean;
|
|
10
10
|
layout?: 'vertical';
|
|
11
11
|
gap?: string | number;
|
|
12
12
|
plots?: SplitPlotOptions[];
|
|
13
|
-
}
|
|
13
|
+
}
|
|
@@ -8,63 +8,63 @@ import type { PieSeries, PieSeriesData } from './pie';
|
|
|
8
8
|
import type { ScatterSeries, ScatterSeriesData } from './scatter';
|
|
9
9
|
import type { TreemapSeries, TreemapSeriesData } from './treemap';
|
|
10
10
|
import type { WaterfallSeries, WaterfallSeriesData } from './waterfall';
|
|
11
|
-
export
|
|
11
|
+
export interface TooltipDataChunkBarX<T = MeaningfulAny> {
|
|
12
12
|
data: BarXSeriesData<T>;
|
|
13
13
|
series: BarXSeries<T>;
|
|
14
|
-
}
|
|
15
|
-
export
|
|
14
|
+
}
|
|
15
|
+
export interface TooltipDataChunkBarY<T = MeaningfulAny> {
|
|
16
16
|
data: BarYSeriesData<T>;
|
|
17
17
|
series: BarYSeries<T>;
|
|
18
|
-
}
|
|
19
|
-
export
|
|
18
|
+
}
|
|
19
|
+
export interface TooltipDataChunkPie<T = MeaningfulAny> {
|
|
20
20
|
data: PieSeriesData<T>;
|
|
21
21
|
series: {
|
|
22
22
|
type: PieSeries['type'];
|
|
23
23
|
id: string;
|
|
24
24
|
name: string;
|
|
25
25
|
};
|
|
26
|
-
}
|
|
27
|
-
export
|
|
26
|
+
}
|
|
27
|
+
export interface TooltipDataChunkScatter<T = MeaningfulAny> {
|
|
28
28
|
data: ScatterSeriesData<T>;
|
|
29
29
|
series: {
|
|
30
30
|
type: ScatterSeries['type'];
|
|
31
31
|
id: string;
|
|
32
32
|
name: string;
|
|
33
33
|
};
|
|
34
|
-
}
|
|
35
|
-
export
|
|
34
|
+
}
|
|
35
|
+
export interface TooltipDataChunkLine<T = MeaningfulAny> {
|
|
36
36
|
data: LineSeriesData<T>;
|
|
37
37
|
series: {
|
|
38
38
|
type: LineSeries['type'];
|
|
39
39
|
id: string;
|
|
40
40
|
name: string;
|
|
41
41
|
};
|
|
42
|
-
}
|
|
43
|
-
export
|
|
42
|
+
}
|
|
43
|
+
export interface TooltipDataChunkArea<T = MeaningfulAny> {
|
|
44
44
|
data: AreaSeriesData<T>;
|
|
45
45
|
series: {
|
|
46
46
|
type: AreaSeries['type'];
|
|
47
47
|
id: string;
|
|
48
48
|
name: string;
|
|
49
49
|
};
|
|
50
|
-
}
|
|
51
|
-
export
|
|
50
|
+
}
|
|
51
|
+
export interface TooltipDataChunkTreemap<T = MeaningfulAny> {
|
|
52
52
|
data: TreemapSeriesData<T>;
|
|
53
53
|
series: TreemapSeries<T>;
|
|
54
|
-
}
|
|
55
|
-
export
|
|
54
|
+
}
|
|
55
|
+
export interface TooltipDataChunkWaterfall<T = MeaningfulAny> {
|
|
56
56
|
data: WaterfallSeriesData<T>;
|
|
57
57
|
series: WaterfallSeries<T>;
|
|
58
|
-
}
|
|
58
|
+
}
|
|
59
59
|
export type TooltipDataChunk<T = MeaningfulAny> = (TooltipDataChunkBarX<T> | TooltipDataChunkBarY<T> | TooltipDataChunkPie<T> | TooltipDataChunkScatter<T> | TooltipDataChunkLine<T> | TooltipDataChunkArea<T> | TooltipDataChunkTreemap<T> | TooltipDataChunkWaterfall<T>) & {
|
|
60
60
|
closest?: boolean;
|
|
61
61
|
};
|
|
62
|
-
export
|
|
62
|
+
export interface ChartTooltipRendererArgs<T = MeaningfulAny> {
|
|
63
63
|
hovered: TooltipDataChunk<T>[];
|
|
64
64
|
xAxis?: ChartXAxis;
|
|
65
65
|
yAxis?: ChartYAxis;
|
|
66
|
-
}
|
|
67
|
-
export
|
|
66
|
+
}
|
|
67
|
+
export interface ChartTooltip<T = MeaningfulAny> {
|
|
68
68
|
enabled?: boolean;
|
|
69
69
|
/** Specifies the renderer for the tooltip. If returned null default tooltip renderer will be used. */
|
|
70
70
|
renderer?: (args: ChartTooltipRendererArgs<T>) => React.ReactElement | null;
|
|
@@ -72,4 +72,4 @@ export type ChartTooltip<T = MeaningfulAny> = {
|
|
|
72
72
|
enabled?: boolean;
|
|
73
73
|
modifierKey?: 'altKey' | 'metaKey';
|
|
74
74
|
};
|
|
75
|
-
}
|
|
75
|
+
}
|
|
@@ -2,7 +2,7 @@ import type { LayoutAlgorithm, SeriesType } from '../../constants';
|
|
|
2
2
|
import type { MeaningfulAny } from '../misc';
|
|
3
3
|
import type { BaseSeries, BaseSeriesData } from './base';
|
|
4
4
|
import type { ChartLegend, RectLegendSymbolOptions } from './legend';
|
|
5
|
-
export
|
|
5
|
+
export interface TreemapSeriesData<T = MeaningfulAny> extends BaseSeriesData<T> {
|
|
6
6
|
/** The name of the node (used in legend, tooltip etc). */
|
|
7
7
|
name: string | string[];
|
|
8
8
|
/** The value of the node. All nodes should have this property except nodes that have children. */
|
|
@@ -14,8 +14,8 @@ export type TreemapSeriesData<T = MeaningfulAny> = BaseSeriesData<T> & {
|
|
|
14
14
|
* If no nodes has a matching id, or this option is undefined, then the parent will be set to the root.
|
|
15
15
|
*/
|
|
16
16
|
parentId?: string;
|
|
17
|
-
}
|
|
18
|
-
export
|
|
17
|
+
}
|
|
18
|
+
export interface TreemapSeries<T = MeaningfulAny> extends BaseSeries {
|
|
19
19
|
type: typeof SeriesType.Treemap;
|
|
20
20
|
data: TreemapSeriesData<T>[];
|
|
21
21
|
/** The name of the series (used in legend, tooltip etc). */
|
|
@@ -43,4 +43,4 @@ export type TreemapSeries<T = MeaningfulAny> = BaseSeries & {
|
|
|
43
43
|
/** Horizontal alignment of the data label inside the tile. */
|
|
44
44
|
align?: 'left' | 'center' | 'right';
|
|
45
45
|
};
|
|
46
|
-
}
|
|
46
|
+
}
|
|
@@ -2,7 +2,7 @@ import type { SeriesType } from '../../constants';
|
|
|
2
2
|
import type { MeaningfulAny } from '../misc';
|
|
3
3
|
import type { BaseSeries, BaseSeriesData } from './base';
|
|
4
4
|
import type { ChartLegend, RectLegendSymbolOptions } from './legend';
|
|
5
|
-
export
|
|
5
|
+
export interface WaterfallSeriesData<T = MeaningfulAny> extends BaseSeriesData<T> {
|
|
6
6
|
/**
|
|
7
7
|
* The `x` value. Depending on the context , it may represents:
|
|
8
8
|
* - numeric value (for `linear` x axis)
|
|
@@ -21,8 +21,8 @@ export type WaterfallSeriesData<T = MeaningfulAny> = BaseSeriesData<T> & {
|
|
|
21
21
|
opacity?: number;
|
|
22
22
|
/** When this property is true, the point display the total sum across the entire series. */
|
|
23
23
|
total?: boolean;
|
|
24
|
-
}
|
|
25
|
-
export
|
|
24
|
+
}
|
|
25
|
+
export interface WaterfallSeries<T = MeaningfulAny> extends BaseSeries {
|
|
26
26
|
type: typeof SeriesType.Waterfall;
|
|
27
27
|
data: WaterfallSeriesData<T>[];
|
|
28
28
|
/** The name of the series (used in legend, tooltip etc). */
|
|
@@ -37,4 +37,4 @@ export type WaterfallSeries<T = MeaningfulAny> = BaseSeries & {
|
|
|
37
37
|
legend?: ChartLegend & {
|
|
38
38
|
symbol?: RectLegendSymbolOptions;
|
|
39
39
|
};
|
|
40
|
-
}
|
|
40
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BaseTextStyle } from './chart/base';
|
|
2
|
-
export
|
|
2
|
+
export interface LabelData {
|
|
3
3
|
text: string;
|
|
4
4
|
x: number;
|
|
5
5
|
y: number;
|
|
@@ -13,12 +13,16 @@ export type LabelData = {
|
|
|
13
13
|
id: string;
|
|
14
14
|
};
|
|
15
15
|
active?: boolean;
|
|
16
|
-
}
|
|
17
|
-
export
|
|
16
|
+
}
|
|
17
|
+
export interface HtmlItem {
|
|
18
18
|
x: number;
|
|
19
19
|
y: number;
|
|
20
20
|
content: string;
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
size: {
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export interface ShapeDataWithHtmlItems {
|
|
23
27
|
htmlElements: HtmlItem[];
|
|
24
|
-
}
|
|
28
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface FormatOptions {
|
|
2
2
|
precision?: number | 'auto';
|
|
3
3
|
unitRate?: number;
|
|
4
4
|
showRankDelimiter?: boolean;
|
|
5
5
|
lang?: string;
|
|
6
6
|
labelMode?: string;
|
|
7
|
-
}
|
|
8
|
-
export
|
|
7
|
+
}
|
|
8
|
+
export interface FormatNumberOptions extends FormatOptions {
|
|
9
9
|
format?: 'number' | 'percent';
|
|
10
10
|
multiplier?: number;
|
|
11
11
|
prefix?: string;
|
|
12
12
|
postfix?: string;
|
|
13
13
|
unit?: 'auto' | 'k' | 'm' | 'b' | 't' | null;
|
|
14
|
-
}
|
|
14
|
+
}
|
|
@@ -25,18 +25,48 @@ export * from './chart/tooltip';
|
|
|
25
25
|
export * from './chart/halo';
|
|
26
26
|
export * from './chart/treemap';
|
|
27
27
|
export * from './chart/waterfall';
|
|
28
|
-
export
|
|
28
|
+
export interface ChartData<T = MeaningfulAny> {
|
|
29
|
+
/**
|
|
30
|
+
* General options for the chart.
|
|
31
|
+
*/
|
|
29
32
|
chart?: ChartOptions;
|
|
33
|
+
/**
|
|
34
|
+
* The legend displays a labeled box for each data element in the chart.
|
|
35
|
+
* It shows a distinctive symbol paired with a name for every series.
|
|
36
|
+
*/
|
|
30
37
|
legend?: ChartLegend;
|
|
38
|
+
/**
|
|
39
|
+
* Represents the series data and series options.
|
|
40
|
+
*/
|
|
31
41
|
series: {
|
|
42
|
+
/**
|
|
43
|
+
* Contains data points to be plotted.
|
|
44
|
+
*/
|
|
32
45
|
data: ChartSeries<T>[];
|
|
46
|
+
/**
|
|
47
|
+
* Allows for customizing the appearance and behavior of the series.
|
|
48
|
+
*/
|
|
33
49
|
options?: ChartSeriesOptions;
|
|
34
50
|
};
|
|
51
|
+
/**
|
|
52
|
+
* The main title of the chart.
|
|
53
|
+
*/
|
|
35
54
|
title?: ChartTitle;
|
|
55
|
+
/**
|
|
56
|
+
* Options for the tooltip that appears when the user hovers over a series or point.
|
|
57
|
+
*/
|
|
36
58
|
tooltip?: ChartTooltip<T>;
|
|
59
|
+
/**
|
|
60
|
+
* Options for the the X axis.
|
|
61
|
+
*/
|
|
37
62
|
xAxis?: ChartXAxis;
|
|
63
|
+
/**
|
|
64
|
+
* Options for the the Y axis or multiple Y axes.
|
|
65
|
+
*/
|
|
38
66
|
yAxis?: ChartYAxis[];
|
|
39
|
-
/**
|
|
40
|
-
*
|
|
67
|
+
/**
|
|
68
|
+
* Setting for displaying charts on different plots.
|
|
69
|
+
* It can be used to visualize related information on multiple charts.
|
|
70
|
+
*/
|
|
41
71
|
split?: ChartSplit;
|
|
42
|
-
}
|
|
72
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ChartTooltip, ChartXAxis, ChartYAxis, TooltipDataChunk } from '../../types';
|
|
3
|
-
export
|
|
3
|
+
export interface ChartTooltipContentProps {
|
|
4
4
|
hovered?: TooltipDataChunk[];
|
|
5
5
|
xAxis?: ChartXAxis;
|
|
6
6
|
yAxis?: ChartYAxis;
|
|
7
7
|
renderer?: ChartTooltip['renderer'];
|
|
8
|
-
}
|
|
8
|
+
}
|
|
9
9
|
export declare const ChartTooltipContent: (props: ChartTooltipContentProps) => React.JSX.Element | null;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Popup,
|
|
2
|
+
import { Popup, useVirtualElement } from '@gravity-ui/uikit';
|
|
3
3
|
import { useTooltip } from '../../hooks';
|
|
4
4
|
import { block } from '../../utils';
|
|
5
5
|
import { ChartTooltipContent } from './ChartTooltipContent';
|
|
6
6
|
import './styles.css';
|
|
7
|
-
const b = block('
|
|
7
|
+
const b = block('tooltip');
|
|
8
8
|
export const Tooltip = (props) => {
|
|
9
9
|
const { tooltip, xAxis, yAxis, svgContainer, dispatcher, tooltipPinned, onOutsideClick } = props;
|
|
10
10
|
const { hovered, pointerPosition } = useTooltip({ dispatcher, tooltip });
|
|
11
11
|
const containerRect = (svgContainer === null || svgContainer === void 0 ? void 0 : svgContainer.getBoundingClientRect()) || { left: 0, top: 0 };
|
|
12
12
|
const left = ((pointerPosition === null || pointerPosition === void 0 ? void 0 : pointerPosition[0]) || 0) + containerRect.left;
|
|
13
13
|
const top = ((pointerPosition === null || pointerPosition === void 0 ? void 0 : pointerPosition[1]) || 0) + containerRect.top;
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
if (svgContainer === null || svgContainer === void 0 ? void 0 : svgContainer.contains(e.target)) {
|
|
14
|
+
const { anchor } = useVirtualElement({ left, top });
|
|
15
|
+
const handleOnOpenChange = (_open, e) => {
|
|
16
|
+
if (svgContainer === null || svgContainer === void 0 ? void 0 : svgContainer.contains(e === null || e === void 0 ? void 0 : e.target)) {
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
19
|
onOutsideClick === null || onOutsideClick === void 0 ? void 0 : onOutsideClick();
|
|
@@ -21,7 +21,7 @@ export const Tooltip = (props) => {
|
|
|
21
21
|
React.useEffect(() => {
|
|
22
22
|
window.dispatchEvent(new CustomEvent('scroll'));
|
|
23
23
|
}, [left, top]);
|
|
24
|
-
return (hovered === null || hovered === void 0 ? void 0 : hovered.length) ? (React.createElement(Popup, { className: b({ pinned: tooltipPinned }),
|
|
24
|
+
return (hovered === null || hovered === void 0 ? void 0 : hovered.length) ? (React.createElement(Popup, { anchorElement: anchor, className: b({ pinned: tooltipPinned }), disableTransition: true, floatingStyles: tooltipPinned ? undefined : { pointerEvents: 'none' }, offset: { mainAxis: 20 }, onOpenChange: tooltipPinned ? handleOnOpenChange : undefined, open: true, placement: ['right', 'left', 'top', 'bottom'] },
|
|
25
25
|
React.createElement("div", { className: b('content') },
|
|
26
26
|
React.createElement(ChartTooltipContent, { hovered: hovered, xAxis: xAxis, yAxis: yAxis, renderer: tooltip.renderer })))) : null;
|
|
27
27
|
};
|
|
@@ -1,28 +1,17 @@
|
|
|
1
|
-
.gcharts-
|
|
2
|
-
--g-
|
|
3
|
-
pointer-events: none;
|
|
4
|
-
}
|
|
5
|
-
.gcharts-d3-tooltip[class] > div {
|
|
6
|
-
animation-duration: unset;
|
|
7
|
-
animation-timing-function: unset;
|
|
8
|
-
animation-fill-mode: unset;
|
|
9
|
-
}
|
|
10
|
-
.gcharts-d3-tooltip[class].gcharts-d3-tooltip_pinned {
|
|
11
|
-
pointer-events: inherit;
|
|
1
|
+
.gcharts-tooltip {
|
|
2
|
+
box-shadow: 0 2px 12px var(--g-color-sfx-shadow);
|
|
12
3
|
}
|
|
13
|
-
.gcharts-
|
|
14
|
-
padding:
|
|
4
|
+
.gcharts-tooltip__content {
|
|
5
|
+
padding: 8px 14px;
|
|
15
6
|
text-wrap: nowrap;
|
|
16
|
-
border:
|
|
17
|
-
border-radius: 3px;
|
|
7
|
+
border-radius: 4px;
|
|
18
8
|
background-color: var(--g-color-infographics-tooltip-bg);
|
|
19
|
-
box-shadow: 0 2px 12px var(--g-color-sfx-shadow);
|
|
20
9
|
}
|
|
21
|
-
.gcharts-
|
|
10
|
+
.gcharts-tooltip__content-row {
|
|
22
11
|
display: flex;
|
|
23
12
|
align-items: center;
|
|
24
13
|
}
|
|
25
|
-
.gcharts-
|
|
14
|
+
.gcharts-tooltip__color {
|
|
26
15
|
display: inline-block;
|
|
27
16
|
width: 16px;
|
|
28
17
|
height: 8px;
|