|
2 | 2 | import { ref, computed, nextTick, onMounted } from "vue"; |
3 | 3 | import { |
4 | 4 | applyDataLabel, |
| 5 | + checkNaN, |
5 | 6 | createCsvContent, |
6 | 7 | createUid, |
7 | 8 | dataLabel, |
@@ -186,7 +187,7 @@ function closestDecimal(number) { |
186 | 187 |
|
187 | 188 | const max = computed(() => { |
188 | 189 | return Math.max(...props.dataset.flatMap(ds => { |
189 | | - return ds.slice(-2); |
| 190 | + return ds.slice(-2).map(v => checkNaN(v)); |
190 | 191 | })); |
191 | 192 | }); |
192 | 193 |
|
@@ -220,16 +221,16 @@ const drawableDataset = computed(() => { |
220 | 221 | ...ds.left, |
221 | 222 | y, |
222 | 223 | color: FINAL_CONFIG.value.style.layout.bars.left.color, |
223 | | - x: drawingArea.value.leftChart.right - (ds.left.proportionToMax * drawingArea.value.leftChart.width), |
224 | | - width: ds.left.proportionToMax * drawingArea.value.leftChart.width, |
| 224 | + x: (drawingArea.value.leftChart.right - (ds.left.proportionToMax * drawingArea.value.leftChart.width)), |
| 225 | + width: checkNaN(ds.left.proportionToMax * drawingArea.value.leftChart.width), |
225 | 226 | height |
226 | 227 | }, |
227 | 228 | right: { |
228 | 229 | ...ds.right, |
229 | 230 | y, |
230 | 231 | color: FINAL_CONFIG.value.style.layout.bars.right.color, |
231 | 232 | x: drawingArea.value.rightChart.left, |
232 | | - width: ds.right.proportionToMax * drawingArea.value.rightChart.width, |
| 233 | + width: checkNaN(ds.right.proportionToMax * drawingArea.value.rightChart.width), |
233 | 234 | height |
234 | 235 | } |
235 | 236 | } |
@@ -279,29 +280,29 @@ function useTooltip(index, datapoint) { |
279 | 280 | html += `<div><b>${selectedSet.segment}</b></div>`; |
280 | 281 | html += `<div>${FINAL_CONFIG.value.translations.age}: ${applyDataLabel( |
281 | 282 | FINAL_CONFIG.value.style.layout.dataLabels.yAxis.formatter, |
282 | | - selectedSet.age, |
283 | | - dataLabel({ v: selectedSet.age }), |
| 283 | + checkNaN(selectedSet.age), |
| 284 | + dataLabel({ v: checkNaN(selectedSet.age) }), |
284 | 285 | { datapoint, seriesIndex: index} |
285 | 286 | )}</div>` |
286 | 287 | html += `<div style="margin-top:6px;padding-top:6px;border-top:1px solid ${FINAL_CONFIG.value.style.tooltip.borderColor}">`; |
287 | 288 | html += `<div style="display:flex; flex-direction:row;gap:12px">`; |
288 | 289 | html += `<div style="display:flex;flex-direction:column;align-items:center;justify-content:center"><svg viewBox="0 0 12 12" height="12" width="12"><rect stroke="none" x="0" y="0" height="12" width="12" rx="2" fill="${FINAL_CONFIG.value.style.layout.bars.gradient.underlayer}"/><rect stroke="none" x="0" y="0" height="12" width="12" rx="2" fill="${FINAL_CONFIG.value.style.layout.bars.gradient.show ? `url(#age_pyramid_left_${uid.value})` : FINAL_CONFIG.value.style.layout.bars.left.color}"/></svg><div>${FINAL_CONFIG.value.translations.female}</div><div><b>${applyDataLabel( |
289 | 290 | FINAL_CONFIG.value.style.layout.dataLabels.xAxis.formatter, |
290 | | - selectedSet.left.value, |
291 | | - dataLabel({ v: selectedSet.left.value }), |
| 291 | + checkNaN(selectedSet.left.value), |
| 292 | + dataLabel({ v: checkNaN(selectedSet.left.value) }), |
292 | 293 | { datapoint, seriesIndex: index } |
293 | 294 | )}</b></div></div>`; |
294 | 295 | html += `<div style="display:flex;flex-direction:column;align-items:center;justify-content:center"><svg viewBox="0 0 12 12" height="12" width="12"><rect stroke="none" x="0" y="0" height="12" width="12" rx="2" fill="${FINAL_CONFIG.value.style.layout.bars.gradient.underlayer}"/><rect stroke="none" x="0" y="0" height="12" width="12" rx="2" fill="${FINAL_CONFIG.value.style.layout.bars.gradient.show ? `url(#age_pyramid_right_${uid.value})` : FINAL_CONFIG.value.style.layout.bars.right.color}"/></svg><div>${FINAL_CONFIG.value.translations.male}</div><div><b>${applyDataLabel( |
295 | 296 | FINAL_CONFIG.value.style.layout.dataLabels.xAxis.formatter, |
296 | | - selectedSet.right.value, |
297 | | - dataLabel({ v: selectedSet.right.value }), |
| 297 | + checkNaN(selectedSet.right.value), |
| 298 | + dataLabel({ v: checkNaN(selectedSet.right.value) }), |
298 | 299 | { datapoint, seriesIndex: index } |
299 | 300 | )}</b></div></div>`; |
300 | 301 | html += `</div>`; |
301 | 302 | html += `<div style="margin-top:6px;padding-top:6px;border-top:1px solid ${FINAL_CONFIG.value.style.tooltip.borderColor}"><div>${FINAL_CONFIG.value.translations.total}</div><div><b>${applyDataLabel( |
302 | 303 | FINAL_CONFIG.value.style.layout.dataLabels.xAxis.formatter, |
303 | | - selectedSet.right.value + selectedSet.left.value, |
304 | | - dataLabel({ v: selectedSet.right.value + selectedSet.left.value }), |
| 304 | + checkNaN(selectedSet.right.value) + checkNaN(selectedSet.left.value), |
| 305 | + dataLabel({ v: checkNaN(selectedSet.right.value) + checkNaN(selectedSet.left.value) }), |
305 | 306 | { datapoint, seriesIndex: index } |
306 | 307 | )}</b></div></div>` |
307 | 308 | html += `</div>`; |
@@ -490,7 +491,7 @@ defineExpose({ |
490 | 491 | <rect |
491 | 492 | :x="segment.left.x" |
492 | 493 | :y="segment.left.y" |
493 | | - :width="segment.left.width <= 0 ? 0.0001 : segment.left.width" |
| 494 | + :width="checkNaN(segment.left.width <= 0 ? 0.0001 : segment.left.width)" |
494 | 495 | :height="segment.left.height <= 0 ? 0.0001 : segment.left.height" |
495 | 496 | :fill="FINAL_CONFIG.style.layout.bars.gradient.underlayer" |
496 | 497 | :rx="FINAL_CONFIG.style.layout.bars.borderRadius" |
|
0 commit comments