@gravity-ui/charts 1.32.1 → 1.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/ChartInner/useChartInnerProps.js +3 -2
- package/dist/cjs/components/Tooltip/DefaultTooltipContent/index.js +5 -1
- package/dist/cjs/hooks/index.d.ts +2 -0
- package/dist/cjs/hooks/index.js +2 -0
- package/dist/cjs/hooks/useAxis/index.d.ts +5 -3
- package/dist/cjs/hooks/useAxis/index.js +3 -3
- package/dist/cjs/hooks/useAxis/types.d.ts +6 -0
- package/dist/cjs/hooks/useAxis/x-axis.js +2 -0
- package/dist/cjs/hooks/useAxis/y-axis.d.ts +10 -0
- package/dist/cjs/hooks/useAxis/y-axis.js +32 -21
- package/dist/cjs/hooks/useAxisScales/index.d.ts +4 -20
- package/dist/cjs/hooks/useAxisScales/index.js +76 -436
- package/dist/cjs/hooks/useAxisScales/types.d.ts +6 -0
- package/dist/cjs/hooks/useAxisScales/types.js +1 -0
- package/dist/cjs/hooks/useAxisScales/utils.d.ts +12 -7
- package/dist/cjs/hooks/useAxisScales/utils.js +54 -14
- package/dist/cjs/hooks/useAxisScales/x-scale.d.ts +15 -0
- package/dist/cjs/hooks/useAxisScales/x-scale.js +247 -0
- package/dist/cjs/hooks/useAxisScales/y-scale.d.ts +10 -0
- package/dist/cjs/hooks/useAxisScales/y-scale.js +299 -0
- package/dist/cjs/hooks/useNormalizedOriginalData/index.d.ts +2 -0
- package/dist/cjs/hooks/useRangeSlider/index.js +1 -0
- package/dist/cjs/hooks/useRangeSlider/types.d.ts +1 -1
- package/dist/cjs/hooks/useRangeSlider/utils.d.ts +1 -1
- package/dist/cjs/hooks/useShapes/area/prepare-data.d.ts +1 -1
- package/dist/cjs/hooks/useShapes/area/prepare-data.js +25 -11
- package/dist/cjs/hooks/useShapes/bar-x/prepare-data.d.ts +1 -1
- package/dist/cjs/hooks/useShapes/bar-y/prepare-data.d.ts +1 -1
- package/dist/cjs/hooks/useShapes/heatmap/prepare-data.d.ts +1 -1
- package/dist/cjs/hooks/useShapes/index.d.ts +1 -1
- package/dist/cjs/hooks/useShapes/line/prepare-data.d.ts +1 -1
- package/dist/cjs/hooks/useShapes/scatter/prepare-data.d.ts +1 -1
- package/dist/cjs/hooks/useShapes/utils.d.ts +1 -1
- package/dist/cjs/hooks/useShapes/waterfall/prepare-data.d.ts +1 -1
- package/dist/cjs/hooks/useYAxisLabelWidth/index.d.ts +11 -0
- package/dist/cjs/hooks/useYAxisLabelWidth/index.js +48 -0
- package/dist/cjs/hooks/useZoom/index.d.ts +1 -1
- package/dist/cjs/hooks/useZoom/utils.d.ts +1 -1
- package/dist/cjs/hooks/utils/bar-x.d.ts +1 -1
- package/dist/cjs/hooks/utils/bar-x.js +1 -1
- package/dist/cjs/hooks/utils/bar-y.d.ts +1 -1
- package/dist/cjs/hooks/utils/bar-y.js +1 -1
- package/dist/cjs/i18n/keysets/en.json +2 -1
- package/dist/cjs/i18n/keysets/ru.json +2 -1
- package/dist/cjs/types/chart/axis.d.ts +25 -0
- package/dist/cjs/types/chart/tooltip.d.ts +3 -2
- package/dist/cjs/utils/chart/axis/common.d.ts +1 -0
- package/dist/cjs/utils/chart/axis/common.js +6 -0
- package/dist/cjs/validation/validate-axes.js +35 -0
- package/dist/esm/components/ChartInner/useChartInnerProps.js +3 -2
- package/dist/esm/components/Tooltip/DefaultTooltipContent/index.js +5 -1
- package/dist/esm/hooks/index.d.ts +2 -0
- package/dist/esm/hooks/index.js +2 -0
- package/dist/esm/hooks/useAxis/index.d.ts +5 -3
- package/dist/esm/hooks/useAxis/index.js +3 -3
- package/dist/esm/hooks/useAxis/types.d.ts +6 -0
- package/dist/esm/hooks/useAxis/x-axis.js +2 -0
- package/dist/esm/hooks/useAxis/y-axis.d.ts +10 -0
- package/dist/esm/hooks/useAxis/y-axis.js +32 -21
- package/dist/esm/hooks/useAxisScales/index.d.ts +4 -20
- package/dist/esm/hooks/useAxisScales/index.js +76 -436
- package/dist/esm/hooks/useAxisScales/types.d.ts +6 -0
- package/dist/esm/hooks/useAxisScales/types.js +1 -0
- package/dist/esm/hooks/useAxisScales/utils.d.ts +12 -7
- package/dist/esm/hooks/useAxisScales/utils.js +54 -14
- package/dist/esm/hooks/useAxisScales/x-scale.d.ts +15 -0
- package/dist/esm/hooks/useAxisScales/x-scale.js +247 -0
- package/dist/esm/hooks/useAxisScales/y-scale.d.ts +10 -0
- package/dist/esm/hooks/useAxisScales/y-scale.js +299 -0
- package/dist/esm/hooks/useNormalizedOriginalData/index.d.ts +2 -0
- package/dist/esm/hooks/useRangeSlider/index.js +1 -0
- package/dist/esm/hooks/useRangeSlider/types.d.ts +1 -1
- package/dist/esm/hooks/useRangeSlider/utils.d.ts +1 -1
- package/dist/esm/hooks/useShapes/area/prepare-data.d.ts +1 -1
- package/dist/esm/hooks/useShapes/area/prepare-data.js +25 -11
- package/dist/esm/hooks/useShapes/bar-x/prepare-data.d.ts +1 -1
- package/dist/esm/hooks/useShapes/bar-y/prepare-data.d.ts +1 -1
- package/dist/esm/hooks/useShapes/heatmap/prepare-data.d.ts +1 -1
- package/dist/esm/hooks/useShapes/index.d.ts +1 -1
- package/dist/esm/hooks/useShapes/line/prepare-data.d.ts +1 -1
- package/dist/esm/hooks/useShapes/scatter/prepare-data.d.ts +1 -1
- package/dist/esm/hooks/useShapes/utils.d.ts +1 -1
- package/dist/esm/hooks/useShapes/waterfall/prepare-data.d.ts +1 -1
- package/dist/esm/hooks/useYAxisLabelWidth/index.d.ts +11 -0
- package/dist/esm/hooks/useYAxisLabelWidth/index.js +48 -0
- package/dist/esm/hooks/useZoom/index.d.ts +1 -1
- package/dist/esm/hooks/useZoom/utils.d.ts +1 -1
- package/dist/esm/hooks/utils/bar-x.d.ts +1 -1
- package/dist/esm/hooks/utils/bar-x.js +1 -1
- package/dist/esm/hooks/utils/bar-y.d.ts +1 -1
- package/dist/esm/hooks/utils/bar-y.js +1 -1
- package/dist/esm/i18n/keysets/en.json +2 -1
- package/dist/esm/i18n/keysets/ru.json +2 -1
- package/dist/esm/types/chart/axis.d.ts +25 -0
- package/dist/esm/types/chart/tooltip.d.ts +3 -2
- package/dist/esm/utils/chart/axis/common.d.ts +1 -0
- package/dist/esm/utils/chart/axis/common.js +6 -0
- package/dist/esm/validation/validate-axes.js +35 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { DEFAULT_PALETTE, SERIES_TYPE } from '../../constants';
|
|
3
|
-
import { useAxis, useAxisScales, useChartDimensions, useNormalizedOriginalData, usePrevious, useSeries, useShapes, useSplit, useZoom, } from '../../hooks';
|
|
3
|
+
import { useAxis, useAxisScales, useChartDimensions, useNormalizedOriginalData, usePrevious, useSeries, useShapes, useSplit, useYAxisLabelWidth, useZoom, } from '../../hooks';
|
|
4
4
|
import { getYAxisWidth } from '../../hooks/useChartDimensions/utils';
|
|
5
5
|
import { getLegendComponents } from '../../hooks/useSeries/prepare-legend';
|
|
6
6
|
import { getPreparedOptions } from '../../hooks/useSeries/prepare-options';
|
|
@@ -77,7 +77,7 @@ export function useChartInnerProps(props) {
|
|
|
77
77
|
preparedLegend,
|
|
78
78
|
});
|
|
79
79
|
}, [width, height, preparedChart.margin, preparedSeries, preparedLegend]);
|
|
80
|
-
const { xAxis, yAxis } = useAxis({
|
|
80
|
+
const { xAxis, yAxis, setAxes } = useAxis({
|
|
81
81
|
height,
|
|
82
82
|
preparedChart,
|
|
83
83
|
preparedLegend,
|
|
@@ -107,6 +107,7 @@ export function useChartInnerProps(props) {
|
|
|
107
107
|
yAxis,
|
|
108
108
|
zoomState,
|
|
109
109
|
});
|
|
110
|
+
useYAxisLabelWidth({ seriesData: preparedSeries, setAxes, yAxis, yScale });
|
|
110
111
|
const isOutsideBounds = React.useCallback((x, y) => {
|
|
111
112
|
return x < 0 || x > boundsWidth || y < 0 || y > boundsHeight;
|
|
112
113
|
}, [boundsHeight, boundsWidth]);
|
|
@@ -23,7 +23,7 @@ export const DefaultTooltipContent = ({ hovered, pinned, rowRenderer, totals, va
|
|
|
23
23
|
const restHoveredValues = pinned || !visibleRows ? [] : hoveredValues.slice(visibleRows);
|
|
24
24
|
const renderRow = ({ id, name, color, active, striped, value, formattedValue, series, }) => {
|
|
25
25
|
if (typeof rowRenderer === 'function') {
|
|
26
|
-
|
|
26
|
+
const result = rowRenderer({
|
|
27
27
|
id,
|
|
28
28
|
name,
|
|
29
29
|
color,
|
|
@@ -34,6 +34,10 @@ export const DefaultTooltipContent = ({ hovered, pinned, rowRenderer, totals, va
|
|
|
34
34
|
className: b('content-row', { active, striped }),
|
|
35
35
|
hovered,
|
|
36
36
|
});
|
|
37
|
+
if (typeof result === 'string') {
|
|
38
|
+
return React.createElement("div", { key: id, dangerouslySetInnerHTML: { __html: result } });
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
37
41
|
}
|
|
38
42
|
const colorSymbol = getTooltipRowColorSymbol({ series, color });
|
|
39
43
|
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 }));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './useAxis';
|
|
2
2
|
export * from './useAxis/types';
|
|
3
3
|
export * from './useAxisScales';
|
|
4
|
+
export * from './useAxisScales/types';
|
|
4
5
|
export * from './useBrush';
|
|
5
6
|
export * from './useBrush/types';
|
|
6
7
|
export * from './useChartDimensions';
|
|
@@ -16,5 +17,6 @@ export * from './useShapes';
|
|
|
16
17
|
export * from './useSplit';
|
|
17
18
|
export * from './useSplit/types';
|
|
18
19
|
export * from './useTooltip';
|
|
20
|
+
export * from './useYAxisLabelWidth';
|
|
19
21
|
export * from './useZoom';
|
|
20
22
|
export * from './useZoom/types';
|
package/dist/cjs/hooks/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './useAxis';
|
|
2
2
|
export * from './useAxis/types';
|
|
3
3
|
export * from './useAxisScales';
|
|
4
|
+
export * from './useAxisScales/types';
|
|
4
5
|
export * from './useBrush';
|
|
5
6
|
export * from './useBrush/types';
|
|
6
7
|
export * from './useChartDimensions';
|
|
@@ -16,5 +17,6 @@ export * from './useShapes';
|
|
|
16
17
|
export * from './useSplit';
|
|
17
18
|
export * from './useSplit/types';
|
|
18
19
|
export * from './useTooltip';
|
|
20
|
+
export * from './useYAxisLabelWidth';
|
|
19
21
|
export * from './useZoom';
|
|
20
22
|
export * from './useZoom/types';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import type { ChartXAxis, ChartYAxis } from '../../types';
|
|
2
3
|
import type { PreparedChart } from '../useChartOptions/types';
|
|
3
4
|
import type { PreparedLegend, PreparedSeries, PreparedSeriesOptions } from '../useSeries/types';
|
|
4
|
-
import type {
|
|
5
|
+
import type { AxesState } from './types';
|
|
5
6
|
interface UseAxesProps {
|
|
6
7
|
height: number;
|
|
7
8
|
preparedChart: PreparedChart;
|
|
@@ -14,7 +15,8 @@ interface UseAxesProps {
|
|
|
14
15
|
yAxis?: ChartYAxis[];
|
|
15
16
|
}
|
|
16
17
|
export declare function useAxis(props: UseAxesProps): {
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
setAxes: React.Dispatch<React.SetStateAction<AxesState>>;
|
|
19
|
+
xAxis: import("./types").PreparedXAxis | null;
|
|
20
|
+
yAxis: import("./types").PreparedYAxis[];
|
|
19
21
|
};
|
|
20
22
|
export {};
|
|
@@ -5,7 +5,7 @@ import { getPreparedXAxis } from './x-axis';
|
|
|
5
5
|
import { getPreparedYAxis } from './y-axis';
|
|
6
6
|
export function useAxis(props) {
|
|
7
7
|
const { boundsHeight, height, preparedChart, preparedLegend, preparedSeries, preparedSeriesOptions, width, xAxis, yAxis, } = props;
|
|
8
|
-
const [axesState,
|
|
8
|
+
const [axesState, setAxes] = React.useState({ xAxis: null, yAxis: [] });
|
|
9
9
|
const axesStateRunRef = React.useRef(0);
|
|
10
10
|
const prevAxesStateValue = React.useRef(axesState);
|
|
11
11
|
const axesStateReady = React.useRef(false);
|
|
@@ -55,7 +55,7 @@ export function useAxis(props) {
|
|
|
55
55
|
const newStateValue = { xAxis: preparedXAxis, yAxis: preparedYAxis };
|
|
56
56
|
if (axesStateRunRef.current === currentRun) {
|
|
57
57
|
if (!isEqual(prevAxesStateValue.current, newStateValue)) {
|
|
58
|
-
|
|
58
|
+
setAxes(newStateValue);
|
|
59
59
|
prevAxesStateValue.current = newStateValue;
|
|
60
60
|
}
|
|
61
61
|
axesStateReady.current = true;
|
|
@@ -72,5 +72,5 @@ export function useAxis(props) {
|
|
|
72
72
|
xAxis,
|
|
73
73
|
yAxis,
|
|
74
74
|
]);
|
|
75
|
-
return axesStateReady.current ? axesState : { xAxis: null, yAxis: [] };
|
|
75
|
+
return axesStateReady.current ? Object.assign(Object.assign({}, axesState), { setAxes }) : { xAxis: null, yAxis: [], setAxes };
|
|
76
76
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type React from 'react';
|
|
1
2
|
import type { DashStyle } from '../../constants';
|
|
2
3
|
import type { AxisCrosshair, AxisPlotBand, BaseTextStyle, ChartAxis, ChartAxisLabels, ChartAxisRangeSlider, ChartAxisTitleAlignment, ChartAxisType, DeepRequired, PlotLayerPlacement } from '../../types';
|
|
3
4
|
type PreparedAxisLabels = Omit<ChartAxisLabels, 'enabled' | 'padding' | 'style' | 'autoRotation'> & Required<Pick<ChartAxisLabels, 'enabled' | 'padding' | 'margin' | 'rotation' | 'html'>> & {
|
|
@@ -68,4 +69,9 @@ export type PreparedXAxis = PreparedBaseAxis & {
|
|
|
68
69
|
};
|
|
69
70
|
export type PreparedYAxis = PreparedBaseAxis;
|
|
70
71
|
export type PreparedAxis = PreparedXAxis | PreparedYAxis;
|
|
72
|
+
export type AxesState = {
|
|
73
|
+
xAxis: PreparedXAxis | null;
|
|
74
|
+
yAxis: PreparedYAxis[];
|
|
75
|
+
};
|
|
76
|
+
export type SetAxes = React.Dispatch<React.SetStateAction<AxesState>>;
|
|
71
77
|
export {};
|
|
@@ -127,6 +127,8 @@ export const getPreparedXAxis = async ({ xAxis, seriesData, width, boundsWidth,
|
|
|
127
127
|
},
|
|
128
128
|
min: get(xAxis, 'min'),
|
|
129
129
|
max: get(xAxis, 'max'),
|
|
130
|
+
startOnTick: get(xAxis, 'startOnTick'),
|
|
131
|
+
endOnTick: get(xAxis, 'endOnTick'),
|
|
130
132
|
maxPadding,
|
|
131
133
|
grid: {
|
|
132
134
|
enabled: shouldHideGrid ? false : get(xAxis, 'grid.enabled', true),
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import type { ChartSeries, ChartYAxis } from '../../types';
|
|
2
|
+
import type { ChartScale } from '../useAxisScales/types';
|
|
3
|
+
import type { PreparedSeries } from '../useSeries/types';
|
|
2
4
|
import type { PreparedYAxis } from './types';
|
|
5
|
+
export declare const getYAxisLabelMaxWidth: (args: {
|
|
6
|
+
axis: PreparedYAxis;
|
|
7
|
+
seriesData: PreparedSeries[] | ChartSeries[];
|
|
8
|
+
scale?: ChartScale;
|
|
9
|
+
}) => Promise<{
|
|
10
|
+
height: number;
|
|
11
|
+
width: number;
|
|
12
|
+
}>;
|
|
3
13
|
export declare const getPreparedYAxis: ({ height, boundsHeight, width, seriesData, yAxis, }: {
|
|
4
14
|
height: number;
|
|
5
15
|
boundsHeight: number;
|
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
import get from 'lodash/get';
|
|
2
2
|
import { getTickValues } from '../../components/AxisY/utils';
|
|
3
3
|
import { DASH_STYLE, DEFAULT_AXIS_LABEL_FONT_SIZE, DEFAULT_AXIS_TYPE, SERIES_TYPE, axisCrosshairDefaults, axisLabelsDefaults, yAxisTitleDefaults, } from '../../constants';
|
|
4
|
-
import { calculateNumericProperty, formatAxisTickLabel, getDefaultDateFormat, getDefaultMinYAxisValue, getHorizontalHtmlTextHeight, getHorizontalSvgTextHeight, getLabelsSize, getMinSpaceBetween, getTextSizeFn, isAxisRelatedSeries, wrapText, } from '../../utils';
|
|
4
|
+
import { calculateNumericProperty, formatAxisTickLabel, getDefaultDateFormat, getDefaultMinYAxisValue, getHorizontalHtmlTextHeight, getHorizontalSvgTextHeight, getLabelsSize, getMinSpaceBetween, getTextSizeFn, isAxisRelatedSeries, shouldSyncAxisWithPrimary, wrapText, } from '../../utils';
|
|
5
5
|
import { createYScale } from '../useAxisScales';
|
|
6
6
|
import { prepareAxisPlotLabel } from './utils';
|
|
7
|
-
const
|
|
8
|
-
const { axis,
|
|
9
|
-
if (!axis.labels.enabled) {
|
|
10
|
-
return { height: 0, width: 0 };
|
|
11
|
-
}
|
|
12
|
-
const scale = createYScale({
|
|
13
|
-
axis,
|
|
14
|
-
boundsHeight: height,
|
|
15
|
-
series: seriesData,
|
|
16
|
-
});
|
|
17
|
-
if (!scale) {
|
|
7
|
+
export const getYAxisLabelMaxWidth = async (args) => {
|
|
8
|
+
const { axis, scale, seriesData } = args;
|
|
9
|
+
if (!axis.labels.enabled || !scale) {
|
|
18
10
|
return { height: 0, width: 0 };
|
|
19
11
|
}
|
|
20
12
|
const getTextSize = getTextSizeFn({ style: axis.labels.style });
|
|
@@ -104,6 +96,21 @@ export const getPreparedYAxis = ({ height, boundsHeight, width, seriesData, yAxi
|
|
|
104
96
|
const axisType = get(axisItem, 'type', DEFAULT_AXIS_TYPE);
|
|
105
97
|
const shouldHideGrid = axisItem.visible === false ||
|
|
106
98
|
axisSeriesData.some((s) => s.type === SERIES_TYPE.Heatmap);
|
|
99
|
+
let gridEnabled;
|
|
100
|
+
if (shouldHideGrid) {
|
|
101
|
+
gridEnabled = false;
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
const gridEnabledProp = get(axisItem, 'grid.enabled');
|
|
105
|
+
if (firstPlotAxis) {
|
|
106
|
+
gridEnabled = gridEnabledProp !== null && gridEnabledProp !== void 0 ? gridEnabledProp : true;
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
gridEnabled = shouldSyncAxisWithPrimary(axisItem, axisByPlot[plotIndex][0])
|
|
110
|
+
? false
|
|
111
|
+
: !((_g = axisByPlot[plotIndex][0].visible) !== null && _g !== void 0 ? _g : true);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
107
114
|
const preparedAxis = {
|
|
108
115
|
type: axisType,
|
|
109
116
|
labels: {
|
|
@@ -119,7 +126,7 @@ export const getPreparedYAxis = ({ height, boundsHeight, width, seriesData, yAxi
|
|
|
119
126
|
width: 0,
|
|
120
127
|
height: 0,
|
|
121
128
|
lineHeight: labelsLineHeight,
|
|
122
|
-
maxWidth: (
|
|
129
|
+
maxWidth: (_j = calculateNumericProperty({ base: width, value: (_h = axisItem.labels) === null || _h === void 0 ? void 0 : _h.maxWidth })) !== null && _j !== void 0 ? _j : axisLabelsDefaults.maxWidth,
|
|
123
130
|
html: labelsHtml,
|
|
124
131
|
},
|
|
125
132
|
lineColor: get(axisItem, 'lineColor'),
|
|
@@ -133,18 +140,17 @@ export const getPreparedYAxis = ({ height, boundsHeight, width, seriesData, yAxi
|
|
|
133
140
|
height: titleSize.maxHeight * estimatedTitleRows.length,
|
|
134
141
|
align: get(axisItem, 'title.align', yAxisTitleDefaults.align),
|
|
135
142
|
maxRowCount: titleMaxRowsCount,
|
|
136
|
-
html: (
|
|
143
|
+
html: (_l = (_k = axisItem.title) === null || _k === void 0 ? void 0 : _k.html) !== null && _l !== void 0 ? _l : false,
|
|
137
144
|
maxWidth: titleMaxWidth !== null && titleMaxWidth !== void 0 ? titleMaxWidth : Infinity,
|
|
138
145
|
rotation: titleRotation,
|
|
139
146
|
},
|
|
140
|
-
min: (
|
|
147
|
+
min: (_m = get(axisItem, 'min')) !== null && _m !== void 0 ? _m : getDefaultMinYAxisValue(axisSeriesData),
|
|
141
148
|
max: get(axisItem, 'max'),
|
|
149
|
+
startOnTick: get(axisItem, 'startOnTick'),
|
|
150
|
+
endOnTick: get(axisItem, 'endOnTick'),
|
|
142
151
|
maxPadding: get(axisItem, 'maxPadding', getMaxPaddingBySeries({ series: axisSeriesData })),
|
|
143
152
|
grid: {
|
|
144
|
-
enabled:
|
|
145
|
-
? false
|
|
146
|
-
: get(axisItem, 'grid.enabled', firstPlotAxis ||
|
|
147
|
-
(!firstPlotAxis && !((_m = axisByPlot[plotIndex][0].visible) !== null && _m !== void 0 ? _m : true))),
|
|
153
|
+
enabled: gridEnabled,
|
|
148
154
|
},
|
|
149
155
|
ticks: {
|
|
150
156
|
pixelInterval: ((_o = axisItem.ticks) === null || _o === void 0 ? void 0 : _o.interval)
|
|
@@ -186,10 +192,15 @@ export const getPreparedYAxis = ({ height, boundsHeight, width, seriesData, yAxi
|
|
|
186
192
|
order: axisItem.order,
|
|
187
193
|
};
|
|
188
194
|
if (labelsEnabled) {
|
|
189
|
-
const
|
|
195
|
+
const scale = createYScale({
|
|
196
|
+
axis: preparedAxis,
|
|
197
|
+
boundsHeight,
|
|
198
|
+
series: axisSeriesData,
|
|
199
|
+
});
|
|
200
|
+
const { height: labelsHeight, width: labelsWidth } = await getYAxisLabelMaxWidth({
|
|
190
201
|
axis: preparedAxis,
|
|
191
202
|
seriesData: axisSeriesData,
|
|
192
|
-
|
|
203
|
+
scale,
|
|
193
204
|
});
|
|
194
205
|
preparedAxis.labels.height = labelsHeight;
|
|
195
206
|
preparedAxis.labels.width = Math.min(preparedAxis.labels.maxWidth, labelsWidth);
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import type { ScaleBand, ScaleLinear, ScaleTime } from 'd3';
|
|
2
1
|
import type { PreparedAxis, PreparedSeries, PreparedSplit, RangeSliderState, ZoomState } from '../../hooks';
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
export type ChartScaleTime = ScaleTime<number, number>;
|
|
7
|
-
export type ChartScale = ChartScaleBand | ChartScaleLinear | ChartScaleTime;
|
|
2
|
+
import type { ChartScale } from './types';
|
|
3
|
+
export { createXScale } from './x-scale';
|
|
4
|
+
export { createYScale } from './y-scale';
|
|
8
5
|
type Args = {
|
|
9
6
|
boundsWidth: number;
|
|
10
7
|
boundsHeight: number;
|
|
@@ -12,6 +9,7 @@ type Args = {
|
|
|
12
9
|
xAxis: PreparedAxis | null;
|
|
13
10
|
yAxis: PreparedAxis[];
|
|
14
11
|
split: PreparedSplit;
|
|
12
|
+
isRangeSlider?: boolean;
|
|
15
13
|
rangeSliderState?: RangeSliderState;
|
|
16
14
|
zoomState?: Partial<ZoomState>;
|
|
17
15
|
};
|
|
@@ -19,21 +17,7 @@ type ReturnValue = {
|
|
|
19
17
|
xScale?: ChartScale;
|
|
20
18
|
yScale?: (ChartScale | undefined)[];
|
|
21
19
|
};
|
|
22
|
-
export declare function createYScale(args: {
|
|
23
|
-
axis: PreparedAxis;
|
|
24
|
-
boundsHeight: number;
|
|
25
|
-
series: (PreparedSeries | ChartSeries)[];
|
|
26
|
-
zoomStateY?: [number, number];
|
|
27
|
-
}): ScaleBand<string> | ScaleLinear<number, number, never> | ScaleTime<number, number, never> | undefined;
|
|
28
|
-
export declare function createXScale(args: {
|
|
29
|
-
axis: PreparedAxis | ChartAxis;
|
|
30
|
-
boundsWidth: number;
|
|
31
|
-
series: (PreparedSeries | ChartSeries)[];
|
|
32
|
-
rangeSliderState?: RangeSliderState;
|
|
33
|
-
zoomStateX?: [number, number];
|
|
34
|
-
}): ScaleBand<string> | ScaleLinear<number, number, never> | ScaleTime<number, number, never> | undefined;
|
|
35
20
|
/**
|
|
36
21
|
* Uses to create scales for axis related series
|
|
37
22
|
*/
|
|
38
23
|
export declare const useAxisScales: (args: Args) => ReturnValue;
|
|
39
|
-
export {};
|