@gravity-ui/charts 0.6.1 → 0.8.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 +2 -2
- package/dist/cjs/components/Axis/AxisY.d.ts +1 -0
- package/dist/cjs/components/Axis/AxisY.js +55 -13
- package/dist/cjs/components/ChartInner/index.js +3 -2
- package/dist/cjs/components/ChartInner/useChartInnerHandlers.js +4 -0
- package/dist/cjs/components/Legend/index.js +1 -2
- package/dist/cjs/components/PlotTitle/index.js +1 -1
- package/dist/cjs/components/PlotTitle/styles.css +1 -1
- package/dist/cjs/components/Tooltip/ChartTooltipContent.d.ts +2 -2
- package/dist/cjs/components/Tooltip/DefaultContent.js +19 -3
- package/dist/cjs/components/Tooltip/index.js +5 -5
- package/dist/cjs/components/Tooltip/styles.css +2 -15
- package/dist/cjs/components/index.d.ts +10 -9
- package/dist/cjs/constants/index.d.ts +1 -0
- package/dist/cjs/constants/index.js +1 -0
- package/dist/cjs/hooks/useChartOptions/types.d.ts +11 -1
- package/dist/cjs/hooks/useChartOptions/x-axis.js +1 -0
- package/dist/cjs/hooks/useChartOptions/y-axis.js +9 -1
- package/dist/cjs/hooks/useSeries/prepare-area.d.ts +1 -1
- package/dist/cjs/hooks/useSeries/prepare-bar-x.d.ts +2 -1
- package/dist/cjs/hooks/useSeries/prepare-bar-x.js +2 -1
- package/dist/cjs/hooks/useSeries/prepare-bar-y.d.ts +2 -1
- package/dist/cjs/hooks/useSeries/prepare-bar-y.js +3 -1
- package/dist/cjs/hooks/useSeries/prepare-line.d.ts +1 -1
- package/dist/cjs/hooks/useSeries/prepare-pie.js +2 -2
- package/dist/cjs/hooks/useSeries/prepare-sankey.d.ts +11 -0
- package/dist/cjs/hooks/useSeries/prepare-sankey.js +38 -0
- package/dist/cjs/hooks/useSeries/prepareSeries.js +21 -2
- package/dist/cjs/hooks/useSeries/types.d.ts +12 -2
- package/dist/cjs/hooks/useSeries/utils.js +1 -1
- package/dist/cjs/hooks/useShapes/bar-x/index.js +16 -2
- package/dist/cjs/hooks/useShapes/bar-x/prepare-data.js +2 -1
- package/dist/cjs/hooks/useShapes/bar-x/types.d.ts +1 -0
- package/dist/cjs/hooks/useShapes/bar-y/index.js +16 -2
- package/dist/cjs/hooks/useShapes/bar-y/prepare-data.js +2 -1
- package/dist/cjs/hooks/useShapes/bar-y/types.d.ts +1 -0
- package/dist/cjs/hooks/useShapes/index.d.ts +2 -1
- package/dist/cjs/hooks/useShapes/index.js +19 -0
- package/dist/cjs/hooks/useShapes/line/index.js +2 -2
- package/dist/cjs/hooks/useShapes/pie/index.js +3 -3
- package/dist/cjs/hooks/useShapes/pie/prepare-data.js +37 -35
- package/dist/cjs/hooks/useShapes/pie/types.d.ts +1 -1
- package/dist/cjs/hooks/useShapes/sankey/index.d.ts +12 -0
- package/dist/cjs/hooks/useShapes/sankey/index.js +67 -0
- package/dist/cjs/hooks/useShapes/sankey/prepare-data.d.ts +7 -0
- package/dist/cjs/hooks/useShapes/sankey/prepare-data.js +72 -0
- package/dist/cjs/hooks/useShapes/sankey/types.d.ts +33 -0
- package/dist/cjs/hooks/useShapes/sankey/types.js +1 -0
- package/dist/cjs/hooks/useShapes/styles.css +2 -2
- package/dist/cjs/hooks/useShapes/utils.d.ts +7 -2
- package/dist/cjs/hooks/useShapes/utils.js +22 -17
- package/dist/cjs/hooks/useShapes/waterfall/index.js +1 -2
- package/dist/cjs/types/chart/area.d.ts +6 -6
- package/dist/cjs/types/chart/axis.d.ts +32 -7
- package/dist/cjs/types/chart/bar-x.d.ts +9 -4
- package/dist/cjs/types/chart/bar-y.d.ts +10 -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 +6 -4
- package/dist/cjs/types/chart/sankey.d.ts +22 -0
- package/dist/cjs/types/chart/sankey.js +1 -0
- package/dist/cjs/types/chart/scatter.d.ts +4 -4
- package/dist/cjs/types/chart/series.d.ts +21 -10
- 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 +27 -21
- 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 +6 -6
- package/dist/cjs/types/formatter.d.ts +4 -4
- package/dist/cjs/types/index.d.ts +35 -4
- package/dist/cjs/types/index.js +1 -0
- package/dist/cjs/utils/chart/get-closest-data.d.ts +2 -0
- package/dist/cjs/utils/chart/get-closest-data.js +39 -3
- package/dist/cjs/utils/chart/index.js +1 -1
- package/dist/cjs/utils/chart/series/index.d.ts +1 -0
- package/dist/cjs/utils/chart/series/index.js +1 -0
- package/dist/cjs/utils/chart/series/line.d.ts +2 -0
- package/dist/cjs/utils/chart/series/line.js +17 -0
- package/dist/esm/components/Axis/AxisY.d.ts +1 -0
- package/dist/esm/components/Axis/AxisY.js +55 -13
- package/dist/esm/components/ChartInner/index.js +3 -2
- package/dist/esm/components/ChartInner/useChartInnerHandlers.js +4 -0
- package/dist/esm/components/Legend/index.js +1 -2
- package/dist/esm/components/PlotTitle/index.js +1 -1
- package/dist/esm/components/PlotTitle/styles.css +1 -1
- package/dist/esm/components/Tooltip/ChartTooltipContent.d.ts +2 -2
- package/dist/esm/components/Tooltip/DefaultContent.js +19 -3
- package/dist/esm/components/Tooltip/index.js +5 -5
- package/dist/esm/components/Tooltip/styles.css +2 -15
- package/dist/esm/components/index.d.ts +10 -9
- package/dist/esm/constants/index.d.ts +1 -0
- package/dist/esm/constants/index.js +1 -0
- package/dist/esm/hooks/useChartOptions/types.d.ts +11 -1
- package/dist/esm/hooks/useChartOptions/x-axis.js +1 -0
- package/dist/esm/hooks/useChartOptions/y-axis.js +9 -1
- package/dist/esm/hooks/useSeries/prepare-area.d.ts +1 -1
- package/dist/esm/hooks/useSeries/prepare-bar-x.d.ts +2 -1
- package/dist/esm/hooks/useSeries/prepare-bar-x.js +2 -1
- package/dist/esm/hooks/useSeries/prepare-bar-y.d.ts +2 -1
- package/dist/esm/hooks/useSeries/prepare-bar-y.js +3 -1
- package/dist/esm/hooks/useSeries/prepare-line.d.ts +1 -1
- package/dist/esm/hooks/useSeries/prepare-pie.js +2 -2
- package/dist/esm/hooks/useSeries/prepare-sankey.d.ts +11 -0
- package/dist/esm/hooks/useSeries/prepare-sankey.js +38 -0
- package/dist/esm/hooks/useSeries/prepareSeries.js +21 -2
- package/dist/esm/hooks/useSeries/types.d.ts +12 -2
- package/dist/esm/hooks/useSeries/utils.js +1 -1
- package/dist/esm/hooks/useShapes/bar-x/index.js +16 -2
- package/dist/esm/hooks/useShapes/bar-x/prepare-data.js +2 -1
- package/dist/esm/hooks/useShapes/bar-x/types.d.ts +1 -0
- package/dist/esm/hooks/useShapes/bar-y/index.js +16 -2
- package/dist/esm/hooks/useShapes/bar-y/prepare-data.js +2 -1
- package/dist/esm/hooks/useShapes/bar-y/types.d.ts +1 -0
- package/dist/esm/hooks/useShapes/index.d.ts +2 -1
- package/dist/esm/hooks/useShapes/index.js +19 -0
- package/dist/esm/hooks/useShapes/line/index.js +2 -2
- package/dist/esm/hooks/useShapes/pie/index.js +3 -3
- package/dist/esm/hooks/useShapes/pie/prepare-data.js +37 -35
- package/dist/esm/hooks/useShapes/pie/types.d.ts +1 -1
- package/dist/esm/hooks/useShapes/sankey/index.d.ts +12 -0
- package/dist/esm/hooks/useShapes/sankey/index.js +67 -0
- package/dist/esm/hooks/useShapes/sankey/prepare-data.d.ts +7 -0
- package/dist/esm/hooks/useShapes/sankey/prepare-data.js +72 -0
- package/dist/esm/hooks/useShapes/sankey/types.d.ts +33 -0
- package/dist/esm/hooks/useShapes/sankey/types.js +1 -0
- package/dist/esm/hooks/useShapes/styles.css +2 -2
- package/dist/esm/hooks/useShapes/utils.d.ts +7 -2
- package/dist/esm/hooks/useShapes/utils.js +22 -17
- package/dist/esm/hooks/useShapes/waterfall/index.js +1 -2
- package/dist/esm/types/chart/area.d.ts +6 -6
- package/dist/esm/types/chart/axis.d.ts +32 -7
- package/dist/esm/types/chart/bar-x.d.ts +9 -4
- package/dist/esm/types/chart/bar-y.d.ts +10 -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 +6 -4
- package/dist/esm/types/chart/sankey.d.ts +22 -0
- package/dist/esm/types/chart/sankey.js +1 -0
- package/dist/esm/types/chart/scatter.d.ts +4 -4
- package/dist/esm/types/chart/series.d.ts +21 -10
- 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 +27 -21
- 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 +6 -6
- package/dist/esm/types/formatter.d.ts +4 -4
- package/dist/esm/types/index.d.ts +35 -4
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/utils/chart/get-closest-data.d.ts +2 -0
- package/dist/esm/utils/chart/get-closest-data.js +39 -3
- package/dist/esm/utils/chart/index.js +1 -1
- package/dist/esm/utils/chart/series/index.d.ts +1 -0
- package/dist/esm/utils/chart/series/index.js +1 -0
- package/dist/esm/utils/chart/series/line.d.ts +2 -0
- package/dist/esm/utils/chart/series/line.js +17 -0
- package/package.json +9 -4
|
@@ -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,12 @@ 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
|
+
/** The individual radius of the pie segment. The default value is series.radius */
|
|
18
|
+
radius?: string | number;
|
|
19
|
+
}
|
|
18
20
|
export type ConnectorShape = 'straight-line' | 'polyline';
|
|
19
21
|
export type ConnectorCurve = 'linear' | 'basic';
|
|
20
|
-
export
|
|
22
|
+
export interface PieSeries<T = MeaningfulAny> extends BaseSeries {
|
|
21
23
|
type: typeof SeriesType.Pie;
|
|
22
24
|
data: PieSeriesData<T>[];
|
|
23
25
|
/**
|
|
@@ -85,4 +87,4 @@ export type PieSeries<T = MeaningfulAny> = BaseSeries & {
|
|
|
85
87
|
innerRadius: number;
|
|
86
88
|
};
|
|
87
89
|
}) => BaseType;
|
|
88
|
-
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { SeriesType } from '../../constants';
|
|
2
|
+
import type { MeaningfulAny } from '../misc';
|
|
3
|
+
import type { BaseSeries, BaseSeriesData } from './base';
|
|
4
|
+
import type { ChartLegend, RectLegendSymbolOptions } from './legend';
|
|
5
|
+
export interface SankeySeriesData<T = MeaningfulAny> extends BaseSeriesData<T> {
|
|
6
|
+
name: string;
|
|
7
|
+
color?: string;
|
|
8
|
+
links: {
|
|
9
|
+
name: string;
|
|
10
|
+
value: number;
|
|
11
|
+
}[];
|
|
12
|
+
}
|
|
13
|
+
export interface SankeySeries<T = MeaningfulAny> extends BaseSeries {
|
|
14
|
+
type: typeof SeriesType.Sankey;
|
|
15
|
+
/** The name of the series (used in legend, tooltip etc). */
|
|
16
|
+
name: string;
|
|
17
|
+
data: SankeySeriesData<T>[];
|
|
18
|
+
/** Individual series legend options. Has higher priority than legend options in widget data. */
|
|
19
|
+
legend?: ChartLegend & {
|
|
20
|
+
symbol?: RectLegendSymbolOptions;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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
|
+
}
|
|
@@ -8,15 +8,16 @@ import type { Halo } from './halo';
|
|
|
8
8
|
import type { LineSeries, LineSeriesData } from './line';
|
|
9
9
|
import type { PointMarkerOptions } from './marker';
|
|
10
10
|
import type { PieSeries, PieSeriesData } from './pie';
|
|
11
|
+
import type { SankeySeries, SankeySeriesData } from './sankey';
|
|
11
12
|
import type { ScatterSeries, ScatterSeriesData } from './scatter';
|
|
12
13
|
import type { TreemapSeries, TreemapSeriesData } from './treemap';
|
|
13
14
|
import type { WaterfallSeries, WaterfallSeriesData } from './waterfall';
|
|
14
|
-
export type ChartSeries<T = MeaningfulAny> = ScatterSeries<T> | PieSeries<T> | BarXSeries<T> | BarYSeries<T> | LineSeries<T> | AreaSeries<T> | TreemapSeries<T> | WaterfallSeries<T>;
|
|
15
|
-
export type ChartSeriesData<T = MeaningfulAny> = ScatterSeriesData<T> | PieSeriesData<T> | BarXSeriesData<T> | BarYSeriesData<T> | LineSeriesData<T> | AreaSeriesData<T> | TreemapSeriesData<T> | WaterfallSeriesData<T>;
|
|
16
|
-
export
|
|
15
|
+
export type ChartSeries<T = MeaningfulAny> = ScatterSeries<T> | PieSeries<T> | BarXSeries<T> | BarYSeries<T> | LineSeries<T> | AreaSeries<T> | TreemapSeries<T> | WaterfallSeries<T> | SankeySeries<T>;
|
|
16
|
+
export type ChartSeriesData<T = MeaningfulAny> = ScatterSeriesData<T> | PieSeriesData<T> | BarXSeriesData<T> | BarYSeriesData<T> | LineSeriesData<T> | AreaSeriesData<T> | TreemapSeriesData<T> | WaterfallSeriesData<T> | SankeySeriesData<T>;
|
|
17
|
+
export interface DataLabelRendererData<T = MeaningfulAny> {
|
|
17
18
|
data: ChartSeriesData<T>;
|
|
18
|
-
}
|
|
19
|
-
export
|
|
19
|
+
}
|
|
20
|
+
export interface BasicHoverState {
|
|
20
21
|
/**
|
|
21
22
|
* Enable separate styles for the hovered series.
|
|
22
23
|
*
|
|
@@ -32,8 +33,8 @@ export type BasicHoverState = {
|
|
|
32
33
|
* @default 0.3
|
|
33
34
|
*/
|
|
34
35
|
brightness?: number;
|
|
35
|
-
}
|
|
36
|
-
export
|
|
36
|
+
}
|
|
37
|
+
export interface BasicInactiveState {
|
|
37
38
|
/**
|
|
38
39
|
* Enable separate styles for the inactive series.
|
|
39
40
|
*
|
|
@@ -46,8 +47,8 @@ export type BasicInactiveState = {
|
|
|
46
47
|
* @default 0.5
|
|
47
48
|
* */
|
|
48
49
|
opacity?: number;
|
|
49
|
-
}
|
|
50
|
-
export
|
|
50
|
+
}
|
|
51
|
+
export interface ChartSeriesOptions {
|
|
51
52
|
/** Individual data label for each point. */
|
|
52
53
|
dataLabels?: {
|
|
53
54
|
/** Enable or disable the data labels */
|
|
@@ -72,6 +73,11 @@ export type ChartSeriesOptions = {
|
|
|
72
73
|
* @default 0.2
|
|
73
74
|
*/
|
|
74
75
|
groupPadding?: number;
|
|
76
|
+
/**
|
|
77
|
+
* The corner radius of the border surrounding each bar.
|
|
78
|
+
* @default 0
|
|
79
|
+
*/
|
|
80
|
+
borderRadius?: number;
|
|
75
81
|
dataSorting?: {
|
|
76
82
|
/** Determines what data value should be used to sort by.
|
|
77
83
|
* Possible values are undefined to disable, "name" to sort by series name or "y"
|
|
@@ -108,6 +114,11 @@ export type ChartSeriesOptions = {
|
|
|
108
114
|
* @default 0.2
|
|
109
115
|
*/
|
|
110
116
|
groupPadding?: number;
|
|
117
|
+
/**
|
|
118
|
+
* The corner radius of the border surrounding each bar.
|
|
119
|
+
* @default 0
|
|
120
|
+
*/
|
|
121
|
+
borderRadius?: number;
|
|
111
122
|
dataSorting?: {
|
|
112
123
|
/** Determines what data value should be used to sort by.
|
|
113
124
|
* Possible values are undefined to disable, "name" to sort by series name or "x"
|
|
@@ -222,4 +233,4 @@ export type ChartSeriesOptions = {
|
|
|
222
233
|
inactive?: BasicInactiveState;
|
|
223
234
|
};
|
|
224
235
|
};
|
|
225
|
-
}
|
|
236
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -5,66 +5,72 @@ import type { BarXSeries, BarXSeriesData } from './bar-x';
|
|
|
5
5
|
import type { BarYSeries, BarYSeriesData } from './bar-y';
|
|
6
6
|
import type { LineSeries, LineSeriesData } from './line';
|
|
7
7
|
import type { PieSeries, PieSeriesData } from './pie';
|
|
8
|
+
import type { SankeySeries, SankeySeriesData } from './sankey';
|
|
8
9
|
import type { ScatterSeries, ScatterSeriesData } from './scatter';
|
|
9
10
|
import type { TreemapSeries, TreemapSeriesData } from './treemap';
|
|
10
11
|
import type { WaterfallSeries, WaterfallSeriesData } from './waterfall';
|
|
11
|
-
export
|
|
12
|
+
export interface TooltipDataChunkBarX<T = MeaningfulAny> {
|
|
12
13
|
data: BarXSeriesData<T>;
|
|
13
14
|
series: BarXSeries<T>;
|
|
14
|
-
}
|
|
15
|
-
export
|
|
15
|
+
}
|
|
16
|
+
export interface TooltipDataChunkBarY<T = MeaningfulAny> {
|
|
16
17
|
data: BarYSeriesData<T>;
|
|
17
18
|
series: BarYSeries<T>;
|
|
18
|
-
}
|
|
19
|
-
export
|
|
19
|
+
}
|
|
20
|
+
export interface TooltipDataChunkPie<T = MeaningfulAny> {
|
|
20
21
|
data: PieSeriesData<T>;
|
|
21
22
|
series: {
|
|
22
23
|
type: PieSeries['type'];
|
|
23
24
|
id: string;
|
|
24
25
|
name: string;
|
|
25
26
|
};
|
|
26
|
-
}
|
|
27
|
-
export
|
|
27
|
+
}
|
|
28
|
+
export interface TooltipDataChunkScatter<T = MeaningfulAny> {
|
|
28
29
|
data: ScatterSeriesData<T>;
|
|
29
30
|
series: {
|
|
30
31
|
type: ScatterSeries['type'];
|
|
31
32
|
id: string;
|
|
32
33
|
name: string;
|
|
33
34
|
};
|
|
34
|
-
}
|
|
35
|
-
export
|
|
35
|
+
}
|
|
36
|
+
export interface TooltipDataChunkLine<T = MeaningfulAny> {
|
|
36
37
|
data: LineSeriesData<T>;
|
|
37
38
|
series: {
|
|
38
39
|
type: LineSeries['type'];
|
|
39
40
|
id: string;
|
|
40
41
|
name: string;
|
|
41
42
|
};
|
|
42
|
-
}
|
|
43
|
-
export
|
|
43
|
+
}
|
|
44
|
+
export interface TooltipDataChunkArea<T = MeaningfulAny> {
|
|
44
45
|
data: AreaSeriesData<T>;
|
|
45
46
|
series: {
|
|
46
47
|
type: AreaSeries['type'];
|
|
47
48
|
id: string;
|
|
48
49
|
name: string;
|
|
49
50
|
};
|
|
50
|
-
}
|
|
51
|
-
export
|
|
51
|
+
}
|
|
52
|
+
export interface TooltipDataChunkTreemap<T = MeaningfulAny> {
|
|
52
53
|
data: TreemapSeriesData<T>;
|
|
53
54
|
series: TreemapSeries<T>;
|
|
54
|
-
}
|
|
55
|
-
export
|
|
55
|
+
}
|
|
56
|
+
export interface TooltipDataChunkSankey<T = MeaningfulAny> {
|
|
57
|
+
data: SankeySeriesData<T>;
|
|
58
|
+
target?: SankeySeriesData<T>;
|
|
59
|
+
series: SankeySeries<T>;
|
|
60
|
+
}
|
|
61
|
+
export interface TooltipDataChunkWaterfall<T = MeaningfulAny> {
|
|
56
62
|
data: WaterfallSeriesData<T>;
|
|
57
63
|
series: WaterfallSeries<T>;
|
|
58
|
-
}
|
|
59
|
-
export type TooltipDataChunk<T = MeaningfulAny> = (TooltipDataChunkBarX<T> | TooltipDataChunkBarY<T> | TooltipDataChunkPie<T> | TooltipDataChunkScatter<T> | TooltipDataChunkLine<T> | TooltipDataChunkArea<T> | TooltipDataChunkTreemap<T> | TooltipDataChunkWaterfall<T>) & {
|
|
64
|
+
}
|
|
65
|
+
export type TooltipDataChunk<T = MeaningfulAny> = (TooltipDataChunkBarX<T> | TooltipDataChunkBarY<T> | TooltipDataChunkPie<T> | TooltipDataChunkScatter<T> | TooltipDataChunkLine<T> | TooltipDataChunkArea<T> | TooltipDataChunkTreemap<T> | TooltipDataChunkSankey<T> | TooltipDataChunkWaterfall<T>) & {
|
|
60
66
|
closest?: boolean;
|
|
61
67
|
};
|
|
62
|
-
export
|
|
68
|
+
export interface ChartTooltipRendererArgs<T = MeaningfulAny> {
|
|
63
69
|
hovered: TooltipDataChunk<T>[];
|
|
64
70
|
xAxis?: ChartXAxis;
|
|
65
71
|
yAxis?: ChartYAxis;
|
|
66
|
-
}
|
|
67
|
-
export
|
|
72
|
+
}
|
|
73
|
+
export interface ChartTooltip<T = MeaningfulAny> {
|
|
68
74
|
enabled?: boolean;
|
|
69
75
|
/** Specifies the renderer for the tooltip. If returned null default tooltip renderer will be used. */
|
|
70
76
|
renderer?: (args: ChartTooltipRendererArgs<T>) => React.ReactElement | null;
|
|
@@ -72,4 +78,4 @@ export type ChartTooltip<T = MeaningfulAny> = {
|
|
|
72
78
|
enabled?: boolean;
|
|
73
79
|
modifierKey?: 'altKey' | 'metaKey';
|
|
74
80
|
};
|
|
75
|
-
}
|
|
81
|
+
}
|
|
@@ -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,8 +13,8 @@ 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;
|
|
@@ -22,7 +22,7 @@ export type HtmlItem = {
|
|
|
22
22
|
width: number;
|
|
23
23
|
height: number;
|
|
24
24
|
};
|
|
25
|
-
}
|
|
26
|
-
export
|
|
25
|
+
}
|
|
26
|
+
export interface ShapeDataWithHtmlItems {
|
|
27
27
|
htmlElements: HtmlItem[];
|
|
28
|
-
}
|
|
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,49 @@ 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 * from './chart/sankey';
|
|
29
|
+
export interface ChartData<T = MeaningfulAny> {
|
|
30
|
+
/**
|
|
31
|
+
* General options for the chart.
|
|
32
|
+
*/
|
|
29
33
|
chart?: ChartOptions;
|
|
34
|
+
/**
|
|
35
|
+
* The legend displays a labeled box for each data element in the chart.
|
|
36
|
+
* It shows a distinctive symbol paired with a name for every series.
|
|
37
|
+
*/
|
|
30
38
|
legend?: ChartLegend;
|
|
39
|
+
/**
|
|
40
|
+
* Represents the series data and series options.
|
|
41
|
+
*/
|
|
31
42
|
series: {
|
|
43
|
+
/**
|
|
44
|
+
* Contains data points to be plotted.
|
|
45
|
+
*/
|
|
32
46
|
data: ChartSeries<T>[];
|
|
47
|
+
/**
|
|
48
|
+
* Allows for customizing the appearance and behavior of the series.
|
|
49
|
+
*/
|
|
33
50
|
options?: ChartSeriesOptions;
|
|
34
51
|
};
|
|
52
|
+
/**
|
|
53
|
+
* The main title of the chart.
|
|
54
|
+
*/
|
|
35
55
|
title?: ChartTitle;
|
|
56
|
+
/**
|
|
57
|
+
* Options for the tooltip that appears when the user hovers over a series or point.
|
|
58
|
+
*/
|
|
36
59
|
tooltip?: ChartTooltip<T>;
|
|
60
|
+
/**
|
|
61
|
+
* Options for the the X axis.
|
|
62
|
+
*/
|
|
37
63
|
xAxis?: ChartXAxis;
|
|
64
|
+
/**
|
|
65
|
+
* Options for the the Y axis or multiple Y axes.
|
|
66
|
+
*/
|
|
38
67
|
yAxis?: ChartYAxis[];
|
|
39
|
-
/**
|
|
40
|
-
*
|
|
68
|
+
/**
|
|
69
|
+
* Setting for displaying charts on different plots.
|
|
70
|
+
* It can be used to visualize related information on multiple charts.
|
|
71
|
+
*/
|
|
41
72
|
split?: ChartSplit;
|
|
42
|
-
}
|
|
73
|
+
}
|
package/dist/esm/types/index.js
CHANGED
|
@@ -35,7 +35,7 @@ function getSeriesType(shapeData) {
|
|
|
35
35
|
return get(shapeData, 'series.type') || get(shapeData, 'point.series.type');
|
|
36
36
|
}
|
|
37
37
|
export function getClosestPoints(args) {
|
|
38
|
-
const { position, shapesData } = args;
|
|
38
|
+
const { position, shapesData, boundsHeight, boundsWidth } = args;
|
|
39
39
|
const [pointerX, pointerY] = position;
|
|
40
40
|
const result = [];
|
|
41
41
|
const groups = groupBy(shapesData, getSeriesType);
|
|
@@ -135,13 +135,13 @@ export function getClosestPoints(args) {
|
|
|
135
135
|
case 'pie': {
|
|
136
136
|
const points = list.map((d) => d.segments).flat();
|
|
137
137
|
const closestPoint = points.find((p) => {
|
|
138
|
-
const { center
|
|
138
|
+
const { center } = p.data.pie;
|
|
139
139
|
const x = pointerX - center[0];
|
|
140
140
|
const y = pointerY - center[1];
|
|
141
141
|
let angle = Math.atan2(y, x) + 0.5 * Math.PI;
|
|
142
142
|
angle = angle < 0 ? Math.PI * 2 + angle : angle;
|
|
143
143
|
const polarRadius = Math.sqrt(x * x + y * y);
|
|
144
|
-
return angle >= p.startAngle && angle <= p.endAngle && polarRadius < radius;
|
|
144
|
+
return (angle >= p.startAngle && angle <= p.endAngle && polarRadius < p.data.radius);
|
|
145
145
|
});
|
|
146
146
|
if (closestPoint) {
|
|
147
147
|
result.push({
|
|
@@ -166,7 +166,43 @@ export function getClosestPoints(args) {
|
|
|
166
166
|
}
|
|
167
167
|
break;
|
|
168
168
|
}
|
|
169
|
+
case 'sankey': {
|
|
170
|
+
const [data] = list;
|
|
171
|
+
const closestLink = data.links.find((d) => {
|
|
172
|
+
var _a;
|
|
173
|
+
return isInsidePath({
|
|
174
|
+
path: (_a = d.path) !== null && _a !== void 0 ? _a : '',
|
|
175
|
+
strokeWidth: d.strokeWidth,
|
|
176
|
+
point: [pointerX, pointerY],
|
|
177
|
+
width: boundsWidth,
|
|
178
|
+
height: boundsHeight,
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
if (closestLink) {
|
|
182
|
+
result.push({
|
|
183
|
+
data: closestLink.source,
|
|
184
|
+
target: closestLink.target,
|
|
185
|
+
series: data.series,
|
|
186
|
+
closest: true,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
169
191
|
}
|
|
170
192
|
});
|
|
171
193
|
return result;
|
|
172
194
|
}
|
|
195
|
+
function isInsidePath(args) {
|
|
196
|
+
const { path, point, width, height, strokeWidth } = args;
|
|
197
|
+
const canvas = document.createElement('canvas');
|
|
198
|
+
canvas.width = width;
|
|
199
|
+
canvas.height = height;
|
|
200
|
+
const ctx = canvas.getContext('2d');
|
|
201
|
+
if (ctx) {
|
|
202
|
+
ctx.lineWidth = strokeWidth;
|
|
203
|
+
const path2D = new Path2D(path);
|
|
204
|
+
ctx.stroke(path2D);
|
|
205
|
+
return ctx.isPointInPath(path2D, ...point) || ctx.isPointInStroke(path2D, ...point);
|
|
206
|
+
}
|
|
207
|
+
return null;
|
|
208
|
+
}
|