@@ -386,25 +386,33 @@ function NpmStatsChart({
386386 alignStartDates : boolean
387387 packages : Array < { packages : string [ ] ; color ?: string | null } >
388388} ) {
389- // Get the range from the URL
390- const { range = '7-days' } = Route . useSearch ( )
391- const [ height , setHeight ] = React . useState ( 400 )
389+ // Get the range and height from the URL
390+ const { range = '7-days' , height : initialHeight = 400 } = Route . useSearch ( )
392391 const [ isDragging , setIsDragging ] = React . useState ( false )
393392 const dragRef = React . useRef < HTMLDivElement > ( null )
394393 const startYRef = React . useRef < number > ( 0 )
395- const startHeightRef = React . useRef < number > ( 0 )
394+ const startHeightRef = React . useRef < number > ( initialHeight )
395+ const navigate = Route . useNavigate ( )
396396
397397 React . useEffect ( ( ) => {
398398 if ( ! dragRef . current ) return
399399
400400 const handleMouseDown = ( e : MouseEvent ) => {
401401 setIsDragging ( true )
402402 startYRef . current = e . clientY
403- startHeightRef . current = height
403+ startHeightRef . current = initialHeight
404404
405405 const handleMouseMove = ( e : MouseEvent ) => {
406406 const deltaY = e . clientY - startYRef . current
407- setHeight ( Math . max ( 300 , startHeightRef . current + deltaY ) )
407+ const newHeight = Math . max ( 300 , startHeightRef . current + deltaY )
408+ navigate ( {
409+ to : '.' ,
410+ search : ( prev ) => ( {
411+ ...prev ,
412+ height : newHeight ,
413+ } ) ,
414+ resetScroll : false ,
415+ } )
408416 }
409417
410418 const handleMouseUp = ( ) => {
@@ -421,7 +429,7 @@ function NpmStatsChart({
421429 return ( ) => {
422430 dragRef . current ?. removeEventListener ( 'mousedown' , handleMouseDown )
423431 }
424- } , [ height ] )
432+ } , [ initialHeight , navigate ] )
425433
426434 if ( ! stats . length ) return null
427435
@@ -610,7 +618,7 @@ function NpmStatsChart({
610618 marginRight : 10 ,
611619 marginBottom : 70 ,
612620 width,
613- height,
621+ height : initialHeight ,
614622 marks : [
615623 Plot . ruleY ( [ 0 ] , {
616624 stroke : 'currentColor' ,
@@ -760,6 +768,7 @@ export const Route = createFileRoute('/stats/npm/')({
760768 viewMode : z . enum ( [ 'absolute' , 'relative' ] ) . optional ( ) ,
761769 binningOption : z . enum ( [ 'yearly' , 'monthly' , 'weekly' , 'daily' ] ) . optional ( ) ,
762770 alignStartDates : z . boolean ( ) . optional ( ) . default ( false ) ,
771+ height : z . number ( ) . optional ( ) . default ( 400 ) ,
763772 } ) ,
764773 loaderDeps : ( { search } ) => ( {
765774 packages : search . packages ,
0 commit comments