@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.
Files changed (72) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/components/Tooltip/ChartTooltipContent.d.ts +2 -2
  3. package/dist/cjs/components/Tooltip/index.js +6 -6
  4. package/dist/cjs/components/Tooltip/styles.css +7 -18
  5. package/dist/cjs/components/index.d.ts +10 -9
  6. package/dist/cjs/hooks/useSeries/prepare-area.d.ts +1 -1
  7. package/dist/cjs/hooks/useSeries/prepare-line.d.ts +1 -1
  8. package/dist/cjs/hooks/useShapes/area/prepare-data.js +4 -0
  9. package/dist/cjs/hooks/useShapes/bar-x/prepare-data.js +1 -0
  10. package/dist/cjs/hooks/useShapes/bar-y/prepare-data.js +1 -0
  11. package/dist/cjs/hooks/useShapes/line/prepare-data.js +1 -0
  12. package/dist/cjs/hooks/useShapes/pie/index.js +2 -1
  13. package/dist/cjs/hooks/useShapes/pie/prepare-data.js +159 -111
  14. package/dist/cjs/hooks/useShapes/pie/types.d.ts +1 -1
  15. package/dist/cjs/hooks/useShapes/treemap/prepare-data.js +1 -0
  16. package/dist/cjs/types/chart/area.d.ts +6 -6
  17. package/dist/cjs/types/chart/axis.d.ts +8 -7
  18. package/dist/cjs/types/chart/bar-x.d.ts +4 -4
  19. package/dist/cjs/types/chart/bar-y.d.ts +5 -6
  20. package/dist/cjs/types/chart/base.d.ts +6 -6
  21. package/dist/cjs/types/chart/chart.d.ts +4 -4
  22. package/dist/cjs/types/chart/halo.d.ts +2 -2
  23. package/dist/cjs/types/chart/legend.d.ts +10 -10
  24. package/dist/cjs/types/chart/line.d.ts +4 -4
  25. package/dist/cjs/types/chart/marker.d.ts +2 -2
  26. package/dist/cjs/types/chart/pie.d.ts +4 -4
  27. package/dist/cjs/types/chart/scatter.d.ts +4 -4
  28. package/dist/cjs/types/chart/series.d.ts +8 -8
  29. package/dist/cjs/types/chart/split.d.ts +4 -4
  30. package/dist/cjs/types/chart/title.d.ts +2 -2
  31. package/dist/cjs/types/chart/tooltip.d.ts +20 -20
  32. package/dist/cjs/types/chart/treemap.d.ts +4 -4
  33. package/dist/cjs/types/chart/waterfall.d.ts +4 -4
  34. package/dist/cjs/types/chart-ui.d.ts +10 -6
  35. package/dist/cjs/types/formatter.d.ts +4 -4
  36. package/dist/cjs/types/index.d.ts +34 -4
  37. package/dist/esm/components/Tooltip/ChartTooltipContent.d.ts +2 -2
  38. package/dist/esm/components/Tooltip/index.js +6 -6
  39. package/dist/esm/components/Tooltip/styles.css +7 -18
  40. package/dist/esm/components/index.d.ts +10 -9
  41. package/dist/esm/hooks/useSeries/prepare-area.d.ts +1 -1
  42. package/dist/esm/hooks/useSeries/prepare-line.d.ts +1 -1
  43. package/dist/esm/hooks/useShapes/area/prepare-data.js +4 -0
  44. package/dist/esm/hooks/useShapes/bar-x/prepare-data.js +1 -0
  45. package/dist/esm/hooks/useShapes/bar-y/prepare-data.js +1 -0
  46. package/dist/esm/hooks/useShapes/line/prepare-data.js +1 -0
  47. package/dist/esm/hooks/useShapes/pie/index.js +2 -1
  48. package/dist/esm/hooks/useShapes/pie/prepare-data.js +159 -111
  49. package/dist/esm/hooks/useShapes/pie/types.d.ts +1 -1
  50. package/dist/esm/hooks/useShapes/treemap/prepare-data.js +1 -0
  51. package/dist/esm/types/chart/area.d.ts +6 -6
  52. package/dist/esm/types/chart/axis.d.ts +8 -7
  53. package/dist/esm/types/chart/bar-x.d.ts +4 -4
  54. package/dist/esm/types/chart/bar-y.d.ts +5 -6
  55. package/dist/esm/types/chart/base.d.ts +6 -6
  56. package/dist/esm/types/chart/chart.d.ts +4 -4
  57. package/dist/esm/types/chart/halo.d.ts +2 -2
  58. package/dist/esm/types/chart/legend.d.ts +10 -10
  59. package/dist/esm/types/chart/line.d.ts +4 -4
  60. package/dist/esm/types/chart/marker.d.ts +2 -2
  61. package/dist/esm/types/chart/pie.d.ts +4 -4
  62. package/dist/esm/types/chart/scatter.d.ts +4 -4
  63. package/dist/esm/types/chart/series.d.ts +8 -8
  64. package/dist/esm/types/chart/split.d.ts +4 -4
  65. package/dist/esm/types/chart/title.d.ts +2 -2
  66. package/dist/esm/types/chart/tooltip.d.ts +20 -20
  67. package/dist/esm/types/chart/treemap.d.ts +4 -4
  68. package/dist/esm/types/chart/waterfall.d.ts +4 -4
  69. package/dist/esm/types/chart-ui.d.ts +10 -6
  70. package/dist/esm/types/formatter.d.ts +4 -4
  71. package/dist/esm/types/index.d.ts +34 -4
  72. 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
- import type { ChartSeriesOptions } from './series';
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 type BarYSeries<T = MeaningfulAny> = BaseSeries & {
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?: ChartSeriesOptions['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 type BaseSeries = {
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 type BaseSeriesData<T = MeaningfulAny> = {
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 type BaseTextStyle = {
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 type ChartMargin = {
3
+ export interface ChartMargin {
4
4
  top: number;
5
5
  right: number;
6
6
  bottom: number;
7
7
  left: number;
8
- };
9
- export type ChartOptions = {
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 type Halo = {
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 type ChartLegend = {
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 type BaseLegendSymbol = {
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 type RectLegendSymbolOptions = BaseLegendSymbol & {
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 type PathLegendSymbolOptions = BaseLegendSymbol & {
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 type SymbolLegendSymbolOptions = BaseLegendSymbol & {
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 type LineSeriesData<T = MeaningfulAny> = BaseSeriesData<T> & {
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 type LineSeries<T = MeaningfulAny> = BaseSeries & {
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 type PointMarkerOptions = {
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 type PieSeriesData<T = MeaningfulAny> = BaseSeriesData<T> & {
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 type PieSeries<T = MeaningfulAny> = BaseSeries & {
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 type ScatterSeriesData<T = MeaningfulAny> = BaseSeriesData<T> & {
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 type ScatterSeries<T = MeaningfulAny> = BaseSeries & {
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 type DataLabelRendererData<T = MeaningfulAny> = {
16
+ export interface DataLabelRendererData<T = MeaningfulAny> {
17
17
  data: ChartSeriesData<T>;
18
- };
19
- export type BasicHoverState = {
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 type BasicInactiveState = {
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 type ChartSeriesOptions = {
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 type SplitPlotOptions = {
2
+ export interface SplitPlotOptions {
3
3
  title?: {
4
4
  text: string;
5
5
  style?: Partial<BaseTextStyle>;
6
6
  };
7
- };
8
- export type ChartSplit = {
7
+ }
8
+ export interface ChartSplit {
9
9
  enable: boolean;
10
10
  layout?: 'vertical';
11
11
  gap?: string | number;
12
12
  plots?: SplitPlotOptions[];
13
- };
13
+ }
@@ -1,5 +1,5 @@
1
1
  import type { BaseTextStyle } from './base';
2
- export type ChartTitle = {
2
+ export interface ChartTitle {
3
3
  text: string;
4
4
  style?: Partial<BaseTextStyle>;
5
- };
5
+ }
@@ -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 type TooltipDataChunkBarX<T = MeaningfulAny> = {
11
+ export interface TooltipDataChunkBarX<T = MeaningfulAny> {
12
12
  data: BarXSeriesData<T>;
13
13
  series: BarXSeries<T>;
14
- };
15
- export type TooltipDataChunkBarY<T = MeaningfulAny> = {
14
+ }
15
+ export interface TooltipDataChunkBarY<T = MeaningfulAny> {
16
16
  data: BarYSeriesData<T>;
17
17
  series: BarYSeries<T>;
18
- };
19
- export type TooltipDataChunkPie<T = MeaningfulAny> = {
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 type TooltipDataChunkScatter<T = MeaningfulAny> = {
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 type TooltipDataChunkLine<T = MeaningfulAny> = {
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 type TooltipDataChunkArea<T = MeaningfulAny> = {
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 type TooltipDataChunkTreemap<T = MeaningfulAny> = {
50
+ }
51
+ export interface TooltipDataChunkTreemap<T = MeaningfulAny> {
52
52
  data: TreemapSeriesData<T>;
53
53
  series: TreemapSeries<T>;
54
- };
55
- export type TooltipDataChunkWaterfall<T = MeaningfulAny> = {
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 type ChartTooltipRendererArgs<T = MeaningfulAny> = {
62
+ export interface ChartTooltipRendererArgs<T = MeaningfulAny> {
63
63
  hovered: TooltipDataChunk<T>[];
64
64
  xAxis?: ChartXAxis;
65
65
  yAxis?: ChartYAxis;
66
- };
67
- export type ChartTooltip<T = MeaningfulAny> = {
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 type TreemapSeriesData<T = MeaningfulAny> = BaseSeriesData<T> & {
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 type TreemapSeries<T = MeaningfulAny> = BaseSeries & {
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 type WaterfallSeriesData<T = MeaningfulAny> = BaseSeriesData<T> & {
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 type WaterfallSeries<T = MeaningfulAny> = BaseSeries & {
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 type LabelData = {
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 type HtmlItem = {
16
+ }
17
+ export interface HtmlItem {
18
18
  x: number;
19
19
  y: number;
20
20
  content: string;
21
- };
22
- export type ShapeDataWithHtmlItems = {
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 type FormatOptions = {
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 type FormatNumberOptions = FormatOptions & {
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 type ChartData<T = MeaningfulAny> = {
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
- /** Setting for displaying charts on different plots.
40
- * It can be used to visualize related information on multiple charts. */
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 type ChartTooltipContentProps = {
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, useVirtualElementRef } from '@gravity-ui/uikit';
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('d3-tooltip');
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 anchorRef = useVirtualElementRef({ rect: { left, top } });
15
- const handleOutsideClick = (e) => {
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 }), open: true, anchorRef: anchorRef, offset: [0, 20], placement: ['right', 'left', 'top', 'bottom'], modifiers: [{ name: 'preventOverflow', options: { padding: 10, altAxis: true } }], onOutsideClick: tooltipPinned ? handleOutsideClick : undefined },
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-d3-tooltip[class] {
2
- --g-popup-border-width: 0;
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-d3-tooltip__content {
14
- padding: 10px 14px;
4
+ .gcharts-tooltip__content {
5
+ padding: 8px 14px;
15
6
  text-wrap: nowrap;
16
- border: 1px solid var(--g-color-line-generic);
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-d3-tooltip__content-row {
10
+ .gcharts-tooltip__content-row {
22
11
  display: flex;
23
12
  align-items: center;
24
13
  }
25
- .gcharts-d3-tooltip__color {
14
+ .gcharts-tooltip__color {
26
15
  display: inline-block;
27
16
  width: 16px;
28
17
  height: 8px;