@gravity-ui/charts 1.38.7 → 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.js +0 -1
- package/dist/cjs/components/ChartInner/index.js +18 -6
- 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 +3 -3
- package/dist/cjs/components/ChartInner/useChartInnerProps.js +14 -17
- 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/{esm/hooks/useYAxisLabelWidth/index.js → cjs/components/ChartInner/utils/axis.js} +1 -1
- package/dist/cjs/{hooks/useChartOptions → components/ChartInner/utils}/chart.d.ts +2 -2
- package/dist/cjs/components/ChartInner/{utils.d.ts → 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/{hooks/useNormalizedOriginalData/index.d.ts → components/ChartInner/utils/normalized-original-data.d.ts} +10 -10
- package/dist/{esm/hooks/useNormalizedOriginalData/index.js → cjs/components/ChartInner/utils/normalized-original-data.js} +1 -1
- 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/cjs/{hooks/useChartOptions → components/ChartInner/utils}/zoom.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 +2 -2
- package/dist/cjs/hooks/useAxis/index.js +1 -1
- package/dist/cjs/hooks/useAxis/y-axis.js +1 -3
- package/dist/cjs/hooks/useAxisScales/x-scale.js +0 -1
- package/dist/cjs/hooks/useAxisScales/y-scale.js +0 -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/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.js +19 -4
- package/dist/cjs/hooks/useShapes/pie/prepare-data.js +0 -1
- package/dist/cjs/hooks/useTooltip/index.d.ts +1 -1
- package/dist/cjs/hooks/useZoom/index.d.ts +1 -1
- 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 +1 -1
- package/dist/cjs/utils/chart/chart-dimensions.d.ts +24 -0
- package/dist/{esm/hooks/useChartDimensions/index.js → cjs/utils/chart/chart-dimensions.js} +43 -5
- 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/{esm/hooks/useChartOptions → cjs/utils/chart}/tooltip.js +2 -7
- package/dist/cjs/utils/chart/zoom.js +0 -2
- package/dist/esm/components/AxisX/prepare-axis-data.js +0 -1
- package/dist/esm/components/ChartInner/index.js +18 -6
- 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 +3 -3
- package/dist/esm/components/ChartInner/useChartInnerProps.js +14 -17
- 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/{cjs/hooks/useYAxisLabelWidth/index.js → esm/components/ChartInner/utils/axis.js} +1 -1
- package/dist/esm/{hooks/useChartOptions → components/ChartInner/utils}/chart.d.ts +2 -2
- package/dist/esm/components/ChartInner/{utils.d.ts → 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/{hooks/useNormalizedOriginalData/index.d.ts → components/ChartInner/utils/normalized-original-data.d.ts} +10 -10
- package/dist/{cjs/hooks/useNormalizedOriginalData/index.js → esm/components/ChartInner/utils/normalized-original-data.js} +1 -1
- 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/esm/{hooks/useChartOptions → components/ChartInner/utils}/zoom.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 +2 -2
- package/dist/esm/hooks/useAxis/index.js +1 -1
- package/dist/esm/hooks/useAxis/y-axis.js +1 -3
- package/dist/esm/hooks/useAxisScales/x-scale.js +0 -1
- package/dist/esm/hooks/useAxisScales/y-scale.js +0 -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/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.js +19 -4
- package/dist/esm/hooks/useShapes/pie/prepare-data.js +0 -1
- package/dist/esm/hooks/useTooltip/index.d.ts +1 -1
- package/dist/esm/hooks/useZoom/index.d.ts +1 -1
- 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 +1 -1
- package/dist/esm/utils/chart/chart-dimensions.d.ts +24 -0
- package/dist/{cjs/hooks/useChartDimensions/index.js → esm/utils/chart/chart-dimensions.js} +43 -5
- 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/{cjs/hooks/useChartOptions → esm/utils/chart}/tooltip.js +2 -7
- package/dist/esm/utils/chart/zoom.js +0 -2
- package/package.json +3 -1
- 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/useYAxisLabelWidth/index.d.ts +0 -44
- 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/useYAxisLabelWidth/index.d.ts +0 -44
- /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
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { group, select } from 'd3';
|
|
2
|
+
import get from 'lodash/get';
|
|
3
|
+
import isNil from 'lodash/isNil';
|
|
4
|
+
import sortBy from 'lodash/sortBy';
|
|
5
|
+
import { DEFAULT_AXIS_LABEL_FONT_SIZE, SERIES_TYPE } from '../../constants';
|
|
6
|
+
import { getSeriesStackId } from '../../hooks/useSeries/utils';
|
|
7
|
+
import { getWaterfallPointSubtotal } from './series/waterfall';
|
|
8
|
+
import { isSeriesWithNumericalXValues, isSeriesWithNumericalYValues } from './series-type-guards';
|
|
9
|
+
export const CHART_SERIES_WITH_VOLUME_ON_Y_AXIS = [
|
|
10
|
+
'bar-x',
|
|
11
|
+
'area',
|
|
12
|
+
'waterfall',
|
|
13
|
+
];
|
|
14
|
+
export const CHART_SERIES_WITH_VOLUME_ON_X_AXIS = ['bar-y'];
|
|
15
|
+
function getDomainDataForStackedSeries(seriesList, keyAttr = 'x', valueAttr = 'y') {
|
|
16
|
+
const acc = [];
|
|
17
|
+
const stackedSeries = group(seriesList, getSeriesStackId);
|
|
18
|
+
Array.from(stackedSeries).forEach(([_stackId, seriesStack]) => {
|
|
19
|
+
const positiveValues = {};
|
|
20
|
+
const negativeValues = {};
|
|
21
|
+
seriesStack.forEach((singleSeries) => {
|
|
22
|
+
const data = new Map();
|
|
23
|
+
singleSeries.data.forEach((point) => {
|
|
24
|
+
const keyValue = point[keyAttr];
|
|
25
|
+
if (keyValue === null) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const key = String(keyValue);
|
|
29
|
+
let value = 0;
|
|
30
|
+
if (valueAttr in point && typeof point[valueAttr] === 'number') {
|
|
31
|
+
value = point[valueAttr];
|
|
32
|
+
}
|
|
33
|
+
if (data.has(key)) {
|
|
34
|
+
value = Math.max(value, data.get(key));
|
|
35
|
+
}
|
|
36
|
+
data.set(key, value);
|
|
37
|
+
});
|
|
38
|
+
Array.from(data).forEach(([key, value]) => {
|
|
39
|
+
if (value >= 0) {
|
|
40
|
+
positiveValues[key] = (positiveValues[key] || 0) + value;
|
|
41
|
+
}
|
|
42
|
+
if (value < 0) {
|
|
43
|
+
negativeValues[key] = (negativeValues[key] || 0) + value;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
acc.push(...Object.values(negativeValues), ...Object.values(positiveValues));
|
|
48
|
+
});
|
|
49
|
+
return acc;
|
|
50
|
+
}
|
|
51
|
+
export const getDomainDataXBySeries = (series) => {
|
|
52
|
+
const groupedSeries = group(series, (item) => item.type);
|
|
53
|
+
const values = Array.from(groupedSeries).reduce((acc, [type, seriesList]) => {
|
|
54
|
+
switch (type) {
|
|
55
|
+
case 'bar-y': {
|
|
56
|
+
acc.push(...getDomainDataForStackedSeries(seriesList, 'y', 'x'));
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
default: {
|
|
60
|
+
seriesList.filter(isSeriesWithNumericalXValues).forEach((s) => {
|
|
61
|
+
acc.push(...s.data.map((d) => d.x));
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return acc;
|
|
66
|
+
}, []);
|
|
67
|
+
return Array.from(new Set(values.filter((v) => v !== null)));
|
|
68
|
+
};
|
|
69
|
+
export function getDefaultMaxXAxisValue(series) {
|
|
70
|
+
if (series.some((s) => s.type === 'bar-y')) {
|
|
71
|
+
return 0;
|
|
72
|
+
}
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
export function getDefaultMinXAxisValue(series) {
|
|
76
|
+
if (series === null || series === void 0 ? void 0 : series.some((s) => CHART_SERIES_WITH_VOLUME_ON_X_AXIS.includes(s.type))) {
|
|
77
|
+
const domainData = getDomainDataXBySeries(series);
|
|
78
|
+
return domainData.reduce((minValue, d) => {
|
|
79
|
+
return Math.min(minValue, d);
|
|
80
|
+
}, 0);
|
|
81
|
+
}
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
export const getDomainDataYBySeries = (series) => {
|
|
85
|
+
const groupedSeries = group(series, (item) => item.type);
|
|
86
|
+
const items = Array.from(groupedSeries).reduce((acc, [type, seriesList]) => {
|
|
87
|
+
switch (type) {
|
|
88
|
+
case 'area':
|
|
89
|
+
case 'bar-x': {
|
|
90
|
+
acc.push(0, ...getDomainDataForStackedSeries(seriesList));
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
case 'waterfall': {
|
|
94
|
+
let yValue = 0;
|
|
95
|
+
const points = seriesList.map((s) => s.data).flat();
|
|
96
|
+
sortBy(points, (p) => p.index).forEach((d) => {
|
|
97
|
+
if (!d.total) {
|
|
98
|
+
yValue += Number(d.y) || 0;
|
|
99
|
+
acc.push(yValue);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
default: {
|
|
105
|
+
seriesList.filter(isSeriesWithNumericalYValues).forEach((s) => {
|
|
106
|
+
acc.push(...s.data.map((d) => d.y));
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return acc;
|
|
111
|
+
}, []);
|
|
112
|
+
return Array.from(new Set(items));
|
|
113
|
+
};
|
|
114
|
+
export function getDefaultMinYAxisValue(series) {
|
|
115
|
+
if (series === null || series === void 0 ? void 0 : series.some((s) => CHART_SERIES_WITH_VOLUME_ON_Y_AXIS.includes(s.type))) {
|
|
116
|
+
if (series.some((s) => s.type === SERIES_TYPE.Waterfall)) {
|
|
117
|
+
const seriesData = series.map((s) => s.data).flat();
|
|
118
|
+
const minSubTotal = seriesData.reduce((res, d) => Math.min(res, getWaterfallPointSubtotal(d, seriesData) || 0), 0);
|
|
119
|
+
return Math.min(0, minSubTotal);
|
|
120
|
+
}
|
|
121
|
+
const domainData = getDomainDataYBySeries(series);
|
|
122
|
+
return domainData.reduce((minValue, d) => {
|
|
123
|
+
return Math.min(minValue, d);
|
|
124
|
+
}, 0);
|
|
125
|
+
}
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
// Uses to get all series names array (except `pie` charts)
|
|
129
|
+
export const getSeriesNames = (series) => {
|
|
130
|
+
return series.reduce((acc, s) => {
|
|
131
|
+
if ('name' in s && typeof s.name === 'string') {
|
|
132
|
+
acc.push(s.name);
|
|
133
|
+
}
|
|
134
|
+
return acc;
|
|
135
|
+
}, []);
|
|
136
|
+
};
|
|
137
|
+
export const getOnlyVisibleSeries = (series) => {
|
|
138
|
+
return series.filter((s) => s.visible);
|
|
139
|
+
};
|
|
140
|
+
export const getHorizontalHtmlTextHeight = (args) => {
|
|
141
|
+
var _a;
|
|
142
|
+
const { text, style } = args;
|
|
143
|
+
const container = select(document.body).append('div');
|
|
144
|
+
const fontSize = get(style, 'fontSize', DEFAULT_AXIS_LABEL_FONT_SIZE);
|
|
145
|
+
container
|
|
146
|
+
.style('position', 'absolute')
|
|
147
|
+
.style('visibility', 'hidden')
|
|
148
|
+
.style('white-space', 'nowrap')
|
|
149
|
+
.html(text);
|
|
150
|
+
if (fontSize) {
|
|
151
|
+
container.style('font-size', fontSize);
|
|
152
|
+
}
|
|
153
|
+
const height = ((_a = container.node()) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().height) || 0;
|
|
154
|
+
container.remove();
|
|
155
|
+
return height;
|
|
156
|
+
};
|
|
157
|
+
export const getHorizontalSvgTextHeight = (args) => {
|
|
158
|
+
var _a;
|
|
159
|
+
const { text, style } = args;
|
|
160
|
+
const container = select(document.body).append('svg');
|
|
161
|
+
const textSelection = container.append('text').text(text);
|
|
162
|
+
const fontSize = get(style, 'fontSize', DEFAULT_AXIS_LABEL_FONT_SIZE);
|
|
163
|
+
if (fontSize) {
|
|
164
|
+
textSelection.style('font-size', fontSize).style('dominant-baseline', 'text-after-edge');
|
|
165
|
+
}
|
|
166
|
+
const height = ((_a = textSelection.node()) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().height) || 0;
|
|
167
|
+
container.remove();
|
|
168
|
+
return height;
|
|
169
|
+
};
|
|
170
|
+
const extractCategoryValue = (args) => {
|
|
171
|
+
const { axisDirection, categories, data } = args;
|
|
172
|
+
const dataCategory = get(data, axisDirection);
|
|
173
|
+
let categoryValue;
|
|
174
|
+
if ('category' in data && data.category) {
|
|
175
|
+
categoryValue = data.category;
|
|
176
|
+
}
|
|
177
|
+
if (typeof dataCategory === 'string') {
|
|
178
|
+
categoryValue = dataCategory;
|
|
179
|
+
}
|
|
180
|
+
if (typeof dataCategory === 'number') {
|
|
181
|
+
categoryValue = categories[dataCategory];
|
|
182
|
+
}
|
|
183
|
+
if (isNil(categoryValue)) {
|
|
184
|
+
throw new Error('It seems you are trying to get non-existing category value');
|
|
185
|
+
}
|
|
186
|
+
return categoryValue;
|
|
187
|
+
};
|
|
188
|
+
export const getDataCategoryValue = (args) => {
|
|
189
|
+
const { axisDirection, categories, data } = args;
|
|
190
|
+
const categoryValue = extractCategoryValue({ axisDirection, categories, data });
|
|
191
|
+
return categoryValue;
|
|
192
|
+
};
|
|
@@ -61,7 +61,6 @@ export function getClosestPoints(args) {
|
|
|
61
61
|
const result = [];
|
|
62
62
|
const groups = groupBy(shapesData, getSeriesType);
|
|
63
63
|
const closestPointsByXValue = [];
|
|
64
|
-
// eslint-disable-next-line complexity
|
|
65
64
|
Object.entries(groups).forEach(([seriesType, list]) => {
|
|
66
65
|
var _a, _b, _c, _d, _e;
|
|
67
66
|
switch (seriesType) {
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import type { BaseTextStyle, ChartSeries, ChartSeriesData } from '../../types';
|
|
2
|
-
import type { UnknownSeries } from './series-type-guards';
|
|
3
|
-
import type { AxisDirection } from './types';
|
|
4
1
|
export * from './axis/common';
|
|
5
2
|
export * from './array';
|
|
6
3
|
export * from './color';
|
|
@@ -14,28 +11,5 @@ export * from './symbol';
|
|
|
14
11
|
export * from './text';
|
|
15
12
|
export * from './time';
|
|
16
13
|
export * from './zoom';
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
export declare const getDomainDataXBySeries: (series: UnknownSeries[]) => ({} | undefined)[];
|
|
20
|
-
export declare function getDefaultMaxXAxisValue(series: UnknownSeries[]): 0 | undefined;
|
|
21
|
-
export declare function getDefaultMinXAxisValue(series: UnknownSeries[]): number | undefined;
|
|
22
|
-
export declare const getDomainDataYBySeries: (series: UnknownSeries[]) => unknown[];
|
|
23
|
-
export declare function getDefaultMinYAxisValue(series?: UnknownSeries[]): number | undefined;
|
|
24
|
-
export declare const getSeriesNames: (series: ChartSeries[]) => string[];
|
|
25
|
-
export declare const getOnlyVisibleSeries: <T extends {
|
|
26
|
-
visible: boolean;
|
|
27
|
-
}>(series: T[]) => T[];
|
|
28
|
-
export declare const getHorizontalHtmlTextHeight: (args: {
|
|
29
|
-
text: string;
|
|
30
|
-
style?: Partial<BaseTextStyle>;
|
|
31
|
-
}) => number;
|
|
32
|
-
export declare const getHorizontalSvgTextHeight: (args: {
|
|
33
|
-
text: string;
|
|
34
|
-
style?: Partial<BaseTextStyle>;
|
|
35
|
-
}) => number;
|
|
36
|
-
export declare const getDataCategoryValue: (args: {
|
|
37
|
-
axisDirection: AxisDirection;
|
|
38
|
-
categories: string[];
|
|
39
|
-
data: ChartSeriesData;
|
|
40
|
-
}) => string;
|
|
41
|
-
export { AxisDirection };
|
|
14
|
+
export * from './chart-dimensions';
|
|
15
|
+
export * from './common';
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
import { group, select } from 'd3';
|
|
2
|
-
import get from 'lodash/get';
|
|
3
|
-
import isNil from 'lodash/isNil';
|
|
4
|
-
import sortBy from 'lodash/sortBy';
|
|
5
|
-
import { DEFAULT_AXIS_LABEL_FONT_SIZE, SERIES_TYPE } from '../../constants';
|
|
6
|
-
import { getSeriesStackId } from '../../hooks/useSeries/utils';
|
|
7
|
-
import { getWaterfallPointSubtotal } from './series/waterfall';
|
|
8
|
-
import { isSeriesWithNumericalXValues, isSeriesWithNumericalYValues } from './series-type-guards';
|
|
9
1
|
export * from './axis/common';
|
|
10
2
|
export * from './array';
|
|
11
3
|
export * from './color';
|
|
@@ -19,187 +11,5 @@ export * from './symbol';
|
|
|
19
11
|
export * from './text';
|
|
20
12
|
export * from './time';
|
|
21
13
|
export * from './zoom';
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
'area',
|
|
25
|
-
'waterfall',
|
|
26
|
-
];
|
|
27
|
-
export const CHART_SERIES_WITH_VOLUME_ON_X_AXIS = ['bar-y'];
|
|
28
|
-
function getDomainDataForStackedSeries(seriesList, keyAttr = 'x', valueAttr = 'y') {
|
|
29
|
-
const acc = [];
|
|
30
|
-
const stackedSeries = group(seriesList, getSeriesStackId);
|
|
31
|
-
Array.from(stackedSeries).forEach(([_stackId, seriesStack]) => {
|
|
32
|
-
const positiveValues = {};
|
|
33
|
-
const negativeValues = {};
|
|
34
|
-
seriesStack.forEach((singleSeries) => {
|
|
35
|
-
const data = new Map();
|
|
36
|
-
singleSeries.data.forEach((point) => {
|
|
37
|
-
const keyValue = point[keyAttr];
|
|
38
|
-
if (keyValue === null) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
const key = String(keyValue);
|
|
42
|
-
let value = 0;
|
|
43
|
-
if (valueAttr in point && typeof point[valueAttr] === 'number') {
|
|
44
|
-
value = point[valueAttr];
|
|
45
|
-
}
|
|
46
|
-
if (data.has(key)) {
|
|
47
|
-
value = Math.max(value, data.get(key));
|
|
48
|
-
}
|
|
49
|
-
data.set(key, value);
|
|
50
|
-
});
|
|
51
|
-
Array.from(data).forEach(([key, value]) => {
|
|
52
|
-
if (value >= 0) {
|
|
53
|
-
positiveValues[key] = (positiveValues[key] || 0) + value;
|
|
54
|
-
}
|
|
55
|
-
if (value < 0) {
|
|
56
|
-
negativeValues[key] = (negativeValues[key] || 0) + value;
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
acc.push(...Object.values(negativeValues), ...Object.values(positiveValues));
|
|
61
|
-
});
|
|
62
|
-
return acc;
|
|
63
|
-
}
|
|
64
|
-
export const getDomainDataXBySeries = (series) => {
|
|
65
|
-
const groupedSeries = group(series, (item) => item.type);
|
|
66
|
-
const values = Array.from(groupedSeries).reduce((acc, [type, seriesList]) => {
|
|
67
|
-
switch (type) {
|
|
68
|
-
case 'bar-y': {
|
|
69
|
-
acc.push(...getDomainDataForStackedSeries(seriesList, 'y', 'x'));
|
|
70
|
-
break;
|
|
71
|
-
}
|
|
72
|
-
default: {
|
|
73
|
-
seriesList.filter(isSeriesWithNumericalXValues).forEach((s) => {
|
|
74
|
-
acc.push(...s.data.map((d) => d.x));
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return acc;
|
|
79
|
-
}, []);
|
|
80
|
-
return Array.from(new Set(values.filter((v) => v !== null)));
|
|
81
|
-
};
|
|
82
|
-
export function getDefaultMaxXAxisValue(series) {
|
|
83
|
-
if (series.some((s) => s.type === 'bar-y')) {
|
|
84
|
-
return 0;
|
|
85
|
-
}
|
|
86
|
-
return undefined;
|
|
87
|
-
}
|
|
88
|
-
export function getDefaultMinXAxisValue(series) {
|
|
89
|
-
if (series === null || series === void 0 ? void 0 : series.some((s) => CHART_SERIES_WITH_VOLUME_ON_X_AXIS.includes(s.type))) {
|
|
90
|
-
const domainData = getDomainDataXBySeries(series);
|
|
91
|
-
return domainData.reduce((minValue, d) => {
|
|
92
|
-
return Math.min(minValue, d);
|
|
93
|
-
}, 0);
|
|
94
|
-
}
|
|
95
|
-
return undefined;
|
|
96
|
-
}
|
|
97
|
-
export const getDomainDataYBySeries = (series) => {
|
|
98
|
-
const groupedSeries = group(series, (item) => item.type);
|
|
99
|
-
const items = Array.from(groupedSeries).reduce((acc, [type, seriesList]) => {
|
|
100
|
-
switch (type) {
|
|
101
|
-
case 'area':
|
|
102
|
-
case 'bar-x': {
|
|
103
|
-
acc.push(0, ...getDomainDataForStackedSeries(seriesList));
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
case 'waterfall': {
|
|
107
|
-
let yValue = 0;
|
|
108
|
-
const points = seriesList.map((s) => s.data).flat();
|
|
109
|
-
sortBy(points, (p) => p.index).forEach((d) => {
|
|
110
|
-
if (!d.total) {
|
|
111
|
-
yValue += Number(d.y) || 0;
|
|
112
|
-
acc.push(yValue);
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
break;
|
|
116
|
-
}
|
|
117
|
-
default: {
|
|
118
|
-
seriesList.filter(isSeriesWithNumericalYValues).forEach((s) => {
|
|
119
|
-
acc.push(...s.data.map((d) => d.y));
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
return acc;
|
|
124
|
-
}, []);
|
|
125
|
-
return Array.from(new Set(items));
|
|
126
|
-
};
|
|
127
|
-
export function getDefaultMinYAxisValue(series) {
|
|
128
|
-
if (series === null || series === void 0 ? void 0 : series.some((s) => CHART_SERIES_WITH_VOLUME_ON_Y_AXIS.includes(s.type))) {
|
|
129
|
-
if (series.some((s) => s.type === SERIES_TYPE.Waterfall)) {
|
|
130
|
-
const seriesData = series.map((s) => s.data).flat();
|
|
131
|
-
const minSubTotal = seriesData.reduce((res, d) => Math.min(res, getWaterfallPointSubtotal(d, seriesData) || 0), 0);
|
|
132
|
-
return Math.min(0, minSubTotal);
|
|
133
|
-
}
|
|
134
|
-
const domainData = getDomainDataYBySeries(series);
|
|
135
|
-
return domainData.reduce((minValue, d) => {
|
|
136
|
-
return Math.min(minValue, d);
|
|
137
|
-
}, 0);
|
|
138
|
-
}
|
|
139
|
-
return undefined;
|
|
140
|
-
}
|
|
141
|
-
// Uses to get all series names array (except `pie` charts)
|
|
142
|
-
export const getSeriesNames = (series) => {
|
|
143
|
-
return series.reduce((acc, s) => {
|
|
144
|
-
if ('name' in s && typeof s.name === 'string') {
|
|
145
|
-
acc.push(s.name);
|
|
146
|
-
}
|
|
147
|
-
return acc;
|
|
148
|
-
}, []);
|
|
149
|
-
};
|
|
150
|
-
export const getOnlyVisibleSeries = (series) => {
|
|
151
|
-
return series.filter((s) => s.visible);
|
|
152
|
-
};
|
|
153
|
-
export const getHorizontalHtmlTextHeight = (args) => {
|
|
154
|
-
var _a;
|
|
155
|
-
const { text, style } = args;
|
|
156
|
-
const container = select(document.body).append('div');
|
|
157
|
-
const fontSize = get(style, 'fontSize', DEFAULT_AXIS_LABEL_FONT_SIZE);
|
|
158
|
-
container
|
|
159
|
-
.style('position', 'absolute')
|
|
160
|
-
.style('visibility', 'hidden')
|
|
161
|
-
.style('white-space', 'nowrap')
|
|
162
|
-
.html(text);
|
|
163
|
-
if (fontSize) {
|
|
164
|
-
container.style('font-size', fontSize);
|
|
165
|
-
}
|
|
166
|
-
const height = ((_a = container.node()) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().height) || 0;
|
|
167
|
-
container.remove();
|
|
168
|
-
return height;
|
|
169
|
-
};
|
|
170
|
-
export const getHorizontalSvgTextHeight = (args) => {
|
|
171
|
-
var _a;
|
|
172
|
-
const { text, style } = args;
|
|
173
|
-
const container = select(document.body).append('svg');
|
|
174
|
-
const textSelection = container.append('text').text(text);
|
|
175
|
-
const fontSize = get(style, 'fontSize', DEFAULT_AXIS_LABEL_FONT_SIZE);
|
|
176
|
-
if (fontSize) {
|
|
177
|
-
textSelection.style('font-size', fontSize).style('dominant-baseline', 'text-after-edge');
|
|
178
|
-
}
|
|
179
|
-
const height = ((_a = textSelection.node()) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().height) || 0;
|
|
180
|
-
container.remove();
|
|
181
|
-
return height;
|
|
182
|
-
};
|
|
183
|
-
const extractCategoryValue = (args) => {
|
|
184
|
-
const { axisDirection, categories, data } = args;
|
|
185
|
-
const dataCategory = get(data, axisDirection);
|
|
186
|
-
let categoryValue;
|
|
187
|
-
if ('category' in data && data.category) {
|
|
188
|
-
categoryValue = data.category;
|
|
189
|
-
}
|
|
190
|
-
if (typeof dataCategory === 'string') {
|
|
191
|
-
categoryValue = dataCategory;
|
|
192
|
-
}
|
|
193
|
-
if (typeof dataCategory === 'number') {
|
|
194
|
-
categoryValue = categories[dataCategory];
|
|
195
|
-
}
|
|
196
|
-
if (isNil(categoryValue)) {
|
|
197
|
-
throw new Error('It seems you are trying to get non-existing category value');
|
|
198
|
-
}
|
|
199
|
-
return categoryValue;
|
|
200
|
-
};
|
|
201
|
-
export const getDataCategoryValue = (args) => {
|
|
202
|
-
const { axisDirection, categories, data } = args;
|
|
203
|
-
const categoryValue = extractCategoryValue({ axisDirection, categories, data });
|
|
204
|
-
return categoryValue;
|
|
205
|
-
};
|
|
14
|
+
export * from './chart-dimensions';
|
|
15
|
+
export * from './common';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ChartSeries, ChartXAxis, ChartYAxis } from '../../types';
|
|
2
|
+
export declare function getDefaultTooltipHeaderFormat({ seriesData, yAxes, xAxis, }: {
|
|
3
|
+
seriesData: ChartSeries[];
|
|
4
|
+
yAxes?: ChartYAxis[];
|
|
5
|
+
xAxis?: ChartXAxis;
|
|
6
|
+
}): import("../..").ValueFormat | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import get from 'lodash/get';
|
|
2
1
|
import { getDefaultValueFormat } from '../../components/Tooltip/DefaultTooltipContent/utils';
|
|
3
|
-
import {
|
|
2
|
+
import { getMinSpaceBetween } from './array';
|
|
3
|
+
import { getDomainDataXBySeries, getDomainDataYBySeries } from './common';
|
|
4
4
|
export function getDefaultTooltipHeaderFormat({ seriesData, yAxes, xAxis, }) {
|
|
5
5
|
if (seriesData.every((item) => ['pie', 'treemap', 'waterfall', 'sankey', 'radar', 'heatmap', 'funnel'].includes(item.type))) {
|
|
6
6
|
return undefined;
|
|
@@ -14,8 +14,3 @@ export function getDefaultTooltipHeaderFormat({ seriesData, yAxes, xAxis, }) {
|
|
|
14
14
|
const closestPointsRange = getMinSpaceBetween(domainData, (d) => d);
|
|
15
15
|
return getDefaultValueFormat({ axis: xAxis, closestPointsRange });
|
|
16
16
|
}
|
|
17
|
-
export const getPreparedTooltip = (args) => {
|
|
18
|
-
var _a, _b;
|
|
19
|
-
const { tooltip, seriesData, yAxes, xAxis } = args;
|
|
20
|
-
return Object.assign(Object.assign({}, tooltip), { enabled: get(tooltip, 'enabled', true), throttle: (_a = tooltip === null || tooltip === void 0 ? void 0 : tooltip.throttle) !== null && _a !== void 0 ? _a : 0, headerFormat: (_b = tooltip === null || tooltip === void 0 ? void 0 : tooltip.headerFormat) !== null && _b !== void 0 ? _b : getDefaultTooltipHeaderFormat({ seriesData, yAxes, xAxis }) });
|
|
21
|
-
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { SERIES_TYPE } from '../../constants';
|
|
2
2
|
const SERIES_TYPE_WITH_HIDDEN_POINTS = [SERIES_TYPE.Area, SERIES_TYPE.Line];
|
|
3
|
-
// eslint-disable-next-line complexity
|
|
4
3
|
function isValueInRange(args) {
|
|
5
4
|
const { axis, max, min, value } = args;
|
|
6
5
|
if (value === undefined) {
|
|
@@ -61,7 +60,6 @@ export function getZoomedSeriesData(args) {
|
|
|
61
60
|
if (!isPreparedZoomableSeries(seriesItem)) {
|
|
62
61
|
return;
|
|
63
62
|
}
|
|
64
|
-
// eslint-disable-next-line complexity
|
|
65
63
|
seriesItem.data.forEach((point, i) => {
|
|
66
64
|
var _a, _b;
|
|
67
65
|
const prevPoint = seriesItem.data[i - 1];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravity-ui/charts",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.39.0",
|
|
4
4
|
"description": "A flexible JavaScript library for data visualization and chart rendering using React",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -57,6 +57,8 @@
|
|
|
57
57
|
"docs:build": "cd ./docs && npm run docs:build",
|
|
58
58
|
"playwright:install": "playwright install chromium webkit --with-deps",
|
|
59
59
|
"playwright": "playwright test --config=playwright/playwright.config.ts",
|
|
60
|
+
"playwright:visual": "playwright test --project=chromium --project=webkit --config=playwright/playwright.config.ts",
|
|
61
|
+
"playwright:perf": "playwright test --project=chromium-perf --workers=1 --no-deps --config=playwright/playwright.config.ts",
|
|
60
62
|
"playwright:update": "npm run playwright -- -u",
|
|
61
63
|
"playwright:clear-cache": "rm -rf ./playwright/.cache",
|
|
62
64
|
"playwright:docker": "./scripts/playwright-docker.sh 'npm run playwright'",
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { PreparedLegend, PreparedSeries, PreparedXAxis, PreparedYAxis } from '../../hooks';
|
|
2
|
-
import type { ChartMargin, LegendConfig } from '../../types';
|
|
3
|
-
export { getBoundsWidth } from './utils';
|
|
4
|
-
type Args = {
|
|
5
|
-
height: number;
|
|
6
|
-
margin: ChartMargin;
|
|
7
|
-
preparedLegend: PreparedLegend | null;
|
|
8
|
-
preparedSeries: PreparedSeries[];
|
|
9
|
-
preparedXAxis: PreparedXAxis | null;
|
|
10
|
-
preparedYAxis: PreparedYAxis[] | null;
|
|
11
|
-
width: number;
|
|
12
|
-
legendConfig: LegendConfig | undefined;
|
|
13
|
-
};
|
|
14
|
-
export declare function getChartDimensions(args: Args): {
|
|
15
|
-
boundsWidth: number;
|
|
16
|
-
boundsHeight: number;
|
|
17
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { PreparedChart, PreparedYAxis } from '../../hooks';
|
|
2
|
-
export declare const getBoundsWidth: (args: {
|
|
3
|
-
chartWidth: number;
|
|
4
|
-
chartMargin: PreparedChart["margin"];
|
|
5
|
-
preparedYAxis: PreparedYAxis[] | null;
|
|
6
|
-
}) => number;
|
|
7
|
-
export declare function getYAxisWidth(axis: PreparedYAxis | undefined): number;
|
|
8
|
-
export declare function getWidthOccupiedByYAxis(args: {
|
|
9
|
-
preparedAxis: PreparedYAxis[] | null;
|
|
10
|
-
}): number;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
export const getBoundsWidth = (args) => {
|
|
2
|
-
const { chartWidth, chartMargin, preparedYAxis } = args;
|
|
3
|
-
return (chartWidth -
|
|
4
|
-
chartMargin.right -
|
|
5
|
-
chartMargin.left -
|
|
6
|
-
getWidthOccupiedByYAxis({ preparedAxis: preparedYAxis }));
|
|
7
|
-
};
|
|
8
|
-
export function getYAxisWidth(axis) {
|
|
9
|
-
if (!(axis === null || axis === void 0 ? void 0 : axis.visible)) {
|
|
10
|
-
return 0;
|
|
11
|
-
}
|
|
12
|
-
let result = 0;
|
|
13
|
-
if (axis === null || axis === void 0 ? void 0 : axis.title.text) {
|
|
14
|
-
result += axis.title.margin;
|
|
15
|
-
if (axis.title.rotation === 0) {
|
|
16
|
-
result += axis.title.width;
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
result += axis.title.height;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
if (axis === null || axis === void 0 ? void 0 : axis.labels.enabled) {
|
|
23
|
-
result += axis.labels.margin + axis.labels.width;
|
|
24
|
-
}
|
|
25
|
-
return result;
|
|
26
|
-
}
|
|
27
|
-
export function getWidthOccupiedByYAxis(args) {
|
|
28
|
-
const { preparedAxis } = args;
|
|
29
|
-
let leftAxisWidth = 0;
|
|
30
|
-
let rightAxisWidth = 0;
|
|
31
|
-
preparedAxis === null || preparedAxis === void 0 ? void 0 : preparedAxis.forEach((axis) => {
|
|
32
|
-
const axisWidth = getYAxisWidth(axis);
|
|
33
|
-
if (axis.position === 'right') {
|
|
34
|
-
rightAxisWidth = Math.max(rightAxisWidth, axisWidth);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
leftAxisWidth = Math.max(leftAxisWidth, axisWidth);
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
return leftAxisWidth + rightAxisWidth;
|
|
41
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { ChartData, ChartSeries, ChartXAxis, ChartYAxis } from '../../types';
|
|
2
|
-
import type { PreparedTooltip } from './types';
|
|
3
|
-
export declare function getDefaultTooltipHeaderFormat({ seriesData, yAxes, xAxis, }: {
|
|
4
|
-
seriesData: ChartSeries[];
|
|
5
|
-
yAxes?: ChartYAxis[];
|
|
6
|
-
xAxis?: ChartXAxis;
|
|
7
|
-
}): import("../../types").ValueFormat | undefined;
|
|
8
|
-
export declare const getPreparedTooltip: (args: {
|
|
9
|
-
tooltip: ChartData["tooltip"];
|
|
10
|
-
seriesData: ChartSeries[];
|
|
11
|
-
yAxes?: ChartYAxis[];
|
|
12
|
-
xAxis?: ChartXAxis;
|
|
13
|
-
}) => PreparedTooltip;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { PreparedYAxis } from '../useAxis/types';
|
|
2
|
-
import type { ChartScale } from '../useAxisScales/types';
|
|
3
|
-
import type { PreparedSeries } from '../useSeries/types';
|
|
4
|
-
export declare function recalculateYAxisLabelsWidth(props: {
|
|
5
|
-
seriesData: PreparedSeries[];
|
|
6
|
-
yAxis: PreparedYAxis[];
|
|
7
|
-
yScale?: (ChartScale | undefined)[];
|
|
8
|
-
}): Promise<(Omit<import("../..").ChartAxis, "type" | "labels" | "plotLines" | "plotBands"> & {
|
|
9
|
-
type: import("../..").ChartAxisType;
|
|
10
|
-
labels: Omit<import("../..").ChartAxisLabels, "enabled" | "style" | "padding" | "autoRotation"> & Required<Pick<import("../..").ChartAxisLabels, "margin" | "html" | "enabled" | "rotation" | "padding">> & {
|
|
11
|
-
style: import("../..").BaseTextStyle;
|
|
12
|
-
rotation: number;
|
|
13
|
-
height: number;
|
|
14
|
-
width: number;
|
|
15
|
-
lineHeight: number;
|
|
16
|
-
maxWidth: number;
|
|
17
|
-
};
|
|
18
|
-
title: {
|
|
19
|
-
height: number;
|
|
20
|
-
width: number;
|
|
21
|
-
text: string;
|
|
22
|
-
margin: number;
|
|
23
|
-
style: import("../..").BaseTextStyle;
|
|
24
|
-
align: import("../..").ChartAxisTitleAlignment;
|
|
25
|
-
maxRowCount: number;
|
|
26
|
-
rotation: number;
|
|
27
|
-
maxWidth: number;
|
|
28
|
-
html: boolean;
|
|
29
|
-
};
|
|
30
|
-
min?: number;
|
|
31
|
-
grid: {
|
|
32
|
-
enabled: boolean;
|
|
33
|
-
};
|
|
34
|
-
maxPadding: number;
|
|
35
|
-
ticks: {
|
|
36
|
-
pixelInterval?: number;
|
|
37
|
-
};
|
|
38
|
-
tickMarks: import("../useAxis/types").PreparedAxisTickMarks;
|
|
39
|
-
position: "left" | "right" | "top" | "bottom";
|
|
40
|
-
plotIndex: number;
|
|
41
|
-
plotLines: import("../useAxis/types").PreparedAxisPlotLine[];
|
|
42
|
-
plotBands: import("../useAxis/types").PreparedAxisPlotBand[];
|
|
43
|
-
crosshair: Required<import("../..").AxisCrosshair>;
|
|
44
|
-
})[]>;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { PreparedLegend, PreparedSeries, PreparedXAxis, PreparedYAxis } from '../../hooks';
|
|
2
|
-
import type { ChartMargin, LegendConfig } from '../../types';
|
|
3
|
-
export { getBoundsWidth } from './utils';
|
|
4
|
-
type Args = {
|
|
5
|
-
height: number;
|
|
6
|
-
margin: ChartMargin;
|
|
7
|
-
preparedLegend: PreparedLegend | null;
|
|
8
|
-
preparedSeries: PreparedSeries[];
|
|
9
|
-
preparedXAxis: PreparedXAxis | null;
|
|
10
|
-
preparedYAxis: PreparedYAxis[] | null;
|
|
11
|
-
width: number;
|
|
12
|
-
legendConfig: LegendConfig | undefined;
|
|
13
|
-
};
|
|
14
|
-
export declare function getChartDimensions(args: Args): {
|
|
15
|
-
boundsWidth: number;
|
|
16
|
-
boundsHeight: number;
|
|
17
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { PreparedChart, PreparedYAxis } from '../../hooks';
|
|
2
|
-
export declare const getBoundsWidth: (args: {
|
|
3
|
-
chartWidth: number;
|
|
4
|
-
chartMargin: PreparedChart["margin"];
|
|
5
|
-
preparedYAxis: PreparedYAxis[] | null;
|
|
6
|
-
}) => number;
|
|
7
|
-
export declare function getYAxisWidth(axis: PreparedYAxis | undefined): number;
|
|
8
|
-
export declare function getWidthOccupiedByYAxis(args: {
|
|
9
|
-
preparedAxis: PreparedYAxis[] | null;
|
|
10
|
-
}): number;
|