Skip to content

Commit 19dddba

Browse files
committed
feat: extend icon treatment to model groupings in charts
Model names in chart legends, tooltips, and bar chart labels now show the AI provider icon (from Simple Icons CDN) alongside the model name, consistent with the SKU/product/user treatment.
1 parent 72fc082 commit 19dddba

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/lib/formatters.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { ComponentType } from 'react';
22
import { createElement } from 'react';
33
import { renderToStaticMarkup } from 'react-dom/server';
4+
import { getModelIconUrl } from './chart-theme';
45
import { AiModelIcon, ContainerIcon, CopilotIcon, DatabaseIcon, FileIcon, PackageIcon, PlayIcon, SparkleIcon, TagIcon } from '@primer/octicons-react';
56

67
type OcticonComponent = ComponentType<{ size?: number; className?: string; fill?: string }>;
@@ -43,6 +44,9 @@ const AVATAR_COLUMNS = new Set(['username', 'organization', 'login', 'userLogin'
4344
export function getGroupIconSvg(rawValue: string, column: string, color?: string): string {
4445
if (column === 'sku') return getSkuIconSvg(rawValue, color);
4546
if (column === 'product') return getProductIconSvg(rawValue, color);
47+
if (column === 'model' && rawValue) {
48+
return `<img src="${getModelIconUrl(rawValue)}" width="16" height="16" style="border-radius:50%;flex-shrink:0;" loading="lazy" />`;
49+
}
4650
if (AVATAR_COLUMNS.has(column) && rawValue) {
4751
return `<img src="${getAvatarUrl(rawValue, 32)}" width="16" height="16" style="border-radius:50%;flex-shrink:0;" loading="lazy" />`;
4852
}
@@ -51,7 +55,7 @@ export function getGroupIconSvg(rawValue: string, column: string, color?: string
5155

5256
/** Check if a column has custom icon/avatar treatment */
5357
export function columnHasIcons(column: string): boolean {
54-
return column === 'sku' || column === 'product' || AVATAR_COLUMNS.has(column);
58+
return column === 'sku' || column === 'product' || column === 'model' || AVATAR_COLUMNS.has(column);
5559
}
5660

5761
/** Get the React icon component for a group value (SKU/product only, not avatars) */

0 commit comments

Comments
 (0)