Resizing your charts

[No canvas support]

 

RGraph has the facility to allow you to resize your charts. This is new as of 10th April 2010. Because of the numerous events it has to install code on, it is possible that it may not work well with another dynamic feature that you may want to use. The context menu does though, and the example shows tooltips. and resizing.

All you need to do to enable it is set chart.resizable to true. There are certain caveats that you should be aware of though:


/**
* This recalculates the Line chart hmargin when the chart is resized
*/
function myOnresizebeforedraw (obj)
{
    var gutterLeft = obj.Get('chart.gutter.left');
    var gutterRight = obj.Get('chart.gutter.right');

    obj.Set('chart.hmargin', (obj.canvas.width - gutterLeft - gutterRight) / (obj.original_data[0].length * 2));
}
RGraph.AddCustomEventListener(myLine, 'onresizebeforedraw', myOnresizebeforedraw);