@@ -84,11 +84,11 @@ const Scene5 = {
8484 const height = container . clientHeight || 450 ;
8585
8686 // Reserve space for legend at bottom
87- const legendHeight = 80 ;
87+ const legendHeight = 120 ;
8888 const pieHeight = height - legendHeight - 10 ;
8989 const centerX = width * 0.5 ;
9090 const centerY = pieHeight * 0.45 ;
91- const radius = Math . min ( width * 0.25 , pieHeight * 0.35 ) ;
91+ const radius = Math . min ( width * 0.8 , pieHeight * 0.42 ) ;
9292
9393 console . log ( 'Composition chart dimensions:' , width , height , radius ) ;
9494
@@ -244,7 +244,7 @@ const Scene5 = {
244244 . attr ( 'text-anchor' , 'middle' )
245245 . attr ( 'dy' , '-0.2em' )
246246 . attr ( 'fill' , '#FFF' )
247- . attr ( 'font-size' , '2.5rem ' )
247+ . attr ( 'font-size' , '2rem ' )
248248 . attr ( 'font-weight' , '400' )
249249 . attr ( 'font-family' , 'Playfair Display, Georgia, serif' )
250250 . text ( total ) ;
@@ -259,8 +259,8 @@ const Scene5 = {
259259 . text ( 'EVENTS' ) ;
260260
261261 // Populate legend
262- const itemsPerRow = Math . ceil ( typeData . length / 2 ) ;
263- const itemWidth = Math . min ( 150 , ( width - 60 ) / itemsPerRow ) ;
262+ const itemsPerRow = Math . min ( Math . ceil ( typeData . length / 2 ) , Math . floor ( ( width - 60 ) / 180 ) ) ;
263+ const itemWidth = Math . max ( 180 , ( width - 60 ) / itemsPerRow ) ;
264264
265265 typeData . forEach ( ( d , i ) => {
266266 const row = Math . floor ( i / itemsPerRow ) ;
@@ -563,6 +563,8 @@ const Scene5 = {
563563 return ;
564564 }
565565
566+ console . log ( 'Sample events for' , iso , ':' , events . slice ( 0 , 3 ) ) ;
567+
566568 const width = container . clientWidth || 600 ;
567569 const height = Math . max ( container . clientHeight || 300 , 300 ) ;
568570 const margin = { top : 20 , right : 70 , bottom : 50 , left : 70 } ;
@@ -606,6 +608,10 @@ const Scene5 = {
606608 return ;
607609 }
608610
611+ console . log ( 'Deaths & Affected data sample:' , combinedData . slice ( 0 , 5 ) ) ;
612+ console . log ( 'Max deaths:' , d3 . max ( combinedData , d => d . deaths ) ) ;
613+ console . log ( 'Max affected:' , d3 . max ( combinedData , d => d . affected ) ) ;
614+
609615 // Scales - use separate y scales for deaths and affected
610616 const x = d3 . scaleLinear ( )
611617 . domain ( d3 . extent ( combinedData , d => d . year ) )
@@ -692,6 +698,28 @@ const Scene5 = {
692698 const peakDeaths = combinedData . reduce ( ( max , d ) => d . deaths > max . deaths ? d : max , combinedData [ 0 ] ) ;
693699 const peakAffected = combinedData . reduce ( ( max , d ) => d . affected > max . affected ? d : max , combinedData [ 0 ] ) ;
694700
701+ // Highlight peak deaths with circle
702+ if ( peakDeaths && peakDeaths . deaths > 0 ) {
703+ g . append ( 'circle' )
704+ . attr ( 'cx' , x ( peakDeaths . year ) )
705+ . attr ( 'cy' , yDeaths ( peakDeaths . deaths ) )
706+ . attr ( 'r' , 6 )
707+ . attr ( 'fill' , 'var(--volcano)' )
708+ . attr ( 'stroke' , '#FFF' )
709+ . attr ( 'stroke-width' , 2 ) ;
710+ }
711+
712+ // Highlight peak affected with circle
713+ if ( peakAffected && peakAffected . affected > 0 ) {
714+ g . append ( 'circle' )
715+ . attr ( 'cx' , x ( peakAffected . year ) )
716+ . attr ( 'cy' , yAffected ( peakAffected . affected ) )
717+ . attr ( 'r' , 6 )
718+ . attr ( 'fill' , 'var(--drought)' )
719+ . attr ( 'stroke' , '#FFF' )
720+ . attr ( 'stroke-width' , 2 ) ;
721+ }
722+
695723 // Update peak label
696724 const peakLabel = document . getElementById ( 'deathsAffectedPeakLabel' ) ;
697725 if ( peakLabel ) {
@@ -792,7 +820,7 @@ const Scene5 = {
792820
793821 // Add legend
794822 const legend = svg . append ( 'g' )
795- . attr ( 'transform' , `translate(${ width - 120 } , 30)` ) ;
823+ . attr ( 'transform' , `translate(${ width - 150 } , 30)` ) ;
796824
797825 legend . append ( 'rect' )
798826 . attr ( 'width' , 14 )
0 commit comments