@gravity-ui/charts 1.34.4 → 1.34.6
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.
|
@@ -74,7 +74,7 @@ async function prepareDataLabels({ series, points, xMax, yAxisTop, }) {
|
|
|
74
74
|
return { svgLabels, htmlLabels };
|
|
75
75
|
}
|
|
76
76
|
export const prepareAreaData = async (args) => {
|
|
77
|
-
var _a, _b;
|
|
77
|
+
var _a, _b, _c;
|
|
78
78
|
const { series, xAxis, xScale, yAxis, yScale, boundsHeight: plotHeight, split, isOutsideBounds, isRangeSlider, } = args;
|
|
79
79
|
const [_xMin, xRangeMax] = xScale.range();
|
|
80
80
|
const xMax = xRangeMax;
|
|
@@ -219,13 +219,6 @@ export const prepareAreaData = async (args) => {
|
|
|
219
219
|
}
|
|
220
220
|
return pointsAcc;
|
|
221
221
|
}, []);
|
|
222
|
-
const labels = [];
|
|
223
|
-
const htmlElements = [];
|
|
224
|
-
if (s.dataLabels.enabled && !isRangeSlider) {
|
|
225
|
-
const labelsData = await prepareDataLabels({ series: s, points, xMax, yAxisTop });
|
|
226
|
-
labels.push(...labelsData.svgLabels);
|
|
227
|
-
htmlElements.push(...labelsData.htmlLabels);
|
|
228
|
-
}
|
|
229
222
|
let markers = [];
|
|
230
223
|
if (s.marker.states.normal.enabled || s.marker.states.hover.enabled) {
|
|
231
224
|
markers = points.reduce((markersAcc, p) => {
|
|
@@ -244,7 +237,7 @@ export const prepareAreaData = async (args) => {
|
|
|
244
237
|
seriesStackData.push({
|
|
245
238
|
points,
|
|
246
239
|
markers,
|
|
247
|
-
labels,
|
|
240
|
+
labels: [],
|
|
248
241
|
color: s.color,
|
|
249
242
|
opacity: s.opacity,
|
|
250
243
|
width: s.lineWidth,
|
|
@@ -252,10 +245,10 @@ export const prepareAreaData = async (args) => {
|
|
|
252
245
|
hovered: false,
|
|
253
246
|
active: true,
|
|
254
247
|
id: s.id,
|
|
255
|
-
htmlElements,
|
|
248
|
+
htmlElements: [],
|
|
256
249
|
});
|
|
257
250
|
}
|
|
258
|
-
if (
|
|
251
|
+
if (seriesStack.some((s) => s.stacking === 'percent')) {
|
|
259
252
|
xValues.forEach(([x], index) => {
|
|
260
253
|
var _a;
|
|
261
254
|
const stackHeight = ((_a = positiveStackValues.get(x)) === null || _a === void 0 ? void 0 : _a.prev) || 0;
|
|
@@ -265,12 +258,33 @@ export const prepareAreaData = async (args) => {
|
|
|
265
258
|
const point = item.points[index];
|
|
266
259
|
if (point.y !== null && point.y !== undefined) {
|
|
267
260
|
const height = (point.y0 - point.y) * ratio;
|
|
268
|
-
|
|
269
|
-
point.
|
|
270
|
-
|
|
261
|
+
const nextAcc = acc + height;
|
|
262
|
+
point.y0 = plotHeight - acc;
|
|
263
|
+
point.y = plotHeight - nextAcc;
|
|
264
|
+
acc = nextAcc;
|
|
271
265
|
}
|
|
272
266
|
});
|
|
273
267
|
});
|
|
268
|
+
seriesStackData.forEach((item) => {
|
|
269
|
+
item.markers.forEach((marker) => {
|
|
270
|
+
marker.clipped = isOutsideBounds(marker.point.x, marker.point.y);
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
for (let itemIndex = 0; itemIndex < seriesStackData.length; itemIndex++) {
|
|
275
|
+
const item = seriesStackData[itemIndex];
|
|
276
|
+
const currentYAxis = yAxis[item.series.yAxis];
|
|
277
|
+
const itemYAxisTop = ((_c = split.plots[currentYAxis.plotIndex]) === null || _c === void 0 ? void 0 : _c.top) || 0;
|
|
278
|
+
if (item.series.dataLabels.enabled && !isRangeSlider) {
|
|
279
|
+
const labelsData = await prepareDataLabels({
|
|
280
|
+
series: item.series,
|
|
281
|
+
points: item.points,
|
|
282
|
+
xMax,
|
|
283
|
+
yAxisTop: itemYAxisTop,
|
|
284
|
+
});
|
|
285
|
+
item.labels.push(...labelsData.svgLabels);
|
|
286
|
+
item.htmlElements.push(...labelsData.htmlLabels);
|
|
287
|
+
}
|
|
274
288
|
}
|
|
275
289
|
result.push(...seriesStackData);
|
|
276
290
|
}
|
|
@@ -5,11 +5,12 @@ async function getHtmlLabel(point, series, xMax) {
|
|
|
5
5
|
var _a;
|
|
6
6
|
const content = String((_a = point.data.label) !== null && _a !== void 0 ? _a : point.data.y);
|
|
7
7
|
const size = await getLabelsSize({ labels: [content], html: true });
|
|
8
|
+
const width = size.maxWidth;
|
|
8
9
|
return {
|
|
9
|
-
x: Math.min(xMax - size.maxWidth, Math.max(0, point.x)),
|
|
10
|
+
x: Math.min(xMax - size.maxWidth, Math.max(0, point.x - width / 2)),
|
|
10
11
|
y: Math.max(0, point.y - series.dataLabels.padding - size.maxHeight),
|
|
11
12
|
content,
|
|
12
|
-
size: { width
|
|
13
|
+
size: { width, height: size.maxHeight },
|
|
13
14
|
style: series.dataLabels.style,
|
|
14
15
|
};
|
|
15
16
|
}
|
|
@@ -74,7 +74,7 @@ async function prepareDataLabels({ series, points, xMax, yAxisTop, }) {
|
|
|
74
74
|
return { svgLabels, htmlLabels };
|
|
75
75
|
}
|
|
76
76
|
export const prepareAreaData = async (args) => {
|
|
77
|
-
var _a, _b;
|
|
77
|
+
var _a, _b, _c;
|
|
78
78
|
const { series, xAxis, xScale, yAxis, yScale, boundsHeight: plotHeight, split, isOutsideBounds, isRangeSlider, } = args;
|
|
79
79
|
const [_xMin, xRangeMax] = xScale.range();
|
|
80
80
|
const xMax = xRangeMax;
|
|
@@ -219,13 +219,6 @@ export const prepareAreaData = async (args) => {
|
|
|
219
219
|
}
|
|
220
220
|
return pointsAcc;
|
|
221
221
|
}, []);
|
|
222
|
-
const labels = [];
|
|
223
|
-
const htmlElements = [];
|
|
224
|
-
if (s.dataLabels.enabled && !isRangeSlider) {
|
|
225
|
-
const labelsData = await prepareDataLabels({ series: s, points, xMax, yAxisTop });
|
|
226
|
-
labels.push(...labelsData.svgLabels);
|
|
227
|
-
htmlElements.push(...labelsData.htmlLabels);
|
|
228
|
-
}
|
|
229
222
|
let markers = [];
|
|
230
223
|
if (s.marker.states.normal.enabled || s.marker.states.hover.enabled) {
|
|
231
224
|
markers = points.reduce((markersAcc, p) => {
|
|
@@ -244,7 +237,7 @@ export const prepareAreaData = async (args) => {
|
|
|
244
237
|
seriesStackData.push({
|
|
245
238
|
points,
|
|
246
239
|
markers,
|
|
247
|
-
labels,
|
|
240
|
+
labels: [],
|
|
248
241
|
color: s.color,
|
|
249
242
|
opacity: s.opacity,
|
|
250
243
|
width: s.lineWidth,
|
|
@@ -252,10 +245,10 @@ export const prepareAreaData = async (args) => {
|
|
|
252
245
|
hovered: false,
|
|
253
246
|
active: true,
|
|
254
247
|
id: s.id,
|
|
255
|
-
htmlElements,
|
|
248
|
+
htmlElements: [],
|
|
256
249
|
});
|
|
257
250
|
}
|
|
258
|
-
if (
|
|
251
|
+
if (seriesStack.some((s) => s.stacking === 'percent')) {
|
|
259
252
|
xValues.forEach(([x], index) => {
|
|
260
253
|
var _a;
|
|
261
254
|
const stackHeight = ((_a = positiveStackValues.get(x)) === null || _a === void 0 ? void 0 : _a.prev) || 0;
|
|
@@ -265,12 +258,33 @@ export const prepareAreaData = async (args) => {
|
|
|
265
258
|
const point = item.points[index];
|
|
266
259
|
if (point.y !== null && point.y !== undefined) {
|
|
267
260
|
const height = (point.y0 - point.y) * ratio;
|
|
268
|
-
|
|
269
|
-
point.
|
|
270
|
-
|
|
261
|
+
const nextAcc = acc + height;
|
|
262
|
+
point.y0 = plotHeight - acc;
|
|
263
|
+
point.y = plotHeight - nextAcc;
|
|
264
|
+
acc = nextAcc;
|
|
271
265
|
}
|
|
272
266
|
});
|
|
273
267
|
});
|
|
268
|
+
seriesStackData.forEach((item) => {
|
|
269
|
+
item.markers.forEach((marker) => {
|
|
270
|
+
marker.clipped = isOutsideBounds(marker.point.x, marker.point.y);
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
for (let itemIndex = 0; itemIndex < seriesStackData.length; itemIndex++) {
|
|
275
|
+
const item = seriesStackData[itemIndex];
|
|
276
|
+
const currentYAxis = yAxis[item.series.yAxis];
|
|
277
|
+
const itemYAxisTop = ((_c = split.plots[currentYAxis.plotIndex]) === null || _c === void 0 ? void 0 : _c.top) || 0;
|
|
278
|
+
if (item.series.dataLabels.enabled && !isRangeSlider) {
|
|
279
|
+
const labelsData = await prepareDataLabels({
|
|
280
|
+
series: item.series,
|
|
281
|
+
points: item.points,
|
|
282
|
+
xMax,
|
|
283
|
+
yAxisTop: itemYAxisTop,
|
|
284
|
+
});
|
|
285
|
+
item.labels.push(...labelsData.svgLabels);
|
|
286
|
+
item.htmlElements.push(...labelsData.htmlLabels);
|
|
287
|
+
}
|
|
274
288
|
}
|
|
275
289
|
result.push(...seriesStackData);
|
|
276
290
|
}
|
|
@@ -5,11 +5,12 @@ async function getHtmlLabel(point, series, xMax) {
|
|
|
5
5
|
var _a;
|
|
6
6
|
const content = String((_a = point.data.label) !== null && _a !== void 0 ? _a : point.data.y);
|
|
7
7
|
const size = await getLabelsSize({ labels: [content], html: true });
|
|
8
|
+
const width = size.maxWidth;
|
|
8
9
|
return {
|
|
9
|
-
x: Math.min(xMax - size.maxWidth, Math.max(0, point.x)),
|
|
10
|
+
x: Math.min(xMax - size.maxWidth, Math.max(0, point.x - width / 2)),
|
|
10
11
|
y: Math.max(0, point.y - series.dataLabels.padding - size.maxHeight),
|
|
11
12
|
content,
|
|
12
|
-
size: { width
|
|
13
|
+
size: { width, height: size.maxHeight },
|
|
13
14
|
style: series.dataLabels.style,
|
|
14
15
|
};
|
|
15
16
|
}
|