Skip to content

Commit fc54aa0

Browse files
committed
Fix - VueUiXy - Hide annotations when no datapoint is visible
1 parent 3fc175d commit fc54aa0

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/components/vue-ui-xy.vue

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,7 @@
11931193
<g v-if="annotationsY.length && !mutableConfig.isStacked">
11941194
<g v-for="annotation in annotationsY" :key="annotation.uid">
11951195
<line
1196-
v-if="annotation.yTop"
1196+
v-if="annotation.yTop && annotation.show"
11971197
:x1="annotation.x1"
11981198
:y1="annotation.yTop"
11991199
:x2="annotation.x2"
@@ -1205,7 +1205,7 @@
12051205
:style="{ animation: 'none !important'}"
12061206
/>
12071207
<line
1208-
v-if="annotation.yBottom"
1208+
v-if="annotation.yBottom && annotation.show"
12091209
:x1="annotation.x1"
12101210
:y1="annotation.yBottom"
12111211
:x2="annotation.x2"
@@ -1217,24 +1217,24 @@
12171217
:style="{ animation: 'none !important'}"
12181218
/>
12191219
<rect
1220-
v-if="annotation.hasArea"
1220+
v-if="annotation.hasArea && annotation.show"
12211221
:y="Math.min(annotation.yTop, annotation.yBottom)"
12221222
:x="annotation.x1"
12231223
:width="drawingArea.width"
1224-
:height="annotation.areaHeight"
1224+
:height="checkNaN(annotation.areaHeight, 0)"
12251225
:fill="setOpacity(annotation.config.area.fill, annotation.config.area.opacity)"
12261226
:style="{ animation: 'none !important' }"
12271227
/>
12281228
<rect
1229-
v-if="annotation.config.label.text"
1229+
v-if="annotation.config.label.text && annotation.show"
12301230
class="vue-ui-xy-annotation-label-box"
12311231
v-bind="annotation._box"
12321232
:style="{ animation: 'none !important', transition: 'none !important'}"
12331233
/>
12341234
<text
1235+
v-if="annotation.config.label.text && annotation.show"
12351236
:id="annotation.id"
12361237
class="vue-ui-xy-annotation-label"
1237-
v-if="annotation.config.label.text"
12381238
:x="annotation._text.x"
12391239
:y="annotation._text.y"
12401240
:font-size="annotation.config.label.fontSize"
@@ -2404,7 +2404,7 @@ export default {
24042404
this.scaleGroups[datapoint.scaleLabel].unique = this.activeSeriesWithStackRatios.filter(el => el.scaleLabel === datapoint.scaleLabel).length === 1
24052405
24062406
const areaZeroPosition = this.mutableConfig.useIndividualScale ? datapoint.autoScaling ? autoScaleZeroPosition : zeroPosition : this.zero;
2407-
const adustedAreaZeroPosition = Math.max(Math.max(datapoint.autoScaling ? autoScaleZeroPosition : scaleYLabels.at(-1).y, this.drawingArea.top), areaZeroPosition);
2407+
const adustedAreaZeroPosition = Math.max(Math.max(datapoint.autoScaling ? autoScaleZeroPosition : scaleYLabels.at(-1).y || 0, this.drawingArea.top), areaZeroPosition);
24082408
24092409
return {
24102410
...datapoint,
@@ -2932,8 +2932,10 @@ export default {
29322932
}
29332933
29342934
const rectY = yText - (textHeight * 0.75) - label.padding.top;
2935+
const show = ![yTop, yBottom, rectY].includes(NaN);
29352936
29362937
return {
2938+
show,
29372939
id: `annotation_y_${this.createUid()}`,
29382940
hasArea,
29392941
areaHeight: hasArea ? Math.abs(yTop - yBottom) : 0,

0 commit comments

Comments
 (0)