JqPlot : Set a fix height value for the graph area not including y axe labels

ε祈祈猫儿з 提交于 2019-11-30 08:31:58

问题


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:


回答1:


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();


来源:https://stackoverflow.com/questions/11229577/jqplot-set-a-fix-height-value-for-the-graph-area-not-including-y-axe-labels

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!