@gravity-ui/charts 1.43.1 → 1.45.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/utils/zoom.js +3 -1
- package/dist/cjs/components/Tooltip/DefaultTooltipContent/index.js +31 -6
- package/dist/cjs/components/Tooltip/DefaultTooltipContent/utils.js +4 -5
- package/dist/cjs/core/constants/chart-types.d.ts +1 -0
- package/dist/cjs/core/constants/chart-types.js +1 -0
- package/dist/cjs/core/constants/defaults/annotation.d.ts +12 -0
- package/dist/cjs/core/constants/defaults/annotation.js +12 -0
- package/dist/cjs/core/constants/defaults/index.d.ts +1 -0
- package/dist/cjs/core/constants/defaults/index.js +1 -0
- package/dist/cjs/core/constants/defaults/series-options.d.ts +5 -1
- package/dist/cjs/core/constants/defaults/series-options.js +13 -0
- package/dist/cjs/core/i18n/keysets/en.json +2 -1
- package/dist/cjs/core/i18n/keysets/ru.json +2 -1
- package/dist/cjs/core/series/constants.d.ts +1 -1
- package/dist/cjs/core/series/constants.js +1 -1
- package/dist/cjs/core/series/prepare-annotation.d.ts +12 -0
- package/dist/cjs/core/series/prepare-annotation.js +31 -0
- package/dist/cjs/core/series/prepare-legend.js +2 -2
- package/dist/cjs/core/series/prepare-x-range.d.ts +11 -0
- package/dist/cjs/core/series/prepare-x-range.js +41 -0
- package/dist/cjs/core/series/prepareSeries.js +9 -0
- package/dist/cjs/core/series/types.d.ts +34 -2
- package/dist/cjs/core/types/chart/annotation.d.ts +45 -0
- package/dist/cjs/core/types/chart/annotation.js +1 -0
- package/dist/cjs/core/types/chart/area.d.ts +10 -1
- package/dist/cjs/core/types/chart/bar-x.d.ts +6 -0
- package/dist/cjs/core/types/chart/line.d.ts +8 -0
- package/dist/cjs/core/types/chart/marker.d.ts +6 -4
- package/dist/cjs/core/types/chart/series.d.ts +36 -2
- package/dist/cjs/core/types/chart/tooltip.d.ts +7 -1
- package/dist/cjs/core/types/chart/x-range.d.ts +59 -0
- package/dist/cjs/core/types/chart/x-range.js +1 -0
- package/dist/cjs/core/types/chart/zoom.d.ts +1 -1
- package/dist/cjs/core/types/index.d.ts +2 -0
- package/dist/cjs/core/types/index.js +2 -0
- package/dist/cjs/core/utils/axis/x-axis.js +9 -1
- package/dist/cjs/core/utils/color.js +6 -0
- package/dist/cjs/core/utils/common.js +10 -0
- package/dist/cjs/core/utils/get-closest-data.js +19 -0
- package/dist/cjs/core/utils/text.d.ts +8 -0
- package/dist/cjs/core/utils/text.js +9 -1
- package/dist/cjs/core/validation/index.js +13 -0
- package/dist/cjs/core/zoom/zoom.js +24 -7
- package/dist/cjs/hooks/useShapes/annotation/index.d.ts +14 -0
- package/dist/cjs/hooks/useShapes/annotation/index.js +200 -0
- package/dist/cjs/hooks/useShapes/area/index.d.ts +2 -0
- package/dist/cjs/hooks/useShapes/area/index.js +21 -2
- package/dist/cjs/hooks/useShapes/area/prepare-data.d.ts +2 -1
- package/dist/cjs/hooks/useShapes/area/prepare-data.js +45 -26
- package/dist/cjs/hooks/useShapes/area/types.d.ts +4 -0
- package/dist/cjs/hooks/useShapes/bar-x/index.d.ts +2 -0
- package/dist/cjs/hooks/useShapes/bar-x/index.js +30 -2
- package/dist/cjs/hooks/useShapes/bar-x/prepare-data.js +32 -11
- package/dist/cjs/hooks/useShapes/bar-x/types.d.ts +2 -0
- package/dist/cjs/hooks/useShapes/index.d.ts +2 -1
- package/dist/cjs/hooks/useShapes/index.js +22 -3
- package/dist/cjs/hooks/useShapes/line/index.d.ts +2 -0
- package/dist/cjs/hooks/useShapes/line/index.js +21 -7
- package/dist/cjs/hooks/useShapes/line/prepare-data.d.ts +2 -1
- package/dist/cjs/hooks/useShapes/line/prepare-data.js +28 -10
- package/dist/cjs/hooks/useShapes/line/types.d.ts +4 -0
- package/dist/cjs/hooks/useShapes/x-range/index.d.ts +14 -0
- package/dist/cjs/hooks/useShapes/x-range/index.js +115 -0
- package/dist/cjs/hooks/useShapes/x-range/prepare-data.d.ts +15 -0
- package/dist/cjs/hooks/useShapes/x-range/prepare-data.js +147 -0
- package/dist/cjs/hooks/useShapes/x-range/types.d.ts +12 -0
- package/dist/cjs/hooks/useShapes/x-range/types.js +1 -0
- package/dist/esm/components/ChartInner/utils/zoom.js +3 -1
- package/dist/esm/components/Tooltip/DefaultTooltipContent/index.js +31 -6
- package/dist/esm/components/Tooltip/DefaultTooltipContent/utils.js +4 -5
- package/dist/esm/core/constants/chart-types.d.ts +1 -0
- package/dist/esm/core/constants/chart-types.js +1 -0
- package/dist/esm/core/constants/defaults/annotation.d.ts +12 -0
- package/dist/esm/core/constants/defaults/annotation.js +12 -0
- package/dist/esm/core/constants/defaults/index.d.ts +1 -0
- package/dist/esm/core/constants/defaults/index.js +1 -0
- package/dist/esm/core/constants/defaults/series-options.d.ts +5 -1
- package/dist/esm/core/constants/defaults/series-options.js +13 -0
- package/dist/esm/core/i18n/keysets/en.json +2 -1
- package/dist/esm/core/i18n/keysets/ru.json +2 -1
- package/dist/esm/core/series/constants.d.ts +1 -1
- package/dist/esm/core/series/constants.js +1 -1
- package/dist/esm/core/series/prepare-annotation.d.ts +12 -0
- package/dist/esm/core/series/prepare-annotation.js +31 -0
- package/dist/esm/core/series/prepare-legend.js +2 -2
- package/dist/esm/core/series/prepare-x-range.d.ts +11 -0
- package/dist/esm/core/series/prepare-x-range.js +41 -0
- package/dist/esm/core/series/prepareSeries.js +9 -0
- package/dist/esm/core/series/types.d.ts +34 -2
- package/dist/esm/core/types/chart/annotation.d.ts +45 -0
- package/dist/esm/core/types/chart/annotation.js +1 -0
- package/dist/esm/core/types/chart/area.d.ts +10 -1
- package/dist/esm/core/types/chart/bar-x.d.ts +6 -0
- package/dist/esm/core/types/chart/line.d.ts +8 -0
- package/dist/esm/core/types/chart/marker.d.ts +6 -4
- package/dist/esm/core/types/chart/series.d.ts +36 -2
- package/dist/esm/core/types/chart/tooltip.d.ts +7 -1
- package/dist/esm/core/types/chart/x-range.d.ts +59 -0
- package/dist/esm/core/types/chart/x-range.js +1 -0
- package/dist/esm/core/types/chart/zoom.d.ts +1 -1
- package/dist/esm/core/types/index.d.ts +2 -0
- package/dist/esm/core/types/index.js +2 -0
- package/dist/esm/core/utils/axis/x-axis.js +9 -1
- package/dist/esm/core/utils/color.js +6 -0
- package/dist/esm/core/utils/common.js +10 -0
- package/dist/esm/core/utils/get-closest-data.js +19 -0
- package/dist/esm/core/utils/text.d.ts +8 -0
- package/dist/esm/core/utils/text.js +9 -1
- package/dist/esm/core/validation/index.js +13 -0
- package/dist/esm/core/zoom/zoom.js +24 -7
- package/dist/esm/hooks/useShapes/annotation/index.d.ts +14 -0
- package/dist/esm/hooks/useShapes/annotation/index.js +200 -0
- package/dist/esm/hooks/useShapes/area/index.d.ts +2 -0
- package/dist/esm/hooks/useShapes/area/index.js +21 -2
- package/dist/esm/hooks/useShapes/area/prepare-data.d.ts +2 -1
- package/dist/esm/hooks/useShapes/area/prepare-data.js +45 -26
- package/dist/esm/hooks/useShapes/area/types.d.ts +4 -0
- package/dist/esm/hooks/useShapes/bar-x/index.d.ts +2 -0
- package/dist/esm/hooks/useShapes/bar-x/index.js +30 -2
- package/dist/esm/hooks/useShapes/bar-x/prepare-data.js +32 -11
- package/dist/esm/hooks/useShapes/bar-x/types.d.ts +2 -0
- package/dist/esm/hooks/useShapes/index.d.ts +2 -1
- package/dist/esm/hooks/useShapes/index.js +22 -3
- package/dist/esm/hooks/useShapes/line/index.d.ts +2 -0
- package/dist/esm/hooks/useShapes/line/index.js +21 -7
- package/dist/esm/hooks/useShapes/line/prepare-data.d.ts +2 -1
- package/dist/esm/hooks/useShapes/line/prepare-data.js +28 -10
- package/dist/esm/hooks/useShapes/line/types.d.ts +4 -0
- package/dist/esm/hooks/useShapes/x-range/index.d.ts +14 -0
- package/dist/esm/hooks/useShapes/x-range/index.js +115 -0
- package/dist/esm/hooks/useShapes/x-range/prepare-data.d.ts +15 -0
- package/dist/esm/hooks/useShapes/x-range/prepare-data.js +147 -0
- package/dist/esm/hooks/useShapes/x-range/types.d.ts +12 -0
- package/dist/esm/hooks/useShapes/x-range/types.js +1 -0
- package/package.json +2 -2
|
@@ -6,7 +6,8 @@ function mapSeriesTypeToZoomType(seriesType) {
|
|
|
6
6
|
case SERIES_TYPE.Area: {
|
|
7
7
|
return [ZOOM_TYPE.X, ZOOM_TYPE.XY, ZOOM_TYPE.Y];
|
|
8
8
|
}
|
|
9
|
-
case SERIES_TYPE.BarX:
|
|
9
|
+
case SERIES_TYPE.BarX:
|
|
10
|
+
case SERIES_TYPE.XRange: {
|
|
10
11
|
return [ZOOM_TYPE.X];
|
|
11
12
|
}
|
|
12
13
|
case SERIES_TYPE.BarY: {
|
|
@@ -36,6 +37,7 @@ function getDefaultZoomType(seriesType) {
|
|
|
36
37
|
}
|
|
37
38
|
case SERIES_TYPE.Area:
|
|
38
39
|
case SERIES_TYPE.BarX:
|
|
40
|
+
case SERIES_TYPE.XRange:
|
|
39
41
|
case SERIES_TYPE.Line:
|
|
40
42
|
case SERIES_TYPE.Waterfall: {
|
|
41
43
|
return ZOOM_TYPE.X;
|
|
@@ -43,12 +43,15 @@ export const DefaultTooltipContent = ({ hovered, pinned, rowRenderer, totals, va
|
|
|
43
43
|
const colorSymbol = getTooltipRowColorSymbol({ series, color });
|
|
44
44
|
return (React.createElement(Row, { key: id, active: active, color: color, colorSymbol: colorSymbol ? (React.createElement("div", { dangerouslySetInnerHTML: { __html: colorSymbol.outerHTML } })) : undefined, label: React.createElement("span", { dangerouslySetInnerHTML: { __html: name } }), striped: striped, value: formattedValue }));
|
|
45
45
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
let formattedHeadValue;
|
|
47
|
+
if (measureValue) {
|
|
48
|
+
formattedHeadValue = headerFormat
|
|
49
|
+
? getFormattedValue({
|
|
50
|
+
value: measureValue.value,
|
|
51
|
+
format: headerFormat,
|
|
52
|
+
})
|
|
53
|
+
: measureValue.formattedValue;
|
|
54
|
+
}
|
|
52
55
|
React.useEffect(() => {
|
|
53
56
|
if (!contentRowsRef.current) {
|
|
54
57
|
return;
|
|
@@ -186,6 +189,28 @@ export const DefaultTooltipContent = ({ hovered, pinned, rowRenderer, totals, va
|
|
|
186
189
|
formattedValue,
|
|
187
190
|
});
|
|
188
191
|
}
|
|
192
|
+
case 'x-range': {
|
|
193
|
+
const xRangeData = data;
|
|
194
|
+
const format = rowValueFormat || getDefaultValueFormat({ axis: xAxis });
|
|
195
|
+
const x0Formatted = getFormattedValue({
|
|
196
|
+
value: xRangeData.x0,
|
|
197
|
+
format,
|
|
198
|
+
});
|
|
199
|
+
const x1Formatted = getFormattedValue({
|
|
200
|
+
value: xRangeData.x1,
|
|
201
|
+
format,
|
|
202
|
+
});
|
|
203
|
+
return renderRow({
|
|
204
|
+
id,
|
|
205
|
+
active,
|
|
206
|
+
color,
|
|
207
|
+
name: series.name,
|
|
208
|
+
striped,
|
|
209
|
+
value: hoveredValues[i],
|
|
210
|
+
formattedValue: `${x0Formatted} — ${x1Formatted}`,
|
|
211
|
+
series,
|
|
212
|
+
});
|
|
213
|
+
}
|
|
189
214
|
default: {
|
|
190
215
|
return null;
|
|
191
216
|
}
|
|
@@ -48,7 +48,7 @@ export const getMeasureValue = ({ data, xAxis, yAxis, headerFormat, }) => {
|
|
|
48
48
|
const value = (_b = (_a = data[0].category) === null || _a === void 0 ? void 0 : _a.key) !== null && _b !== void 0 ? _b : null;
|
|
49
49
|
return { value };
|
|
50
50
|
}
|
|
51
|
-
if (data.some((item) => item.series.type
|
|
51
|
+
if (data.some((item) => ['bar-y', 'x-range'].includes(item.series.type))) {
|
|
52
52
|
const value = getYRowData((_c = data[0]) === null || _c === void 0 ? void 0 : _c.data, yAxis);
|
|
53
53
|
const formattedValue = getFormattedValue({
|
|
54
54
|
value: getYRowData((_d = data[0]) === null || _d === void 0 ? void 0 : _d.data, yAxis),
|
|
@@ -72,7 +72,9 @@ export function getHoveredValues(args) {
|
|
|
72
72
|
case 'area':
|
|
73
73
|
case 'line':
|
|
74
74
|
case 'bar-x':
|
|
75
|
-
case '
|
|
75
|
+
case 'waterfall':
|
|
76
|
+
case 'scatter':
|
|
77
|
+
case 'x-range': {
|
|
76
78
|
return getYRowData(data, yAxis);
|
|
77
79
|
}
|
|
78
80
|
case 'bar-y': {
|
|
@@ -90,9 +92,6 @@ export function getHoveredValues(args) {
|
|
|
90
92
|
const { target, data: source } = seriesItem;
|
|
91
93
|
return (_a = source.links.find((d) => d.name === (target === null || target === void 0 ? void 0 : target.name))) === null || _a === void 0 ? void 0 : _a.value;
|
|
92
94
|
}
|
|
93
|
-
case 'waterfall': {
|
|
94
|
-
return getYRowData(data, yAxis);
|
|
95
|
-
}
|
|
96
95
|
default: {
|
|
97
96
|
return undefined;
|
|
98
97
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const annotationLabelDefaults: {
|
|
2
|
+
style: {
|
|
3
|
+
fontSize: string;
|
|
4
|
+
fontColor: string;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
export declare const annotationPopupDefaults: {
|
|
8
|
+
backgroundColor: string;
|
|
9
|
+
borderRadius: number;
|
|
10
|
+
offset: number;
|
|
11
|
+
padding: [number, number];
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const annotationLabelDefaults = {
|
|
2
|
+
style: {
|
|
3
|
+
fontSize: '13px',
|
|
4
|
+
fontColor: 'var(--g-color-text-light-primary)',
|
|
5
|
+
},
|
|
6
|
+
};
|
|
7
|
+
export const annotationPopupDefaults = {
|
|
8
|
+
backgroundColor: 'var(--g-color-base-float-heavy)',
|
|
9
|
+
borderRadius: 4,
|
|
10
|
+
offset: 5,
|
|
11
|
+
padding: [4, 8],
|
|
12
|
+
};
|
|
@@ -21,7 +21,11 @@ type DefaultWaterfallSeriesOptions = Partial<ChartSeriesOptions['waterfall']> &
|
|
|
21
21
|
barPadding: number;
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
|
-
export type SeriesOptionsDefaults = Partial<ChartSeriesOptions> & DefaultBarXSeriesOptions & DefaultBarYSeriesOptions & DefaultWaterfallSeriesOptions
|
|
24
|
+
export type SeriesOptionsDefaults = Partial<ChartSeriesOptions> & DefaultBarXSeriesOptions & DefaultBarYSeriesOptions & DefaultWaterfallSeriesOptions & {
|
|
25
|
+
'x-range': {
|
|
26
|
+
borderRadius: number;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
25
29
|
export declare const seriesOptionsDefaults: SeriesOptionsDefaults;
|
|
26
30
|
export declare const seriesRangeSliderOptionsDefaults: Required<ChartSeriesRangeSliderOptions>;
|
|
27
31
|
export {};
|
|
@@ -133,6 +133,19 @@ export const seriesOptionsDefaults = {
|
|
|
133
133
|
},
|
|
134
134
|
},
|
|
135
135
|
},
|
|
136
|
+
'x-range': {
|
|
137
|
+
borderRadius: 0,
|
|
138
|
+
states: {
|
|
139
|
+
hover: {
|
|
140
|
+
enabled: true,
|
|
141
|
+
brightness: 0.3,
|
|
142
|
+
},
|
|
143
|
+
inactive: {
|
|
144
|
+
enabled: false,
|
|
145
|
+
opacity: 0.5,
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
},
|
|
136
149
|
};
|
|
137
150
|
export const seriesRangeSliderOptionsDefaults = {
|
|
138
151
|
visible: true,
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"label_invalid-axis-labels-html-not-supported-axis-type": "It seems you are trying to use \"labels.html\" property for an axis with an unsupported type. This property is supported only for \"category\" axis.",
|
|
22
22
|
"label_duplicate-axis-categories": "It seems you have duplicate value \"{{duplicate}}\" found in {{key}}[{{axisIndex}}].",
|
|
23
23
|
"label_invalid-axis-categories": "It seems you are trying to use inappropriate value for \"categories\", or defined it incorrectly. Categories must be a non-empty array for an axis with \"category\" type.",
|
|
24
|
-
"label_inconsistent-y-axis-configuration": "It seems you have inconsistent Y-axis configuration. Possible reasons:\n1. Multiple Y axes with the same position and plot index.\n2. At the moment, 'category' axis is not supported in dual Y-axis configurations."
|
|
24
|
+
"label_inconsistent-y-axis-configuration": "It seems you have inconsistent Y-axis configuration. Possible reasons:\n1. Multiple Y axes with the same position and plot index.\n2. At the moment, 'category' axis is not supported in dual Y-axis configurations.",
|
|
25
|
+
"label_stacking-area-connect-null-mode": "It seems you are using \"nullMode: 'connect'\" with a stacking area series. The \"connect\" null mode is not supported in stacking mode. Use \"zero\" or \"skip\" instead."
|
|
25
26
|
},
|
|
26
27
|
"tooltip": {
|
|
27
28
|
"label_totals_sum": "Sum",
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"label_invalid-axis-labels-html-not-supported-axis-type": "Похоже, что вы пытаетесь использовать свойство \"labels.html\" для оси с неподдерживаемым типом. Это свойство поддерживается только для оси типа \"category\".",
|
|
22
22
|
"label_duplicate-axis-categories": "Похоже, что у вас есть дублирующееся значение категории \"{{duplicate}}\" в оси {{key}}[{{axisIndex}}].",
|
|
23
23
|
"label_invalid-axis-categories": "Похоже, что вы пытаетесь использовать недопустимое значение для \"categories\", или указали его неверно. Категории для оси типа \"category\" должны быть непустым массивом.",
|
|
24
|
-
"label_inconsistent-y-axis-configuration": "Похоже, что конфигурация осей Y неконсистентна. Возможные причины:\n1. Несколько осей Y имеют одинаковые значения position и plotIndex.\n2. На данный момент категорийные оси не поддерживаются в конфигурациях с двумя осями Y."
|
|
24
|
+
"label_inconsistent-y-axis-configuration": "Похоже, что конфигурация осей Y неконсистентна. Возможные причины:\n1. Несколько осей Y имеют одинаковые значения position и plotIndex.\n2. На данный момент категорийные оси не поддерживаются в конфигурациях с двумя осями Y.",
|
|
25
|
+
"label_stacking-area-connect-null-mode": "Похоже, что вы используете \"nullMode: 'connect'\" с серией area с накоплением. Режим null \"connect\" не поддерживается в режиме накопления. Используйте \"zero\" или \"skip\"."
|
|
25
26
|
},
|
|
26
27
|
"tooltip": {
|
|
27
28
|
"label_totals_sum": "Сумма",
|
|
@@ -4,4 +4,4 @@ export declare const DEFAULT_LEGEND_SYMBOL_SIZE = 8;
|
|
|
4
4
|
export declare const DEFAULT_LEGEND_SYMBOL_PADDING = 5;
|
|
5
5
|
export declare const DEFAULT_DATALABELS_PADDING = 5;
|
|
6
6
|
export declare const DEFAULT_HALO_OPTIONS: Required<Halo>;
|
|
7
|
-
export declare const DEFAULT_POINT_MARKER_OPTIONS: Omit<Required<PointMarkerOptions>, 'enabled'>;
|
|
7
|
+
export declare const DEFAULT_POINT_MARKER_OPTIONS: Omit<Required<PointMarkerOptions>, 'color' | 'enabled'>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ChartAnnotationLabel, ChartAnnotationPopup } from '../../types';
|
|
2
|
+
import type { PreparedAnnotation } from './types';
|
|
3
|
+
type AnnotationOptionsLabel = Omit<ChartAnnotationLabel, 'text'> | undefined;
|
|
4
|
+
export declare function prepareAnnotation(args: {
|
|
5
|
+
annotation: {
|
|
6
|
+
label: ChartAnnotationLabel;
|
|
7
|
+
popup?: ChartAnnotationPopup;
|
|
8
|
+
};
|
|
9
|
+
optionsLabel?: AnnotationOptionsLabel;
|
|
10
|
+
optionsPopup?: ChartAnnotationPopup;
|
|
11
|
+
}): Promise<PreparedAnnotation>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { annotationLabelDefaults, annotationPopupDefaults } from '../constants';
|
|
2
|
+
import { getTextSizeFn } from '../utils';
|
|
3
|
+
function resolvePadding(padding) {
|
|
4
|
+
if (padding === undefined) {
|
|
5
|
+
return annotationPopupDefaults.padding;
|
|
6
|
+
}
|
|
7
|
+
if (typeof padding === 'number') {
|
|
8
|
+
return [padding, padding];
|
|
9
|
+
}
|
|
10
|
+
return padding;
|
|
11
|
+
}
|
|
12
|
+
export async function prepareAnnotation(args) {
|
|
13
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
14
|
+
const { annotation, optionsLabel, optionsPopup } = args;
|
|
15
|
+
const style = Object.assign(Object.assign(Object.assign({}, annotationLabelDefaults.style), optionsLabel === null || optionsLabel === void 0 ? void 0 : optionsLabel.style), annotation.label.style);
|
|
16
|
+
const getTextSize = getTextSizeFn({ style });
|
|
17
|
+
const textSize = await getTextSize(annotation.label.text);
|
|
18
|
+
return {
|
|
19
|
+
label: {
|
|
20
|
+
style,
|
|
21
|
+
text: annotation.label.text,
|
|
22
|
+
size: { height: textSize.height, width: textSize.width },
|
|
23
|
+
},
|
|
24
|
+
popup: {
|
|
25
|
+
backgroundColor: (_c = (_b = (_a = annotation.popup) === null || _a === void 0 ? void 0 : _a.backgroundColor) !== null && _b !== void 0 ? _b : optionsPopup === null || optionsPopup === void 0 ? void 0 : optionsPopup.backgroundColor) !== null && _c !== void 0 ? _c : annotationPopupDefaults.backgroundColor,
|
|
26
|
+
borderRadius: (_f = (_e = (_d = annotation.popup) === null || _d === void 0 ? void 0 : _d.borderRadius) !== null && _e !== void 0 ? _e : optionsPopup === null || optionsPopup === void 0 ? void 0 : optionsPopup.borderRadius) !== null && _f !== void 0 ? _f : annotationPopupDefaults.borderRadius,
|
|
27
|
+
offset: (_j = (_h = (_g = annotation.popup) === null || _g === void 0 ? void 0 : _g.offset) !== null && _h !== void 0 ? _h : optionsPopup === null || optionsPopup === void 0 ? void 0 : optionsPopup.offset) !== null && _j !== void 0 ? _j : annotationPopupDefaults.offset,
|
|
28
|
+
padding: resolvePadding((_l = (_k = annotation.popup) === null || _k === void 0 ? void 0 : _k.padding) !== null && _l !== void 0 ? _l : optionsPopup === null || optionsPopup === void 0 ? void 0 : optionsPopup.padding),
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -136,7 +136,7 @@ async function getGroupedLegendItems(args) {
|
|
|
136
136
|
else {
|
|
137
137
|
resultItem.textWidth = textWidth;
|
|
138
138
|
}
|
|
139
|
-
textWidthsInLine.push(textWidth);
|
|
139
|
+
textWidthsInLine.push(resultItem.textWidth);
|
|
140
140
|
const textsWidth = textWidthsInLine.reduce((acc, width) => acc + width, 0);
|
|
141
141
|
if (!result[lineIndex]) {
|
|
142
142
|
result[lineIndex] = [];
|
|
@@ -155,7 +155,7 @@ async function getGroupedLegendItems(args) {
|
|
|
155
155
|
else if (isCurrentLineOverMaxWidth) {
|
|
156
156
|
result[lineIndex].pop();
|
|
157
157
|
lineIndex += 1;
|
|
158
|
-
textWidthsInLine = [textWidth];
|
|
158
|
+
textWidthsInLine = [resultItem.textWidth];
|
|
159
159
|
const nextLineIndex = lineIndex;
|
|
160
160
|
result[nextLineIndex] = [];
|
|
161
161
|
result[nextLineIndex].push(resultItem);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ScaleOrdinal } from 'd3-scale';
|
|
2
|
+
import type { ChartSeriesOptions, XRangeSeries } from '../../types';
|
|
3
|
+
import type { PreparedLegend, PreparedXRangeSeries } from './types';
|
|
4
|
+
type PrepareXRangeSeriesArgs = {
|
|
5
|
+
colorScale: ScaleOrdinal<string, string>;
|
|
6
|
+
series: XRangeSeries[];
|
|
7
|
+
legend: PreparedLegend;
|
|
8
|
+
seriesOptions?: ChartSeriesOptions;
|
|
9
|
+
};
|
|
10
|
+
export declare function prepareXRangeSeries(args: PrepareXRangeSeriesArgs): PreparedXRangeSeries[];
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import get from 'lodash/get';
|
|
2
|
+
import { getUniqId } from '../utils';
|
|
3
|
+
import { DASH_STYLE, DEFAULT_DATALABELS_STYLE } from '../constants';
|
|
4
|
+
import { DEFAULT_DATALABELS_PADDING } from './constants';
|
|
5
|
+
import { prepareLegendSymbol } from './utils';
|
|
6
|
+
export function prepareXRangeSeries(args) {
|
|
7
|
+
const { colorScale, series: seriesList, seriesOptions, legend } = args;
|
|
8
|
+
return seriesList.map((series) => {
|
|
9
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
10
|
+
const name = series.name || '';
|
|
11
|
+
const color = series.color || colorScale(name);
|
|
12
|
+
return {
|
|
13
|
+
type: series.type,
|
|
14
|
+
color,
|
|
15
|
+
name,
|
|
16
|
+
id: getUniqId(),
|
|
17
|
+
visible: get(series, 'visible', true),
|
|
18
|
+
legend: {
|
|
19
|
+
enabled: get(series, 'legend.enabled', legend.enabled),
|
|
20
|
+
symbol: prepareLegendSymbol(series),
|
|
21
|
+
groupId: (_b = (_a = series.legend) === null || _a === void 0 ? void 0 : _a.groupId) !== null && _b !== void 0 ? _b : getUniqId(),
|
|
22
|
+
itemText: (_d = (_c = series.legend) === null || _c === void 0 ? void 0 : _c.itemText) !== null && _d !== void 0 ? _d : name,
|
|
23
|
+
},
|
|
24
|
+
data: series.data,
|
|
25
|
+
opacity: (_e = series.opacity) !== null && _e !== void 0 ? _e : null,
|
|
26
|
+
borderRadius: (_h = (_f = series.borderRadius) !== null && _f !== void 0 ? _f : (_g = seriesOptions === null || seriesOptions === void 0 ? void 0 : seriesOptions['x-range']) === null || _g === void 0 ? void 0 : _g.borderRadius) !== null && _h !== void 0 ? _h : 0,
|
|
27
|
+
borderWidth: (_l = (_j = series.borderWidth) !== null && _j !== void 0 ? _j : (_k = seriesOptions === null || seriesOptions === void 0 ? void 0 : seriesOptions['x-range']) === null || _k === void 0 ? void 0 : _k.borderWidth) !== null && _l !== void 0 ? _l : 0,
|
|
28
|
+
borderColor: (_p = (_m = series.borderColor) !== null && _m !== void 0 ? _m : (_o = seriesOptions === null || seriesOptions === void 0 ? void 0 : seriesOptions['x-range']) === null || _o === void 0 ? void 0 : _o.borderColor) !== null && _p !== void 0 ? _p : 'var(--gcharts-shape-border-color)',
|
|
29
|
+
borderDashStyle: (_s = (_q = series.borderDashStyle) !== null && _q !== void 0 ? _q : (_r = seriesOptions === null || seriesOptions === void 0 ? void 0 : seriesOptions['x-range']) === null || _r === void 0 ? void 0 : _r.borderDashStyle) !== null && _s !== void 0 ? _s : DASH_STYLE.Solid,
|
|
30
|
+
cursor: get(series, 'cursor', null),
|
|
31
|
+
tooltip: series.tooltip,
|
|
32
|
+
dataLabels: {
|
|
33
|
+
enabled: get(series, 'dataLabels.enabled', false),
|
|
34
|
+
style: Object.assign({}, DEFAULT_DATALABELS_STYLE, (_t = series.dataLabels) === null || _t === void 0 ? void 0 : _t.style),
|
|
35
|
+
html: get(series, 'dataLabels.html', false),
|
|
36
|
+
padding: get(series, 'dataLabels.padding', DEFAULT_DATALABELS_PADDING),
|
|
37
|
+
format: (_u = series.dataLabels) === null || _u === void 0 ? void 0 : _u.format,
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -11,6 +11,7 @@ import { prepareSankeySeries } from './prepare-sankey';
|
|
|
11
11
|
import { prepareScatterSeries } from './prepare-scatter';
|
|
12
12
|
import { prepareTreemap } from './prepare-treemap';
|
|
13
13
|
import { prepareWaterfallSeries } from './prepare-waterfall';
|
|
14
|
+
import { prepareXRangeSeries } from './prepare-x-range';
|
|
14
15
|
export async function prepareSeries(args) {
|
|
15
16
|
const { type, series, seriesOptions, legend, colors, colorScale } = args;
|
|
16
17
|
switch (type) {
|
|
@@ -108,6 +109,14 @@ export async function prepareSeries(args) {
|
|
|
108
109
|
colors,
|
|
109
110
|
});
|
|
110
111
|
}
|
|
112
|
+
case 'x-range': {
|
|
113
|
+
return prepareXRangeSeries({
|
|
114
|
+
series: series,
|
|
115
|
+
seriesOptions,
|
|
116
|
+
legend,
|
|
117
|
+
colorScale,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
111
120
|
default: {
|
|
112
121
|
throw new ChartError({
|
|
113
122
|
message: `Series type "${type}" does not support data preparation for series that do not support the presence of axes`,
|
|
@@ -1,5 +1,21 @@
|
|
|
1
|
-
import type { AreaSeries, AreaSeriesData, BarXSeries, BarXSeriesData, BarYSeries, BarYSeriesData, BaseTextStyle, ChartLegend, ChartSeries, ChartSeriesRangeSliderOptions, ConnectorCurve, ConnectorShape, FunnelSeries, FunnelSeriesData, HeatmapSeries, HeatmapSeriesData, LineSeries, LineSeriesData, LineSeriesLineBaseStyle, PathLegendSymbolOptions, PieSeries, PieSeriesData, RadarSeries, RadarSeriesCategory, RadarSeriesData, RectLegendSymbolOptions, SankeySeries, SankeySeriesData, ScatterSeries, ScatterSeriesData, SymbolLegendSymbolOptions, TreemapSeries, TreemapSeriesData, ValueFormat, WaterfallSeries, WaterfallSeriesData } from '../../types';
|
|
1
|
+
import type { AreaSeries, AreaSeriesData, BarXSeries, BarXSeriesData, BarYSeries, BarYSeriesData, BaseTextStyle, ChartLegend, ChartSeries, ChartSeriesRangeSliderOptions, ConnectorCurve, ConnectorShape, FunnelSeries, FunnelSeriesData, HeatmapSeries, HeatmapSeriesData, LineSeries, LineSeriesData, LineSeriesLineBaseStyle, PathLegendSymbolOptions, PieSeries, PieSeriesData, RadarSeries, RadarSeriesCategory, RadarSeriesData, RectLegendSymbolOptions, SankeySeries, SankeySeriesData, ScatterSeries, ScatterSeriesData, SymbolLegendSymbolOptions, TreemapSeries, TreemapSeriesData, ValueFormat, WaterfallSeries, WaterfallSeriesData, XRangeSeries, XRangeSeriesData } from '../../types';
|
|
2
2
|
import type { DashStyle, LayoutAlgorithm, LineCap, LineJoin, SeriesOptionsDefaults, SymbolType } from '../constants';
|
|
3
|
+
export type PreparedAnnotation = {
|
|
4
|
+
label: {
|
|
5
|
+
size: {
|
|
6
|
+
height: number;
|
|
7
|
+
width: number;
|
|
8
|
+
};
|
|
9
|
+
style: BaseTextStyle;
|
|
10
|
+
text: string;
|
|
11
|
+
};
|
|
12
|
+
popup: {
|
|
13
|
+
backgroundColor: string;
|
|
14
|
+
borderRadius: number;
|
|
15
|
+
offset: number;
|
|
16
|
+
padding: [number, number];
|
|
17
|
+
};
|
|
18
|
+
};
|
|
3
19
|
export type RectLegendSymbol = {
|
|
4
20
|
shape: 'rect';
|
|
5
21
|
} & Required<RectLegendSymbolOptions>;
|
|
@@ -339,7 +355,23 @@ export type PreparedFunnelSeries = {
|
|
|
339
355
|
};
|
|
340
356
|
connectors: Required<FunnelSeries['connectors']>;
|
|
341
357
|
} & BasePreparedSeries;
|
|
342
|
-
export type
|
|
358
|
+
export type PreparedXRangeSeries = {
|
|
359
|
+
type: XRangeSeries['type'];
|
|
360
|
+
data: XRangeSeriesData[];
|
|
361
|
+
borderRadius: number;
|
|
362
|
+
borderWidth: number;
|
|
363
|
+
borderColor: string;
|
|
364
|
+
borderDashStyle: DashStyle;
|
|
365
|
+
opacity: number | null;
|
|
366
|
+
dataLabels: {
|
|
367
|
+
enabled: boolean;
|
|
368
|
+
style: BaseTextStyle;
|
|
369
|
+
html: boolean;
|
|
370
|
+
padding: number;
|
|
371
|
+
format?: ValueFormat;
|
|
372
|
+
};
|
|
373
|
+
} & BasePreparedSeries;
|
|
374
|
+
export type PreparedSeries = PreparedScatterSeries | PreparedBarXSeries | PreparedBarYSeries | PreparedPieSeries | PreparedLineSeries | PreparedAreaSeries | PreparedTreemapSeries | PreparedWaterfallSeries | PreparedSankeySeries | PreparedRadarSeries | PreparedHeatmapSeries | PreparedFunnelSeries | PreparedXRangeSeries;
|
|
343
375
|
export type PreparedZoomableSeries = Extract<PreparedSeries, {
|
|
344
376
|
data: Array<unknown>;
|
|
345
377
|
}>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { BaseTextStyle } from './base';
|
|
2
|
+
export interface ChartAnnotationLabel {
|
|
3
|
+
/** Annotation text */
|
|
4
|
+
text: string;
|
|
5
|
+
/** Text style. fontColor defaults to 'var(--g-color-text-light-primary)' */
|
|
6
|
+
style?: Partial<BaseTextStyle>;
|
|
7
|
+
}
|
|
8
|
+
export interface ChartAnnotationPopup {
|
|
9
|
+
/**
|
|
10
|
+
* Background color of the popup.
|
|
11
|
+
* @default 'var(--g-color-base-float-heavy)'
|
|
12
|
+
*/
|
|
13
|
+
backgroundColor?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Border radius of the popup.
|
|
16
|
+
* @default 4
|
|
17
|
+
*/
|
|
18
|
+
borderRadius?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Distance in pixels between the anchor point and the popup edge along the main axis.
|
|
21
|
+
* The main axis depends on the automatically chosen placement:
|
|
22
|
+
* for top/bottom — vertical distance, for left/right — horizontal distance.
|
|
23
|
+
* @default 5
|
|
24
|
+
*/
|
|
25
|
+
offset?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Popup padding. Number or [vertical, horizontal].
|
|
28
|
+
* @default [4, 8]
|
|
29
|
+
*/
|
|
30
|
+
padding?: number | [number, number];
|
|
31
|
+
}
|
|
32
|
+
/** Default annotation settings applied to all data points in a series */
|
|
33
|
+
export interface ChartAnnotationSeriesOptions {
|
|
34
|
+
/** Default label style for annotations */
|
|
35
|
+
label?: Omit<ChartAnnotationLabel, 'text'>;
|
|
36
|
+
/** Default popup settings for annotations */
|
|
37
|
+
popup?: ChartAnnotationPopup;
|
|
38
|
+
}
|
|
39
|
+
/** Annotation for a specific data point. Renders as a popup with text label near the data point. */
|
|
40
|
+
export interface ChartPointAnnotation {
|
|
41
|
+
/** Text content and style of the annotation */
|
|
42
|
+
label: ChartAnnotationLabel;
|
|
43
|
+
/** Visual settings for the annotation popup container (background, padding, etc.) */
|
|
44
|
+
popup?: ChartAnnotationPopup;
|
|
45
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { SERIES_TYPE } from '../../constants';
|
|
2
2
|
import type { MeaningfulAny } from '../misc';
|
|
3
|
+
import type { ChartPointAnnotation } from './annotation';
|
|
3
4
|
import type { BaseSeries, BaseSeriesData, BaseSeriesLegend } from './base';
|
|
4
5
|
import type { RectLegendSymbolOptions } from './legend';
|
|
5
6
|
import type { PointMarkerOptions } from './marker';
|
|
@@ -23,6 +24,8 @@ export interface AreaSeriesData<T = MeaningfulAny> extends BaseSeriesData<T> {
|
|
|
23
24
|
label?: string | number;
|
|
24
25
|
/** Individual marker options for the point. */
|
|
25
26
|
marker?: {
|
|
27
|
+
/** Fill color of the marker for this point */
|
|
28
|
+
color?: string;
|
|
26
29
|
/** States for a single point marker. */
|
|
27
30
|
states?: {
|
|
28
31
|
/** The normal state of a single point marker. */
|
|
@@ -35,6 +38,11 @@ export interface AreaSeriesData<T = MeaningfulAny> extends BaseSeriesData<T> {
|
|
|
35
38
|
};
|
|
36
39
|
};
|
|
37
40
|
};
|
|
41
|
+
/**
|
|
42
|
+
* Annotation displayed near this data point as a bubble with text label and optional marker.
|
|
43
|
+
* Useful for highlighting specific values, events, or adding contextual notes.
|
|
44
|
+
*/
|
|
45
|
+
annotation?: ChartPointAnnotation;
|
|
38
46
|
}
|
|
39
47
|
export type AreaMarkerSymbol = 'circle' | 'square';
|
|
40
48
|
export interface AreaMarkerOptions extends PointMarkerOptions {
|
|
@@ -76,9 +84,10 @@ export interface AreaSeries<T = MeaningfulAny> extends BaseSeries {
|
|
|
76
84
|
/**
|
|
77
85
|
* Specifies how null or undefined values should be handled in the series.
|
|
78
86
|
*
|
|
79
|
-
* - `'connect'`: Connect points across null values (skip nulls in rendering)
|
|
87
|
+
* - `'connect'`: Connect points across null values (skip nulls in rendering). **Not supported with `stacking`.**
|
|
80
88
|
* - `'zero'`: Treat null values as zero
|
|
81
89
|
* - `'skip'`: Omit the data point (creates gap in area)
|
|
90
|
+
*
|
|
82
91
|
* @default 'skip'
|
|
83
92
|
*/
|
|
84
93
|
nullMode?: 'connect' | 'zero' | 'skip';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { SERIES_TYPE } from '../../constants';
|
|
2
2
|
import type { MeaningfulAny } from '../misc';
|
|
3
|
+
import type { ChartPointAnnotation } from './annotation';
|
|
3
4
|
import type { BaseSeries, BaseSeriesData, BaseSeriesLegend } from './base';
|
|
4
5
|
import type { RectLegendSymbolOptions } from './legend';
|
|
5
6
|
import type { ChartSeriesOptions, ChartSeriesRangeSliderOptions } from './series';
|
|
@@ -27,6 +28,11 @@ export interface BarXSeriesData<T = MeaningfulAny> extends BaseSeriesData<T> {
|
|
|
27
28
|
label?: string | number;
|
|
28
29
|
/** Individual opacity for the bar-x column. */
|
|
29
30
|
opacity?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Annotation displayed near this data point as a bubble with text label.
|
|
33
|
+
* Useful for highlighting specific values, events, or adding contextual notes.
|
|
34
|
+
*/
|
|
35
|
+
annotation?: ChartPointAnnotation;
|
|
30
36
|
}
|
|
31
37
|
export interface BarXSeries<T = MeaningfulAny> extends BaseSeries {
|
|
32
38
|
type: typeof SERIES_TYPE.BarX;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { DashStyle, LineCap, LineJoin, SERIES_TYPE } from '../../constants';
|
|
2
2
|
import type { MeaningfulAny } from '../misc';
|
|
3
|
+
import type { ChartPointAnnotation } from './annotation';
|
|
3
4
|
import type { BaseSeries, BaseSeriesData, BaseSeriesLegend } from './base';
|
|
4
5
|
import type { RectLegendSymbolOptions } from './legend';
|
|
5
6
|
import type { PointMarkerOptions } from './marker';
|
|
@@ -22,12 +23,19 @@ export interface LineSeriesData<T = MeaningfulAny> extends BaseSeriesData<T> {
|
|
|
22
23
|
/** Data label value of the point. If not specified, the y value is used. */
|
|
23
24
|
label?: string | number;
|
|
24
25
|
marker?: {
|
|
26
|
+
/** Fill color of the marker for this point */
|
|
27
|
+
color?: string;
|
|
25
28
|
states?: {
|
|
26
29
|
normal?: {
|
|
27
30
|
enabled: boolean;
|
|
28
31
|
};
|
|
29
32
|
};
|
|
30
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* Annotation displayed near this data point as a bubble with text label and optional marker.
|
|
36
|
+
* Useful for highlighting specific values, events, or adding contextual notes.
|
|
37
|
+
*/
|
|
38
|
+
annotation?: ChartPointAnnotation;
|
|
31
39
|
}
|
|
32
40
|
export interface LineSeriesLineBaseStyle {
|
|
33
41
|
/**
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { SymbolType } from '../../constants';
|
|
2
2
|
export interface PointMarkerOptions {
|
|
3
|
-
/** Enable or disable the point marker */
|
|
4
|
-
enabled?: boolean;
|
|
5
|
-
/** The radius of the point marker */
|
|
6
|
-
radius?: number;
|
|
7
3
|
/** The color of the point marker's border */
|
|
8
4
|
borderColor?: string;
|
|
9
5
|
/** The width of the point marker's border */
|
|
10
6
|
borderWidth?: number;
|
|
7
|
+
/** Fill color of the marker */
|
|
8
|
+
color?: string;
|
|
9
|
+
/** Enable or disable the point marker */
|
|
10
|
+
enabled?: boolean;
|
|
11
|
+
/** The radius of the point marker */
|
|
12
|
+
radius?: number;
|
|
11
13
|
symbol?: `${SymbolType}`;
|
|
12
14
|
}
|