@gravity-ui/charts 1.34.3 → 1.34.4
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/hooks/useSeries/prepare-bar-y.js +1 -1
- package/dist/cjs/hooks/useShapes/area/prepare-data.js +2 -1
- package/dist/cjs/hooks/useShapes/bar-x/prepare-data.js +2 -1
- package/dist/cjs/hooks/useShapes/bar-y/prepare-data.js +3 -3
- package/dist/cjs/hooks/useShapes/line/prepare-data.js +6 -5
- package/dist/cjs/hooks/useShapes/pie/prepare-data.js +2 -1
- package/dist/esm/hooks/useSeries/prepare-bar-y.js +1 -1
- package/dist/esm/hooks/useShapes/area/prepare-data.js +2 -1
- package/dist/esm/hooks/useShapes/bar-x/prepare-data.js +2 -1
- package/dist/esm/hooks/useShapes/bar-y/prepare-data.js +3 -3
- package/dist/esm/hooks/useShapes/line/prepare-data.js +6 -5
- package/dist/esm/hooks/useShapes/pie/prepare-data.js +2 -1
- package/package.json +1 -1
|
@@ -22,7 +22,7 @@ async function prepareDataLabels(series) {
|
|
|
22
22
|
const style = Object.assign({}, DEFAULT_DATALABELS_STYLE, (_a = series.dataLabels) === null || _a === void 0 ? void 0 : _a.style);
|
|
23
23
|
const html = get(series, 'dataLabels.html', false);
|
|
24
24
|
const labels = enabled
|
|
25
|
-
? series.data.map((d) => getFormattedValue(Object.assign({ value: d.label
|
|
25
|
+
? series.data.map((d) => { var _a; return getFormattedValue(Object.assign({ value: (_a = d.label) !== null && _a !== void 0 ? _a : d.x }, series.dataLabels)); })
|
|
26
26
|
: [];
|
|
27
27
|
const { maxHeight = 0, maxWidth = 0 } = await getLabelsSize({
|
|
28
28
|
labels,
|
|
@@ -28,6 +28,7 @@ function getXValues(series, xAxis, xScale) {
|
|
|
28
28
|
return Array.from(xValues);
|
|
29
29
|
}
|
|
30
30
|
async function prepareDataLabels({ series, points, xMax, yAxisTop, }) {
|
|
31
|
+
var _a;
|
|
31
32
|
const svgLabels = [];
|
|
32
33
|
const htmlLabels = [];
|
|
33
34
|
const getTextSize = getTextSizeFn({ style: series.dataLabels.style });
|
|
@@ -36,7 +37,7 @@ async function prepareDataLabels({ series, points, xMax, yAxisTop, }) {
|
|
|
36
37
|
if (point.y === null) {
|
|
37
38
|
continue;
|
|
38
39
|
}
|
|
39
|
-
const text = getFormattedValue(Object.assign({ value: point.data.label
|
|
40
|
+
const text = getFormattedValue(Object.assign({ value: (_a = point.data.label) !== null && _a !== void 0 ? _a : point.data.y }, series.dataLabels));
|
|
40
41
|
if (series.dataLabels.html) {
|
|
41
42
|
const size = await getLabelsSize({
|
|
42
43
|
labels: [text],
|
|
@@ -6,10 +6,11 @@ import { getSeriesStackId } from '../../useSeries/utils';
|
|
|
6
6
|
import { getBarXLayout } from '../../utils/bar-x';
|
|
7
7
|
const isSeriesDataValid = (d) => d.y !== null;
|
|
8
8
|
async function getLabelData(d) {
|
|
9
|
+
var _a;
|
|
9
10
|
if (!d.series.dataLabels.enabled) {
|
|
10
11
|
return undefined;
|
|
11
12
|
}
|
|
12
|
-
const text = getFormattedValue(Object.assign({ value: d.data.label
|
|
13
|
+
const text = getFormattedValue(Object.assign({ value: (_a = d.data.label) !== null && _a !== void 0 ? _a : d.data.y }, d.series.dataLabels));
|
|
13
14
|
const style = d.series.dataLabels.style;
|
|
14
15
|
const html = d.series.dataLabels.html;
|
|
15
16
|
const { maxHeight: height, maxWidth: width } = await getLabelsSize({
|
|
@@ -4,7 +4,7 @@ import { filterOverlappingLabels, getHtmlLabelConstraintedPosition, getLabelsSiz
|
|
|
4
4
|
import { getFormattedValue } from '../../../utils/chart/format';
|
|
5
5
|
import { getBarYLayout, groupBarYDataByYValue } from '../../utils';
|
|
6
6
|
export async function prepareBarYData(args) {
|
|
7
|
-
var _a;
|
|
7
|
+
var _a, _b;
|
|
8
8
|
const { boundsHeight, boundsWidth, series, seriesOptions, xAxis, yAxis, xScale, yScale: [yScale], } = args;
|
|
9
9
|
const stackGap = seriesOptions['bar-y'].stackGap;
|
|
10
10
|
const xLinearScale = xScale;
|
|
@@ -139,7 +139,7 @@ export async function prepareBarYData(args) {
|
|
|
139
139
|
const dataLabels = prepared.series.dataLabels;
|
|
140
140
|
if (dataLabels.enabled) {
|
|
141
141
|
const data = prepared.data;
|
|
142
|
-
const content = getFormattedValue(Object.assign({ value: data.label
|
|
142
|
+
const content = getFormattedValue(Object.assign({ value: (_a = data.label) !== null && _a !== void 0 ? _a : data.x }, dataLabels));
|
|
143
143
|
const y = prepared.y + prepared.height / 2;
|
|
144
144
|
if (dataLabels.html) {
|
|
145
145
|
const { maxHeight: height, maxWidth: width } = await getLabelsSize({
|
|
@@ -195,7 +195,7 @@ export async function prepareBarYData(args) {
|
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
|
-
const allowOverlap = (
|
|
198
|
+
const allowOverlap = (_b = result[0]) === null || _b === void 0 ? void 0 : _b.series.dataLabels.allowOverlap;
|
|
199
199
|
if (labels.length && !allowOverlap) {
|
|
200
200
|
labels = filterOverlappingLabels(labels);
|
|
201
201
|
}
|
|
@@ -2,7 +2,8 @@ import { getLabelsSize, getTextSizeFn } from '../../../utils';
|
|
|
2
2
|
import { getFormattedValue } from '../../../utils/chart/format';
|
|
3
3
|
import { getXValue, getYValue } from '../utils';
|
|
4
4
|
async function getHtmlLabel(point, series, xMax) {
|
|
5
|
-
|
|
5
|
+
var _a;
|
|
6
|
+
const content = String((_a = point.data.label) !== null && _a !== void 0 ? _a : point.data.y);
|
|
6
7
|
const size = await getLabelsSize({ labels: [content], html: true });
|
|
7
8
|
return {
|
|
8
9
|
x: Math.min(xMax - size.maxWidth, Math.max(0, point.x)),
|
|
@@ -13,7 +14,7 @@ async function getHtmlLabel(point, series, xMax) {
|
|
|
13
14
|
};
|
|
14
15
|
}
|
|
15
16
|
export const prepareLineData = async (args) => {
|
|
16
|
-
var _a, _b, _c;
|
|
17
|
+
var _a, _b, _c, _d;
|
|
17
18
|
const { series, xAxis, yAxis, xScale, yScale, split, isOutsideBounds, isRangeSlider } = args;
|
|
18
19
|
const [_xMin, xRangeMax] = xScale.range();
|
|
19
20
|
const xMax = xRangeMax;
|
|
@@ -60,7 +61,7 @@ export const prepareLineData = async (args) => {
|
|
|
60
61
|
for (let index = 0; index < points.length; index++) {
|
|
61
62
|
const point = points[index];
|
|
62
63
|
if (point.y !== null && point.x !== null) {
|
|
63
|
-
const text = getFormattedValue(Object.assign({ value: point.data.label
|
|
64
|
+
const text = getFormattedValue(Object.assign({ value: (_b = point.data.label) !== null && _b !== void 0 ? _b : point.data.y }, s.dataLabels));
|
|
64
65
|
const labelSize = await getTextSize(text);
|
|
65
66
|
const style = s.dataLabels.style;
|
|
66
67
|
const y = Math.max(yAxisTop, point.y - s.dataLabels.padding - labelSize.height);
|
|
@@ -105,11 +106,11 @@ export const prepareLineData = async (args) => {
|
|
|
105
106
|
id: s.id,
|
|
106
107
|
htmlElements,
|
|
107
108
|
color: s.color,
|
|
108
|
-
lineWidth: (
|
|
109
|
+
lineWidth: (_c = (isRangeSlider ? s.rangeSlider.lineWidth : undefined)) !== null && _c !== void 0 ? _c : s.lineWidth,
|
|
109
110
|
dashStyle: s.dashStyle,
|
|
110
111
|
linecap: s.linecap,
|
|
111
112
|
linejoin: s.linejoin,
|
|
112
|
-
opacity: (
|
|
113
|
+
opacity: (_d = (isRangeSlider ? s.rangeSlider.opacity : undefined)) !== null && _d !== void 0 ? _d : s.opacity,
|
|
113
114
|
};
|
|
114
115
|
acc.push(result);
|
|
115
116
|
}
|
|
@@ -82,6 +82,7 @@ export function preparePieData(args) {
|
|
|
82
82
|
return data;
|
|
83
83
|
};
|
|
84
84
|
const getLabels = async ({ series }) => {
|
|
85
|
+
var _a;
|
|
85
86
|
const { dataLabels } = series[0];
|
|
86
87
|
if (!dataLabels.enabled) {
|
|
87
88
|
return {};
|
|
@@ -90,7 +91,7 @@ export function preparePieData(args) {
|
|
|
90
91
|
const acc = {};
|
|
91
92
|
for (let i = 0; i < series.length; i++) {
|
|
92
93
|
const d = series[i];
|
|
93
|
-
const text = getFormattedValue(Object.assign({ value: d.data.label
|
|
94
|
+
const text = getFormattedValue(Object.assign({ value: (_a = d.data.label) !== null && _a !== void 0 ? _a : d.data.value }, d.dataLabels));
|
|
94
95
|
let labelWidth = 0;
|
|
95
96
|
let labelHeight = 0;
|
|
96
97
|
if (dataLabels.html) {
|
|
@@ -22,7 +22,7 @@ async function prepareDataLabels(series) {
|
|
|
22
22
|
const style = Object.assign({}, DEFAULT_DATALABELS_STYLE, (_a = series.dataLabels) === null || _a === void 0 ? void 0 : _a.style);
|
|
23
23
|
const html = get(series, 'dataLabels.html', false);
|
|
24
24
|
const labels = enabled
|
|
25
|
-
? series.data.map((d) => getFormattedValue(Object.assign({ value: d.label
|
|
25
|
+
? series.data.map((d) => { var _a; return getFormattedValue(Object.assign({ value: (_a = d.label) !== null && _a !== void 0 ? _a : d.x }, series.dataLabels)); })
|
|
26
26
|
: [];
|
|
27
27
|
const { maxHeight = 0, maxWidth = 0 } = await getLabelsSize({
|
|
28
28
|
labels,
|
|
@@ -28,6 +28,7 @@ function getXValues(series, xAxis, xScale) {
|
|
|
28
28
|
return Array.from(xValues);
|
|
29
29
|
}
|
|
30
30
|
async function prepareDataLabels({ series, points, xMax, yAxisTop, }) {
|
|
31
|
+
var _a;
|
|
31
32
|
const svgLabels = [];
|
|
32
33
|
const htmlLabels = [];
|
|
33
34
|
const getTextSize = getTextSizeFn({ style: series.dataLabels.style });
|
|
@@ -36,7 +37,7 @@ async function prepareDataLabels({ series, points, xMax, yAxisTop, }) {
|
|
|
36
37
|
if (point.y === null) {
|
|
37
38
|
continue;
|
|
38
39
|
}
|
|
39
|
-
const text = getFormattedValue(Object.assign({ value: point.data.label
|
|
40
|
+
const text = getFormattedValue(Object.assign({ value: (_a = point.data.label) !== null && _a !== void 0 ? _a : point.data.y }, series.dataLabels));
|
|
40
41
|
if (series.dataLabels.html) {
|
|
41
42
|
const size = await getLabelsSize({
|
|
42
43
|
labels: [text],
|
|
@@ -6,10 +6,11 @@ import { getSeriesStackId } from '../../useSeries/utils';
|
|
|
6
6
|
import { getBarXLayout } from '../../utils/bar-x';
|
|
7
7
|
const isSeriesDataValid = (d) => d.y !== null;
|
|
8
8
|
async function getLabelData(d) {
|
|
9
|
+
var _a;
|
|
9
10
|
if (!d.series.dataLabels.enabled) {
|
|
10
11
|
return undefined;
|
|
11
12
|
}
|
|
12
|
-
const text = getFormattedValue(Object.assign({ value: d.data.label
|
|
13
|
+
const text = getFormattedValue(Object.assign({ value: (_a = d.data.label) !== null && _a !== void 0 ? _a : d.data.y }, d.series.dataLabels));
|
|
13
14
|
const style = d.series.dataLabels.style;
|
|
14
15
|
const html = d.series.dataLabels.html;
|
|
15
16
|
const { maxHeight: height, maxWidth: width } = await getLabelsSize({
|
|
@@ -4,7 +4,7 @@ import { filterOverlappingLabels, getHtmlLabelConstraintedPosition, getLabelsSiz
|
|
|
4
4
|
import { getFormattedValue } from '../../../utils/chart/format';
|
|
5
5
|
import { getBarYLayout, groupBarYDataByYValue } from '../../utils';
|
|
6
6
|
export async function prepareBarYData(args) {
|
|
7
|
-
var _a;
|
|
7
|
+
var _a, _b;
|
|
8
8
|
const { boundsHeight, boundsWidth, series, seriesOptions, xAxis, yAxis, xScale, yScale: [yScale], } = args;
|
|
9
9
|
const stackGap = seriesOptions['bar-y'].stackGap;
|
|
10
10
|
const xLinearScale = xScale;
|
|
@@ -139,7 +139,7 @@ export async function prepareBarYData(args) {
|
|
|
139
139
|
const dataLabels = prepared.series.dataLabels;
|
|
140
140
|
if (dataLabels.enabled) {
|
|
141
141
|
const data = prepared.data;
|
|
142
|
-
const content = getFormattedValue(Object.assign({ value: data.label
|
|
142
|
+
const content = getFormattedValue(Object.assign({ value: (_a = data.label) !== null && _a !== void 0 ? _a : data.x }, dataLabels));
|
|
143
143
|
const y = prepared.y + prepared.height / 2;
|
|
144
144
|
if (dataLabels.html) {
|
|
145
145
|
const { maxHeight: height, maxWidth: width } = await getLabelsSize({
|
|
@@ -195,7 +195,7 @@ export async function prepareBarYData(args) {
|
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
|
-
const allowOverlap = (
|
|
198
|
+
const allowOverlap = (_b = result[0]) === null || _b === void 0 ? void 0 : _b.series.dataLabels.allowOverlap;
|
|
199
199
|
if (labels.length && !allowOverlap) {
|
|
200
200
|
labels = filterOverlappingLabels(labels);
|
|
201
201
|
}
|
|
@@ -2,7 +2,8 @@ import { getLabelsSize, getTextSizeFn } from '../../../utils';
|
|
|
2
2
|
import { getFormattedValue } from '../../../utils/chart/format';
|
|
3
3
|
import { getXValue, getYValue } from '../utils';
|
|
4
4
|
async function getHtmlLabel(point, series, xMax) {
|
|
5
|
-
|
|
5
|
+
var _a;
|
|
6
|
+
const content = String((_a = point.data.label) !== null && _a !== void 0 ? _a : point.data.y);
|
|
6
7
|
const size = await getLabelsSize({ labels: [content], html: true });
|
|
7
8
|
return {
|
|
8
9
|
x: Math.min(xMax - size.maxWidth, Math.max(0, point.x)),
|
|
@@ -13,7 +14,7 @@ async function getHtmlLabel(point, series, xMax) {
|
|
|
13
14
|
};
|
|
14
15
|
}
|
|
15
16
|
export const prepareLineData = async (args) => {
|
|
16
|
-
var _a, _b, _c;
|
|
17
|
+
var _a, _b, _c, _d;
|
|
17
18
|
const { series, xAxis, yAxis, xScale, yScale, split, isOutsideBounds, isRangeSlider } = args;
|
|
18
19
|
const [_xMin, xRangeMax] = xScale.range();
|
|
19
20
|
const xMax = xRangeMax;
|
|
@@ -60,7 +61,7 @@ export const prepareLineData = async (args) => {
|
|
|
60
61
|
for (let index = 0; index < points.length; index++) {
|
|
61
62
|
const point = points[index];
|
|
62
63
|
if (point.y !== null && point.x !== null) {
|
|
63
|
-
const text = getFormattedValue(Object.assign({ value: point.data.label
|
|
64
|
+
const text = getFormattedValue(Object.assign({ value: (_b = point.data.label) !== null && _b !== void 0 ? _b : point.data.y }, s.dataLabels));
|
|
64
65
|
const labelSize = await getTextSize(text);
|
|
65
66
|
const style = s.dataLabels.style;
|
|
66
67
|
const y = Math.max(yAxisTop, point.y - s.dataLabels.padding - labelSize.height);
|
|
@@ -105,11 +106,11 @@ export const prepareLineData = async (args) => {
|
|
|
105
106
|
id: s.id,
|
|
106
107
|
htmlElements,
|
|
107
108
|
color: s.color,
|
|
108
|
-
lineWidth: (
|
|
109
|
+
lineWidth: (_c = (isRangeSlider ? s.rangeSlider.lineWidth : undefined)) !== null && _c !== void 0 ? _c : s.lineWidth,
|
|
109
110
|
dashStyle: s.dashStyle,
|
|
110
111
|
linecap: s.linecap,
|
|
111
112
|
linejoin: s.linejoin,
|
|
112
|
-
opacity: (
|
|
113
|
+
opacity: (_d = (isRangeSlider ? s.rangeSlider.opacity : undefined)) !== null && _d !== void 0 ? _d : s.opacity,
|
|
113
114
|
};
|
|
114
115
|
acc.push(result);
|
|
115
116
|
}
|
|
@@ -82,6 +82,7 @@ export function preparePieData(args) {
|
|
|
82
82
|
return data;
|
|
83
83
|
};
|
|
84
84
|
const getLabels = async ({ series }) => {
|
|
85
|
+
var _a;
|
|
85
86
|
const { dataLabels } = series[0];
|
|
86
87
|
if (!dataLabels.enabled) {
|
|
87
88
|
return {};
|
|
@@ -90,7 +91,7 @@ export function preparePieData(args) {
|
|
|
90
91
|
const acc = {};
|
|
91
92
|
for (let i = 0; i < series.length; i++) {
|
|
92
93
|
const d = series[i];
|
|
93
|
-
const text = getFormattedValue(Object.assign({ value: d.data.label
|
|
94
|
+
const text = getFormattedValue(Object.assign({ value: (_a = d.data.label) !== null && _a !== void 0 ? _a : d.data.value }, d.dataLabels));
|
|
94
95
|
let labelWidth = 0;
|
|
95
96
|
let labelHeight = 0;
|
|
96
97
|
if (dataLabels.html) {
|