@@ -4,8 +4,8 @@ import * as d3 from "d3";
44
55
66// Constants
7- export const margin = { top : 32 , right : 16 , bottom : 32 , left : 0 } ; // Added padding/margin
8- export const barSize = 48 ;
7+ export const margin = { top : 16 , right : 16 , bottom : 16 , left : 0 } ; // Added padding/margin
8+ export const barSize = 38 ;
99export const maxNumberVisible = 12 ;
1010export let color ;
1111
@@ -15,20 +15,21 @@ let dateFormatter;
1515
1616// Function to initialize the chart
1717export const initializeChart = ( svgRef , dataset , width , title , colorPaletteArray , timeUnit , locale ) => {
18- const chartMargin = 30 ; // Adjust this value to increase the space
18+ const chartMarginTop = 30 ;
19+ const chartMarginBottom = 12 ;
1920
2021 // Create SVG element
2122 svgRef . current = d3
2223 . select ( "#container" )
2324 . append ( "svg" )
24- . attr ( "viewBox" , [ 0 , - chartMargin , width , margin . top + barSize * maxNumberVisible + margin . bottom + chartMargin ] ) ;
25+ . attr ( "viewBox" , [ 0 , - chartMarginTop , width , margin . top + barSize * maxNumberVisible + margin . bottom + chartMarginBottom ] ) ;
2526
2627 // Add a title to the SVG
2728 svgRef . current . append ( "text" )
2829 . attr ( "x" , width / 2 ) // Center horizontally
29- . attr ( "y" , - 11 ) // Adjust this value to move the title up
30+ . attr ( "y" , - 12 ) // Adjust this value to move the title up
3031 . attr ( "text-anchor" , "middle" ) // Center the text
31- . attr ( "font-size" , "24px " )
32+ . attr ( "font-size" , "16px " )
3233 . attr ( "font-weight" , "bold" )
3334 . text ( title || "" ) ;
3435
@@ -49,7 +50,7 @@ export const initializeChart = (svgRef, dataset, width, title, colorPaletteArray
4950 const y = d3
5051 . scaleBand ( )
5152 . domain ( d3 . range ( maxNumberVisible + 2 ) )
52- . rangeRound ( [ margin . top , margin . top + barSize * ( maxNumberVisible + 1 + 0.1 ) ] )
53+ . rangeRound ( [ - 16 , barSize * ( maxNumberVisible + 1.3 ) ] )
5354 . padding ( 0.1 ) ;
5455
5556 const scale = d3 . scaleOrdinal ( colorPaletteArray ) ;
@@ -120,7 +121,7 @@ function cap_at_max_rank(rank) {
120121function labels ( svgRef , x , y , prev , next ) {
121122 let label = svgRef
122123 . append ( "g" )
123- . style ( "font" , "bold 12px var(--sans-serif)" )
124+ . style ( "font" , "bold 11px var(--sans-serif)" )
124125 . style ( "font-variant-numeric" , "tabular-nums" )
125126 . attr ( "text-anchor" , "end" )
126127 . selectAll ( "text" ) ;
0 commit comments