@@ -655,3 +655,71 @@ describe('axis config properties', () => {
655655 expect ( axes . x ! . labelFlush ) . toBeUndefined ( ) ;
656656 } ) ;
657657} ) ;
658+
659+ // ---------------------------------------------------------------------------
660+ // Y-axis produces ~5 ticks at standard sizes
661+ // ---------------------------------------------------------------------------
662+
663+ describe ( 'y-axis tick density' , ( ) => {
664+ it ( 'produces 5+ y-axis ticks at standard chart size with full density' , ( ) => {
665+ const scales = computeScales ( lineSpec , chartArea , lineSpec . data ) ;
666+ const axes = computeAxes ( scales , chartArea , fullStrategy , theme ) ;
667+
668+ // A 500x300 chart with domain [100, 500] should show ~5+ ticks, not just 2
669+ expect ( axes . y ! . ticks . length ) . toBeGreaterThanOrEqual ( 5 ) ;
670+ } ) ;
671+
672+ it ( 'y-axis thinning uses vertical overlap, not horizontal text width' , ( ) => {
673+ // Even with a measureText that reports very wide labels, y-axis should
674+ // not thin aggressively because overlap is checked vertically
675+ const wideMeasure = ( ) => ( { width : 500 , height : 12 } ) ;
676+ const scales = computeScales ( lineSpec , chartArea , lineSpec . data ) ;
677+ const axes = computeAxes ( scales , chartArea , fullStrategy , theme , wideMeasure ) ;
678+
679+ // Wide label text shouldn't cause y-axis thinning (only height matters)
680+ expect ( axes . y ! . ticks . length ) . toBeGreaterThanOrEqual ( 5 ) ;
681+ } ) ;
682+ } ) ;
683+
684+ // ---------------------------------------------------------------------------
685+ // Vertical orientation overlap detection
686+ // ---------------------------------------------------------------------------
687+
688+ describe ( 'ticksOverlap with vertical orientation' , ( ) => {
689+ const fontSize = 12 ;
690+ const fontWeight = 400 ;
691+
692+ it ( 'returns false when vertical ticks have sufficient spacing' , ( ) => {
693+ // Labels at 30px intervals with 12px font (14.4px with lineHeight)
694+ const ticks : AxisTick [ ] = [
695+ { value : 0 , position : 0 , label : '100' } ,
696+ { value : 1 , position : 30 , label : '200' } ,
697+ { value : 2 , position : 60 , label : '300' } ,
698+ { value : 3 , position : 90 , label : '400' } ,
699+ { value : 4 , position : 120 , label : '500' } ,
700+ ] ;
701+ expect ( ticksOverlap ( ticks , fontSize , fontWeight , undefined , 'vertical' ) ) . toBe ( false ) ;
702+ } ) ;
703+
704+ it ( 'returns true when vertical ticks are too close' , ( ) => {
705+ // Labels at 10px intervals with 12px font - should overlap vertically
706+ const ticks : AxisTick [ ] = [
707+ { value : 0 , position : 0 , label : '100' } ,
708+ { value : 1 , position : 10 , label : '200' } ,
709+ { value : 2 , position : 20 , label : '300' } ,
710+ ] ;
711+ expect ( ticksOverlap ( ticks , fontSize , fontWeight , undefined , 'vertical' ) ) . toBe ( true ) ;
712+ } ) ;
713+
714+ it ( 'ignores label text width for vertical orientation' , ( ) => {
715+ // Very wide labels but well-spaced vertically - should NOT overlap
716+ const ticks : AxisTick [ ] = [
717+ { value : 0 , position : 0 , label : 'Very Long Label Text Here' } ,
718+ { value : 1 , position : 40 , label : 'Another Very Long Label' } ,
719+ { value : 2 , position : 80 , label : 'Yet Another Long Label' } ,
720+ ] ;
721+ // Horizontal would detect overlap, vertical should not
722+ expect ( ticksOverlap ( ticks , fontSize , fontWeight , undefined , 'horizontal' ) ) . toBe ( true ) ;
723+ expect ( ticksOverlap ( ticks , fontSize , fontWeight , undefined , 'vertical' ) ) . toBe ( false ) ;
724+ } ) ;
725+ } ) ;
0 commit comments