@gravity-ui/charts 1.38.6 → 1.39.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/prepare-axis-data.d.ts +1 -1
- package/dist/cjs/components/AxisX/prepare-axis-data.js +10 -10
- package/dist/cjs/components/AxisY/prepare-axis-data.d.ts +1 -1
- package/dist/cjs/components/AxisY/prepare-axis-data.js +2 -2
- package/dist/cjs/components/ChartInner/index.js +25 -8
- package/dist/cjs/components/ChartInner/useChartInnerHandlers.d.ts +1 -2
- package/dist/cjs/components/ChartInner/useChartInnerHandlers.js +5 -1
- package/dist/cjs/components/ChartInner/useChartInnerProps.d.ts +19 -20
- package/dist/cjs/components/ChartInner/useChartInnerProps.js +230 -139
- package/dist/cjs/components/ChartInner/useChartInnerState.js +2 -1
- package/dist/cjs/components/ChartInner/useDefaultState.d.ts +26 -0
- package/dist/cjs/components/ChartInner/useDefaultState.js +74 -0
- package/dist/cjs/components/ChartInner/utils/axis.d.ts +44 -0
- package/dist/cjs/components/ChartInner/utils/axis.js +35 -0
- package/dist/cjs/{hooks/useChartOptions → components/ChartInner/utils}/chart.d.ts +2 -2
- package/dist/{esm/components/ChartInner/utils.d.ts → cjs/components/ChartInner/utils/common.d.ts} +2 -1
- package/dist/cjs/components/ChartInner/utils/index.d.ts +7 -0
- package/dist/cjs/components/ChartInner/utils/index.js +7 -0
- package/dist/cjs/components/ChartInner/utils/normalized-original-data.d.ts +33 -0
- package/dist/cjs/components/ChartInner/utils/normalized-original-data.js +21 -0
- package/dist/cjs/{hooks/useChartOptions → components/ChartInner/utils}/title.d.ts +2 -2
- package/dist/{esm/hooks/useChartOptions → cjs/components/ChartInner/utils}/title.js +1 -1
- package/dist/cjs/components/ChartInner/utils/tooltip.d.ts +8 -0
- package/dist/cjs/components/ChartInner/utils/tooltip.js +7 -0
- package/dist/cjs/{hooks/useChartOptions → components/ChartInner/utils}/zoom.d.ts +3 -3
- package/dist/{esm/hooks/useChartOptions → cjs/components/ChartInner/utils}/zoom.js +1 -1
- package/dist/cjs/components/Legend/index.d.ts +1 -1
- package/dist/cjs/components/Legend/index.js +1 -1
- package/dist/cjs/hooks/index.d.ts +1 -4
- package/dist/cjs/hooks/index.js +1 -4
- package/dist/cjs/hooks/{useChartOptions/types.d.ts → types.d.ts} +1 -1
- package/dist/cjs/hooks/useAxis/index.d.ts +41 -6
- package/dist/cjs/hooks/useAxis/index.js +55 -40
- package/dist/cjs/hooks/useAxis/types.d.ts +0 -2
- package/dist/cjs/hooks/useAxis/y-axis.js +1 -3
- package/dist/cjs/hooks/useAxisScales/index.d.ts +4 -0
- package/dist/cjs/hooks/useAxisScales/index.js +1 -1
- package/dist/cjs/hooks/useAxisScales/x-scale.js +0 -1
- package/dist/cjs/hooks/useAxisScales/y-scale.js +0 -1
- package/dist/cjs/hooks/useCrosshair/index.d.ts +1 -1
- package/dist/cjs/hooks/useRangeSlider/types.d.ts +1 -1
- package/dist/cjs/hooks/useRangeSlider/utils.d.ts +1 -1
- package/dist/cjs/hooks/useSeries/index.d.ts +10 -14
- package/dist/cjs/hooks/useSeries/index.js +8 -80
- package/dist/cjs/hooks/useSeries/prepare-area.d.ts +2 -2
- package/dist/cjs/hooks/useSeries/prepare-legend.d.ts +1 -1
- package/dist/cjs/hooks/useSeries/prepare-line.d.ts +2 -2
- package/dist/cjs/hooks/useSeries/prepare-radar.d.ts +1 -1
- package/dist/cjs/hooks/useShapes/index.d.ts +4 -0
- package/dist/cjs/hooks/useShapes/index.js +209 -189
- package/dist/cjs/hooks/useShapes/pie/prepare-data.js +0 -1
- package/dist/cjs/hooks/useSplit/index.d.ts +5 -2
- package/dist/cjs/hooks/useSplit/index.js +27 -30
- package/dist/cjs/hooks/useTooltip/index.d.ts +1 -1
- package/dist/cjs/hooks/useZoom/index.d.ts +2 -2
- package/dist/cjs/hooks/useZoom/index.js +2 -2
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/types/index.d.ts +24 -11
- package/dist/cjs/utils/chart/axis/common.d.ts +2 -2
- package/dist/cjs/utils/chart/axis/common.js +1 -1
- package/dist/cjs/utils/chart/chart-dimensions.d.ts +24 -0
- package/dist/cjs/{hooks/useChartDimensions/index.js → utils/chart/chart-dimensions.js} +56 -33
- package/dist/cjs/utils/chart/common.d.ts +28 -0
- package/dist/cjs/utils/chart/common.js +192 -0
- package/dist/cjs/utils/chart/get-closest-data.js +0 -1
- package/dist/cjs/utils/chart/index.d.ts +2 -28
- package/dist/cjs/utils/chart/index.js +2 -192
- package/dist/cjs/utils/chart/tooltip.d.ts +6 -0
- package/dist/cjs/{hooks/useChartOptions → utils/chart}/tooltip.js +2 -7
- package/dist/cjs/utils/chart/zoom.js +0 -2
- package/dist/esm/components/AxisX/prepare-axis-data.d.ts +1 -1
- package/dist/esm/components/AxisX/prepare-axis-data.js +10 -10
- package/dist/esm/components/AxisY/prepare-axis-data.d.ts +1 -1
- package/dist/esm/components/AxisY/prepare-axis-data.js +2 -2
- package/dist/esm/components/ChartInner/index.js +25 -8
- package/dist/esm/components/ChartInner/useChartInnerHandlers.d.ts +1 -2
- package/dist/esm/components/ChartInner/useChartInnerHandlers.js +5 -1
- package/dist/esm/components/ChartInner/useChartInnerProps.d.ts +19 -20
- package/dist/esm/components/ChartInner/useChartInnerProps.js +230 -139
- package/dist/esm/components/ChartInner/useChartInnerState.js +2 -1
- package/dist/esm/components/ChartInner/useDefaultState.d.ts +26 -0
- package/dist/esm/components/ChartInner/useDefaultState.js +74 -0
- package/dist/esm/components/ChartInner/utils/axis.d.ts +44 -0
- package/dist/esm/components/ChartInner/utils/axis.js +35 -0
- package/dist/esm/{hooks/useChartOptions → components/ChartInner/utils}/chart.d.ts +2 -2
- package/dist/{cjs/components/ChartInner/utils.d.ts → esm/components/ChartInner/utils/common.d.ts} +2 -1
- package/dist/esm/components/ChartInner/utils/index.d.ts +7 -0
- package/dist/esm/components/ChartInner/utils/index.js +7 -0
- package/dist/esm/components/ChartInner/utils/normalized-original-data.d.ts +33 -0
- package/dist/esm/components/ChartInner/utils/normalized-original-data.js +21 -0
- package/dist/esm/{hooks/useChartOptions → components/ChartInner/utils}/title.d.ts +2 -2
- package/dist/{cjs/hooks/useChartOptions → esm/components/ChartInner/utils}/title.js +1 -1
- package/dist/esm/components/ChartInner/utils/tooltip.d.ts +8 -0
- package/dist/esm/components/ChartInner/utils/tooltip.js +7 -0
- package/dist/esm/{hooks/useChartOptions → components/ChartInner/utils}/zoom.d.ts +3 -3
- package/dist/{cjs/hooks/useChartOptions → esm/components/ChartInner/utils}/zoom.js +1 -1
- package/dist/esm/components/Legend/index.d.ts +1 -1
- package/dist/esm/components/Legend/index.js +1 -1
- package/dist/esm/hooks/index.d.ts +1 -4
- package/dist/esm/hooks/index.js +1 -4
- package/dist/esm/hooks/{useChartOptions/types.d.ts → types.d.ts} +1 -1
- package/dist/esm/hooks/useAxis/index.d.ts +41 -6
- package/dist/esm/hooks/useAxis/index.js +55 -40
- package/dist/esm/hooks/useAxis/types.d.ts +0 -2
- package/dist/esm/hooks/useAxis/y-axis.js +1 -3
- package/dist/esm/hooks/useAxisScales/index.d.ts +4 -0
- package/dist/esm/hooks/useAxisScales/index.js +1 -1
- package/dist/esm/hooks/useAxisScales/x-scale.js +0 -1
- package/dist/esm/hooks/useAxisScales/y-scale.js +0 -1
- package/dist/esm/hooks/useCrosshair/index.d.ts +1 -1
- package/dist/esm/hooks/useRangeSlider/types.d.ts +1 -1
- package/dist/esm/hooks/useRangeSlider/utils.d.ts +1 -1
- package/dist/esm/hooks/useSeries/index.d.ts +10 -14
- package/dist/esm/hooks/useSeries/index.js +8 -80
- package/dist/esm/hooks/useSeries/prepare-area.d.ts +2 -2
- package/dist/esm/hooks/useSeries/prepare-legend.d.ts +1 -1
- package/dist/esm/hooks/useSeries/prepare-line.d.ts +2 -2
- package/dist/esm/hooks/useSeries/prepare-radar.d.ts +1 -1
- package/dist/esm/hooks/useShapes/index.d.ts +4 -0
- package/dist/esm/hooks/useShapes/index.js +209 -189
- package/dist/esm/hooks/useShapes/pie/prepare-data.js +0 -1
- package/dist/esm/hooks/useSplit/index.d.ts +5 -2
- package/dist/esm/hooks/useSplit/index.js +27 -30
- package/dist/esm/hooks/useTooltip/index.d.ts +1 -1
- package/dist/esm/hooks/useZoom/index.d.ts +2 -2
- package/dist/esm/hooks/useZoom/index.js +2 -2
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/types/index.d.ts +24 -11
- package/dist/esm/utils/chart/axis/common.d.ts +2 -2
- package/dist/esm/utils/chart/axis/common.js +1 -1
- package/dist/esm/utils/chart/chart-dimensions.d.ts +24 -0
- package/dist/esm/{hooks/useChartDimensions/index.js → utils/chart/chart-dimensions.js} +56 -33
- package/dist/esm/utils/chart/common.d.ts +28 -0
- package/dist/esm/utils/chart/common.js +192 -0
- package/dist/esm/utils/chart/get-closest-data.js +0 -1
- package/dist/esm/utils/chart/index.d.ts +2 -28
- package/dist/esm/utils/chart/index.js +2 -192
- package/dist/esm/utils/chart/tooltip.d.ts +6 -0
- package/dist/esm/{hooks/useChartOptions → utils/chart}/tooltip.js +2 -7
- package/dist/esm/utils/chart/zoom.js +0 -2
- package/package.json +3 -1
- package/dist/cjs/components/ChartInner/useLegend.d.ts +0 -14
- package/dist/cjs/components/ChartInner/useLegend.js +0 -34
- package/dist/cjs/hooks/useChartDimensions/index.d.ts +0 -17
- package/dist/cjs/hooks/useChartDimensions/utils.d.ts +0 -10
- package/dist/cjs/hooks/useChartDimensions/utils.js +0 -41
- package/dist/cjs/hooks/useChartOptions/tooltip.d.ts +0 -13
- package/dist/cjs/hooks/useNormalizedOriginalData/index.d.ts +0 -38
- package/dist/cjs/hooks/useNormalizedOriginalData/index.js +0 -32
- package/dist/cjs/hooks/useYAxisLabelWidth/index.d.ts +0 -11
- package/dist/cjs/hooks/useYAxisLabelWidth/index.js +0 -48
- package/dist/esm/components/ChartInner/useLegend.d.ts +0 -14
- package/dist/esm/components/ChartInner/useLegend.js +0 -34
- package/dist/esm/hooks/useChartDimensions/index.d.ts +0 -17
- package/dist/esm/hooks/useChartDimensions/utils.d.ts +0 -10
- package/dist/esm/hooks/useChartDimensions/utils.js +0 -41
- package/dist/esm/hooks/useChartOptions/tooltip.d.ts +0 -13
- package/dist/esm/hooks/useNormalizedOriginalData/index.d.ts +0 -38
- package/dist/esm/hooks/useNormalizedOriginalData/index.js +0 -32
- package/dist/esm/hooks/useYAxisLabelWidth/index.d.ts +0 -11
- package/dist/esm/hooks/useYAxisLabelWidth/index.js +0 -48
- /package/dist/cjs/{hooks/useChartOptions → components/ChartInner/utils}/chart.js +0 -0
- /package/dist/cjs/components/ChartInner/{utils.js → utils/common.js} +0 -0
- /package/dist/cjs/hooks/{useChartOptions/types.js → types.js} +0 -0
- /package/dist/esm/{hooks/useChartOptions → components/ChartInner/utils}/chart.js +0 -0
- /package/dist/esm/components/ChartInner/{utils.js → utils/common.js} +0 -0
- /package/dist/esm/hooks/{useChartOptions/types.js → types.js} +0 -0
|
@@ -68,21 +68,21 @@ async function getSvgAxisLabel({ getTextSize, text, axis, top, left, labelMaxWid
|
|
|
68
68
|
};
|
|
69
69
|
return svgLabel;
|
|
70
70
|
}
|
|
71
|
-
// eslint-disable-next-line complexity
|
|
72
71
|
export async function prepareXAxisData({ axis, boundsOffsetLeft, boundsOffsetRight, boundsWidth, height, scale, series, split, yAxis, }) {
|
|
73
|
-
var _a, _b, _c, _d, _e, _f;
|
|
72
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
74
73
|
const xAxisItems = [];
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
const splitPlots = (_a = split === null || split === void 0 ? void 0 : split.plots) !== null && _a !== void 0 ? _a : [];
|
|
75
|
+
for (let plotIndex = 0; plotIndex < splitPlots.length; plotIndex++) {
|
|
76
|
+
const plot = splitPlots[plotIndex];
|
|
77
77
|
const axisTop = plot.top;
|
|
78
78
|
const axisHeight = plot.height;
|
|
79
79
|
const axisWidth = boundsWidth;
|
|
80
|
-
const isBottomPlot = plotIndex ===
|
|
80
|
+
const isBottomPlot = plotIndex === splitPlots.length - 1;
|
|
81
81
|
const plotYAxes = yAxis.filter((a) => a.plotIndex === plotIndex);
|
|
82
|
-
const yDomainLeftPosition = ((
|
|
82
|
+
const yDomainLeftPosition = ((_b = plotYAxes.find((a) => a.position === 'left')) === null || _b === void 0 ? void 0 : _b.visible)
|
|
83
83
|
? 0
|
|
84
84
|
: null;
|
|
85
|
-
const yDomainRightPosition = ((
|
|
85
|
+
const yDomainRightPosition = ((_c = plotYAxes.find((a) => a.position === 'right')) === null || _c === void 0 ? void 0 : _c.visible)
|
|
86
86
|
? axisWidth
|
|
87
87
|
: null;
|
|
88
88
|
let domain = null;
|
|
@@ -90,7 +90,7 @@ export async function prepareXAxisData({ axis, boundsOffsetLeft, boundsOffsetRig
|
|
|
90
90
|
domain = {
|
|
91
91
|
start: [0, axisTop + axisHeight],
|
|
92
92
|
end: [axisWidth, axisTop + axisHeight],
|
|
93
|
-
lineColor: (
|
|
93
|
+
lineColor: (_d = axis.lineColor) !== null && _d !== void 0 ? _d : '',
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
96
|
const ticks = [];
|
|
@@ -255,7 +255,7 @@ export async function prepareXAxisData({ axis, boundsOffsetLeft, boundsOffsetRig
|
|
|
255
255
|
axisScale,
|
|
256
256
|
axis: 'x',
|
|
257
257
|
});
|
|
258
|
-
const halfBandwidth = ((
|
|
258
|
+
const halfBandwidth = ((_f = (_e = axisScale.bandwidth) === null || _e === void 0 ? void 0 : _e.call(axisScale)) !== null && _f !== void 0 ? _f : 0) / 2;
|
|
259
259
|
const startPos = halfBandwidth + Math.min(from, to);
|
|
260
260
|
const endPos = Math.min(Math.abs(to - from), axisWidth - Math.min(from, to));
|
|
261
261
|
const getPlotLabelSize = getTextSizeFn({ style: plotBand.label.style });
|
|
@@ -279,7 +279,7 @@ export async function prepareXAxisData({ axis, boundsOffsetLeft, boundsOffsetRig
|
|
|
279
279
|
text: plotBand.label.text,
|
|
280
280
|
style: plotBand.label.style,
|
|
281
281
|
x: plotBand.label.padding,
|
|
282
|
-
y: plotBand.label.padding + ((
|
|
282
|
+
y: plotBand.label.padding + ((_g = labelSize === null || labelSize === void 0 ? void 0 : labelSize.width) !== null && _g !== void 0 ? _g : 0),
|
|
283
283
|
rotate: -90,
|
|
284
284
|
qa: plotBand.label.qa,
|
|
285
285
|
}
|
|
@@ -2,7 +2,7 @@ import type { ChartScale, PreparedAxis, PreparedSeries, PreparedSplit } from '..
|
|
|
2
2
|
import type { AxisYData } from './types';
|
|
3
3
|
export declare function prepareYAxisData({ axis, split, scale, top: topOffset, width, height, series, }: {
|
|
4
4
|
axis: PreparedAxis;
|
|
5
|
-
split: PreparedSplit;
|
|
5
|
+
split: PreparedSplit | undefined;
|
|
6
6
|
scale: ChartScale;
|
|
7
7
|
top: number;
|
|
8
8
|
width: number;
|
|
@@ -110,8 +110,8 @@ async function getSvgAxisLabel({ getTextSize, text, axis, top, left, labelMaxHei
|
|
|
110
110
|
}
|
|
111
111
|
export async function prepareYAxisData({ axis, split, scale, top: topOffset, width, height, series, }) {
|
|
112
112
|
var _a, _b, _c;
|
|
113
|
-
const axisPlotTopPosition = ((_a = split.plots[axis.plotIndex]) === null || _a === void 0 ? void 0 : _a.top) || 0;
|
|
114
|
-
const axisHeight = ((_b = split.plots[axis.plotIndex]) === null || _b === void 0 ? void 0 : _b.height) || height;
|
|
113
|
+
const axisPlotTopPosition = ((_a = split === null || split === void 0 ? void 0 : split.plots[axis.plotIndex]) === null || _a === void 0 ? void 0 : _a.top) || 0;
|
|
114
|
+
const axisHeight = ((_b = split === null || split === void 0 ? void 0 : split.plots[axis.plotIndex]) === null || _b === void 0 ? void 0 : _b.height) || height;
|
|
115
115
|
const domainX = axis.position === 'left' ? 0 : width;
|
|
116
116
|
let domain = null;
|
|
117
117
|
if (axis.visible) {
|
|
@@ -3,9 +3,6 @@ import { ArrowRotateLeft } from '@gravity-ui/icons';
|
|
|
3
3
|
import { Button, ButtonIcon, useUniqId } from '@gravity-ui/uikit';
|
|
4
4
|
import { useCrosshair, usePrevious } from '../../hooks';
|
|
5
5
|
import { getPreparedRangeSlider } from '../../hooks/useAxis/range-slider';
|
|
6
|
-
import { getPreparedChart } from '../../hooks/useChartOptions/chart';
|
|
7
|
-
import { getPreparedTitle } from '../../hooks/useChartOptions/title';
|
|
8
|
-
import { getPreparedTooltip } from '../../hooks/useChartOptions/tooltip';
|
|
9
6
|
import { getClipPathIdByBounds } from '../../hooks/useShapes/utils';
|
|
10
7
|
import { EventType, block, getDispatcher, isBandScale } from '../../utils';
|
|
11
8
|
import { AxisX } from '../AxisX/AxisX';
|
|
@@ -21,7 +18,8 @@ import { getInitialRangeSliderState } from '../utils';
|
|
|
21
18
|
import { useChartInnerHandlers } from './useChartInnerHandlers';
|
|
22
19
|
import { useChartInnerProps } from './useChartInnerProps';
|
|
23
20
|
import { useChartInnerState } from './useChartInnerState';
|
|
24
|
-
import {
|
|
21
|
+
import { useDefaultState } from './useDefaultState';
|
|
22
|
+
import { getPreparedChart, getPreparedTitle, getPreparedTooltip, getResetZoomButtonStyle, useAsyncState, useDebouncedValue, } from './utils';
|
|
25
23
|
import './styles.css';
|
|
26
24
|
const b = block('chart');
|
|
27
25
|
const DEBOUNCED_VALUE_DELAY = 10;
|
|
@@ -63,12 +61,14 @@ export const ChartInner = (props) => {
|
|
|
63
61
|
preparedRangeSlider,
|
|
64
62
|
tooltip: preparedTooltip,
|
|
65
63
|
});
|
|
66
|
-
const { allPreparedSeries, boundsHeight, boundsOffsetLeft, boundsOffsetTop, boundsWidth, handleLegendItemClick,
|
|
64
|
+
const { 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,
|
|
67
65
|
dispatcher,
|
|
68
66
|
htmlLayout, plotNode: plotRef.current, preparedChart,
|
|
69
67
|
rangeSliderState,
|
|
70
68
|
updateZoomState,
|
|
71
69
|
zoomState }));
|
|
70
|
+
const prevWidth = usePrevious(width);
|
|
71
|
+
const prevHeight = usePrevious(height);
|
|
72
72
|
const debouncedBoundsWidth = useDebouncedValue({
|
|
73
73
|
value: boundsWidth,
|
|
74
74
|
delay: DEBOUNCED_VALUE_DELAY,
|
|
@@ -97,7 +97,21 @@ export const ChartInner = (props) => {
|
|
|
97
97
|
xScale,
|
|
98
98
|
yScale,
|
|
99
99
|
tooltipThrottle: preparedTooltip.throttle,
|
|
100
|
-
|
|
100
|
+
});
|
|
101
|
+
useDefaultState({
|
|
102
|
+
boundsHeight,
|
|
103
|
+
boundsOffsetLeft,
|
|
104
|
+
boundsOffsetTop,
|
|
105
|
+
boundsWidth,
|
|
106
|
+
defaultState: data.defaultState,
|
|
107
|
+
dispatcher,
|
|
108
|
+
shapesData,
|
|
109
|
+
shapesReady,
|
|
110
|
+
svgRef,
|
|
111
|
+
xAxis,
|
|
112
|
+
yAxis,
|
|
113
|
+
xScale,
|
|
114
|
+
yScale,
|
|
101
115
|
});
|
|
102
116
|
const clickHandler = (_b = (_a = data.chart) === null || _a === void 0 ? void 0 : _a.events) === null || _b === void 0 ? void 0 : _b.click;
|
|
103
117
|
const pointerMoveHandler = (_d = (_c = data.chart) === null || _c === void 0 ? void 0 : _c.events) === null || _d === void 0 ? void 0 : _d.pointermove;
|
|
@@ -237,7 +251,7 @@ export const ChartInner = (props) => {
|
|
|
237
251
|
React.createElement("clipPath", { id: getClipPathIdByBounds({ clipPathId, bounds: 'horizontal' }) },
|
|
238
252
|
React.createElement("rect", { x: 0, y: -boundsHeight, width: boundsWidth, height: boundsHeight * 3 }))),
|
|
239
253
|
preparedTitle && React.createElement(Title, Object.assign({}, preparedTitle, { chartWidth: width })),
|
|
240
|
-
React.createElement("g", { transform: `translate(0, ${boundsOffsetTop})` }, preparedSplit.plots.map((plot, index) => {
|
|
254
|
+
React.createElement("g", { transform: `translate(0, ${boundsOffsetTop})` }, preparedSplit === null || preparedSplit === void 0 ? void 0 : preparedSplit.plots.map((plot, index) => {
|
|
241
255
|
return React.createElement(PlotTitle, { key: `plot-${index}`, title: plot.title });
|
|
242
256
|
})),
|
|
243
257
|
React.createElement("g", { className: b('content'), width: boundsWidth, height: boundsHeight, transform: `translate(${[boundsOffsetLeft, boundsOffsetTop].join(',')})`, ref: plotRef },
|
|
@@ -253,7 +267,10 @@ export const ChartInner = (props) => {
|
|
|
253
267
|
React.createElement("g", { ref: plotBeforeRef }),
|
|
254
268
|
shapes,
|
|
255
269
|
React.createElement("g", { ref: plotAfterRef })),
|
|
256
|
-
((_e = xAxis === null || xAxis === void 0 ? void 0 : xAxis.rangeSlider) === null || _e === void 0 ? void 0 : _e.enabled) &&
|
|
270
|
+
((_e = xAxis === null || xAxis === void 0 ? void 0 : xAxis.rangeSlider) === null || _e === void 0 ? void 0 : _e.enabled) &&
|
|
271
|
+
preparedLegend &&
|
|
272
|
+
debouncedAllPreparedSeries &&
|
|
273
|
+
preparedSeriesOptions && (React.createElement(RangeSlider, { 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 })),
|
|
257
274
|
(preparedLegend === null || preparedLegend === void 0 ? void 0 : preparedLegend.enabled) && legendConfig && (React.createElement(Legend, { chartSeries: preparedSeries, legend: preparedLegend, items: legendItems, config: legendConfig, onItemClick: handleLegendItemClick, onUpdate: unpinTooltip, htmlLayout: htmlLayout }))));
|
|
258
275
|
return (React.createElement("div", { className: b() },
|
|
259
276
|
React.createElement("svg", { ref: svgRef, width: width, height: height,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import type { Dispatch } from 'd3';
|
|
3
3
|
import type { PreparedXAxis, PreparedYAxis, ShapeData } from '../../hooks';
|
|
4
4
|
import type { ChartScale } from '../../hooks/useAxisScales/types';
|
|
@@ -20,7 +20,6 @@ type Props = {
|
|
|
20
20
|
xScale?: ChartScale;
|
|
21
21
|
yScale?: (ChartScale | undefined)[];
|
|
22
22
|
tooltipThrottle: number;
|
|
23
|
-
isOutsideBounds: (x: number, y: number) => boolean;
|
|
24
23
|
};
|
|
25
24
|
export declare function useChartInnerHandlers(props: Props): {
|
|
26
25
|
handleChartClick: (event: React.MouseEvent<SVGSVGElement>) => void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { pointer } from 'd3';
|
|
2
3
|
import get from 'lodash/get';
|
|
3
4
|
import throttle from 'lodash/throttle';
|
|
@@ -6,7 +7,10 @@ import { EventType } from '../../utils';
|
|
|
6
7
|
import { getClosestPoints } from '../../utils/chart/get-closest-data';
|
|
7
8
|
import { getHoveredPlots } from '../../utils/chart/get-hovered-plots';
|
|
8
9
|
export function useChartInnerHandlers(props) {
|
|
9
|
-
const { boundsHeight, boundsOffsetLeft, boundsOffsetTop, boundsWidth, dispatcher, shapesData, svgContainer, togglePinTooltip, tooltipPinned, unpinTooltip, xAxis, yAxis, xScale, yScale, tooltipThrottle,
|
|
10
|
+
const { boundsHeight, boundsOffsetLeft, boundsOffsetTop, boundsWidth, dispatcher, shapesData, svgContainer, togglePinTooltip, tooltipPinned, unpinTooltip, xAxis, yAxis, xScale, yScale, tooltipThrottle, } = props;
|
|
11
|
+
const isOutsideBounds = React.useCallback((x, y) => {
|
|
12
|
+
return x < 0 || x > boundsWidth || y < 0 || y > boundsHeight;
|
|
13
|
+
}, [boundsHeight, boundsWidth]);
|
|
10
14
|
const handleMove = ([pointerX, pointerY], event) => {
|
|
11
15
|
if (tooltipPinned) {
|
|
12
16
|
return;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { Dispatch } from 'd3';
|
|
3
|
-
import type {
|
|
3
|
+
import type { ChartScale, LegendItem, OnLegendItemClick, PreparedLegend, PreparedSeries, PreparedSplit, PreparedXAxis, RangeSliderState, ShapeData, ZoomState } from '../../hooks';
|
|
4
|
+
import type { PreparedChart } from '../../hooks/types';
|
|
4
5
|
import type { LegendConfig } from '../../types';
|
|
5
6
|
import type { ChartInnerProps } from './types';
|
|
6
7
|
type Props = ChartInnerProps & {
|
|
@@ -14,29 +15,15 @@ type Props = ChartInnerProps & {
|
|
|
14
15
|
rangeSliderState?: RangeSliderState;
|
|
15
16
|
};
|
|
16
17
|
export declare function useChartInnerProps(props: Props): {
|
|
17
|
-
|
|
18
|
-
boundsHeight: number;
|
|
18
|
+
preparedSeries: PreparedSeries[];
|
|
19
19
|
boundsOffsetLeft: number;
|
|
20
20
|
boundsOffsetTop: number;
|
|
21
|
+
boundsHeight: number;
|
|
21
22
|
boundsWidth: number;
|
|
22
|
-
|
|
23
|
-
isOutsideBounds: (x: number, y: number) => boolean;
|
|
24
|
-
legendConfig: LegendConfig | undefined;
|
|
25
|
-
legendItems: import("../../hooks").LegendItem[][];
|
|
26
|
-
preparedLegend: PreparedLegend | null;
|
|
27
|
-
preparedSeries: import("../../hooks").PreparedSeries[];
|
|
28
|
-
preparedSeriesOptions: import("../../constants").SeriesOptionsDefaults;
|
|
29
|
-
preparedSplit: import("../../hooks").PreparedSplit;
|
|
30
|
-
prevHeight: number | undefined;
|
|
31
|
-
prevWidth: number | undefined;
|
|
32
|
-
shapes: React.ReactElement<any, string | React.JSXElementConstructor<any>>[];
|
|
33
|
-
shapesData: import("../../hooks").ShapeData[];
|
|
34
|
-
shapesReady: boolean;
|
|
35
|
-
xAxis: import("../../hooks").PreparedXAxis | null;
|
|
36
|
-
xScale: import("../../hooks").ChartScale | undefined;
|
|
23
|
+
xAxis: PreparedXAxis | null;
|
|
37
24
|
yAxis: (Omit<import("../../types").ChartAxis, "type" | "labels" | "plotLines" | "plotBands"> & {
|
|
38
25
|
type: import("../../types").ChartAxisType;
|
|
39
|
-
labels: Omit<import("../../types").ChartAxisLabels, "
|
|
26
|
+
labels: Omit<import("../../types").ChartAxisLabels, "style" | "enabled" | "padding" | "autoRotation"> & Required<Pick<import("../../types").ChartAxisLabels, "margin" | "enabled" | "html" | "rotation" | "padding">> & {
|
|
40
27
|
style: import("../../types").BaseTextStyle;
|
|
41
28
|
rotation: number;
|
|
42
29
|
height: number;
|
|
@@ -71,6 +58,18 @@ export declare function useChartInnerProps(props: Props): {
|
|
|
71
58
|
plotBands: import("../../hooks").PreparedAxisPlotBand[];
|
|
72
59
|
crosshair: Required<import("../../types").AxisCrosshair>;
|
|
73
60
|
})[];
|
|
74
|
-
|
|
61
|
+
shapesData: ShapeData[];
|
|
62
|
+
shapesReady: boolean;
|
|
63
|
+
handleLegendItemClick: OnLegendItemClick;
|
|
64
|
+
allPreparedSeries?: PreparedSeries[] | undefined;
|
|
65
|
+
legendConfig?: LegendConfig | undefined;
|
|
66
|
+
legendItems?: LegendItem[][] | undefined;
|
|
67
|
+
preparedLegend?: PreparedLegend | undefined;
|
|
68
|
+
preparedSeriesOptions?: import("../../constants").SeriesOptionsDefaults | undefined;
|
|
69
|
+
preparedSplit?: PreparedSplit | undefined;
|
|
70
|
+
shapes?: React.ReactElement<any, string | React.JSXElementConstructor<any>>[] | undefined;
|
|
71
|
+
xScale?: ChartScale | undefined;
|
|
72
|
+
yScale?: (ChartScale | undefined)[] | undefined;
|
|
73
|
+
activeLegendItems?: string[] | undefined;
|
|
75
74
|
};
|
|
76
75
|
export {};
|