fix: allocation chart — illegal top-level return in ES module

`return` at the top level of a <script type="module"> is a SyntaxError
in strict mode, so the entire Three.js chart script was killed before
executing regardless of whether prices were available.

Replaced `if (total <= 0) return` with `if (total > 0) { ... }` wrapping
the full chart body. Also filter out holdings with value=0 before building
the arc geometry so a single un-priced ISIN can't produce a zero-arc slice.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Gonçalo Rodrigues 2026-06-13 18:55:38 +01:00
parent d77020dcc5
commit a2d3b60500

View File

@ -99,10 +99,11 @@ const palette = [
const holdings = [
{{range $d.Holdings}}{ name: "{{.Name}}", value: {{.CurrentValueCents}} },{{end}}
];
].filter(h => h.value > 0);
const total = holdings.reduce((s, h) => s + h.value, 0);
if (total <= 0) return;
if (total > 0) {
const container = document.getElementById('allocation3d');
const W = container.clientWidth, H = 380;
@ -211,6 +212,8 @@ window.addEventListener('resize', () => {
camera.updateProjectionMatrix();
renderer.setSize(w2, H);
});
} // end if (total > 0)
</script>
{{else}}