@@ -13,6 +13,9 @@ const FEATURED_COMPARISON_PROVIDER_IDS = ['anthropic', 'openai', 'google']
1313
1414/** Max latest models pulled from each featured provider. */
1515const MAX_MODELS_PER_PROVIDER = 4
16+ const CHART_BAR_HEIGHT = 1
17+ const CHART_BAR_END_RADIUS_X = 1
18+ const CHART_BAR_END_RADIUS_Y = 3 / 28
1619
1720const PROVIDER_ICON_MAP : Record < string , ComponentType < { className ?: string } > > = ( ( ) => {
1821 const map : Record < string , ComponentType < { className ?: string } > > = { }
@@ -24,6 +27,14 @@ const PROVIDER_ICON_MAP: Record<string, ComponentType<{ className?: string }>> =
2427 return map
2528} ) ( )
2629
30+ function getRoundedRightBarPath ( x : number , width : number ) : string {
31+ const right = x + width
32+ const radiusX = Math . min ( CHART_BAR_END_RADIUS_X , width / 2 )
33+ const radiusY = CHART_BAR_END_RADIUS_Y
34+
35+ return `M ${ x } 0 H ${ right - radiusX } Q ${ right } 0 ${ right } ${ radiusY } V ${ CHART_BAR_HEIGHT - radiusY } Q ${ right } ${ CHART_BAR_HEIGHT } ${ right - radiusX } ${ CHART_BAR_HEIGHT } H ${ x } Z`
36+ }
37+
2738function selectComparisonModels ( models : CatalogModel [ ] ) : CatalogModel [ ] {
2839 const seen = new Set < string > ( )
2940 const result : CatalogModel [ ] = [ ]
@@ -96,14 +107,17 @@ function StackedCostChart({ models }: ChartProps) {
96107 Cost
97108 </ h3 >
98109 < span className = 'text-[var(--text-muted)] text-sm leading-[150%] tracking-[0.02em]' >
99- Per 1M tokens
110+ Standard short-context rates per 1M tokens
100111 </ span >
101112 </ div >
102113
103114 < div className = 'flex flex-col gap-1.5' >
104115 { data . entries . map ( ( { model, input, output, total } ) => {
105116 const totalPct = data . maxTotal > 0 ? ( total / data . maxTotal ) * 100 : 0
106117 const inputPct = total > 0 ? ( input / total ) * 100 : 0
118+ const plottedTotalPct = Math . max ( totalPct , 3 )
119+ const plottedInputPct = ( plottedTotalPct * inputPct ) / 100
120+ const plottedOutputPct = plottedTotalPct - plottedInputPct
107121 const color = getProviderColor ( model . providerId )
108122
109123 return (
@@ -113,29 +127,34 @@ function StackedCostChart({ models }: ChartProps) {
113127 className = '-mx-2 flex items-center gap-3 rounded-md px-2 transition-colors hover:bg-[var(--surface-hover)]'
114128 >
115129 < ModelLabel model = { model } />
116- < div className = 'relative flex h-7 min-w-0 flex-1 items-center' >
117- < div
118- className = 'hidden h-full overflow-hidden rounded-r-[3px] sm:flex'
119- style = { { width : `${ Math . max ( totalPct , 3 ) } %` } }
120- >
121- < div
122- className = 'h-full'
123- style = { {
124- width : `${ inputPct } %` ,
125- backgroundColor : color ,
126- opacity : 0.8 ,
127- } }
128- />
129- < div
130- className = 'h-full'
131- style = { {
132- width : `${ 100 - inputPct } %` ,
133- backgroundColor : color ,
134- opacity : 0.35 ,
135- } }
136- />
130+ < div className = 'flex h-7 min-w-0 flex-1 items-center gap-2.5' >
131+ < div className = 'hidden h-full min-w-0 flex-1 sm:block' >
132+ < svg
133+ aria-hidden = 'true'
134+ className = 'size-full'
135+ preserveAspectRatio = 'none'
136+ viewBox = '0 0 100 1'
137+ >
138+ { plottedInputPct > 0 &&
139+ ( plottedOutputPct > 0 ? (
140+ < rect fill = { color } fillOpacity = { 0.8 } height = '1' width = { plottedInputPct } />
141+ ) : (
142+ < path
143+ d = { getRoundedRightBarPath ( 0 , plottedInputPct ) }
144+ fill = { color }
145+ fillOpacity = { 0.8 }
146+ />
147+ ) ) }
148+ { plottedOutputPct > 0 && (
149+ < path
150+ d = { getRoundedRightBarPath ( plottedInputPct , plottedOutputPct ) }
151+ fill = { color }
152+ fillOpacity = { 0.35 }
153+ />
154+ ) }
155+ </ svg >
137156 </ div >
138- < span className = 'shrink-0 text-[11px] text-[var(--text-muted)] sm:ml-2.5 sm:text-xs' >
157+ < span className = 'shrink-0 text-[11px] text-[var(--text-muted)] sm:w-[148px] sm:text-xs' >
139158 { formatPrice ( input ) } input / { formatPrice ( output ) } output
140159 </ span >
141160 </ div >
@@ -184,16 +203,22 @@ function ContextWindowChart({ models }: ChartProps) {
184203 className = '-mx-2 flex items-center gap-3 rounded-md px-2 transition-colors hover:bg-[var(--surface-hover)]'
185204 >
186205 < ModelLabel model = { model } />
187- < div className = 'relative flex h-7 min-w-0 flex-1 items-center' >
188- < div
189- className = 'h-full rounded-r-[3px]'
190- style = { {
191- width : `${ Math . max ( pct , 3 ) } %` ,
192- backgroundColor : color ,
193- opacity : 0.8 ,
194- } }
195- />
196- < span className = 'ml-2.5 shrink-0 text-[11px] text-[var(--text-muted)] sm:text-xs' >
206+ < div className = 'flex h-7 min-w-0 flex-1 items-center gap-2.5' >
207+ < div className = 'h-full min-w-0 flex-1' >
208+ < svg
209+ aria-hidden = 'true'
210+ className = 'size-full'
211+ preserveAspectRatio = 'none'
212+ viewBox = '0 0 100 1'
213+ >
214+ < path
215+ d = { getRoundedRightBarPath ( 0 , Math . max ( pct , 3 ) ) }
216+ fill = { color }
217+ fillOpacity = { 0.8 }
218+ />
219+ </ svg >
220+ </ div >
221+ < span className = 'w-10 shrink-0 text-right text-[11px] text-[var(--text-muted)] tabular-nums sm:text-xs' >
197222 { formatTokenCount ( value ) }
198223 </ span >
199224 </ div >
@@ -228,11 +253,11 @@ export function ModelComparisonCharts({ models }: ModelComparisonChartsProps) {
228253
229254 < div className = 'h-px w-full bg-[var(--border)]' />
230255
231- < div className = 'flex flex-col sm :flex-row' >
256+ < div className = 'flex flex-col lg :flex-row' >
232257 < div className = 'flex-1 p-6' >
233258 < StackedCostChart models = { comparisonModels } />
234259 </ div >
235- < div className = 'h-px w-full bg-[var(--border)] sm :h-auto sm :w-px' />
260+ < div className = 'h-px w-full bg-[var(--border)] lg :h-auto lg :w-px' />
236261 < div className = 'flex-1 p-6' >
237262 < ContextWindowChart models = { comparisonModels } />
238263 </ div >
0 commit comments