File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,10 @@ const DistributionBarChart = ({
2323 const [ containerWidth , setContainerWidth ] = useState ( 800 ) ;
2424 const { t } = useTranslation ( ) ;
2525
26+ const formatTickAsPercentage = ( value : number ) => {
27+ return `${ ( value * 100 ) . toFixed ( 1 ) } %` ;
28+ } ;
29+
2630 useEffect ( ( ) => {
2731 const plotWidth = containerWidth - margin . left - margin . right ;
2832 const plotHeight = height - margin . top - margin . bottom ;
@@ -146,7 +150,12 @@ const DistributionBarChart = ({
146150 . attr ( 'dx' , '-.8em' )
147151 . attr ( 'dy' , '.15em' ) ;
148152
149- svg . append ( 'g' ) . call ( d3 . axisLeft ( yScale ) ) ;
153+ svg . append ( 'g' ) . call (
154+ d3
155+ . axisLeft ( yScale )
156+ . ticks ( 5 ) // Reduce number of ticks
157+ . tickFormat ( d => formatTickAsPercentage ( d as number ) )
158+ ) ;
150159
151160 // Add title
152161 svg . append ( 'text' )
You can’t perform that action at this time.
0 commit comments