File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,6 @@ const ViolinChart = ({
2424 const { t } = useTranslation ( ) ;
2525
2626 useEffect ( ( ) => {
27- const plotWidth = containerWidth - margin . left - margin . right ;
2827 const plotHeight = height - margin . top - margin . bottom ;
2928
3029 // Get unique categories
@@ -62,6 +61,11 @@ const ViolinChart = ({
6261 . append ( 'g' )
6362 . attr ( 'transform' , `translate(${ margin . left } ,${ margin . top } )` ) ;
6463
64+ // Reserve space for legend (120px width + 20px padding)
65+ const legendWidth = 140 ;
66+ const plotWidth =
67+ containerWidth - margin . left - margin . right - legendWidth ;
68+
6569 // Create scales
6670 const xScale = d3
6771 . scaleBand ( )
@@ -237,11 +241,13 @@ const ViolinChart = ({
237241 . attr ( 'font-size' , '12px' )
238242 . text ( numericColumn ) ;
239243
240- // Add legend
244+ // Add legend at fixed position relative to plot area
241245 const legend = svg
242246 . append ( 'g' )
243247 . attr ( 'class' , 'legend' )
244- . attr ( 'transform' , `translate(${ plotWidth - 120 } , 30)` ) ;
248+ . attr ( 'transform' , `translate(${ plotWidth + 20 } , 30)` ) ;
249+
250+ // No need to adjust SVG width since we reserved space for legend
245251
246252 // Add background rectangle for legend
247253 legend
You can’t perform that action at this time.
0 commit comments