2012-10-25 71 views
0

我使用jqplot绘制条形图。如果x轴的最大值是没有太大的一切似乎都很正常,就像这样: enter image description herex轴超出div宽度

但如果是大我得到这样的: enter image description here

x轴似乎是更广泛比格我用来绘制图表

这div有以下样式:

.barChart { 
    min-width: 735px; 
    margin-left: 15px; 
    height: 200px; 
    color: #333; 
    background: white; 
    overflow: auto; 
    border-top: 2px solid #369; 
    border-bottom: 2px solid #369; 
    line-height: 14px; 
    font-size: 12px; 
} 

那么,如何才能让X轴是不是比用图表的DIV宽?

回答

1

您可以应用特定的图表大小。我开了一个问题,关于这个话题在这里:JqPlot : Set a fix height value for the graph area not including y axe labels

的解决办法是用精确的图表大小像这样重新绘制:

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

希望这是帮助

+0

感谢您的反馈,您的解决方案给了我一个关于如何解决这个问题的想法。我刚刚制作了一个div,不用'$(“#”+ el).width($(“#”+ el).width()+ 5)重新绘制;' – k102

+0

我很乐意帮助你 – sdespont