Skip to content

Commit fb06c72

Browse files
quantbaiclaude
andcommitted
viz: fix asset detail card showing undefined class/sector after wedge click
Zoomed-mode asset wedge click handler was setting selectedAsset to the hierarchy leaf (only asset_id/symbol/name/chain_ecosystem/effective_from) instead of looking up the full record from assets_flat. Result: detail card rendered "undefined — undefined" for class, sector, sub-sector. Build assetById lookup at initSunburst top; click + keydown handlers now resolve via assetById[d.data.asset_id] before setState. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent ef022a1 commit fb06c72

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

docs/app.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,11 @@ function initSunburst(hierarchy, assetsFlat) {
370370
const container = document.getElementById('sunburst-chart');
371371
if (!container || typeof d3 === 'undefined') return;
372372

373+
// Hierarchy leaves are lean (no class/sector context). Look up full asset
374+
// record from assets_flat when wiring asset wedges to selectedAsset state.
375+
const assetById = {};
376+
assetsFlat.forEach(a => { assetById[a.asset_id] = a; });
377+
373378
const DESKTOP_SIZE = 640;
374379
const MOBILE_SIZE = Math.min(window.innerWidth - 48, 540);
375380
let size = window.innerWidth >= 1024 ? DESKTOP_SIZE : MOBILE_SIZE;
@@ -710,8 +715,8 @@ function initSunburst(hierarchy, assetsFlat) {
710715
.on('mouseleave', hideTooltip)
711716
.on('click', (event, d) => {
712717
event.stopPropagation();
713-
const asset = d.data;
714-
// Find full asset details from flat list
718+
// Resolve full asset record (hierarchy leaf lacks class/sector context)
719+
const asset = assetById[d.data.asset_id] || d.data;
715720
setState({ selectedAsset: asset });
716721
srAnnounce('Selected ' + asset.name + ', ' + asset.symbol);
717722
// Highlight this wedge
@@ -722,7 +727,8 @@ function initSunburst(hierarchy, assetsFlat) {
722727
.on('keydown', (event, d) => {
723728
if (event.key === 'Enter' || event.key === ' ') {
724729
event.preventDefault();
725-
setState({ selectedAsset: d.data });
730+
const asset = assetById[d.data.asset_id] || d.data;
731+
setState({ selectedAsset: asset });
726732
}
727733
});
728734

0 commit comments

Comments
 (0)