Ben Casalino
Ben Casalino

Reputation: 2383

Chart.js, changing the max height (not w/ canvas) or rounding up rule?

I am trying to get a chart working with the Chart.js library. My max value is 16 for this chart. However the default chart seems to go to 20 or is just rounding up to 20 from 16. Is there a way I can make 16 the max height of the chart (not the size of the canvas). I've read lots of the great documentation on chart.js I just can't seem to find a rule that targets the max height specifically! Thanks!

JS Fiddle

datasets: [
           {
             label: "test",
             fillColor: "rgba(220,220,220,0.2)",
             strokeColor: "rgba(220,220,220,1)",
             pointColor: "rgba(220,220,220,1)",
             pointStrokeColor: "#fff",
             pointHighlightFill: "#fff",
             pointHighlightStroke: "rgba(220,220,220,1)",
             data: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
           },  etc.....

when I set the max value of the data as 4, the highest point on the chart is 4. However when I set it to 16 the highest point on the chart is now 20. Any ideas on how to set the default rounding value?

Upvotes: 0

Views: 596

Answers (1)

potatopeelings
potatopeelings

Reputation: 41075

You can just override the scale instead, like so

     ...
     scaleOverride: true,
     scaleSteps: 15,
     scaleStepWidth: 1,
     scaleStartValue: 1,
 });

for a value range from 1 to 16.

Upvotes: 1

Related Questions