@@ -447,6 +447,8 @@ export default function ChartContainer({
447447 return maxDecimals ;
448448 } , [ parsedData ] ) ;
449449
450+ const tickStep = useMemo ( ( ) => Math . pow ( 10 , - yDecimalPlaces ) , [ yDecimalPlaces ] ) ;
451+
450452 const chartOptions = useMemo ( ( ) => ( {
451453 responsive : true ,
452454 maintainAspectRatio : false ,
@@ -562,14 +564,15 @@ export default function ChartContainer({
562564 title : { display : true , text : 'Value' } ,
563565 bounds : 'data' ,
564566 ticks : {
567+ stepSize : tickStep ,
565568 callback : function ( value ) {
566569 return Number ( value . toFixed ( yDecimalPlaces ) ) ;
567570 }
568571 }
569572 }
570573 } ,
571574 elements : { point : { radius : 0 } }
572- } ) , [ xRange , onXRangeChange , yDecimalPlaces ] ) ;
575+ } ) , [ xRange , onXRangeChange , yDecimalPlaces , tickStep ] ) ;
573576
574577 const buildComparisonChartData = ( dataArray ) => {
575578 const baselineVal =
@@ -704,11 +707,13 @@ export default function ChartContainer({
704707 const showComparison = dataArray . length >= 2 ;
705708
706709 const yRange = calculateYRange ( dataArray ) ;
710+ const yMin = Math . floor ( yRange . min / tickStep ) * tickStep ;
711+ const yMax = Math . ceil ( yRange . max / tickStep ) * tickStep ;
707712 const options = {
708713 ...chartOptions ,
709714 scales : {
710715 ...chartOptions . scales ,
711- y : { ...chartOptions . scales . y , min : yRange . min , max : yRange . max }
716+ y : { ...chartOptions . scales . y , min : yMin , max : yMax }
712717 }
713718 } ;
714719
@@ -717,12 +722,14 @@ export default function ChartContainer({
717722 if ( showComparison ) {
718723 const compResult = buildComparisonChartData ( dataArray ) ;
719724 stats = compResult . stats . length > 0 ? compResult . stats : null ;
720- const compRange = calculateYRange ( compResult . datasets ) ;
725+ const compRange = calculateYRange ( compResult . datasets ) ;
726+ const compMin = Math . floor ( compRange . min / tickStep ) * tickStep ;
727+ const compMax = Math . ceil ( compRange . max / tickStep ) * tickStep ;
721728 const compOptions = {
722729 ...chartOptions ,
723730 scales : {
724731 ...chartOptions . scales ,
725- y : { ...chartOptions . scales . y , min : compRange . min , max : compRange . max }
732+ y : { ...chartOptions . scales . y , min : compMin , max : compMax }
726733 }
727734 } ;
728735 const compActions = (
0 commit comments