Skip to content

Commit ecb527d

Browse files
committed
Fix - VueUiXy - Fixed issues with null values on line series
1 parent 7d1bfef commit ecb527d

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/components/vue-ui-xy.vue

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@
311311
<g v-for="(plot, j) in serie.plots" :key="`line_${i}_${j}`">
312312
<line
313313
:data-cy="`xy-line-segment-${i}-${j}`"
314-
v-if="j < serie.plots.length - 1 && canShowValue(plot.value) && canShowValue(serie.plots[j+1].value)"
314+
v-if="plot && j < serie.plots.length - 1 && serie.plots[j+1] && canShowValue(plot.value) && canShowValue(serie.plots[j+1].value)"
315315
:x1="plot.x"
316316
:x2="serie.plots[j+1].x"
317317
:y1="plot.y"
@@ -324,7 +324,7 @@
324324
/>
325325
<line
326326
:data-cy="`xy-line-segment-${i}-${j}`"
327-
v-if="j < serie.plots.length - 1 && canShowValue(plot.value) && canShowValue(serie.plots[j+1].value)"
327+
v-if="plot && j < serie.plots.length - 1 && serie.plots[j+1] && canShowValue(plot.value) && canShowValue(serie.plots[j+1].value)"
328328
:x1="plot.x"
329329
:x2="serie.plots[j+1].x"
330330
:y1="plot.y"
@@ -342,7 +342,7 @@
342342

343343
<Shape
344344
:data-cy="`xy-plot-${i}-${j}`"
345-
v-if="canShowValue(plot.value)"
345+
v-if="plot && canShowValue(plot.value)"
346346
:shape="['triangle', 'square', 'diamond', 'pentagon', 'hexagon', 'star'].includes(serie.shape) ? serie.shape : 'circle'"
347347
:color="chartConfig.line.useGradient ? `url(#lineGradient_${i}_${uniqueId})` : serie.color"
348348
:plot="{ x: plot.x, y: plot.y }"
@@ -1330,13 +1330,11 @@ export default {
13301330
},
13311331
lineSet() {
13321332
return this.activeSeriesWithStackRatios.filter(s => s.type === 'line').map((datapoint) => {
1333-
1334-
const min = Math.min(...datapoint.absoluteValues);
1335-
const max = Math.max(...datapoint.absoluteValues);
1336-
const autoScaledRatios = datapoint.absoluteValues.map(v => {
1333+
const min = Math.min(...datapoint.absoluteValues.filter(v => ![undefined, null].includes(v)));
1334+
const max = Math.max(...datapoint.absoluteValues.filter(v => ![undefined, null].includes(v)));
1335+
const autoScaledRatios = datapoint.absoluteValues.filter(v => ![null, undefined].includes(v)).map(v => {
13371336
return (v - min) / (max - min)
13381337
});
1339-
13401338
const autoScale = {
13411339
ratios: autoScaledRatios,
13421340
valueMin: min,
@@ -1389,10 +1387,12 @@ export default {
13891387
})
13901388
13911389
const autoScalePlots = datapoint.series.map((plot, j) => {
1392-
return {
1393-
x: (this.drawingArea.left + (this.slot.line/2)) + (this.slot.line * j),
1394-
y: this.drawingArea.bottom - yOffset - (individualHeight * autoScaleRatiosToNiceScale[j]),
1395-
value: datapoint.absoluteValues[j]
1390+
if(![undefined, null].includes(datapoint.absoluteValues[j])) {
1391+
return {
1392+
x: (this.drawingArea.left + (this.slot.line/2)) + (this.slot.line * j),
1393+
y: this.drawingArea.bottom - yOffset - (individualHeight * autoScaleRatiosToNiceScale[j]),
1394+
value: datapoint.absoluteValues[j]
1395+
}
13961396
}
13971397
})
13981398
const curve = this.createSmoothPath(plots);
@@ -1919,7 +1919,7 @@ export default {
19191919
const start = { x: plots[0].x, y: zero };
19201920
const end = { x: plots.at(-1).x, y: zero };
19211921
const path = [];
1922-
plots.forEach(plot => {
1922+
plots.filter(p => !!p).forEach(plot => {
19231923
path.push(`${plot.x},${plot.y} `);
19241924
});
19251925
return [ start.x, start.y, ...path, end.x, end.y].toString();

0 commit comments

Comments
 (0)