@gravity-ui/charts 1.24.2 → 1.26.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/dist/cjs/components/ChartInner/useChartInnerProps.d.ts +3 -3
- package/dist/cjs/components/ChartInner/useChartInnerProps.js +34 -16
- package/dist/cjs/components/Legend/index.js +50 -28
- package/dist/cjs/hooks/useAxis/index.js +0 -1
- package/dist/cjs/hooks/useAxis/x-axis.d.ts +1 -3
- package/dist/cjs/hooks/useAxis/x-axis.js +3 -4
- package/dist/cjs/hooks/useAxisScales/index.d.ts +1 -3
- package/dist/cjs/hooks/useAxisScales/index.js +6 -35
- package/dist/cjs/hooks/useChartDimensions/index.js +16 -1
- package/dist/cjs/hooks/useRangeSlider/index.js +0 -1
- package/dist/cjs/hooks/useSeries/index.js +8 -8
- package/dist/cjs/hooks/useSeries/prepare-area.js +7 -5
- package/dist/cjs/hooks/useSeries/prepare-bar-x.js +8 -6
- package/dist/cjs/hooks/useSeries/prepare-bar-y.d.ts +2 -0
- package/dist/cjs/hooks/useSeries/prepare-bar-y.js +7 -5
- package/dist/cjs/hooks/useSeries/prepare-funnel.js +14 -10
- package/dist/cjs/hooks/useSeries/prepare-heatmap.js +9 -7
- package/dist/cjs/hooks/useSeries/prepare-legend.js +75 -15
- package/dist/cjs/hooks/useSeries/prepare-line.js +6 -4
- package/dist/cjs/hooks/useSeries/prepare-pie.js +10 -6
- package/dist/cjs/hooks/useSeries/prepare-radar.js +7 -5
- package/dist/cjs/hooks/useSeries/prepare-sankey.js +3 -1
- package/dist/cjs/hooks/useSeries/prepare-scatter.js +4 -1
- package/dist/cjs/hooks/useSeries/prepare-treemap.js +4 -2
- package/dist/cjs/hooks/useSeries/prepare-waterfall.js +13 -8
- package/dist/cjs/hooks/useSeries/types.d.ts +5 -0
- package/dist/cjs/hooks/useSeries/utils.d.ts +7 -3
- package/dist/cjs/hooks/useSeries/utils.js +2 -2
- package/dist/cjs/hooks/useShapes/area/prepare-data.js +3 -0
- package/dist/cjs/hooks/useShapes/bar-x/prepare-data.js +24 -46
- package/dist/cjs/hooks/useShapes/bar-y/prepare-data.js +0 -3
- package/dist/cjs/hooks/useShapes/waterfall/prepare-data.js +4 -1
- package/dist/cjs/hooks/utils/bar-x.d.ts +3 -2
- package/dist/cjs/hooks/utils/bar-x.js +8 -6
- package/dist/cjs/hooks/utils/bar-y.d.ts +0 -1
- package/dist/cjs/hooks/utils/bar-y.js +3 -3
- package/dist/cjs/types/chart/area.d.ts +3 -3
- package/dist/cjs/types/chart/axis.d.ts +1 -0
- package/dist/cjs/types/chart/bar-x.d.ts +3 -3
- package/dist/cjs/types/chart/bar-y.d.ts +3 -3
- package/dist/cjs/types/chart/base.d.ts +9 -0
- package/dist/cjs/types/chart/funnel.d.ts +10 -6
- package/dist/cjs/types/chart/heatmap.d.ts +3 -3
- package/dist/cjs/types/chart/legend.d.ts +12 -10
- package/dist/cjs/types/chart/line.d.ts +3 -3
- package/dist/cjs/types/chart/pie.d.ts +10 -6
- package/dist/cjs/types/chart/radar.d.ts +3 -3
- package/dist/cjs/types/chart/sankey.d.ts +3 -3
- package/dist/cjs/types/chart/scatter.d.ts +3 -3
- package/dist/cjs/types/chart/treemap.d.ts +3 -3
- package/dist/cjs/types/chart/waterfall.d.ts +2 -2
- package/dist/esm/components/ChartInner/useChartInnerProps.d.ts +3 -3
- package/dist/esm/components/ChartInner/useChartInnerProps.js +34 -16
- package/dist/esm/components/Legend/index.js +50 -28
- package/dist/esm/hooks/useAxis/index.js +0 -1
- package/dist/esm/hooks/useAxis/x-axis.d.ts +1 -3
- package/dist/esm/hooks/useAxis/x-axis.js +3 -4
- package/dist/esm/hooks/useAxisScales/index.d.ts +1 -3
- package/dist/esm/hooks/useAxisScales/index.js +6 -35
- package/dist/esm/hooks/useChartDimensions/index.js +16 -1
- package/dist/esm/hooks/useRangeSlider/index.js +0 -1
- package/dist/esm/hooks/useSeries/index.js +8 -8
- package/dist/esm/hooks/useSeries/prepare-area.js +7 -5
- package/dist/esm/hooks/useSeries/prepare-bar-x.js +8 -6
- package/dist/esm/hooks/useSeries/prepare-bar-y.d.ts +2 -0
- package/dist/esm/hooks/useSeries/prepare-bar-y.js +7 -5
- package/dist/esm/hooks/useSeries/prepare-funnel.js +14 -10
- package/dist/esm/hooks/useSeries/prepare-heatmap.js +9 -7
- package/dist/esm/hooks/useSeries/prepare-legend.js +75 -15
- package/dist/esm/hooks/useSeries/prepare-line.js +6 -4
- package/dist/esm/hooks/useSeries/prepare-pie.js +10 -6
- package/dist/esm/hooks/useSeries/prepare-radar.js +7 -5
- package/dist/esm/hooks/useSeries/prepare-sankey.js +3 -1
- package/dist/esm/hooks/useSeries/prepare-scatter.js +4 -1
- package/dist/esm/hooks/useSeries/prepare-treemap.js +4 -2
- package/dist/esm/hooks/useSeries/prepare-waterfall.js +13 -8
- package/dist/esm/hooks/useSeries/types.d.ts +5 -0
- package/dist/esm/hooks/useSeries/utils.d.ts +7 -3
- package/dist/esm/hooks/useSeries/utils.js +2 -2
- package/dist/esm/hooks/useShapes/area/prepare-data.js +3 -0
- package/dist/esm/hooks/useShapes/bar-x/prepare-data.js +24 -46
- package/dist/esm/hooks/useShapes/bar-y/prepare-data.js +0 -3
- package/dist/esm/hooks/useShapes/waterfall/prepare-data.js +4 -1
- package/dist/esm/hooks/utils/bar-x.d.ts +3 -2
- package/dist/esm/hooks/utils/bar-x.js +8 -6
- package/dist/esm/hooks/utils/bar-y.d.ts +0 -1
- package/dist/esm/hooks/utils/bar-y.js +3 -3
- package/dist/esm/types/chart/area.d.ts +3 -3
- package/dist/esm/types/chart/axis.d.ts +1 -0
- package/dist/esm/types/chart/bar-x.d.ts +3 -3
- package/dist/esm/types/chart/bar-y.d.ts +3 -3
- package/dist/esm/types/chart/base.d.ts +9 -0
- package/dist/esm/types/chart/funnel.d.ts +10 -6
- package/dist/esm/types/chart/heatmap.d.ts +3 -3
- package/dist/esm/types/chart/legend.d.ts +12 -10
- package/dist/esm/types/chart/line.d.ts +3 -3
- package/dist/esm/types/chart/pie.d.ts +10 -6
- package/dist/esm/types/chart/radar.d.ts +3 -3
- package/dist/esm/types/chart/sankey.d.ts +3 -3
- package/dist/esm/types/chart/scatter.d.ts +3 -3
- package/dist/esm/types/chart/treemap.d.ts +3 -3
- package/dist/esm/types/chart/waterfall.d.ts +2 -2
- package/package.json +1 -1
|
@@ -17,7 +17,6 @@ export async function prepareBarYData(args) {
|
|
|
17
17
|
htmlElements: [],
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
-
const yScaleRange = yLinearScale.range();
|
|
21
20
|
const sortingOptions = get(seriesOptions, 'bar-y.dataSorting');
|
|
22
21
|
const comparator = (sortingOptions === null || sortingOptions === void 0 ? void 0 : sortingOptions.direction) === 'desc' ? descending : ascending;
|
|
23
22
|
const sortKey = (() => {
|
|
@@ -34,11 +33,9 @@ export async function prepareBarYData(args) {
|
|
|
34
33
|
}
|
|
35
34
|
})();
|
|
36
35
|
const groupedData = groupBarYDataByYValue(series, yAxis);
|
|
37
|
-
const plotHeight = Math.abs(yScaleRange[0] - yScaleRange[1]);
|
|
38
36
|
const { bandSize, barGap, barSize } = getBarYLayout({
|
|
39
37
|
groupedData,
|
|
40
38
|
seriesOptions,
|
|
41
|
-
plotHeight,
|
|
42
39
|
scale: yScale,
|
|
43
40
|
});
|
|
44
41
|
const result = [];
|
|
@@ -86,7 +86,10 @@ export const prepareWaterfallData = async (args) => {
|
|
|
86
86
|
if (typeof item.data.y !== 'number' && !item.data.total) {
|
|
87
87
|
continue;
|
|
88
88
|
}
|
|
89
|
-
if (
|
|
89
|
+
if (item.data.total) {
|
|
90
|
+
item.data.y = totalValue;
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
90
93
|
totalValue += Number(item.data.y);
|
|
91
94
|
}
|
|
92
95
|
const prevPoint = result[result.length - 1];
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import type { BarXSeries, BarXSeriesData } from '../../types';
|
|
2
2
|
import type { PreparedXAxis } from '../useAxis/types';
|
|
3
|
+
import type { ChartScale } from '../useAxisScales';
|
|
3
4
|
import type { PreparedBarXSeries, PreparedSeriesOptions } from '../useSeries/types';
|
|
4
5
|
export declare function groupBarXDataByXValue<T extends BarXSeries | PreparedBarXSeries>(series: T[], xAxis: PreparedXAxis): Record<string | number, Record<string, {
|
|
5
6
|
data: BarXSeriesData;
|
|
6
7
|
series: T;
|
|
7
8
|
}[]>>;
|
|
8
|
-
export declare function
|
|
9
|
-
plotWidth: number;
|
|
9
|
+
export declare function getBarXLayout(args: {
|
|
10
10
|
seriesOptions: PreparedSeriesOptions;
|
|
11
11
|
groupedData: ReturnType<typeof groupBarXDataByXValue>;
|
|
12
|
+
scale: ChartScale | undefined;
|
|
12
13
|
}): {
|
|
13
14
|
bandSize: number;
|
|
14
15
|
barGap: number;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { max } from 'd3';
|
|
1
2
|
import get from 'lodash/get';
|
|
2
3
|
import { getDataCategoryValue } from '../../utils';
|
|
3
4
|
import { MIN_BAR_GAP, MIN_BAR_GROUP_GAP, MIN_BAR_WIDTH } from '../constants';
|
|
4
5
|
import { getSeriesStackId } from '../useSeries/utils';
|
|
6
|
+
import { getBandSize } from './get-band-size';
|
|
5
7
|
export function groupBarXDataByXValue(series, xAxis) {
|
|
6
8
|
const data = {};
|
|
7
9
|
series.forEach((s) => {
|
|
@@ -25,17 +27,17 @@ export function groupBarXDataByXValue(series, xAxis) {
|
|
|
25
27
|
});
|
|
26
28
|
return data;
|
|
27
29
|
}
|
|
28
|
-
export function
|
|
29
|
-
const {
|
|
30
|
+
export function getBarXLayout(args) {
|
|
31
|
+
const { groupedData, seriesOptions, scale } = args;
|
|
30
32
|
const barMaxWidth = get(seriesOptions, 'bar-x.barMaxWidth');
|
|
31
33
|
const barPadding = get(seriesOptions, 'bar-x.barPadding');
|
|
32
34
|
const groupPadding = get(seriesOptions, 'bar-x.groupPadding');
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const bandSize = plotWidth / groups.length;
|
|
35
|
+
const domain = Object.keys(groupedData);
|
|
36
|
+
const bandSize = getBandSize({ domain, scale: scale });
|
|
36
37
|
const groupGap = Math.max(bandSize * groupPadding, MIN_BAR_GROUP_GAP);
|
|
38
|
+
const maxGroupSize = max(Object.values(groupedData), (d) => Object.values(d).length) || 1;
|
|
37
39
|
const groupSize = bandSize - groupGap;
|
|
38
40
|
const barGap = Math.max(bandSize * barPadding, MIN_BAR_GAP);
|
|
39
|
-
const barSize = Math.max(MIN_BAR_WIDTH, Math.min(
|
|
41
|
+
const barSize = Math.max(MIN_BAR_WIDTH, Math.min(groupSize / maxGroupSize - barGap, barMaxWidth));
|
|
40
42
|
return { bandSize, barGap, barSize };
|
|
41
43
|
}
|
|
@@ -13,7 +13,6 @@ export declare function groupBarYDataByYValue<T extends BarYSeries | PreparedBar
|
|
|
13
13
|
series: T;
|
|
14
14
|
}[]>>;
|
|
15
15
|
export declare function getBarYLayout(args: {
|
|
16
|
-
plotHeight: number;
|
|
17
16
|
seriesOptions: PreparedSeriesOptions;
|
|
18
17
|
groupedData: ReturnType<typeof groupBarYDataByYValue>;
|
|
19
18
|
scale: ChartScale | undefined;
|
|
@@ -8,13 +8,13 @@ const isSeriesDataValid = (d) => d.x !== null;
|
|
|
8
8
|
export function groupBarYDataByYValue(series, yAxis) {
|
|
9
9
|
const data = {};
|
|
10
10
|
series.forEach((s) => {
|
|
11
|
+
const axisIndex = get(s, 'yAxis', 0);
|
|
12
|
+
const seriesYAxis = yAxis[axisIndex];
|
|
13
|
+
const categories = get(seriesYAxis, 'categories', []);
|
|
11
14
|
s.data.forEach((d) => {
|
|
12
15
|
if (!isSeriesDataValid(d)) {
|
|
13
16
|
return;
|
|
14
17
|
}
|
|
15
|
-
const axisIndex = get(s, 'yAxis', 0);
|
|
16
|
-
const seriesYAxis = yAxis[axisIndex];
|
|
17
|
-
const categories = get(seriesYAxis, 'categories', []);
|
|
18
18
|
const key = seriesYAxis.type === 'category'
|
|
19
19
|
? getDataCategoryValue({ axisDirection: 'y', categories, data: d })
|
|
20
20
|
: d.y;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SERIES_TYPE } from '../../constants';
|
|
2
2
|
import type { MeaningfulAny } from '../misc';
|
|
3
|
-
import type { BaseSeries, BaseSeriesData } from './base';
|
|
4
|
-
import type {
|
|
3
|
+
import type { BaseSeries, BaseSeriesData, BaseSeriesLegend } from './base';
|
|
4
|
+
import type { RectLegendSymbolOptions } from './legend';
|
|
5
5
|
import type { PointMarkerOptions } from './marker';
|
|
6
6
|
import type { ChartSeriesRangeSliderOptions } from './series';
|
|
7
7
|
export interface AreaSeriesData<T = MeaningfulAny> extends BaseSeriesData<T> {
|
|
@@ -67,7 +67,7 @@ export interface AreaSeries<T = MeaningfulAny> extends BaseSeries {
|
|
|
67
67
|
* */
|
|
68
68
|
lineWidth?: number;
|
|
69
69
|
/** Individual series legend options. Has higher priority than legend options in widget data */
|
|
70
|
-
legend?:
|
|
70
|
+
legend?: BaseSeriesLegend & {
|
|
71
71
|
symbol?: RectLegendSymbolOptions;
|
|
72
72
|
};
|
|
73
73
|
/** Options for the point markers of line in area series */
|
|
@@ -145,6 +145,7 @@ export interface ChartAxis {
|
|
|
145
145
|
};
|
|
146
146
|
/** Padding of the max value relative to the length of the axis.
|
|
147
147
|
* A padding of 0.05 will make a 100px axis 5px longer.
|
|
148
|
+
* Does not apply for series with data normalization along on a specific axis (stacking: 'percent').
|
|
148
149
|
* @default 0.05 for Y axis, 0.01 for X axis
|
|
149
150
|
*/
|
|
150
151
|
maxPadding?: number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SERIES_TYPE } from '../../constants';
|
|
2
2
|
import type { MeaningfulAny } from '../misc';
|
|
3
|
-
import type { BaseSeries, BaseSeriesData } from './base';
|
|
4
|
-
import type {
|
|
3
|
+
import type { BaseSeries, BaseSeriesData, BaseSeriesLegend } from './base';
|
|
4
|
+
import type { RectLegendSymbolOptions } from './legend';
|
|
5
5
|
import type { ChartSeriesOptions, ChartSeriesRangeSliderOptions } from './series';
|
|
6
6
|
export interface BarXSeriesData<T = MeaningfulAny> extends BaseSeriesData<T> {
|
|
7
7
|
/**
|
|
@@ -64,7 +64,7 @@ export interface BarXSeries<T = MeaningfulAny> extends BaseSeries {
|
|
|
64
64
|
inside?: boolean;
|
|
65
65
|
};
|
|
66
66
|
/** Individual series legend options. Has higher priority than legend options in widget data */
|
|
67
|
-
legend?:
|
|
67
|
+
legend?: BaseSeriesLegend & {
|
|
68
68
|
symbol?: RectLegendSymbolOptions;
|
|
69
69
|
};
|
|
70
70
|
/** Y-axis index (when using two axes) */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SERIES_TYPE } from '../../constants';
|
|
2
2
|
import type { MeaningfulAny } from '../misc';
|
|
3
|
-
import type { BaseSeries, BaseSeriesData } from './base';
|
|
4
|
-
import type {
|
|
3
|
+
import type { BaseSeries, BaseSeriesData, BaseSeriesLegend } from './base';
|
|
4
|
+
import type { RectLegendSymbolOptions } from './legend';
|
|
5
5
|
export interface BarYSeriesData<T = MeaningfulAny> extends BaseSeriesData<T> {
|
|
6
6
|
/**
|
|
7
7
|
* The `x` value of the bar. Depending on the context , it may represents:
|
|
@@ -68,7 +68,7 @@ export interface BarYSeries<T = MeaningfulAny> extends BaseSeries {
|
|
|
68
68
|
inside?: boolean;
|
|
69
69
|
};
|
|
70
70
|
/** Individual series legend options. Has higher priority than legend options in widget data */
|
|
71
|
-
legend?:
|
|
71
|
+
legend?: BaseSeriesLegend & {
|
|
72
72
|
symbol?: RectLegendSymbolOptions;
|
|
73
73
|
};
|
|
74
74
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { FormatNumberOptions } from '../formatter';
|
|
2
2
|
import type { MeaningfulAny } from '../misc';
|
|
3
|
+
import type { ChartLegendItem } from './legend';
|
|
3
4
|
type NumberFormat = {
|
|
4
5
|
type: 'number';
|
|
5
6
|
} & FormatNumberOptions;
|
|
@@ -67,6 +68,14 @@ export interface BaseSeriesData<T = MeaningfulAny> {
|
|
|
67
68
|
/** Individual color for the data chunk (point in scatter, segment in pie, bar etc) */
|
|
68
69
|
color?: string;
|
|
69
70
|
}
|
|
71
|
+
export interface BaseSeriesLegend extends ChartLegendItem {
|
|
72
|
+
/** For multiple series with the same groupId, only one label in the legend will be displayed.
|
|
73
|
+
* The legend element uses the name and symbol from the first series of the group.
|
|
74
|
+
*/
|
|
75
|
+
groupId?: string;
|
|
76
|
+
/** The text is displayed in the legend instead of the series name. */
|
|
77
|
+
itemText?: string;
|
|
78
|
+
}
|
|
70
79
|
export interface BaseTextStyle {
|
|
71
80
|
fontSize: string;
|
|
72
81
|
fontWeight?: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DashStyle, SERIES_TYPE } from '../../constants';
|
|
2
2
|
import type { MeaningfulAny } from '../misc';
|
|
3
|
-
import type { BaseDataLabels, BaseSeries, BaseSeriesData } from './base';
|
|
4
|
-
import type {
|
|
3
|
+
import type { BaseDataLabels, BaseSeries, BaseSeriesData, BaseSeriesLegend } from './base';
|
|
4
|
+
import type { ChartLegendItem, RectLegendSymbolOptions } from './legend';
|
|
5
5
|
export interface FunnelSeriesData<T = MeaningfulAny> extends BaseSeriesData<T> {
|
|
6
6
|
/** The value of the funnel segment. */
|
|
7
7
|
value: number;
|
|
@@ -9,6 +9,10 @@ export interface FunnelSeriesData<T = MeaningfulAny> extends BaseSeriesData<T> {
|
|
|
9
9
|
name: string;
|
|
10
10
|
/** Initial data label of the funnel segment. If not specified, the value is used. */
|
|
11
11
|
label?: string;
|
|
12
|
+
/** Individual series legend options. Has higher priority than legend options in series data */
|
|
13
|
+
legend?: BaseSeriesLegend & {
|
|
14
|
+
symbol?: RectLegendSymbolOptions;
|
|
15
|
+
};
|
|
12
16
|
}
|
|
13
17
|
export interface FunnelSeries<T = MeaningfulAny> extends Omit<BaseSeries, 'dataLabels'> {
|
|
14
18
|
type: typeof SERIES_TYPE.Funnel;
|
|
@@ -17,10 +21,6 @@ export interface FunnelSeries<T = MeaningfulAny> extends Omit<BaseSeries, 'dataL
|
|
|
17
21
|
name?: string;
|
|
18
22
|
/** The color of the funnel series. */
|
|
19
23
|
color?: string;
|
|
20
|
-
/** Individual series legend options. Has higher priority than legend options in widget data */
|
|
21
|
-
legend?: ChartLegend & {
|
|
22
|
-
symbol?: RectLegendSymbolOptions;
|
|
23
|
-
};
|
|
24
24
|
/** Lines or areas connecting the funnel segments. */
|
|
25
25
|
connectors?: {
|
|
26
26
|
enabled?: boolean;
|
|
@@ -43,4 +43,8 @@ export interface FunnelSeries<T = MeaningfulAny> extends Omit<BaseSeries, 'dataL
|
|
|
43
43
|
/** Horizontal alignment of the data labels. */
|
|
44
44
|
align?: 'left' | 'center' | 'right';
|
|
45
45
|
};
|
|
46
|
+
/** Individual series legend options. Has higher priority than legend options in widget data */
|
|
47
|
+
legend?: ChartLegendItem & {
|
|
48
|
+
symbol?: RectLegendSymbolOptions;
|
|
49
|
+
};
|
|
46
50
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SERIES_TYPE } from '../../constants';
|
|
2
2
|
import type { MeaningfulAny } from '../misc';
|
|
3
|
-
import type { BaseSeries, BaseSeriesData } from './base';
|
|
4
|
-
import type {
|
|
3
|
+
import type { BaseSeries, BaseSeriesData, BaseSeriesLegend } from './base';
|
|
4
|
+
import type { RectLegendSymbolOptions } from './legend';
|
|
5
5
|
export interface HeatmapSeriesData<T = MeaningfulAny> extends BaseSeriesData<T> {
|
|
6
6
|
/**
|
|
7
7
|
* The `x` value of the heatmap cell. Depending on the context, it may represents:
|
|
@@ -31,7 +31,7 @@ export interface HeatmapSeries<T = MeaningfulAny> extends BaseSeries {
|
|
|
31
31
|
color?: string;
|
|
32
32
|
dataLabels?: BaseSeries['dataLabels'];
|
|
33
33
|
/** Individual series legend options. Has higher priority than legend options in widget data */
|
|
34
|
-
legend?:
|
|
34
|
+
legend?: BaseSeriesLegend & {
|
|
35
35
|
symbol?: RectLegendSymbolOptions;
|
|
36
36
|
};
|
|
37
37
|
/**
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import type { BaseTextStyle } from './base';
|
|
2
|
-
export interface
|
|
2
|
+
export interface ChartLegendItem {
|
|
3
3
|
enabled?: boolean;
|
|
4
|
+
/**
|
|
5
|
+
* Defines the pixel distance between each legend item
|
|
6
|
+
*
|
|
7
|
+
* @default 20
|
|
8
|
+
* */
|
|
9
|
+
itemDistance?: number;
|
|
10
|
+
/** CSS styles for each legend item */
|
|
11
|
+
itemStyle?: BaseTextStyle;
|
|
12
|
+
}
|
|
13
|
+
export interface ChartLegend extends ChartLegendItem {
|
|
4
14
|
/**
|
|
5
15
|
* Different types for different color schemes.
|
|
6
16
|
* If the color scheme is continuous, a gradient legend will be drawn.
|
|
@@ -21,14 +31,6 @@ export interface ChartLegend {
|
|
|
21
31
|
* @default center
|
|
22
32
|
* */
|
|
23
33
|
justifyContent?: 'start' | 'center';
|
|
24
|
-
/**
|
|
25
|
-
* Defines the pixel distance between each legend item
|
|
26
|
-
*
|
|
27
|
-
* @default 20
|
|
28
|
-
* */
|
|
29
|
-
itemDistance?: number;
|
|
30
|
-
/** CSS styles for each legend item */
|
|
31
|
-
itemStyle?: BaseTextStyle;
|
|
32
34
|
/**
|
|
33
35
|
* The space between the legend and the axis labels or chart area.
|
|
34
36
|
*
|
|
@@ -64,7 +66,7 @@ export interface ChartLegend {
|
|
|
64
66
|
*
|
|
65
67
|
* @default 'bottom'
|
|
66
68
|
* */
|
|
67
|
-
position?: 'top' | 'bottom';
|
|
69
|
+
position?: 'top' | 'bottom' | 'left' | 'right';
|
|
68
70
|
}
|
|
69
71
|
export interface BaseLegendSymbol {
|
|
70
72
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DashStyle, LineCap, SERIES_TYPE } from '../../constants';
|
|
2
2
|
import type { MeaningfulAny } from '../misc';
|
|
3
|
-
import type { BaseSeries, BaseSeriesData } from './base';
|
|
4
|
-
import type {
|
|
3
|
+
import type { BaseSeries, BaseSeriesData, BaseSeriesLegend } from './base';
|
|
4
|
+
import type { RectLegendSymbolOptions } from './legend';
|
|
5
5
|
import type { PointMarkerOptions } from './marker';
|
|
6
6
|
import type { ChartSeriesRangeSliderOptions } from './series';
|
|
7
7
|
export interface LineSeriesData<T = MeaningfulAny> extends BaseSeriesData<T> {
|
|
@@ -42,7 +42,7 @@ export interface LineSeries<T = MeaningfulAny> extends BaseSeries {
|
|
|
42
42
|
* */
|
|
43
43
|
lineWidth?: number;
|
|
44
44
|
/** Individual series legend options. Has higher priority than legend options in widget data */
|
|
45
|
-
legend?:
|
|
45
|
+
legend?: BaseSeriesLegend & {
|
|
46
46
|
symbol?: RectLegendSymbolOptions;
|
|
47
47
|
};
|
|
48
48
|
/** Options for the point markers of line series */
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { BaseType } from 'd3';
|
|
2
2
|
import type { SERIES_TYPE } from '../../constants';
|
|
3
3
|
import type { MeaningfulAny } from '../misc';
|
|
4
|
-
import type { BaseSeries, BaseSeriesData } from './base';
|
|
5
|
-
import type {
|
|
4
|
+
import type { BaseSeries, BaseSeriesData, BaseSeriesLegend } from './base';
|
|
5
|
+
import type { ChartLegendItem, RectLegendSymbolOptions } from './legend';
|
|
6
6
|
export interface PieSeriesData<T = MeaningfulAny> extends BaseSeriesData<T> {
|
|
7
7
|
/** The value of the pie segment. */
|
|
8
8
|
value: number | null;
|
|
@@ -16,6 +16,10 @@ export interface PieSeriesData<T = MeaningfulAny> extends BaseSeriesData<T> {
|
|
|
16
16
|
opacity?: number;
|
|
17
17
|
/** The individual radius of the pie segment. The default value is series.radius */
|
|
18
18
|
radius?: string | number;
|
|
19
|
+
/** Individual series legend options. Has higher priority than legend options in series data */
|
|
20
|
+
legend?: BaseSeriesLegend & {
|
|
21
|
+
symbol?: RectLegendSymbolOptions;
|
|
22
|
+
};
|
|
19
23
|
}
|
|
20
24
|
export type ConnectorShape = 'straight-line' | 'polyline';
|
|
21
25
|
export type ConnectorCurve = 'linear' | 'basic';
|
|
@@ -54,10 +58,6 @@ export interface PieSeries<T = MeaningfulAny> extends BaseSeries {
|
|
|
54
58
|
* If not specified, the minimum radius is calculated as 30% of the height or width of the chart (the minimum value is taken) minus the halo effect.
|
|
55
59
|
*/
|
|
56
60
|
minRadius?: string | number;
|
|
57
|
-
/** Individual series legend options. Has higher priority than legend options in widget data */
|
|
58
|
-
legend?: ChartLegend & {
|
|
59
|
-
symbol?: RectLegendSymbolOptions;
|
|
60
|
-
};
|
|
61
61
|
dataLabels?: BaseSeries['dataLabels'] & {
|
|
62
62
|
/**
|
|
63
63
|
* The distance of the data label from the pie's edge.
|
|
@@ -85,6 +85,10 @@ export interface PieSeries<T = MeaningfulAny> extends BaseSeries {
|
|
|
85
85
|
* */
|
|
86
86
|
connectorCurve?: ConnectorCurve;
|
|
87
87
|
};
|
|
88
|
+
/** Individual series legend options. Has higher priority than legend options in chart data */
|
|
89
|
+
legend?: ChartLegendItem & {
|
|
90
|
+
symbol?: RectLegendSymbolOptions;
|
|
91
|
+
};
|
|
88
92
|
/**
|
|
89
93
|
* Function for adding custom svg nodes for a series
|
|
90
94
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SERIES_TYPE } from '../../constants';
|
|
2
2
|
import type { MeaningfulAny } from '../misc';
|
|
3
|
-
import type { BaseSeries, BaseSeriesData } from './base';
|
|
4
|
-
import type {
|
|
3
|
+
import type { BaseSeries, BaseSeriesData, BaseSeriesLegend } from './base';
|
|
4
|
+
import type { RectLegendSymbolOptions } from './legend';
|
|
5
5
|
import type { PointMarkerOptions } from './marker';
|
|
6
6
|
export interface RadarSeriesData<T = MeaningfulAny> extends BaseSeriesData<T> {
|
|
7
7
|
/** The value of the radar point. */
|
|
@@ -42,7 +42,7 @@ export interface RadarSeries<T = MeaningfulAny> extends BaseSeries {
|
|
|
42
42
|
*/
|
|
43
43
|
fillOpacity?: number;
|
|
44
44
|
/** Individual series legend options. Has higher priority than legend options in widget data */
|
|
45
|
-
legend?:
|
|
45
|
+
legend?: BaseSeriesLegend & {
|
|
46
46
|
symbol?: RectLegendSymbolOptions;
|
|
47
47
|
};
|
|
48
48
|
/** Options for the point markers of line in radar series */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SERIES_TYPE } from '../../constants';
|
|
2
2
|
import type { MeaningfulAny } from '../misc';
|
|
3
|
-
import type { BaseSeries, BaseSeriesData } from './base';
|
|
4
|
-
import type {
|
|
3
|
+
import type { BaseSeries, BaseSeriesData, BaseSeriesLegend } from './base';
|
|
4
|
+
import type { RectLegendSymbolOptions } from './legend';
|
|
5
5
|
export interface SankeySeriesData<T = MeaningfulAny> extends BaseSeriesData<T> {
|
|
6
6
|
name: string;
|
|
7
7
|
color?: string;
|
|
@@ -16,7 +16,7 @@ export interface SankeySeries<T = MeaningfulAny> extends BaseSeries {
|
|
|
16
16
|
name: string;
|
|
17
17
|
data: SankeySeriesData<T>[];
|
|
18
18
|
/** Individual series legend options. Has higher priority than legend options in widget data. */
|
|
19
|
-
legend?:
|
|
19
|
+
legend?: BaseSeriesLegend & {
|
|
20
20
|
symbol?: RectLegendSymbolOptions;
|
|
21
21
|
};
|
|
22
22
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SERIES_TYPE, SymbolType } from '../../constants';
|
|
2
2
|
import type { MeaningfulAny } from '../misc';
|
|
3
|
-
import type { BaseSeries, BaseSeriesData } from './base';
|
|
4
|
-
import type {
|
|
3
|
+
import type { BaseSeries, BaseSeriesData, BaseSeriesLegend } from './base';
|
|
4
|
+
import type { RectLegendSymbolOptions } from './legend';
|
|
5
5
|
import type { ChartSeriesRangeSliderOptions } from './series';
|
|
6
6
|
export interface ScatterSeriesData<T = MeaningfulAny> extends BaseSeriesData<T> {
|
|
7
7
|
/**
|
|
@@ -39,7 +39,7 @@ export interface ScatterSeries<T = MeaningfulAny> extends BaseSeries {
|
|
|
39
39
|
/** A predefined shape or symbol for the dot */
|
|
40
40
|
symbolType?: `${SymbolType}`;
|
|
41
41
|
/** Individual series legend options. Has higher priority than legend options in widget data */
|
|
42
|
-
legend?:
|
|
42
|
+
legend?: BaseSeriesLegend & {
|
|
43
43
|
symbol?: RectLegendSymbolOptions;
|
|
44
44
|
};
|
|
45
45
|
/** Y-axis index (when using two axes) */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { LayoutAlgorithm, SERIES_TYPE } from '../../constants';
|
|
2
2
|
import type { MeaningfulAny } from '../misc';
|
|
3
|
-
import type { BaseSeries, BaseSeriesData } from './base';
|
|
4
|
-
import type {
|
|
3
|
+
import type { BaseSeries, BaseSeriesData, BaseSeriesLegend } from './base';
|
|
4
|
+
import type { RectLegendSymbolOptions } from './legend';
|
|
5
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[];
|
|
@@ -23,7 +23,7 @@ export interface TreemapSeries<T = MeaningfulAny> extends BaseSeries {
|
|
|
23
23
|
/** The main color of the series (hex, rgba). */
|
|
24
24
|
color?: string;
|
|
25
25
|
/** Individual series legend options. Has higher priority than legend options in widget data. */
|
|
26
|
-
legend?:
|
|
26
|
+
legend?: BaseSeriesLegend & {
|
|
27
27
|
symbol?: RectLegendSymbolOptions;
|
|
28
28
|
};
|
|
29
29
|
/** Set options on specific levels. Takes precedence over series options, but not point options. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SERIES_TYPE } from '../../constants';
|
|
2
2
|
import type { MeaningfulAny } from '../misc';
|
|
3
3
|
import type { BaseSeries, BaseSeriesData } from './base';
|
|
4
|
-
import type {
|
|
4
|
+
import type { ChartLegendItem, RectLegendSymbolOptions } from './legend';
|
|
5
5
|
export interface WaterfallSeriesData<T = MeaningfulAny> extends BaseSeriesData<T> {
|
|
6
6
|
/**
|
|
7
7
|
* The `x` value. Depending on the context , it may represents:
|
|
@@ -34,7 +34,7 @@ export interface WaterfallSeries<T = MeaningfulAny> extends BaseSeries {
|
|
|
34
34
|
/** The color used for negative values. If it is not specified, the general color of the series is used. */
|
|
35
35
|
negativeColor?: string;
|
|
36
36
|
/** Individual series legend options. Has higher priority than legend options in widget data. */
|
|
37
|
-
legend?:
|
|
37
|
+
legend?: ChartLegendItem & {
|
|
38
38
|
symbol?: RectLegendSymbolOptions;
|
|
39
39
|
/** The legend item text for positive, negative values and totals. */
|
|
40
40
|
itemText?: {
|