@gravity-ui/chartkit 5.4.0 → 5.6.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/build/constants/widget-data.d.ts +1 -0
- package/build/constants/widget-data.js +1 -0
- package/build/i18n/keysets/en.json +2 -1
- package/build/i18n/keysets/ru.json +2 -4
- package/build/plugins/d3/examples/area/TwoYAxis.d.ts +2 -0
- package/build/plugins/d3/examples/area/TwoYAxis.js +58 -0
- package/build/plugins/d3/examples/bar-x/TwoYAxis.d.ts +2 -0
- package/build/plugins/d3/examples/bar-x/TwoYAxis.js +58 -0
- package/build/plugins/d3/examples/line/TwoYAxis.d.ts +2 -0
- package/build/plugins/d3/examples/line/TwoYAxis.js +58 -0
- package/build/plugins/d3/examples/mars-weather.d.ts +13 -0
- package/build/plugins/d3/examples/mars-weather.js +1203 -0
- package/build/plugins/d3/examples/scatter/TwoYAxis.d.ts +2 -0
- package/build/plugins/d3/examples/scatter/TwoYAxis.js +58 -0
- package/build/plugins/d3/renderer/components/AxisY.d.ts +1 -1
- package/build/plugins/d3/renderer/components/AxisY.js +112 -79
- package/build/plugins/d3/renderer/components/Chart.js +4 -3
- package/build/plugins/d3/renderer/components/Tooltip/DefaultContent.js +19 -2
- package/build/plugins/d3/renderer/constants/defaults/series-options.d.ts +7 -1
- package/build/plugins/d3/renderer/constants/defaults/series-options.js +14 -0
- package/build/plugins/d3/renderer/hooks/useAxisScales/index.d.ts +1 -1
- package/build/plugins/d3/renderer/hooks/useAxisScales/index.js +8 -1
- package/build/plugins/d3/renderer/hooks/useChartDimensions/utils.d.ts +1 -0
- package/build/plugins/d3/renderer/hooks/useChartDimensions/utils.js +11 -10
- package/build/plugins/d3/renderer/hooks/useChartOptions/types.d.ts +1 -0
- package/build/plugins/d3/renderer/hooks/useChartOptions/x-axis.js +1 -0
- package/build/plugins/d3/renderer/hooks/useChartOptions/y-axis.js +69 -53
- package/build/plugins/d3/renderer/hooks/useSeries/prepare-area.d.ts +1 -1
- package/build/plugins/d3/renderer/hooks/useSeries/prepare-area.js +1 -0
- package/build/plugins/d3/renderer/hooks/useSeries/prepare-bar-x.js +1 -0
- package/build/plugins/d3/renderer/hooks/useSeries/prepare-legend.js +3 -3
- package/build/plugins/d3/renderer/hooks/useSeries/prepare-line.d.ts +1 -1
- package/build/plugins/d3/renderer/hooks/useSeries/prepare-line.js +1 -0
- package/build/plugins/d3/renderer/hooks/useSeries/prepare-scatter.js +1 -0
- package/build/plugins/d3/renderer/hooks/useSeries/prepare-waterfall.d.ts +10 -0
- package/build/plugins/d3/renderer/hooks/useSeries/prepare-waterfall.js +36 -0
- package/build/plugins/d3/renderer/hooks/useSeries/prepareSeries.js +8 -0
- package/build/plugins/d3/renderer/hooks/useSeries/types.d.ts +18 -2
- package/build/plugins/d3/renderer/hooks/useShapes/area/prepare-data.d.ts +2 -1
- package/build/plugins/d3/renderer/hooks/useShapes/area/prepare-data.js +7 -6
- package/build/plugins/d3/renderer/hooks/useShapes/bar-x/prepare-data.d.ts +2 -1
- package/build/plugins/d3/renderer/hooks/useShapes/bar-x/prepare-data.js +4 -4
- package/build/plugins/d3/renderer/hooks/useShapes/bar-y/prepare-data.d.ts +1 -1
- package/build/plugins/d3/renderer/hooks/useShapes/bar-y/prepare-data.js +1 -1
- package/build/plugins/d3/renderer/hooks/useShapes/index.d.ts +3 -2
- package/build/plugins/d3/renderer/hooks/useShapes/index.js +19 -1
- package/build/plugins/d3/renderer/hooks/useShapes/line/prepare-data.d.ts +1 -1
- package/build/plugins/d3/renderer/hooks/useShapes/line/prepare-data.js +2 -1
- package/build/plugins/d3/renderer/hooks/useShapes/scatter/prepare-data.d.ts +2 -2
- package/build/plugins/d3/renderer/hooks/useShapes/scatter/prepare-data.js +5 -2
- package/build/plugins/d3/renderer/hooks/useShapes/styles.css +4 -0
- package/build/plugins/d3/renderer/hooks/useShapes/waterfall/index.d.ts +12 -0
- package/build/plugins/d3/renderer/hooks/useShapes/waterfall/index.js +125 -0
- package/build/plugins/d3/renderer/hooks/useShapes/waterfall/prepare-data.d.ts +12 -0
- package/build/plugins/d3/renderer/hooks/useShapes/waterfall/prepare-data.js +132 -0
- package/build/plugins/d3/renderer/hooks/useShapes/waterfall/types.d.ts +14 -0
- package/build/plugins/d3/renderer/hooks/useShapes/waterfall/types.js +1 -0
- package/build/plugins/d3/renderer/utils/get-closest-data.js +16 -5
- package/build/plugins/d3/renderer/utils/index.d.ts +1 -0
- package/build/plugins/d3/renderer/utils/index.js +11 -0
- package/build/plugins/d3/renderer/utils/series/index.d.ts +1 -0
- package/build/plugins/d3/renderer/utils/series/index.js +1 -0
- package/build/plugins/d3/renderer/utils/series/waterfall.d.ts +4 -0
- package/build/plugins/d3/renderer/utils/series/waterfall.js +25 -0
- package/build/plugins/d3/renderer/utils/text.js +1 -1
- package/build/plugins/d3/renderer/validation/index.js +13 -4
- package/build/plugins/d3/utils/pie-center-text.js +1 -1
- package/build/plugins/highcharts/renderer/components/HighchartsComponent.d.ts +5 -0
- package/build/plugins/highcharts/renderer/helpers/config/config.d.ts +5 -0
- package/build/plugins/highcharts/renderer/helpers/config/config.js +8 -0
- package/build/plugins/highcharts/renderer/helpers/config/options.js +1 -1
- package/build/plugins/highcharts/renderer/helpers/graph.d.ts +5 -0
- package/build/types/widget-data/area.d.ts +2 -0
- package/build/types/widget-data/bar-x.d.ts +2 -0
- package/build/types/widget-data/index.d.ts +1 -0
- package/build/types/widget-data/index.js +1 -0
- package/build/types/widget-data/line.d.ts +2 -0
- package/build/types/widget-data/scatter.d.ts +2 -0
- package/build/types/widget-data/series.d.ts +21 -2
- package/build/types/widget-data/tooltip.d.ts +6 -1
- package/build/types/widget-data/waterfall.d.ts +39 -0
- package/build/types/widget-data/waterfall.js +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import get from 'lodash/get';
|
|
2
|
+
import sortBy from 'lodash/sortBy';
|
|
3
|
+
import { getLabelsSize } from '../../../utils';
|
|
4
|
+
import { MIN_BAR_GAP, MIN_BAR_WIDTH } from '../constants';
|
|
5
|
+
import { getXValue, getYValue } from '../utils';
|
|
6
|
+
function getLabelData(d, plotHeight) {
|
|
7
|
+
if (!d.series.dataLabels.enabled) {
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
const text = String(d.data.label || d.subTotal);
|
|
11
|
+
const style = d.series.dataLabels.style;
|
|
12
|
+
const { maxHeight: height, maxWidth: width } = getLabelsSize({ labels: [text], style });
|
|
13
|
+
let y;
|
|
14
|
+
if (Number(d.data.y) > 0 || d.data.total) {
|
|
15
|
+
y = Math.max(height, d.y - d.series.dataLabels.padding);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
y = Math.min(plotHeight - d.series.dataLabels.padding, d.y + d.height + d.series.dataLabels.padding + height);
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
text,
|
|
22
|
+
x: d.x + d.width / 2,
|
|
23
|
+
y,
|
|
24
|
+
style,
|
|
25
|
+
size: { width, height },
|
|
26
|
+
textAnchor: 'middle',
|
|
27
|
+
series: d.series,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function getBandWidth(args) {
|
|
31
|
+
const { series, xAxis, xScale } = args;
|
|
32
|
+
if (xAxis.type === 'category') {
|
|
33
|
+
const xBandScale = xScale;
|
|
34
|
+
return xBandScale.bandwidth();
|
|
35
|
+
}
|
|
36
|
+
const xLinearScale = xScale;
|
|
37
|
+
const xValues = series.reduce((acc, s) => {
|
|
38
|
+
s.data.forEach((dataItem) => acc.push(Number(dataItem.x)));
|
|
39
|
+
return acc;
|
|
40
|
+
}, []);
|
|
41
|
+
let bandWidth = Infinity;
|
|
42
|
+
xValues.sort().forEach((xValue, index) => {
|
|
43
|
+
if (index > 0 && xValue !== xValues[index - 1]) {
|
|
44
|
+
const dist = xLinearScale(xValue) - xLinearScale(xValues[index - 1]);
|
|
45
|
+
if (dist < bandWidth) {
|
|
46
|
+
bandWidth = dist;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
return bandWidth;
|
|
51
|
+
}
|
|
52
|
+
export const prepareWaterfallData = (args) => {
|
|
53
|
+
const { series, seriesOptions, xAxis, xScale, yAxis: [yAxis], yScale: [yScale], } = args;
|
|
54
|
+
const yLinearScale = yScale;
|
|
55
|
+
const plotHeight = yLinearScale(yLinearScale.domain()[0]);
|
|
56
|
+
const barMaxWidth = get(seriesOptions, 'waterfall.barMaxWidth');
|
|
57
|
+
const barPadding = get(seriesOptions, 'waterfall.barPadding');
|
|
58
|
+
const flattenData = series.reduce((acc, s) => {
|
|
59
|
+
acc.push(...s.data.map((d) => ({ data: d, series: s })));
|
|
60
|
+
return acc;
|
|
61
|
+
}, []);
|
|
62
|
+
const data = sortBy(flattenData, (d) => d.data.x);
|
|
63
|
+
const bandWidth = getBandWidth({
|
|
64
|
+
series,
|
|
65
|
+
xAxis,
|
|
66
|
+
xScale,
|
|
67
|
+
});
|
|
68
|
+
const rectGap = Math.max(bandWidth * barPadding, MIN_BAR_GAP);
|
|
69
|
+
const rectWidth = Math.max(MIN_BAR_WIDTH, Math.min(bandWidth - rectGap, barMaxWidth));
|
|
70
|
+
const yZero = getYValue({
|
|
71
|
+
point: { y: 0 },
|
|
72
|
+
yScale,
|
|
73
|
+
yAxis,
|
|
74
|
+
});
|
|
75
|
+
let totalValue = 0;
|
|
76
|
+
const result = [];
|
|
77
|
+
data.forEach((item, _index) => {
|
|
78
|
+
if (typeof item.data.y !== 'number' && !item.data.total) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (!item.data.total) {
|
|
82
|
+
totalValue += Number(item.data.y);
|
|
83
|
+
}
|
|
84
|
+
const prevPoint = result[result.length - 1];
|
|
85
|
+
const xCenter = getXValue({ point: item.data, xAxis, xScale });
|
|
86
|
+
const x = xCenter - rectWidth / 2;
|
|
87
|
+
const yValue = Number(item.data.total ? totalValue : item.data.y);
|
|
88
|
+
const height = yZero -
|
|
89
|
+
getYValue({
|
|
90
|
+
point: { y: Math.abs(yValue) },
|
|
91
|
+
yScale,
|
|
92
|
+
yAxis,
|
|
93
|
+
});
|
|
94
|
+
let y;
|
|
95
|
+
if (!prevPoint || item.data.total) {
|
|
96
|
+
y = getYValue({
|
|
97
|
+
point: {
|
|
98
|
+
y: yValue > 0 ? yValue : 0,
|
|
99
|
+
},
|
|
100
|
+
yScale,
|
|
101
|
+
yAxis,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
else if (Number(prevPoint.data.y) < 0) {
|
|
105
|
+
if (Number(item.data.y) > 0) {
|
|
106
|
+
y = prevPoint.y + prevPoint.height - height;
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
y = prevPoint.y + prevPoint.height;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
else if (Number(item.data.y) < 0) {
|
|
113
|
+
y = prevPoint.y;
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
y = prevPoint.y - height;
|
|
117
|
+
}
|
|
118
|
+
const preparedData = {
|
|
119
|
+
x,
|
|
120
|
+
y,
|
|
121
|
+
width: rectWidth,
|
|
122
|
+
height,
|
|
123
|
+
opacity: get(item.data, 'opacity', null),
|
|
124
|
+
data: item.data,
|
|
125
|
+
series: item.series,
|
|
126
|
+
subTotal: totalValue,
|
|
127
|
+
};
|
|
128
|
+
preparedData.label = getLabelData(preparedData, plotHeight);
|
|
129
|
+
result.push(preparedData);
|
|
130
|
+
});
|
|
131
|
+
return result;
|
|
132
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { WaterfallSeriesData } from '../../../../../../types';
|
|
2
|
+
import { LabelData } from '../../../types';
|
|
3
|
+
import { PreparedWaterfallSeries } from '../../useSeries/types';
|
|
4
|
+
export type PreparedWaterfallData = {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
opacity: number | null;
|
|
10
|
+
series: PreparedWaterfallSeries;
|
|
11
|
+
data: WaterfallSeriesData;
|
|
12
|
+
label?: LabelData;
|
|
13
|
+
subTotal: number;
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -45,7 +45,18 @@ export function getClosestPoints(args) {
|
|
|
45
45
|
y0: d.y,
|
|
46
46
|
y1: d.y + d.height,
|
|
47
47
|
}));
|
|
48
|
-
|
|
48
|
+
result.push(...getClosestPointsByXValue(pointerX, pointerY, points));
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
case 'waterfall': {
|
|
52
|
+
const points = list.map((d) => ({
|
|
53
|
+
data: d.data,
|
|
54
|
+
series: d.series,
|
|
55
|
+
x: d.x + d.width / 2,
|
|
56
|
+
y0: d.y,
|
|
57
|
+
y1: d.y + d.height,
|
|
58
|
+
}));
|
|
59
|
+
result.push(...getClosestPointsByXValue(pointerX, pointerY, points));
|
|
49
60
|
break;
|
|
50
61
|
}
|
|
51
62
|
case 'area': {
|
|
@@ -59,12 +70,12 @@ export function getClosestPoints(args) {
|
|
|
59
70
|
})));
|
|
60
71
|
return acc;
|
|
61
72
|
}, []);
|
|
62
|
-
|
|
73
|
+
result.push(...getClosestPointsByXValue(pointerX, pointerY, points));
|
|
63
74
|
break;
|
|
64
75
|
}
|
|
65
76
|
case 'line': {
|
|
66
77
|
const points = list.reduce((acc, d) => {
|
|
67
|
-
|
|
78
|
+
acc.push(...d.points.map((p) => ({
|
|
68
79
|
data: p.data,
|
|
69
80
|
series: p.series,
|
|
70
81
|
x: p.x,
|
|
@@ -73,7 +84,7 @@ export function getClosestPoints(args) {
|
|
|
73
84
|
})));
|
|
74
85
|
return acc;
|
|
75
86
|
}, []);
|
|
76
|
-
|
|
87
|
+
result.push(...getClosestPointsByXValue(pointerX, pointerY, points));
|
|
77
88
|
break;
|
|
78
89
|
}
|
|
79
90
|
case 'bar-y': {
|
|
@@ -96,7 +107,7 @@ export function getClosestPoints(args) {
|
|
|
96
107
|
closestXIndex = closestPoints.findIndex((p) => pointerX > p.x && pointerX < p.x + p.width);
|
|
97
108
|
}
|
|
98
109
|
}
|
|
99
|
-
|
|
110
|
+
result.push(...closestPoints.map((p, i) => ({
|
|
100
111
|
data: p.data,
|
|
101
112
|
series: p.series,
|
|
102
113
|
closest: i === closestXIndex,
|
|
@@ -13,6 +13,7 @@ export * from './time';
|
|
|
13
13
|
export * from './axis';
|
|
14
14
|
export * from './labels';
|
|
15
15
|
export * from './symbol';
|
|
16
|
+
export * from './series';
|
|
16
17
|
const CHARTS_WITHOUT_AXIS = ['pie', 'treemap'];
|
|
17
18
|
/**
|
|
18
19
|
* Checks whether the series should be drawn with axes.
|
|
@@ -70,6 +71,16 @@ export const getDomainDataYBySeries = (series) => {
|
|
|
70
71
|
});
|
|
71
72
|
break;
|
|
72
73
|
}
|
|
74
|
+
case 'waterfall': {
|
|
75
|
+
let yValue = 0;
|
|
76
|
+
seriesList.forEach((s) => {
|
|
77
|
+
s.data.forEach((d) => {
|
|
78
|
+
yValue += Number(d.y) || 0;
|
|
79
|
+
acc.push(yValue);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
73
84
|
default: {
|
|
74
85
|
seriesList.filter(isSeriesWithNumericalYValues).forEach((s) => {
|
|
75
86
|
acc.push(...s.data.map((d) => d.y));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './waterfall';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './waterfall';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { WaterfallSeriesData } from '../../../../../types';
|
|
2
|
+
import { PreparedWaterfallSeries } from '../../hooks';
|
|
3
|
+
export declare function getWaterfallPointColor(point: WaterfallSeriesData, series: PreparedWaterfallSeries): string;
|
|
4
|
+
export declare function getWaterfallPointSubtotal(point: WaterfallSeriesData, series: PreparedWaterfallSeries): number | null;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function getWaterfallPointColor(point, series) {
|
|
2
|
+
if (point.color) {
|
|
3
|
+
return point.color;
|
|
4
|
+
}
|
|
5
|
+
if (point.total) {
|
|
6
|
+
return series.color;
|
|
7
|
+
}
|
|
8
|
+
if (Number(point.y) > 0) {
|
|
9
|
+
return series.positiveColor;
|
|
10
|
+
}
|
|
11
|
+
return series.negativeColor;
|
|
12
|
+
}
|
|
13
|
+
export function getWaterfallPointSubtotal(point, series) {
|
|
14
|
+
const pointIndex = series.data.indexOf(point);
|
|
15
|
+
if (pointIndex === -1) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
return series.data.reduce((sum, d, index) => {
|
|
19
|
+
if (index <= pointIndex) {
|
|
20
|
+
const value = d.total ? 0 : Number(d.y);
|
|
21
|
+
return sum + value;
|
|
22
|
+
}
|
|
23
|
+
return sum;
|
|
24
|
+
}, 0);
|
|
25
|
+
}
|
|
@@ -6,9 +6,19 @@ import { CHARTKIT_ERROR_CODE, ChartKitError } from '../../../../libs';
|
|
|
6
6
|
import { DEFAULT_AXIS_TYPE } from '../constants';
|
|
7
7
|
const AVAILABLE_SERIES_TYPES = Object.values(SeriesType);
|
|
8
8
|
const validateXYSeries = (args) => {
|
|
9
|
-
const { series, xAxis, yAxis } = args;
|
|
9
|
+
const { series, xAxis, yAxis = [] } = args;
|
|
10
|
+
const yAxisIndex = get(series, 'yAxis', 0);
|
|
11
|
+
const seriesYAxis = yAxis[yAxisIndex];
|
|
12
|
+
if (yAxisIndex !== 0 && typeof seriesYAxis === 'undefined') {
|
|
13
|
+
throw new ChartKitError({
|
|
14
|
+
code: CHARTKIT_ERROR_CODE.INVALID_DATA,
|
|
15
|
+
message: i18n('error', 'label_invalid-y-axis-index', {
|
|
16
|
+
index: yAxisIndex,
|
|
17
|
+
}),
|
|
18
|
+
});
|
|
19
|
+
}
|
|
10
20
|
const xType = get(xAxis, 'type', DEFAULT_AXIS_TYPE);
|
|
11
|
-
const yType = get(
|
|
21
|
+
const yType = get(seriesYAxis, 'type', DEFAULT_AXIS_TYPE);
|
|
12
22
|
series.data.forEach(({ x, y }) => {
|
|
13
23
|
switch (xType) {
|
|
14
24
|
case 'category': {
|
|
@@ -203,7 +213,6 @@ export const validateData = (data) => {
|
|
|
203
213
|
});
|
|
204
214
|
}
|
|
205
215
|
data.series.data.forEach((series) => {
|
|
206
|
-
|
|
207
|
-
validateSeries({ series, yAxis: (_a = data.yAxis) === null || _a === void 0 ? void 0 : _a[0], xAxis: data.xAxis });
|
|
216
|
+
validateSeries({ series, yAxis: data.yAxis, xAxis: data.xAxis });
|
|
208
217
|
});
|
|
209
218
|
};
|
|
@@ -363,6 +363,11 @@ export declare class HighchartsComponent extends React.PureComponent<Props, Stat
|
|
|
363
363
|
mouseOut: () => void;
|
|
364
364
|
click: (event: any) => void;
|
|
365
365
|
};
|
|
366
|
+
point: {
|
|
367
|
+
events: {
|
|
368
|
+
click: () => false;
|
|
369
|
+
};
|
|
370
|
+
};
|
|
366
371
|
marker: {
|
|
367
372
|
states: {
|
|
368
373
|
hover: {
|
|
@@ -526,6 +526,11 @@ export function prepareConfig(data: any, options: any, isMobile: any, holidays:
|
|
|
526
526
|
mouseOut: () => void;
|
|
527
527
|
click: (event: any) => void;
|
|
528
528
|
};
|
|
529
|
+
point: {
|
|
530
|
+
events: {
|
|
531
|
+
click: () => false;
|
|
532
|
+
};
|
|
533
|
+
};
|
|
529
534
|
marker: {
|
|
530
535
|
states: {
|
|
531
536
|
hover: {
|
|
@@ -1264,6 +1264,14 @@ export function prepareConfig(data, options, isMobile, holidays) {
|
|
|
1264
1264
|
}
|
|
1265
1265
|
},
|
|
1266
1266
|
},
|
|
1267
|
+
point: {
|
|
1268
|
+
events: {
|
|
1269
|
+
click: function () {
|
|
1270
|
+
// Prevent slicing of pie segment after clicking it
|
|
1271
|
+
return false;
|
|
1272
|
+
},
|
|
1273
|
+
},
|
|
1274
|
+
},
|
|
1267
1275
|
marker: options.splitTooltip
|
|
1268
1276
|
? {
|
|
1269
1277
|
states: {
|
|
@@ -357,6 +357,11 @@ declare function getGraph({ options, data, comments, isMobile, holidays }: GetGr
|
|
|
357
357
|
mouseOut: () => void;
|
|
358
358
|
click: (event: any) => void;
|
|
359
359
|
};
|
|
360
|
+
point: {
|
|
361
|
+
events: {
|
|
362
|
+
click: () => false;
|
|
363
|
+
};
|
|
364
|
+
};
|
|
360
365
|
marker: {
|
|
361
366
|
states: {
|
|
362
367
|
hover: {
|
|
@@ -9,8 +9,9 @@ import type { PointMarkerOptions } from './marker';
|
|
|
9
9
|
import type { PieSeries, PieSeriesData } from './pie';
|
|
10
10
|
import type { ScatterSeries, ScatterSeriesData } from './scatter';
|
|
11
11
|
import type { TreemapSeries, TreemapSeriesData } from './treemap';
|
|
12
|
-
|
|
13
|
-
export type
|
|
12
|
+
import type { WaterfallSeries, WaterfallSeriesData } from './waterfall';
|
|
13
|
+
export type ChartKitWidgetSeries<T = any> = ScatterSeries<T> | PieSeries<T> | BarXSeries<T> | BarYSeries<T> | LineSeries<T> | AreaSeries<T> | TreemapSeries<T> | WaterfallSeries<T>;
|
|
14
|
+
export type ChartKitWidgetSeriesData<T = any> = ScatterSeriesData<T> | PieSeriesData<T> | BarXSeriesData<T> | BarYSeriesData<T> | LineSeriesData<T> | AreaSeriesData<T> | TreemapSeriesData<T> | WaterfallSeriesData<T>;
|
|
14
15
|
export type DataLabelRendererData<T = any> = {
|
|
15
16
|
data: ChartKitWidgetSeriesData<T>;
|
|
16
17
|
};
|
|
@@ -202,5 +203,23 @@ export type ChartKitWidgetSeriesOptions = {
|
|
|
202
203
|
inactive?: BasicInactiveState;
|
|
203
204
|
};
|
|
204
205
|
};
|
|
206
|
+
waterfall?: {
|
|
207
|
+
/** The maximum allowed pixel width for a column.
|
|
208
|
+
* This prevents the columns from becoming too wide when there is a small number of points in the chart.
|
|
209
|
+
*
|
|
210
|
+
* @default 50
|
|
211
|
+
*/
|
|
212
|
+
barMaxWidth?: number;
|
|
213
|
+
/** Padding between each column or bar, in x axis units.
|
|
214
|
+
*
|
|
215
|
+
* @default 0.1
|
|
216
|
+
* */
|
|
217
|
+
barPadding?: number;
|
|
218
|
+
/** Options for the series states that provide additional styling information to the series. */
|
|
219
|
+
states?: {
|
|
220
|
+
hover?: BasicHoverState;
|
|
221
|
+
inactive?: BasicInactiveState;
|
|
222
|
+
};
|
|
223
|
+
};
|
|
205
224
|
};
|
|
206
225
|
export {};
|
|
@@ -6,6 +6,7 @@ import type { LineSeries, LineSeriesData } from './line';
|
|
|
6
6
|
import type { PieSeries, PieSeriesData } from './pie';
|
|
7
7
|
import type { ScatterSeries, ScatterSeriesData } from './scatter';
|
|
8
8
|
import type { TreemapSeries, TreemapSeriesData } from './treemap';
|
|
9
|
+
import type { WaterfallSeries, WaterfallSeriesData } from './waterfall';
|
|
9
10
|
export type TooltipDataChunkBarX<T = any> = {
|
|
10
11
|
data: BarXSeriesData<T>;
|
|
11
12
|
series: BarXSeries<T>;
|
|
@@ -50,7 +51,11 @@ export type TooltipDataChunkTreemap<T = any> = {
|
|
|
50
51
|
data: TreemapSeriesData<T>;
|
|
51
52
|
series: TreemapSeries<T>;
|
|
52
53
|
};
|
|
53
|
-
export type
|
|
54
|
+
export type TooltipDataChunkWaterfall<T = any> = {
|
|
55
|
+
data: WaterfallSeriesData<T>;
|
|
56
|
+
series: WaterfallSeries<T>;
|
|
57
|
+
};
|
|
58
|
+
export type TooltipDataChunk<T = any> = (TooltipDataChunkBarX<T> | TooltipDataChunkBarY<T> | TooltipDataChunkPie<T> | TooltipDataChunkScatter<T> | TooltipDataChunkLine<T> | TooltipDataChunkArea<T> | TooltipDataChunkTreemap<T> | TooltipDataChunkWaterfall<T>) & {
|
|
54
59
|
closest?: boolean;
|
|
55
60
|
};
|
|
56
61
|
export type ChartKitWidgetTooltip<T = any> = {
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { SeriesType } from '../../constants';
|
|
2
|
+
import type { BaseSeries, BaseSeriesData } from './base';
|
|
3
|
+
import { ChartKitWidgetLegend, RectLegendSymbolOptions } from './legend';
|
|
4
|
+
export type WaterfallSeriesData<T = any> = BaseSeriesData<T> & {
|
|
5
|
+
/**
|
|
6
|
+
* The `x` value. Depending on the context , it may represents:
|
|
7
|
+
* - numeric value (for `linear` x axis)
|
|
8
|
+
* - timestamp value (for `datetime` x axis)
|
|
9
|
+
* - x axis category value (for `category` x axis). If the type is a string, then it is a category value itself. If the type is a number, then it is the index of an element in the array of categories described in `xAxis.categories`
|
|
10
|
+
*/
|
|
11
|
+
x?: string | number;
|
|
12
|
+
/**
|
|
13
|
+
* The `y` value. Depending on the context , it may represents:
|
|
14
|
+
* - numeric value (for `linear` y axis)
|
|
15
|
+
*/
|
|
16
|
+
y?: number;
|
|
17
|
+
/** Data label value of the point. If not specified, the y value is used. */
|
|
18
|
+
label?: string | number;
|
|
19
|
+
/** Individual opacity for the point. */
|
|
20
|
+
opacity?: number;
|
|
21
|
+
/** When this property is true, the point display the total sum across the entire series. */
|
|
22
|
+
total?: boolean;
|
|
23
|
+
};
|
|
24
|
+
export type WaterfallSeries<T = any> = BaseSeries & {
|
|
25
|
+
type: typeof SeriesType.Waterfall;
|
|
26
|
+
data: WaterfallSeriesData<T>[];
|
|
27
|
+
/** The name of the series (used in legend, tooltip etc). */
|
|
28
|
+
name: string;
|
|
29
|
+
/** The main color of the series (hex, rgba). */
|
|
30
|
+
color?: string;
|
|
31
|
+
/** The color used for positive values. If it is not specified, the general color of the series is used. */
|
|
32
|
+
positiveColor?: string;
|
|
33
|
+
/** The color used for negative values. If it is not specified, the general color of the series is used. */
|
|
34
|
+
negativeColor?: string;
|
|
35
|
+
/** Individual series legend options. Has higher priority than legend options in widget data. */
|
|
36
|
+
legend?: ChartKitWidgetLegend & {
|
|
37
|
+
symbol?: RectLegendSymbolOptions;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravity-ui/chartkit",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.6.0",
|
|
4
4
|
"description": "React component used to render charts based on any sources you need",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "git@github.com:gravity-ui/ChartKit.git",
|
|
@@ -75,6 +75,7 @@
|
|
|
75
75
|
"@storybook/react": "^7.0.26",
|
|
76
76
|
"@storybook/react-webpack5": "^7.0.26",
|
|
77
77
|
"@types/d3": "^7.4.0",
|
|
78
|
+
"@types/d3-selection": "^3.0.10",
|
|
78
79
|
"@types/jest": "^28.1.3",
|
|
79
80
|
"@types/lodash": "^4.14.177",
|
|
80
81
|
"@types/node": "^18.0.0",
|