@gravity-ui/charts 1.18.1 → 1.18.2
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/AxisY/prepare-axis-data.js +1 -1
- package/dist/cjs/components/Legend/index.js +1 -1
- package/dist/cjs/hooks/useShapes/bar-y/prepare-data.js +7 -4
- package/dist/cjs/validation/index.js +4 -1
- package/dist/esm/components/AxisY/prepare-axis-data.js +1 -1
- package/dist/esm/components/Legend/index.js +1 -1
- package/dist/esm/hooks/useShapes/bar-y/prepare-data.js +7 -4
- package/dist/esm/validation/index.js +4 -1
- package/package.json +1 -1
|
@@ -226,7 +226,7 @@ export async function prepareAxisData({ axis, split, scale, top: topOffset, widt
|
|
|
226
226
|
content: titleContent,
|
|
227
227
|
style: axis.title.style,
|
|
228
228
|
size: rotatedTitleSize,
|
|
229
|
-
x
|
|
229
|
+
x,
|
|
230
230
|
y: axisPlotTopPosition + y,
|
|
231
231
|
rotate: rotateAngle,
|
|
232
232
|
offset: -(originalTextSize.height / titleContent.length) * (titleContent.length - 1),
|
|
@@ -113,9 +113,6 @@ export async function prepareBarYData(args) {
|
|
|
113
113
|
if (dataLabels.enabled) {
|
|
114
114
|
const data = prepared.data;
|
|
115
115
|
const content = getFormattedValue(Object.assign({ value: data.label || data.x }, dataLabels));
|
|
116
|
-
const x = dataLabels.inside
|
|
117
|
-
? prepared.x + prepared.width / 2
|
|
118
|
-
: prepared.x + prepared.width + DEFAULT_LABEL_PADDING;
|
|
119
116
|
const y = prepared.y + prepared.height / 2;
|
|
120
117
|
if (dataLabels.html) {
|
|
121
118
|
const { maxHeight: height, maxWidth: width } = await getLabelsSize({
|
|
@@ -123,6 +120,9 @@ export async function prepareBarYData(args) {
|
|
|
123
120
|
style: dataLabels.style,
|
|
124
121
|
html: dataLabels.html,
|
|
125
122
|
});
|
|
123
|
+
const x = dataLabels.inside
|
|
124
|
+
? prepared.x + prepared.width / 2 - width / 2
|
|
125
|
+
: prepared.x + prepared.width + DEFAULT_LABEL_PADDING;
|
|
126
126
|
const constrainedPosition = getHtmlLabelConstraintedPosition({
|
|
127
127
|
boundsHeight,
|
|
128
128
|
boundsWidth,
|
|
@@ -145,6 +145,9 @@ export async function prepareBarYData(args) {
|
|
|
145
145
|
}
|
|
146
146
|
const getTextSize = map.get(dataLabels.style);
|
|
147
147
|
const { width, height } = await getTextSize(content);
|
|
148
|
+
const x = dataLabels.inside
|
|
149
|
+
? prepared.x + prepared.width / 2 - width / 2
|
|
150
|
+
: prepared.x + prepared.width + DEFAULT_LABEL_PADDING;
|
|
148
151
|
const constrainedPosition = getSvgLabelConstraintedPosition({
|
|
149
152
|
boundsHeight,
|
|
150
153
|
boundsWidth,
|
|
@@ -158,7 +161,7 @@ export async function prepareBarYData(args) {
|
|
|
158
161
|
series: prepared.series,
|
|
159
162
|
style: dataLabels.style,
|
|
160
163
|
text: content,
|
|
161
|
-
textAnchor:
|
|
164
|
+
textAnchor: 'start',
|
|
162
165
|
x: constrainedPosition.x,
|
|
163
166
|
y: constrainedPosition.y,
|
|
164
167
|
});
|
|
@@ -368,7 +368,10 @@ function validateTooltip({ tooltip }) {
|
|
|
368
368
|
}
|
|
369
369
|
}
|
|
370
370
|
export function validateData(data) {
|
|
371
|
-
if (isEmpty(data) ||
|
|
371
|
+
if (isEmpty(data) ||
|
|
372
|
+
isEmpty(data.series) ||
|
|
373
|
+
isEmpty(data.series.data) ||
|
|
374
|
+
data.series.data.every((s) => isEmpty(s.data))) {
|
|
372
375
|
throw new ChartError({
|
|
373
376
|
code: CHART_ERROR_CODE.NO_DATA,
|
|
374
377
|
message: i18n('error', 'label_no-data'),
|
|
@@ -226,7 +226,7 @@ export async function prepareAxisData({ axis, split, scale, top: topOffset, widt
|
|
|
226
226
|
content: titleContent,
|
|
227
227
|
style: axis.title.style,
|
|
228
228
|
size: rotatedTitleSize,
|
|
229
|
-
x
|
|
229
|
+
x,
|
|
230
230
|
y: axisPlotTopPosition + y,
|
|
231
231
|
rotate: rotateAngle,
|
|
232
232
|
offset: -(originalTextSize.height / titleContent.length) * (titleContent.length - 1),
|
|
@@ -113,9 +113,6 @@ export async function prepareBarYData(args) {
|
|
|
113
113
|
if (dataLabels.enabled) {
|
|
114
114
|
const data = prepared.data;
|
|
115
115
|
const content = getFormattedValue(Object.assign({ value: data.label || data.x }, dataLabels));
|
|
116
|
-
const x = dataLabels.inside
|
|
117
|
-
? prepared.x + prepared.width / 2
|
|
118
|
-
: prepared.x + prepared.width + DEFAULT_LABEL_PADDING;
|
|
119
116
|
const y = prepared.y + prepared.height / 2;
|
|
120
117
|
if (dataLabels.html) {
|
|
121
118
|
const { maxHeight: height, maxWidth: width } = await getLabelsSize({
|
|
@@ -123,6 +120,9 @@ export async function prepareBarYData(args) {
|
|
|
123
120
|
style: dataLabels.style,
|
|
124
121
|
html: dataLabels.html,
|
|
125
122
|
});
|
|
123
|
+
const x = dataLabels.inside
|
|
124
|
+
? prepared.x + prepared.width / 2 - width / 2
|
|
125
|
+
: prepared.x + prepared.width + DEFAULT_LABEL_PADDING;
|
|
126
126
|
const constrainedPosition = getHtmlLabelConstraintedPosition({
|
|
127
127
|
boundsHeight,
|
|
128
128
|
boundsWidth,
|
|
@@ -145,6 +145,9 @@ export async function prepareBarYData(args) {
|
|
|
145
145
|
}
|
|
146
146
|
const getTextSize = map.get(dataLabels.style);
|
|
147
147
|
const { width, height } = await getTextSize(content);
|
|
148
|
+
const x = dataLabels.inside
|
|
149
|
+
? prepared.x + prepared.width / 2 - width / 2
|
|
150
|
+
: prepared.x + prepared.width + DEFAULT_LABEL_PADDING;
|
|
148
151
|
const constrainedPosition = getSvgLabelConstraintedPosition({
|
|
149
152
|
boundsHeight,
|
|
150
153
|
boundsWidth,
|
|
@@ -158,7 +161,7 @@ export async function prepareBarYData(args) {
|
|
|
158
161
|
series: prepared.series,
|
|
159
162
|
style: dataLabels.style,
|
|
160
163
|
text: content,
|
|
161
|
-
textAnchor:
|
|
164
|
+
textAnchor: 'start',
|
|
162
165
|
x: constrainedPosition.x,
|
|
163
166
|
y: constrainedPosition.y,
|
|
164
167
|
});
|
|
@@ -368,7 +368,10 @@ function validateTooltip({ tooltip }) {
|
|
|
368
368
|
}
|
|
369
369
|
}
|
|
370
370
|
export function validateData(data) {
|
|
371
|
-
if (isEmpty(data) ||
|
|
371
|
+
if (isEmpty(data) ||
|
|
372
|
+
isEmpty(data.series) ||
|
|
373
|
+
isEmpty(data.series.data) ||
|
|
374
|
+
data.series.data.every((s) => isEmpty(s.data))) {
|
|
372
375
|
throw new ChartError({
|
|
373
376
|
code: CHART_ERROR_CODE.NO_DATA,
|
|
374
377
|
message: i18n('error', 'label_no-data'),
|