Skip to content

Commit 8f28490

Browse files
committed
Fix - VueUiStackline - Treat null value as zero in area computation
1 parent af0ed4e commit 8f28490

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/components/vue-ui-stackline.vue

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ const _formattedDataset = computed(() => {
971971

972972
const scale = (!FINAL_CONFIG.value.style.chart.lines.distributed &&
973973
(FINAL_CONFIG.value.style.chart.grid.scale.scaleMax !== null ||
974-
FINAL_CONFIG.value.style.chart.grid.scale.scaleMin !== null))
974+
FINAL_CONFIG.value.style.chart.grid.scale.scaleMin !== null))
975975
? calculateNiceScaleWithExactExtremes(
976976
FINAL_CONFIG.value.style.chart.grid.scale.scaleMin !== null
977977
? FINAL_CONFIG.value.style.chart.grid.scale.scaleMin
@@ -997,7 +997,7 @@ const _formattedDataset = computed(() => {
997997
const cumPos = Array(winLen).fill(0);
998998
const cumNeg = Array(winLen).fill(0);
999999

1000-
const xAtRel = (rel) => {
1000+
const computeXFromRelativeIndex = (rel) => {
10011001
if (winLen <= 1) return drawingArea.value.left + drawingArea.value.width / 2;
10021002
return drawingArea.value.left + (rel / (winLen - 1)) * drawingArea.value.width;
10031003
};
@@ -1054,14 +1054,9 @@ const _formattedDataset = computed(() => {
10541054
relIndices.push(rel);
10551055
seriesVals.push(dp);
10561056
signedVals.push(sign ?? (dp >= 0 ? 1 : -1));
1057-
1058-
if (isMissing) {
1059-
baseY[rel] = ZERO_POSITION;
1060-
topY[rel] = ZERO_POSITION;
1061-
}
10621057
}
10631058

1064-
const points = relIndices.map(rel => ({ x: xAtRel(rel), y: topY[rel] }));
1059+
const points = relIndices.map(rel => ({ x: computeXFromRelativeIndex(rel), y: topY[rel] }));
10651060
const x = points.map(p => p.x);
10661061

10671062
const absoluteTotal = seriesVals.reduce((a, b) => a + Math.abs(b || 0), 0);
@@ -1091,7 +1086,6 @@ const _formattedDataset = computed(() => {
10911086
});
10921087
});
10931088

1094-
10951089
const formattedDataset = computed(() => {
10961090
const stripMove = (d) =>
10971091
typeof d === 'string'

0 commit comments

Comments
 (0)