Accepted answer

not sure precisely what you're looking for, but this might help.

i put together an example a while ago to adjust the height of the chart according to the number of bars, using some preset parameters:

var barcount     = chartdata.length; 
var pointwidth   = 20;
var margintop    = 60;
var marginright  = 10;
var marginbottom = 50;
var marginleft   = 100;
var pointpadding = 0.3;

var chartheight = margintop 
            + marginbottom 
            + ((pointwidth * barcount) * (1 + grouppadding + pointpadding));

so, tell it what size you want the bars, how much padding between them, how much margin at top and bottom of chart, and how many data points you have.

bars will stay the same size and spacing while the chart itself grows to accommodate them.


to see it work, change the 12 in this line:

var chartdata = randomdata(12, true);

to whatever number you want.


since you are working with grouped data, you'll have to change the math a little'll need to account for the number of groups, and multiply hat by the grouppadding, added to the number of points * the pointpadding.

you'll also have to make getting your count of data points slightly more complex.


this can be done with the pointwidth parameter like:

plotoptions: {
  series: {
    pointwidth: 20 //width of the bar/column/point.

to allow scrollbar you should probably upgrade to highstock but that only works horizontally. or you could set up a div that allows the chart to be "larger" on the inside and scroll through that div window.

Related Query

More Query from same tag