如何在jqPlot中定义图形的大小

时间:2022-09-15 10:53:46

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

我正在使用jqPlot在页面上呈现图形。

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

我正在关注此链接。 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?

我给图表的数据点是动态的。所以有时候图表的大小是不同的。有没有办法/或能够为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.

确切地说,问题是如何设置图形的高度和宽度,以便每次获得新数据时图形的大小和标签的大小始终相同。 jsFiddle的一个例子可以帮助包括我自己在内的所有人。

3 个解决方案

#1


8  

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提供高度和宽度:

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

#2


5  

if you specify the height and width for div, then it has preference over the height and width specified inside the option for JqPlot.

如果指定div的高度和宽度,则它优先于JqPlot选项中指定的高度和宽度。

#3


0  

Try this: (its inline CSS)...

试试这个:(它的内联CSS)......

<div id="chart1" style="height:400px;width:300px; "></div>

*div id ( chart1 ) must be same like the jqPlot JS File.

* div id(chart1)必须与jqPlot JS File相同。

plot1 = $.jqplot("chart1", [DATA]

plot1 = $ .jqplot(“chart1”,[DATA]

You can change the height and width as per your requirements.

您可以根据自己的要求更改高度和宽度。

#1


8  

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提供高度和宽度:

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

#2


5  

if you specify the height and width for div, then it has preference over the height and width specified inside the option for JqPlot.

如果指定div的高度和宽度,则它优先于JqPlot选项中指定的高度和宽度。

#3


0  

Try this: (its inline CSS)...

试试这个:(它的内联CSS)......

<div id="chart1" style="height:400px;width:300px; "></div>

*div id ( chart1 ) must be same like the jqPlot JS File.

* div id(chart1)必须与jqPlot JS File相同。

plot1 = $.jqplot("chart1", [DATA]

plot1 = $ .jqplot(“chart1”,[DATA]

You can change the height and width as per your requirements.

您可以根据自己的要求更改高度和宽度。