How to define the size of graph in jqPlot

VolleyBall Player picture VolleyBall Player · Jul 31, 2013 · Viewed 15.2k times · Source

I am using jqPlot to render a graph on a page.

I am following this link. http://www.jqplot.com/tests/bar-charts.php

The data point that I give to the graph are dynamic. so sometime the size of the graph is different. Is there a way/or able to set property for jqPlot?

To be precise, the question is how to set the height and width of graph so that every time I get new data the size of the graph and size of labels are always same. An example with jsFiddle would help everyone including myself.

Answer

zs2020 picture zs2020 · Jul 31, 2013

You can fix the size by configuring the height and width:

$.jqplot('chartdiv', [data],
{
    height: 400,
    width: 400,
    ...

You also need to give the height and width to the target div:

<div id="chartdiv" style="height:500px; width:500px;"></div>