@@ -66,46 +66,6 @@ function mergeDailyPoints(points: DailyRawPoint[]): DailyRawPoint[] {
6666 . map ( ( [ day , value ] ) => ( { day, value } ) )
6767}
6868
69- function roundToHundredths ( value : number ) : number {
70- return Math . round ( value * 100 ) / 100
71- }
72-
73- /** Catmull-Rom monotone cubic spline — same algorithm as vue-data-ui's smoothPath for OG Images */
74- export function smoothPath ( pts : { x : number ; y : number } [ ] ) : string {
75- if ( pts . length < 2 ) return '0,0'
76- const n = pts . length - 1
77- const out = [ `${ roundToHundredths ( pts [ 0 ] ! . x ) } ,${ roundToHundredths ( pts [ 0 ] ! . y ) } ` ]
78- const dx : number [ ] = [ ]
79- const dy : number [ ] = [ ]
80- const m : number [ ] = [ ]
81- const t : number [ ] = [ ]
82-
83- for ( let i = 0 ; i < n ; i ++ ) {
84- dx [ i ] = pts [ i + 1 ] ! . x - pts [ i ] ! . x
85- dy [ i ] = pts [ i + 1 ] ! . y - pts [ i ] ! . y
86- m [ i ] = dx [ i ] === 0 ? 0 : dy [ i ] ! / dx [ i ] !
87- }
88-
89- t [ 0 ] = m [ 0 ] !
90- t [ n ] = m [ n - 1 ] !
91- for ( let i = 1 ; i < n ; i ++ ) {
92- t [ i ] = m [ i - 1 ] ! * m [ i ] ! <= 0 ? 0 : ( 2 * m [ i - 1 ] ! * m [ i ] ! ) / ( m [ i - 1 ] ! + m [ i ] ! )
93- }
94-
95- for ( let i = 0 ; i < n ; i ++ ) {
96- const x0 = pts [ i ] ! . x ,
97- y0 = pts [ i ] ! . y
98- const x1 = pts [ i + 1 ] ! . x ,
99- y1 = pts [ i + 1 ] ! . y
100- const seg = x1 - x0
101- out . push (
102- `C ${ roundToHundredths ( x0 + seg / 3 ) } ,${ roundToHundredths ( y0 + ( t [ i ] ! * seg ) / 3 ) } ${ roundToHundredths ( x1 - seg / 3 ) } ,${ roundToHundredths ( y1 - ( t [ i + 1 ] ! * seg ) / 3 ) } ${ roundToHundredths ( x1 ) } ,${ roundToHundredths ( y1 ) } ` ,
103- )
104- }
105-
106- return out . join ( ' ' )
107- }
108-
10969const npmDailyRangeCache = import . meta. client ? new Map < string , Promise < DailyRawPoint [ ] > > ( ) : null
11070const likesEvolutionCache = import . meta. client ? new Map < string , Promise < DailyRawPoint [ ] > > ( ) : null
11171const contributorsEvolutionCache = import . meta. client
0 commit comments