FVANCOP / ChartNew.js

MIT License
420 stars 142 forks source link

Dynamic chart size / Fixed bar-chart bar thickness #416

Closed rwits closed 8 years ago

rwits commented 8 years ago

Hi,

Is there any way to fix the bar size (vertical thickness) on a horizontal bar chart and have the chart automatically resize itself to accomodate all the bars without squashing them?

Situation is that i have data coming from a database and i dont know how many items are going to be returned and i need to display all of them. It might be 5 items on some occassions, it might be 20 on another.

Example below... The 3 charts will be displayed together on the same page below one another so it makes visual sense for the bar thickness to be consisent and the chart height to vary accordingly.

Thanks Martin

chart

FVANCOP commented 8 years ago

Hi,

Fixing the bar width is not implemented because it is more related to the canvas height.;

In the sample folder, you will find the "resize_canvas.html"; You can apply the same idea for horizontal bars; Change "canvas.width" to "canvas.height" in the resizeCanvas function and try to find the ad-hoc values that fits for your chart.

François