@@ -5,7 +5,7 @@ import { ActionList, ActionMenu, SegmentedControl } from '@primer/react';
55import { CopilotIcon , CreditCardIcon } from '@primer/octicons-react' ;
66import { useReport } from '../../context/useReport' ;
77import { groupBy , sumBy , topN } from '../../lib/aggregation' ;
8- import { humanizeColumn , formatCompact , formatDisplayValue , getAvatarUrl , getSkuIconSvg } from '../../lib/formatters' ;
8+ import { humanizeColumn , formatCompact , formatDisplayValue , getAvatarUrl , getGroupIconSvg } from '../../lib/formatters' ;
99import { buildColorMap , getModelIconUrl } from '../../lib/chart-theme' ;
1010import { REPORT_TYPES } from '../../lib/types' ;
1111import type { MetricOption } from '../../lib/report-schema' ;
@@ -93,8 +93,8 @@ export function GroupBreakdownChart({ stackField = 'model', metricOptions }: Gro
9393
9494 const seriesColor = colorMap . get ( stackInfo . stack ) ?? '#808fa3' ;
9595 const displayName = formatDisplayValue ( stackInfo . stack , stackField ) || ' ' ;
96- const isSku = stackField === 'sku' ;
97- const iconHtml = isSku ? getSkuIconSvg ( stackInfo . stack , seriesColor ) : '' ;
96+ const hasIcons = stackField === 'sku' || stackField === 'product ';
97+ const iconHtml = hasIcons ? getGroupIconSvg ( stackInfo . stack , stackField , seriesColor ) : '' ;
9898 return {
9999 type : 'bar' as const ,
100100 name : iconHtml
@@ -103,11 +103,11 @@ export function GroupBreakdownChart({ stackField = 'model', metricOptions }: Gro
103103 data,
104104 color : seriesColor ,
105105 visible : ! isHidden ,
106- ...( isSku && {
106+ ...( hasIcons && {
107107 tooltip : {
108108 pointFormatter : function ( this : Highcharts . Point ) {
109109 const val = this . y ?? 0 ;
110- const icon = getSkuIconSvg ( stackInfo . stack , String ( this . color ) ) ;
110+ const icon = getGroupIconSvg ( stackInfo . stack , stackField , String ( this . color ) ) ;
111111 const formatted = activeMetric . isCurrency
112112 ? `$${ val . toLocaleString ( undefined , { minimumFractionDigits : 2 , maximumFractionDigits : 2 } ) } `
113113 : formatCompact ( val ) ;
@@ -136,17 +136,17 @@ export function GroupBreakdownChart({ stackField = 'model', metricOptions }: Gro
136136 const name = typeof this . value === 'string' ? this . value : String ( this . value ) ;
137137 const isAvatar = groupByColumn === 'username' || groupByColumn === 'organization' ;
138138 const isModel = groupByColumn === 'model' ;
139- const isSku = groupByColumn === 'sku' ;
139+ const hasIcons = groupByColumn === 'sku' || groupByColumn === 'product ';
140140 if ( isAvatar && name ) {
141141 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>` ;
142142 }
143143 if ( isModel && name ) {
144144 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>` ;
145145 }
146- if ( isSku ) {
146+ if ( hasIcons ) {
147147 // Find the raw SKU key from the sorted data for this category index
148148 const rawKey = sorted [ typeof this . pos === 'number' ? this . pos : 0 ] ?. key ?? '' ;
149- const icon = rawKey ? getSkuIconSvg ( rawKey ) : '' ;
149+ const icon = rawKey ? getGroupIconSvg ( rawKey , groupByColumn ) : '' ;
150150 return icon ? `<span style="display:inline-flex;align-items:center;gap:4px;">${ icon } ${ name } </span>` : name ;
151151 }
152152 return name || ' ' ;
@@ -174,7 +174,7 @@ export function GroupBreakdownChart({ stackField = 'model', metricOptions }: Gro
174174 : '<tr style="border-top: 1px solid var(--borderColor-muted, #d1d9e0b3);"><td><b>Total: </b></td><td style="text-align: right;"><b>{point.total:,.0f}</b></td></tr></table>' ,
175175 } ,
176176 plotOptions : { bar : { stacking : 'normal' } } ,
177- legend : stackField === 'sku'
177+ legend : stackField === 'sku' || stackField === 'product'
178178 ? { symbolWidth : 0 , symbolHeight : 0 , symbolPadding : 0 }
179179 : { symbolWidth : 16 , symbolHeight : 12 , symbolPadding : 5 } ,
180180 series,
0 commit comments