JqPlot:为不包含y ax标签的图形区域设置固定高度值 [英] JqPlot : Set a fix height value for the graph area not including y axe labels

查看:120
本文介绍了JqPlot:为不包含y ax标签的图形区域设置固定高度值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用JqPlot。

图形高度取决于主容器的高度或默认的JqPlot值。

我的问题是,如果y标签很长,图表大小会减小以适应主容器。

是否可以设置一个不依赖于标签文本长度的图形高度的固定值?

我需要:我总是显示相同的图形高度(例如400px)而不是这取决于y标签的文字长度这些图片描述了我的问题:


=http://jsfiddle.net/Boro/AqKZz/33/ =nofollow>出现在这个例子中。

打电话给拜在该图中,调用下面的代码来获得当前图的大小,并相应地通过添加由周围的div所采用的大小来调整它(即,标题&轴)。
在结果中,无论您为 CSS 中的图表大小设置的图表的图形部分如何, ($。jqplot-yaxis)。width(),10)+ parseInt

($(#chart).width(),10);
var h = parseInt($(。jqplot-title)。height(),10)+ parseInt($(。jqplot-xaxis)。height(),10)+ parseInt($( #chart)。height(),10);
$(#chart)。width(w).height(h);
plot.replot();


I am using JqPlot.

The graph height is depending on the height of the main container or the default JqPlot value.

My problem is that if the y label is very long, the graph size is reduced to fit in the main container.

Is it possible to set a fix value for the graph height which is not depending on the label text length?

My need : I would like always display the same graph height (400px for example) not depending on the y label text length

Here is an image to depict my problem:

解决方案

Only thing that comes to my mind is something along these lines presented in this sample.
After the call to paint the plot, call the below code to get the current plot's size and adjust it accordingly by adding the size taken by the surrounding divs (i.e. title & axes).
In result whatever you set for the size of your chart in CSS will be taken by the graphical part of the chart, just as you want it.

var w = parseInt($(".jqplot-yaxis").width(), 10) + parseInt($("#chart").width(), 10);
var h = parseInt($(".jqplot-title").height(), 10) + parseInt($(".jqplot-xaxis").height(), 10) + parseInt($("#chart").height(), 10);
$("#chart").width(w).height(h);
plot.replot();

这篇关于JqPlot:为不包含y ax标签的图形区域设置固定高度值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆