@gravity-ui/charts 1.42.3 → 1.43.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/AxisX/AxisX.js +31 -4
- package/dist/cjs/components/AxisX/prepare-axis-data.js +58 -13
- package/dist/cjs/components/AxisX/types.d.ts +18 -1
- package/dist/cjs/components/AxisY/AxisY.js +31 -4
- package/dist/cjs/components/AxisY/prepare-axis-data.js +68 -21
- package/dist/cjs/components/AxisY/prepare-axis-title.js +8 -3
- package/dist/cjs/components/AxisY/styles.css +1 -1
- package/dist/cjs/components/AxisY/types.d.ts +18 -1
- package/dist/cjs/components/ChartInner/index.js +21 -15
- package/dist/cjs/components/ChartInner/useChartInnerHandlers.js +6 -5
- package/dist/cjs/components/ChartInner/useChartInnerProps.d.ts +3 -2
- package/dist/cjs/components/ChartInner/useChartInnerProps.js +22 -11
- package/dist/cjs/components/ChartInner/useDefaultState.js +4 -3
- package/dist/cjs/components/ChartInner/utils/chart.js +1 -1
- package/dist/cjs/components/ChartInner/utils/normalized-original-data.d.ts +1 -0
- package/dist/cjs/components/ChartInner/utils/title.d.ts +3 -2
- package/dist/cjs/components/ChartInner/utils/title.js +69 -11
- package/dist/cjs/components/Legend/index.js +8 -11
- package/dist/cjs/components/Legend/styles.css +1 -1
- package/dist/cjs/components/Title/index.js +3 -5
- package/dist/cjs/components/Tooltip/ChartTooltipContent.d.ts +2 -1
- package/dist/cjs/components/Tooltip/ChartTooltipContent.js +3 -2
- package/dist/cjs/components/Tooltip/index.js +2 -2
- package/dist/cjs/components/utils/axis-title.js +1 -1
- package/dist/cjs/core/axes/types.d.ts +26 -9
- package/dist/cjs/core/axes/x-axis.js +16 -3
- package/dist/cjs/core/axes/y-axis.js +21 -8
- package/dist/cjs/core/constants/defaults/axis.d.ts +1 -0
- package/dist/cjs/core/constants/defaults/axis.js +1 -0
- package/dist/cjs/core/layout/split.d.ts +2 -2
- package/dist/cjs/core/layout/split.js +22 -19
- package/dist/cjs/core/scales/y-scale.js +37 -13
- package/dist/cjs/core/series/prepare-legend.js +7 -7
- package/dist/cjs/core/series/types.d.ts +2 -0
- package/dist/cjs/core/types/chart/axis.d.ts +43 -1
- package/dist/cjs/core/types/chart/title.d.ts +10 -0
- package/dist/cjs/core/types/chart/tooltip.d.ts +3 -1
- package/dist/cjs/core/utils/axis-generators/bottom.js +6 -16
- package/dist/cjs/core/utils/common.d.ts +0 -4
- package/dist/cjs/core/utils/common.js +1 -14
- package/dist/cjs/core/utils/get-hovered-plots.d.ts +3 -2
- package/dist/cjs/core/utils/get-hovered-plots.js +28 -4
- package/dist/cjs/core/utils/labels.d.ts +1 -0
- package/dist/cjs/core/utils/labels.js +5 -5
- package/dist/cjs/core/utils/text.d.ts +1 -0
- package/dist/cjs/core/utils/text.js +16 -2
- package/dist/cjs/hooks/types.d.ts +5 -2
- package/dist/cjs/hooks/useShapes/area/prepare-data.js +12 -7
- package/dist/cjs/hooks/useShapes/bar-x/prepare-data.js +12 -4
- package/dist/cjs/hooks/useShapes/bar-y/prepare-data.js +3 -2
- package/dist/cjs/hooks/useShapes/funnel/prepare-data.js +4 -1
- package/dist/cjs/hooks/useShapes/heatmap/prepare-data.js +1 -1
- package/dist/cjs/hooks/useShapes/line/prepare-data.js +4 -1
- package/dist/cjs/hooks/useShapes/pie/prepare-data.js +9 -2
- package/dist/cjs/hooks/useShapes/radar/prepare-data.js +17 -7
- package/dist/cjs/hooks/useShapes/sankey/prepare-data.js +1 -1
- package/dist/cjs/hooks/useShapes/sankey/sankey-layout.d.ts +49 -0
- package/dist/cjs/hooks/useShapes/sankey/sankey-layout.js +362 -0
- package/dist/cjs/hooks/useShapes/styles.css +4 -4
- package/dist/cjs/hooks/useShapes/treemap/prepare-data.js +3 -1
- package/dist/cjs/hooks/useTooltip/index.d.ts +3 -2
- package/dist/cjs/hooks/useTooltip/index.js +5 -3
- package/dist/cjs/types/chart-ui.d.ts +1 -0
- package/dist/esm/components/AxisX/AxisX.js +31 -4
- package/dist/esm/components/AxisX/prepare-axis-data.js +58 -13
- package/dist/esm/components/AxisX/types.d.ts +18 -1
- package/dist/esm/components/AxisY/AxisY.js +31 -4
- package/dist/esm/components/AxisY/prepare-axis-data.js +68 -21
- package/dist/esm/components/AxisY/prepare-axis-title.js +8 -3
- package/dist/esm/components/AxisY/styles.css +1 -1
- package/dist/esm/components/AxisY/types.d.ts +18 -1
- package/dist/esm/components/ChartInner/index.js +21 -15
- package/dist/esm/components/ChartInner/useChartInnerHandlers.js +6 -5
- package/dist/esm/components/ChartInner/useChartInnerProps.d.ts +3 -2
- package/dist/esm/components/ChartInner/useChartInnerProps.js +22 -11
- package/dist/esm/components/ChartInner/useDefaultState.js +4 -3
- package/dist/esm/components/ChartInner/utils/chart.js +1 -1
- package/dist/esm/components/ChartInner/utils/normalized-original-data.d.ts +1 -0
- package/dist/esm/components/ChartInner/utils/title.d.ts +3 -2
- package/dist/esm/components/ChartInner/utils/title.js +69 -11
- package/dist/esm/components/Legend/index.js +8 -11
- package/dist/esm/components/Legend/styles.css +1 -1
- package/dist/esm/components/Title/index.js +3 -5
- package/dist/esm/components/Tooltip/ChartTooltipContent.d.ts +2 -1
- package/dist/esm/components/Tooltip/ChartTooltipContent.js +3 -2
- package/dist/esm/components/Tooltip/index.js +2 -2
- package/dist/esm/components/utils/axis-title.js +1 -1
- package/dist/esm/core/axes/types.d.ts +26 -9
- package/dist/esm/core/axes/x-axis.js +16 -3
- package/dist/esm/core/axes/y-axis.js +21 -8
- package/dist/esm/core/constants/defaults/axis.d.ts +1 -0
- package/dist/esm/core/constants/defaults/axis.js +1 -0
- package/dist/esm/core/layout/split.d.ts +2 -2
- package/dist/esm/core/layout/split.js +22 -19
- package/dist/esm/core/scales/y-scale.js +37 -13
- package/dist/esm/core/series/prepare-legend.js +7 -7
- package/dist/esm/core/series/types.d.ts +2 -0
- package/dist/esm/core/types/chart/axis.d.ts +43 -1
- package/dist/esm/core/types/chart/title.d.ts +10 -0
- package/dist/esm/core/types/chart/tooltip.d.ts +3 -1
- package/dist/esm/core/utils/axis-generators/bottom.js +6 -16
- package/dist/esm/core/utils/common.d.ts +0 -4
- package/dist/esm/core/utils/common.js +1 -14
- package/dist/esm/core/utils/get-hovered-plots.d.ts +3 -2
- package/dist/esm/core/utils/get-hovered-plots.js +28 -4
- package/dist/esm/core/utils/labels.d.ts +1 -0
- package/dist/esm/core/utils/labels.js +5 -5
- package/dist/esm/core/utils/text.d.ts +1 -0
- package/dist/esm/core/utils/text.js +16 -2
- package/dist/esm/hooks/types.d.ts +5 -2
- package/dist/esm/hooks/useShapes/area/prepare-data.js +12 -7
- package/dist/esm/hooks/useShapes/bar-x/prepare-data.js +12 -4
- package/dist/esm/hooks/useShapes/bar-y/prepare-data.js +3 -2
- package/dist/esm/hooks/useShapes/funnel/prepare-data.js +4 -1
- package/dist/esm/hooks/useShapes/heatmap/prepare-data.js +1 -1
- package/dist/esm/hooks/useShapes/line/prepare-data.js +4 -1
- package/dist/esm/hooks/useShapes/pie/prepare-data.js +9 -2
- package/dist/esm/hooks/useShapes/radar/prepare-data.js +17 -7
- package/dist/esm/hooks/useShapes/sankey/prepare-data.js +1 -1
- package/dist/esm/hooks/useShapes/sankey/sankey-layout.d.ts +49 -0
- package/dist/esm/hooks/useShapes/sankey/sankey-layout.js +362 -0
- package/dist/esm/hooks/useShapes/styles.css +4 -4
- package/dist/esm/hooks/useShapes/treemap/prepare-data.js +3 -1
- package/dist/esm/hooks/useTooltip/index.d.ts +3 -2
- package/dist/esm/hooks/useTooltip/index.js +5 -3
- package/dist/esm/types/chart-ui.d.ts +1 -0
- package/package.json +1 -3
|
@@ -20,7 +20,7 @@ import { useChartInnerHandlers } from './useChartInnerHandlers';
|
|
|
20
20
|
import { useChartInnerProps } from './useChartInnerProps';
|
|
21
21
|
import { useChartInnerState } from './useChartInnerState';
|
|
22
22
|
import { useDefaultState } from './useDefaultState';
|
|
23
|
-
import {
|
|
23
|
+
import { getPreparedTooltip, getResetZoomButtonStyle, useAsyncState, useDebouncedValue, } from './utils';
|
|
24
24
|
import './styles.css';
|
|
25
25
|
const b = block('chart');
|
|
26
26
|
const DEBOUNCED_VALUE_DELAY = 10;
|
|
@@ -36,16 +36,6 @@ export const ChartInner = (props) => {
|
|
|
36
36
|
const rangeSliderRef = React.useRef(null);
|
|
37
37
|
const dispatcher = React.useMemo(() => getDispatcher(), []);
|
|
38
38
|
const clipPathId = useUniqId();
|
|
39
|
-
const preparedTitle = React.useMemo(() => {
|
|
40
|
-
return getPreparedTitle({ title: data.title });
|
|
41
|
-
}, [data.title]);
|
|
42
|
-
const preparedChart = React.useMemo(() => {
|
|
43
|
-
return getPreparedChart({
|
|
44
|
-
chart: data.chart,
|
|
45
|
-
seriesData: data.series.data,
|
|
46
|
-
preparedTitle,
|
|
47
|
-
});
|
|
48
|
-
}, [data.chart, data.series.data, preparedTitle]);
|
|
49
39
|
const preparedTooltip = React.useMemo(() => {
|
|
50
40
|
return getPreparedTooltip({
|
|
51
41
|
tooltip: data.tooltip,
|
|
@@ -62,10 +52,9 @@ export const ChartInner = (props) => {
|
|
|
62
52
|
preparedRangeSlider,
|
|
63
53
|
tooltip: preparedTooltip,
|
|
64
54
|
});
|
|
65
|
-
const { activeLegendItems, allPreparedSeries, boundsHeight, boundsOffsetLeft, boundsOffsetTop, boundsWidth, handleLegendItemClick, legendConfig, legendItems, preparedLegend, preparedSeries, preparedSeriesOptions, preparedSplit, shapes, shapesData, shapesReady, xAxis, xScale, yAxis, yScale, } = useChartInnerProps(Object.assign(Object.assign({}, props), { clipPathId,
|
|
55
|
+
const { activeLegendItems, allPreparedSeries, boundsHeight, boundsOffsetLeft, boundsOffsetTop, boundsWidth, handleLegendItemClick, legendConfig, legendItems, preparedLegend, preparedSeries, preparedSeriesOptions, preparedSplit, shapes, shapesData, shapesReady, xAxis, xScale, yAxis, yScale, preparedTitle, preparedChart, } = useChartInnerProps(Object.assign(Object.assign({}, props), { clipPathId,
|
|
66
56
|
dispatcher,
|
|
67
|
-
htmlLayout, plotNode: plotRef.current,
|
|
68
|
-
rangeSliderState,
|
|
57
|
+
htmlLayout, plotNode: plotRef.current, rangeSliderState,
|
|
69
58
|
updateZoomState,
|
|
70
59
|
zoomState }));
|
|
71
60
|
const prevWidth = usePrevious(width);
|
|
@@ -165,6 +154,13 @@ export const ChartInner = (props) => {
|
|
|
165
154
|
split: preparedSplit,
|
|
166
155
|
series: preparedSeries.filter((s) => s.visible),
|
|
167
156
|
});
|
|
157
|
+
axisData.plotShapes.forEach((shapeData, j) => {
|
|
158
|
+
if (axis.plotShapes[j]) {
|
|
159
|
+
axis.plotShapes[j].hitbox = shapeData.hitbox;
|
|
160
|
+
axis.plotShapes[j].x = shapeData.x;
|
|
161
|
+
axis.plotShapes[j].y = shapeData.y;
|
|
162
|
+
}
|
|
163
|
+
});
|
|
168
164
|
items.push(axisData);
|
|
169
165
|
}
|
|
170
166
|
}
|
|
@@ -191,6 +187,15 @@ export const ChartInner = (props) => {
|
|
|
191
187
|
split: preparedSplit,
|
|
192
188
|
yAxis,
|
|
193
189
|
});
|
|
190
|
+
axisData.forEach((data) => {
|
|
191
|
+
data.plotShapes.forEach((shapeData, i) => {
|
|
192
|
+
if (axis.plotShapes[i]) {
|
|
193
|
+
axis.plotShapes[i].hitbox = shapeData.hitbox;
|
|
194
|
+
axis.plotShapes[i].x = shapeData.x;
|
|
195
|
+
axis.plotShapes[i].y = shapeData.y;
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
});
|
|
194
199
|
items.push(...axisData);
|
|
195
200
|
}
|
|
196
201
|
return items;
|
|
@@ -269,6 +274,7 @@ export const ChartInner = (props) => {
|
|
|
269
274
|
shapes,
|
|
270
275
|
React.createElement("g", { ref: plotAfterRef })),
|
|
271
276
|
((_e = xAxis === null || xAxis === void 0 ? void 0 : xAxis.rangeSlider) === null || _e === void 0 ? void 0 : _e.enabled) &&
|
|
277
|
+
preparedChart &&
|
|
272
278
|
preparedLegend &&
|
|
273
279
|
debouncedAllPreparedSeries &&
|
|
274
280
|
preparedSeriesOptions && (React.createElement(RangeSlider, { activeLegendItems: activeLegendItems !== null && activeLegendItems !== void 0 ? activeLegendItems : [], boundsOffsetLeft: debouncedOffsetLeft, boundsWidth: debouncedBoundsWidth, height: height, htmlLayout: htmlLayout, onUpdate: updateRangeSliderState, preparedChart: preparedChart, preparedLegend: preparedLegend, preparedSeries: debouncedAllPreparedSeries, preparedSeriesOptions: preparedSeriesOptions, preparedRangeSlider: xAxis.rangeSlider, rangeSliderState: rangeSliderState, ref: rangeSliderRef, width: width, xAxis: data.xAxis, yAxis: data.yAxis, legendConfig: legendConfig })),
|
|
@@ -281,7 +287,7 @@ export const ChartInner = (props) => {
|
|
|
281
287
|
React.createElement("div", { className: b('html-layer'), ref: setHtmlLayout, style: {
|
|
282
288
|
'--g-html-layout-transform': `translate(${boundsOffsetLeft}px, ${boundsOffsetTop}px)`,
|
|
283
289
|
} }),
|
|
284
|
-
Object.keys(zoomState).length > 0 && preparedChart.zoom && (React.createElement(Button, { className: b('reset-zoom-button'), onClick: () => {
|
|
290
|
+
Object.keys(zoomState).length > 0 && (preparedChart === null || preparedChart === void 0 ? void 0 : preparedChart.zoom) && (React.createElement(Button, { className: b('reset-zoom-button'), onClick: () => {
|
|
285
291
|
var _a;
|
|
286
292
|
updateZoomState({});
|
|
287
293
|
(_a = rangeSliderRef.current) === null || _a === void 0 ? void 0 : _a.resetState();
|
|
@@ -29,7 +29,7 @@ export function useChartInnerHandlers(props) {
|
|
|
29
29
|
boundsHeight,
|
|
30
30
|
boundsWidth,
|
|
31
31
|
});
|
|
32
|
-
const { plotLines,
|
|
32
|
+
const { plotBands, plotLines, plotShapes } = getHoveredPlots({
|
|
33
33
|
pointerX: x,
|
|
34
34
|
pointerY: y,
|
|
35
35
|
xAxis,
|
|
@@ -37,7 +37,7 @@ export function useChartInnerHandlers(props) {
|
|
|
37
37
|
xScale,
|
|
38
38
|
yScale,
|
|
39
39
|
});
|
|
40
|
-
const hoveredPlotsArg = { lines: plotLines,
|
|
40
|
+
const hoveredPlotsArg = { bands: plotBands, lines: plotLines, shapes: plotShapes };
|
|
41
41
|
dispatcher.call(EventType.HOVER_SHAPE, event.target, closest, [pointerX, pointerY], hoveredPlotsArg);
|
|
42
42
|
dispatcher.call(EventType.POINTERMOVE_CHART, {}, {
|
|
43
43
|
hovered: closest,
|
|
@@ -93,7 +93,7 @@ export function useChartInnerHandlers(props) {
|
|
|
93
93
|
dispatcher.call(EventType.CLICK_CHART, undefined, { point: selected.data, series: selected.series }, event);
|
|
94
94
|
const nextTooltipFixed = !tooltipPinned;
|
|
95
95
|
if (!nextTooltipFixed) {
|
|
96
|
-
const { plotLines,
|
|
96
|
+
const { plotBands, plotLines, plotShapes } = getHoveredPlots({
|
|
97
97
|
pointerX: x,
|
|
98
98
|
pointerY: y,
|
|
99
99
|
xAxis,
|
|
@@ -101,14 +101,15 @@ export function useChartInnerHandlers(props) {
|
|
|
101
101
|
xScale,
|
|
102
102
|
yScale,
|
|
103
103
|
});
|
|
104
|
-
const hoveredPlotsArg = { lines: plotLines,
|
|
104
|
+
const hoveredPlotsArg = { bands: plotBands, lines: plotLines, shapes: plotShapes };
|
|
105
105
|
dispatcher.call(EventType.HOVER_SHAPE, event.target, items, [pointerX, pointerY], hoveredPlotsArg);
|
|
106
106
|
dispatcher.call(EventType.POINTERMOVE_CHART, {}, {
|
|
107
107
|
hovered: items,
|
|
108
108
|
xAxis,
|
|
109
109
|
yAxis: yAxis[0],
|
|
110
|
-
hoveredPlotLines: plotLines,
|
|
111
110
|
hoveredPlotBands: plotBands,
|
|
111
|
+
hoveredPlotLines: plotLines,
|
|
112
|
+
hoveredPlotShapes: plotShapes,
|
|
112
113
|
}, event);
|
|
113
114
|
}
|
|
114
115
|
togglePinTooltip === null || togglePinTooltip === void 0 ? void 0 : togglePinTooltip(nextTooltipFixed, event);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { Dispatch } from 'd3-dispatch';
|
|
3
3
|
import type { ChartScale, LegendItem, OnLegendItemClick, PreparedLegend, PreparedSeries, PreparedSplit, PreparedXAxis, PreparedYAxis, RangeSliderState, ShapeData, ZoomState } from '../../hooks';
|
|
4
|
-
import type { PreparedChart } from '../../hooks/types';
|
|
4
|
+
import type { PreparedChart, PreparedTitle } from '../../hooks/types';
|
|
5
5
|
import type { LegendConfig } from '../../types';
|
|
6
6
|
import type { ChartInnerProps } from './types';
|
|
7
7
|
type Props = ChartInnerProps & {
|
|
@@ -9,7 +9,6 @@ type Props = ChartInnerProps & {
|
|
|
9
9
|
dispatcher: Dispatch<object>;
|
|
10
10
|
htmlLayout: HTMLElement | null;
|
|
11
11
|
plotNode: SVGGElement | null;
|
|
12
|
-
preparedChart: PreparedChart;
|
|
13
12
|
updateZoomState: (nextZoomState: Partial<ZoomState>) => void;
|
|
14
13
|
zoomState: Partial<ZoomState>;
|
|
15
14
|
rangeSliderState?: RangeSliderState;
|
|
@@ -25,6 +24,8 @@ export declare function useChartInnerProps(props: Props): {
|
|
|
25
24
|
shapesData: ShapeData[];
|
|
26
25
|
shapesReady: boolean;
|
|
27
26
|
handleLegendItemClick: OnLegendItemClick;
|
|
27
|
+
preparedTitle: PreparedTitle | undefined;
|
|
28
|
+
preparedChart: PreparedChart | undefined;
|
|
28
29
|
allPreparedSeries?: PreparedSeries[] | undefined;
|
|
29
30
|
legendConfig?: LegendConfig | undefined;
|
|
30
31
|
legendItems?: LegendItem[][] | undefined;
|
|
@@ -6,7 +6,7 @@ import { getPreparedOptions } from '../../core/series/prepare-options';
|
|
|
6
6
|
import { getChartDimensions, getEffectiveXRange, getSortedSeriesData, getYAxisWidth, getZoomedSeriesData, isAxisRelatedSeries, } from '../../core/utils';
|
|
7
7
|
import { createScales, getAxes, getPreparedSeries, getShapes, getSplit, getVisibleSeries, useZoom, } from '../../hooks';
|
|
8
8
|
import { getActiveLegendItems, getAllLegendItems } from '../../hooks/useSeries/utils';
|
|
9
|
-
import { getNormalizedXAxis, getNormalizedYAxis, recalculateYAxisLabelsWidth } from './utils';
|
|
9
|
+
import { getNormalizedXAxis, getNormalizedYAxis, getPreparedChart, getPreparedTitle, recalculateYAxisLabelsWidth, } from './utils';
|
|
10
10
|
import { hasAtLeastOneSeriesDataPerPlot } from './utils/common';
|
|
11
11
|
const CLIP_PATH_BY_SERIES_TYPE = {
|
|
12
12
|
[SERIES_TYPE.Scatter]: false,
|
|
@@ -37,8 +37,8 @@ function getBoundsOffsetLeft(args) {
|
|
|
37
37
|
return chartMarginLeft + legendOffset + leftAxisWidth;
|
|
38
38
|
}
|
|
39
39
|
export function useChartInnerProps(props) {
|
|
40
|
-
var _a, _b, _c, _d, _e, _f;
|
|
41
|
-
const { clipPathId, data, dispatcher, height, htmlLayout, plotNode,
|
|
40
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
41
|
+
const { clipPathId, data, dispatcher, height, htmlLayout, plotNode, rangeSliderState, width, updateZoomState, zoomState, } = props;
|
|
42
42
|
const [selectedLegendItems, setSelectedLegendItems] = React.useState(null);
|
|
43
43
|
const [chartState, setState] = React.useState(null);
|
|
44
44
|
const prevStateValue = React.useRef(chartState);
|
|
@@ -50,6 +50,12 @@ export function useChartInnerProps(props) {
|
|
|
50
50
|
(async function () {
|
|
51
51
|
var _a, _b, _c;
|
|
52
52
|
const chartDataChanged = !(previousChartData.current && isEqual(previousChartData.current, data));
|
|
53
|
+
const preparedTitle = await getPreparedTitle({ title: data.title, chartWidth: width });
|
|
54
|
+
const preparedChart = getPreparedChart({
|
|
55
|
+
chart: data.chart,
|
|
56
|
+
seriesData: data.series.data,
|
|
57
|
+
preparedTitle,
|
|
58
|
+
});
|
|
53
59
|
const colors = (_a = data.colors) !== null && _a !== void 0 ? _a : DEFAULT_PALETTE;
|
|
54
60
|
const normalizedSeriesData = getSortedSeriesData({
|
|
55
61
|
seriesData: data.series.data,
|
|
@@ -119,7 +125,7 @@ export function useChartInnerProps(props) {
|
|
|
119
125
|
let yScale;
|
|
120
126
|
let boundsWidth = 0;
|
|
121
127
|
let boundsHeight = 0;
|
|
122
|
-
const calculateAxisBasedProps = () => {
|
|
128
|
+
const calculateAxisBasedProps = async () => {
|
|
123
129
|
const chartDimensions = getChartDimensions({
|
|
124
130
|
height,
|
|
125
131
|
margin: preparedChart.margin,
|
|
@@ -132,7 +138,11 @@ export function useChartInnerProps(props) {
|
|
|
132
138
|
});
|
|
133
139
|
boundsHeight = chartDimensions.boundsHeight;
|
|
134
140
|
boundsWidth = chartDimensions.boundsWidth;
|
|
135
|
-
preparedSplit = getSplit({
|
|
141
|
+
preparedSplit = await getSplit({
|
|
142
|
+
split: data.split,
|
|
143
|
+
boundsHeight,
|
|
144
|
+
chartWidth: width,
|
|
145
|
+
});
|
|
136
146
|
if (preparedSeries.some(isAxisRelatedSeries)) {
|
|
137
147
|
({ xScale, yScale } = createScales({
|
|
138
148
|
boundsWidth,
|
|
@@ -147,7 +157,7 @@ export function useChartInnerProps(props) {
|
|
|
147
157
|
}));
|
|
148
158
|
}
|
|
149
159
|
};
|
|
150
|
-
calculateAxisBasedProps();
|
|
160
|
+
await calculateAxisBasedProps();
|
|
151
161
|
const newYAxis = await recalculateYAxisLabelsWidth({
|
|
152
162
|
seriesData: preparedSeries,
|
|
153
163
|
yAxis,
|
|
@@ -155,7 +165,7 @@ export function useChartInnerProps(props) {
|
|
|
155
165
|
});
|
|
156
166
|
if (!isEqual(yAxis, newYAxis)) {
|
|
157
167
|
yAxis = newYAxis;
|
|
158
|
-
calculateAxisBasedProps();
|
|
168
|
+
await calculateAxisBasedProps();
|
|
159
169
|
}
|
|
160
170
|
const { shapes, shapesData } = await getShapes({
|
|
161
171
|
boundsWidth,
|
|
@@ -209,6 +219,8 @@ export function useChartInnerProps(props) {
|
|
|
209
219
|
yAxis,
|
|
210
220
|
yScale,
|
|
211
221
|
activeLegendItems,
|
|
222
|
+
preparedChart,
|
|
223
|
+
preparedTitle,
|
|
212
224
|
};
|
|
213
225
|
if (currentRunRef.current === currentRun) {
|
|
214
226
|
if (!isEqual(prevStateValue.current, newStateValue)) {
|
|
@@ -225,7 +237,6 @@ export function useChartInnerProps(props) {
|
|
|
225
237
|
selectedLegendItems,
|
|
226
238
|
zoomState,
|
|
227
239
|
rangeSliderState,
|
|
228
|
-
preparedChart,
|
|
229
240
|
dispatcher,
|
|
230
241
|
htmlLayout,
|
|
231
242
|
clipPathId,
|
|
@@ -277,15 +288,15 @@ export function useChartInnerProps(props) {
|
|
|
277
288
|
plotContainerHeight: boundsHeight,
|
|
278
289
|
plotContainerWidth: boundsWidth,
|
|
279
290
|
preparedSplit: chartState === null || chartState === void 0 ? void 0 : chartState.preparedSplit,
|
|
280
|
-
preparedZoom: preparedChart.zoom,
|
|
291
|
+
preparedZoom: (_e = (_d = chartState === null || chartState === void 0 ? void 0 : chartState.preparedChart) === null || _d === void 0 ? void 0 : _d.zoom) !== null && _e !== void 0 ? _e : null,
|
|
281
292
|
xAxis,
|
|
282
293
|
xScale: chartState === null || chartState === void 0 ? void 0 : chartState.xScale,
|
|
283
294
|
yAxis,
|
|
284
295
|
yScale: chartState === null || chartState === void 0 ? void 0 : chartState.yScale,
|
|
285
296
|
});
|
|
286
297
|
// additional end
|
|
287
|
-
return Object.assign(Object.assign({}, chartState), { preparedSeries, boundsOffsetLeft: (
|
|
298
|
+
return Object.assign(Object.assign({}, chartState), { preparedSeries, boundsOffsetLeft: (_f = chartState === null || chartState === void 0 ? void 0 : chartState.boundsOffsetLeft) !== null && _f !== void 0 ? _f : 0, boundsOffsetTop: (_g = chartState === null || chartState === void 0 ? void 0 : chartState.boundsOffsetTop) !== null && _g !== void 0 ? _g : 0, boundsHeight,
|
|
288
299
|
boundsWidth,
|
|
289
300
|
xAxis,
|
|
290
|
-
yAxis, shapesData: (
|
|
301
|
+
yAxis, shapesData: (_h = chartState === null || chartState === void 0 ? void 0 : chartState.shapesData) !== null && _h !== void 0 ? _h : [], shapesReady: Boolean(chartState), handleLegendItemClick, preparedTitle: chartState === null || chartState === void 0 ? void 0 : chartState.preparedTitle, preparedChart: chartState === null || chartState === void 0 ? void 0 : chartState.preparedChart });
|
|
291
302
|
}
|
|
@@ -29,7 +29,7 @@ export function useDefaultState(props) {
|
|
|
29
29
|
boundsHeight,
|
|
30
30
|
boundsWidth,
|
|
31
31
|
});
|
|
32
|
-
const { plotLines,
|
|
32
|
+
const { plotBands, plotLines, plotShapes } = getHoveredPlots({
|
|
33
33
|
pointerX: x,
|
|
34
34
|
pointerY: y,
|
|
35
35
|
xAxis,
|
|
@@ -37,7 +37,7 @@ export function useDefaultState(props) {
|
|
|
37
37
|
xScale,
|
|
38
38
|
yScale,
|
|
39
39
|
});
|
|
40
|
-
const hoveredPlotsArg = { lines: plotLines,
|
|
40
|
+
const hoveredPlotsArg = { bands: plotBands, lines: plotLines, shapes: plotShapes };
|
|
41
41
|
const svgPointerX = x + boundsOffsetLeft;
|
|
42
42
|
const svgPointerY = y + boundsOffsetTop;
|
|
43
43
|
dispatcher.call(EventType.HOVER_SHAPE, undefined, closest, [svgPointerX, svgPointerY], hoveredPlotsArg);
|
|
@@ -55,8 +55,9 @@ export function useDefaultState(props) {
|
|
|
55
55
|
hovered: closest,
|
|
56
56
|
xAxis,
|
|
57
57
|
yAxis: yAxis[0],
|
|
58
|
-
hoveredPlotLines: plotLines,
|
|
59
58
|
hoveredPlotBands: plotBands,
|
|
59
|
+
hoveredPlotLines: plotLines,
|
|
60
|
+
hoveredPlotShapes: plotShapes,
|
|
60
61
|
}, syntheticEvent);
|
|
61
62
|
});
|
|
62
63
|
}, [
|
|
@@ -4,7 +4,7 @@ const getMarginTop = (args) => {
|
|
|
4
4
|
const { chart, preparedTitle } = args;
|
|
5
5
|
let marginTop = get(chart, 'margin.top', 0);
|
|
6
6
|
if (preparedTitle === null || preparedTitle === void 0 ? void 0 : preparedTitle.height) {
|
|
7
|
-
marginTop += preparedTitle.height;
|
|
7
|
+
marginTop += preparedTitle.height + preparedTitle.margin;
|
|
8
8
|
}
|
|
9
9
|
return marginTop;
|
|
10
10
|
};
|
|
@@ -22,6 +22,7 @@ export declare function getNormalizedXAxis(props: {
|
|
|
22
22
|
maxPadding?: number;
|
|
23
23
|
plotLines?: import("../../../types").AxisPlotLine[];
|
|
24
24
|
plotBands?: import("../../../types").AxisPlotBand[];
|
|
25
|
+
plotShapes?: import("../../../types").AxisPlotShape[];
|
|
25
26
|
tickMarks?: import("../../../types").ChartAxisTickMarks;
|
|
26
27
|
visible?: boolean;
|
|
27
28
|
order?: "sortAsc" | "sortDesc" | "reverse";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { PreparedTitle } from '../../../hooks/types';
|
|
2
2
|
import type { ChartData } from '../../../types';
|
|
3
|
-
export declare const getPreparedTitle: ({ title, }: {
|
|
3
|
+
export declare const getPreparedTitle: ({ title, chartWidth, }: {
|
|
4
4
|
title: ChartData["title"];
|
|
5
|
-
|
|
5
|
+
chartWidth: number;
|
|
6
|
+
}) => Promise<PreparedTitle | undefined>;
|
|
@@ -1,20 +1,78 @@
|
|
|
1
1
|
import get from 'lodash/get';
|
|
2
|
-
import {
|
|
2
|
+
import { getTextSizeFn, getTextWithElipsis, wrapText } from '../../../core/utils';
|
|
3
3
|
const DEFAULT_TITLE_FONT_SIZE = '15px';
|
|
4
|
-
const
|
|
5
|
-
export const getPreparedTitle = ({ title, }) => {
|
|
6
|
-
var _a, _b, _c, _d, _e, _f;
|
|
4
|
+
const DEFAULT_TITLE_MARGIN = 10;
|
|
5
|
+
export const getPreparedTitle = async ({ title, chartWidth, }) => {
|
|
6
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
7
7
|
const titleText = get(title, 'text');
|
|
8
8
|
const titleStyle = {
|
|
9
9
|
fontSize: (_b = (_a = title === null || title === void 0 ? void 0 : title.style) === null || _a === void 0 ? void 0 : _a.fontSize) !== null && _b !== void 0 ? _b : DEFAULT_TITLE_FONT_SIZE,
|
|
10
10
|
fontWeight: (_d = (_c = title === null || title === void 0 ? void 0 : title.style) === null || _c === void 0 ? void 0 : _c.fontWeight) !== null && _d !== void 0 ? _d : 'var(--g-text-subheader-font-weight)',
|
|
11
11
|
fontColor: (_f = (_e = title === null || title === void 0 ? void 0 : title.style) === null || _e === void 0 ? void 0 : _e.fontColor) !== null && _f !== void 0 ? _f : 'var(--g-color-text-primary)',
|
|
12
12
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
if (!titleText) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
const getTitleTextSize = getTextSizeFn({ style: titleStyle });
|
|
17
|
+
const maxRowCount = (_g = title === null || title === void 0 ? void 0 : title.maxRowCount) !== null && _g !== void 0 ? _g : 1;
|
|
18
|
+
const contentRows = [];
|
|
19
|
+
if (maxRowCount > 1) {
|
|
20
|
+
let titleTextRows = await wrapText({
|
|
21
|
+
text: titleText,
|
|
22
|
+
style: titleStyle,
|
|
23
|
+
width: chartWidth,
|
|
24
|
+
getTextSize: getTitleTextSize,
|
|
25
|
+
});
|
|
26
|
+
titleTextRows = titleTextRows.reduce((acc, row, index) => {
|
|
27
|
+
if (index < maxRowCount) {
|
|
28
|
+
acc.push(row);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
acc[maxRowCount - 1].text += row.text;
|
|
32
|
+
}
|
|
33
|
+
return acc;
|
|
34
|
+
}, []);
|
|
35
|
+
for (let i = 0; i < titleTextRows.length; i++) {
|
|
36
|
+
const textRow = titleTextRows[i];
|
|
37
|
+
let textRowContent = textRow.text.trim();
|
|
38
|
+
if (i === titleTextRows.length - 1) {
|
|
39
|
+
textRowContent = await getTextWithElipsis({
|
|
40
|
+
text: textRowContent,
|
|
41
|
+
maxWidth: chartWidth,
|
|
42
|
+
getTextWidth: async (s) => (await getTitleTextSize(s)).width,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
const textRowSize = await getTitleTextSize(textRowContent);
|
|
46
|
+
contentRows.push({
|
|
47
|
+
text: textRowContent,
|
|
48
|
+
x: 0,
|
|
49
|
+
y: textRow.y + textRowSize.hangingOffset,
|
|
50
|
+
size: textRowSize,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
const truncatedText = await getTextWithElipsis({
|
|
56
|
+
text: titleText,
|
|
57
|
+
maxWidth: chartWidth,
|
|
58
|
+
getTextWidth: async (s) => (await getTitleTextSize(s)).width,
|
|
59
|
+
});
|
|
60
|
+
const textSize = await getTitleTextSize(truncatedText);
|
|
61
|
+
contentRows.push({
|
|
62
|
+
text: truncatedText,
|
|
63
|
+
x: 0,
|
|
64
|
+
y: textSize.hangingOffset,
|
|
65
|
+
size: textSize,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
const totalTextHeight = contentRows.reduce((acc, row) => acc + row.size.height, 0);
|
|
69
|
+
const titleHeight = totalTextHeight;
|
|
70
|
+
return {
|
|
71
|
+
text: titleText,
|
|
72
|
+
style: titleStyle,
|
|
73
|
+
height: titleHeight,
|
|
74
|
+
margin: (_h = title === null || title === void 0 ? void 0 : title.margin) !== null && _h !== void 0 ? _h : DEFAULT_TITLE_MARGIN,
|
|
75
|
+
qa: title === null || title === void 0 ? void 0 : title.qa,
|
|
76
|
+
contentRows,
|
|
77
|
+
};
|
|
20
78
|
};
|
|
@@ -3,7 +3,7 @@ import { scaleLinear } from 'd3-scale';
|
|
|
3
3
|
import { select } from 'd3-selection';
|
|
4
4
|
import { symbol } from 'd3-shape';
|
|
5
5
|
import { CONTINUOUS_LEGEND_SIZE } from '../../core/constants';
|
|
6
|
-
import { createGradientRect, getContinuesColorFn,
|
|
6
|
+
import { createGradientRect, getContinuesColorFn, getSymbol, getTextSizeFn, getUniqId, } from '../../core/utils';
|
|
7
7
|
import { axisBottom } from '../../core/utils/axis-generators';
|
|
8
8
|
import { formatNumber } from '../../libs';
|
|
9
9
|
import { block } from '../../utils';
|
|
@@ -116,15 +116,13 @@ function renderLegendSymbol(args) {
|
|
|
116
116
|
}
|
|
117
117
|
case 'symbol': {
|
|
118
118
|
const symbolAreaSize = Math.pow(d.symbol.width, 2);
|
|
119
|
-
const y = legendLineHeight / 2;
|
|
120
119
|
const bboxWidth = d.symbol.bboxWidth;
|
|
120
|
+
const translateX = x + bboxWidth / 2;
|
|
121
|
+
const translateY = legendLineHeight / 2;
|
|
121
122
|
element
|
|
122
123
|
.append('svg:path')
|
|
123
124
|
.attr('d', () => symbol(scatterSymbol, symbolAreaSize)())
|
|
124
|
-
.attr('transform', (
|
|
125
|
-
const translateX = x + bboxWidth / 2;
|
|
126
|
-
return 'translate(' + translateX + ',' + y + ')';
|
|
127
|
-
})
|
|
125
|
+
.attr('transform', 'translate(' + translateX + ',' + translateY + ')')
|
|
128
126
|
.attr('class', className)
|
|
129
127
|
.style('fill', color);
|
|
130
128
|
break;
|
|
@@ -234,6 +232,7 @@ export const Legend = (props) => {
|
|
|
234
232
|
legendItem.symbol.bboxWidth +
|
|
235
233
|
legendItem.symbol.padding);
|
|
236
234
|
})
|
|
235
|
+
.attr('y', legend.hangingOffset)
|
|
237
236
|
.attr('height', legend.height)
|
|
238
237
|
.attr('class', function (d) {
|
|
239
238
|
const mods = { selected: d.visible, unselected: !d.visible };
|
|
@@ -364,10 +363,7 @@ export const Legend = (props) => {
|
|
|
364
363
|
}
|
|
365
364
|
const legendTitleClassname = b('title');
|
|
366
365
|
if (legend.title.enable) {
|
|
367
|
-
const {
|
|
368
|
-
labels: [legend.title.text],
|
|
369
|
-
style: legend.title.style,
|
|
370
|
-
});
|
|
366
|
+
const { width: titleWidth } = await getTextSizeFn({ style: legend.title.style })(legend.title.text);
|
|
371
367
|
let dx = 0;
|
|
372
368
|
switch (legend.title.align) {
|
|
373
369
|
case 'center': {
|
|
@@ -390,10 +386,11 @@ export const Legend = (props) => {
|
|
|
390
386
|
.attr('class', legendTitleClassname)
|
|
391
387
|
.append('text')
|
|
392
388
|
.attr('dx', dx)
|
|
389
|
+
.attr('y', legend.title.hangingOffset)
|
|
393
390
|
.attr('font-weight', (_f = legend.title.style.fontWeight) !== null && _f !== void 0 ? _f : null)
|
|
394
391
|
.attr('font-size', (_g = legend.title.style.fontSize) !== null && _g !== void 0 ? _g : null)
|
|
395
392
|
.attr('fill', (_h = legend.title.style.fontColor) !== null && _h !== void 0 ? _h : null)
|
|
396
|
-
.style('dominant-baseline', '
|
|
393
|
+
.style('dominant-baseline', 'hanging')
|
|
397
394
|
.html(legend.title.text);
|
|
398
395
|
}
|
|
399
396
|
else {
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export const Title = (props) => {
|
|
3
|
-
const { chartWidth,
|
|
4
|
-
return (React.createElement("text", {
|
|
3
|
+
const { chartWidth, style, qa, contentRows } = props;
|
|
4
|
+
return (React.createElement("text", { dominantBaseline: "hanging", textAnchor: "middle", style: {
|
|
5
5
|
fill: style === null || style === void 0 ? void 0 : style.fontColor,
|
|
6
6
|
fontSize: style === null || style === void 0 ? void 0 : style.fontSize,
|
|
7
7
|
fontWeight: style === null || style === void 0 ? void 0 : style.fontWeight,
|
|
8
|
-
|
|
9
|
-
}, "data-qa": qa },
|
|
10
|
-
React.createElement("tspan", { dangerouslySetInnerHTML: { __html: text } })));
|
|
8
|
+
}, "data-qa": qa }, contentRows.map((row, i) => (React.createElement("tspan", { key: i, x: chartWidth / 2, y: row.y, dominantBaseline: "hanging", dangerouslySetInnerHTML: { __html: row.text } })))));
|
|
11
9
|
};
|
|
@@ -7,8 +7,9 @@ export interface ChartTooltipContentProps {
|
|
|
7
7
|
rowRenderer?: ChartTooltip['rowRenderer'];
|
|
8
8
|
valueFormat?: ChartTooltip['valueFormat'];
|
|
9
9
|
headerFormat?: ChartTooltip['headerFormat'];
|
|
10
|
-
hoveredPlotLines?: ChartTooltipRendererArgs['hoveredPlotLines'];
|
|
11
10
|
hoveredPlotBands?: ChartTooltipRendererArgs['hoveredPlotBands'];
|
|
11
|
+
hoveredPlotLines?: ChartTooltipRendererArgs['hoveredPlotLines'];
|
|
12
|
+
hoveredPlotShapes?: ChartTooltipRendererArgs['hoveredPlotShapes'];
|
|
12
13
|
totals?: ChartTooltip['totals'];
|
|
13
14
|
xAxis?: ChartXAxis | null;
|
|
14
15
|
yAxis?: ChartYAxis;
|
|
@@ -2,15 +2,16 @@ import React from 'react';
|
|
|
2
2
|
import isNil from 'lodash/isNil';
|
|
3
3
|
import { DefaultTooltipContent } from './DefaultTooltipContent';
|
|
4
4
|
export const ChartTooltipContent = React.memo((props) => {
|
|
5
|
-
const { hovered, hoveredPlotLines,
|
|
5
|
+
const { hovered, hoveredPlotBands, hoveredPlotLines, hoveredPlotShapes, xAxis, yAxis, renderer, rowRenderer, valueFormat, headerFormat, totals, pinned, qa, } = props;
|
|
6
6
|
if (!hovered) {
|
|
7
7
|
return null;
|
|
8
8
|
}
|
|
9
9
|
const customTooltip = renderer === null || renderer === void 0 ? void 0 : renderer({
|
|
10
10
|
headerFormat,
|
|
11
11
|
hovered,
|
|
12
|
-
hoveredPlotLines,
|
|
13
12
|
hoveredPlotBands,
|
|
13
|
+
hoveredPlotLines,
|
|
14
|
+
hoveredPlotShapes,
|
|
14
15
|
xAxis,
|
|
15
16
|
yAxis,
|
|
16
17
|
});
|
|
@@ -7,7 +7,7 @@ import './styles.css';
|
|
|
7
7
|
const b = block('tooltip');
|
|
8
8
|
export const Tooltip = (props) => {
|
|
9
9
|
const { tooltip, xAxis, yAxis, svgContainer, dispatcher, tooltipPinned, onOutsideClick } = props;
|
|
10
|
-
const { hovered, hoveredPlotLines,
|
|
10
|
+
const { hovered, hoveredPlotBands, hoveredPlotLines, hoveredPlotShapes, pointerPosition } = useTooltip({
|
|
11
11
|
dispatcher,
|
|
12
12
|
tooltip,
|
|
13
13
|
xAxis,
|
|
@@ -28,5 +28,5 @@ export const Tooltip = (props) => {
|
|
|
28
28
|
}, [left, top]);
|
|
29
29
|
return (hovered === null || hovered === void 0 ? void 0 : hovered.length) ? (React.createElement(Popup, { anchorElement: anchor, className: b({ pinned: tooltipPinned }), disableTransition: true, floatingStyles: tooltipPinned ? undefined : { pointerEvents: 'none' }, offset: { mainAxis: 20 }, onOpenChange: tooltipPinned ? handleOnOpenChange : undefined, open: true, placement: ['right', 'left', 'top', 'bottom'] },
|
|
30
30
|
React.createElement("div", { className: b('popup-content') },
|
|
31
|
-
React.createElement(ChartTooltipContent, { hovered: hovered, hoveredPlotLines: hoveredPlotLines,
|
|
31
|
+
React.createElement(ChartTooltipContent, { hovered: hovered, hoveredPlotBands: hoveredPlotBands, hoveredPlotLines: hoveredPlotLines, hoveredPlotShapes: hoveredPlotShapes, pinned: tooltipPinned, renderer: tooltip.renderer, rowRenderer: tooltip.rowRenderer, totals: tooltip.totals, valueFormat: tooltip.valueFormat, headerFormat: tooltip.headerFormat, xAxis: xAxis, yAxis: yAxis, qa: tooltip.qa })))) : null;
|
|
32
32
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AxisCrosshair, AxisPlotBand, BaseTextStyle, ChartAxis, ChartAxisLabels, ChartAxisRangeSlider, ChartAxisTitleAlignment, ChartAxisTitleRotation, ChartAxisType, DeepRequired, MeaningfulAny, PlotLayerPlacement } from '../../types';
|
|
1
|
+
import type { AxisCrosshair, AxisPlotBand, AxisPlotShape, BaseTextStyle, ChartAxis, ChartAxisLabels, ChartAxisRangeSlider, ChartAxisTitleAlignment, ChartAxisTitleRotation, ChartAxisType, DeepRequired, MeaningfulAny, PlotLayerPlacement } from '../../types';
|
|
2
2
|
import type { DashStyle } from '../constants';
|
|
3
3
|
type PreparedAxisLabels = Omit<ChartAxisLabels, 'enabled' | 'padding' | 'style' | 'autoRotation'> & Required<Pick<ChartAxisLabels, 'enabled' | 'padding' | 'margin' | 'rotation' | 'html'>> & {
|
|
4
4
|
style: BaseTextStyle;
|
|
@@ -19,19 +19,35 @@ export type PreparedAxisPlotBand = Required<AxisPlotBand> & {
|
|
|
19
19
|
};
|
|
20
20
|
type PreparedAxisCrosshair = Required<AxisCrosshair>;
|
|
21
21
|
export type PreparedAxisPlotLine = {
|
|
22
|
-
value: number;
|
|
23
22
|
color: string;
|
|
24
|
-
width: number;
|
|
25
|
-
dashStyle: DashStyle;
|
|
26
|
-
opacity: number;
|
|
27
|
-
layerPlacement: PlotLayerPlacement;
|
|
28
23
|
custom?: MeaningfulAny;
|
|
24
|
+
dashStyle: DashStyle;
|
|
25
|
+
hoverThreshold: number;
|
|
29
26
|
label: {
|
|
30
|
-
text: string;
|
|
31
|
-
style: BaseTextStyle;
|
|
32
27
|
padding: number;
|
|
33
28
|
qa?: string;
|
|
29
|
+
style: BaseTextStyle;
|
|
30
|
+
text: string;
|
|
34
31
|
};
|
|
32
|
+
layerPlacement: PlotLayerPlacement;
|
|
33
|
+
opacity: number;
|
|
34
|
+
value: number;
|
|
35
|
+
width: number;
|
|
36
|
+
};
|
|
37
|
+
export type PreparedAxisPlotShape = {
|
|
38
|
+
custom?: MeaningfulAny;
|
|
39
|
+
hitbox: {
|
|
40
|
+
height: number;
|
|
41
|
+
width: number;
|
|
42
|
+
x: number;
|
|
43
|
+
y: number;
|
|
44
|
+
};
|
|
45
|
+
layerPlacement: PlotLayerPlacement;
|
|
46
|
+
opacity: number;
|
|
47
|
+
renderer: AxisPlotShape['renderer'];
|
|
48
|
+
value: number | string;
|
|
49
|
+
x: number;
|
|
50
|
+
y: number;
|
|
35
51
|
};
|
|
36
52
|
export type PreparedRangeSlider = DeepRequired<Omit<ChartAxisRangeSlider, 'defaultRange'>> & {
|
|
37
53
|
defaultRange?: ChartAxisRangeSlider['defaultRange'];
|
|
@@ -40,7 +56,7 @@ export type PreparedAxisTickMarks = {
|
|
|
40
56
|
enabled: boolean;
|
|
41
57
|
length: number;
|
|
42
58
|
};
|
|
43
|
-
type PreparedBaseAxis = Omit<ChartAxis, 'type' | 'labels' | 'plotLines' | 'plotBands'> & {
|
|
59
|
+
type PreparedBaseAxis = Omit<ChartAxis, 'type' | 'labels' | 'plotLines' | 'plotBands' | 'plotShapes'> & {
|
|
44
60
|
type: ChartAxisType;
|
|
45
61
|
labels: PreparedAxisLabels;
|
|
46
62
|
title: {
|
|
@@ -67,6 +83,7 @@ type PreparedBaseAxis = Omit<ChartAxis, 'type' | 'labels' | 'plotLines' | 'plotB
|
|
|
67
83
|
plotIndex: number;
|
|
68
84
|
plotLines: PreparedAxisPlotLine[];
|
|
69
85
|
plotBands: PreparedAxisPlotBand[];
|
|
86
|
+
plotShapes: PreparedAxisPlotShape[];
|
|
70
87
|
crosshair: PreparedAxisCrosshair;
|
|
71
88
|
};
|
|
72
89
|
export type PreparedXAxis = PreparedBaseAxis & {
|