Skip to content

Commit c994ff4

Browse files
committed
feat: add product icons to bar chart x-axis labels when grouped by SKU
1 parent 2e17196 commit c994ff4

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/components/charts/ModelBreakdownChart.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,19 @@ export function GroupBreakdownChart({ stackField = 'model', metricOptions }: Gro
121121
const name = typeof this.value === 'string' ? this.value : String(this.value);
122122
const isAvatar = groupByColumn === 'username' || groupByColumn === 'organization';
123123
const isModel = groupByColumn === 'model';
124+
const isSku = groupByColumn === 'sku';
124125
if (isAvatar && name) {
125126
return `<span style="display:inline-flex;align-items:center;gap:6px;">${name}<img src="${getAvatarUrl(name)}" width="16" height="16" style="border-radius:50%;" loading="lazy" /></span>`;
126127
}
127128
if (isModel && name) {
128129
return `<span style="display:inline-flex;align-items:center;gap:6px;">${name}<img src="${getModelIconUrl(name)}" width="16" height="16" style="border-radius:50%;" loading="lazy" /></span>`;
129130
}
131+
if (isSku) {
132+
// Find the raw SKU key from the sorted data for this category index
133+
const rawKey = sorted[typeof this.pos === 'number' ? this.pos : 0]?.key ?? '';
134+
const icon = rawKey ? getSkuIconSvg(rawKey) : '';
135+
return icon ? `<span style="display:inline-flex;align-items:center;gap:4px;">${icon}${name}</span>` : name;
136+
}
130137
return name || ' ';
131138
},
132139
},

0 commit comments

Comments
 (0)