Chart.js: Help with grid lines height

Created on 14 Nov 2016  ·  6Comments  ·  Source: chartjs/Chart.js

How to change height of grid lines? (Keeping chart responsive)
I am using LineChart with following data sets
data: [60, 75, 70, 75, 59, 65],
but its height remains same even if I tried to change the data set like this
data: [30, 45, 40, 45, 29, [35]

How should I change the height of grid lines?

support

Most helpful comment

From what I see in your picture, it appears that setting the dimensions of the canvas will allow you to achieve the desired effect. Here is an example (notice the height of each canvas in relation to the width): http://codepen.io/anon/pen/YpGzVZ

All 6 comments

Do you have an example of what you are looking for?

Take a look at this image...
https://s3.postimg.org/4z2gf1hc3/chart.jpg

I tried to set its height by css, It somehow looks the way I want but it looks like warped image...
You can see that in right side of the image shown above.
I wanted to achieve the same effect but with clear text. How should I do that...?

You can set the size of the canvas by specifying the size of a surrounding <div> (using max-width and max-height). The height and width on the canvas element itself can be used to set the aspect ratio for the chart.

by specifying max-height it looks like compressed chart where labels are not seen clearly...
can't we do that using JavaScript/Jquery or using any other module of chart.js?

Any other option to set height of grid-lines or steps of Y-Axis?

From what I see in your picture, it appears that setting the dimensions of the canvas will allow you to achieve the desired effect. Here is an example (notice the height of each canvas in relation to the width): http://codepen.io/anon/pen/YpGzVZ

Its working like a charm :+1:
Thank you very very much :smiley:

Was this page helpful?
0 / 5 - 0 ratings