Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to define the size of graph in jqPlot

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.

like image 541
VolleyBall Player Avatar asked Jul 31 '13 20:07

VolleyBall Player


1 Answers

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>
like image 66
zs2020 Avatar answered Oct 08 '22 00:10

zs2020