Javascript 如何增加highchart的高度?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8487911/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to increase the height of highchart?
提问by Shahrukh A.
I am using HighCharts for displaying some statistical data but i have a problem that when values of x axis increases, it cuts down the values. I am attaching screenshot.
我使用 HighCharts 来显示一些统计数据,但我有一个问题,当 x 轴的值增加时,它会减少值。我附上截图。
回答by eolsson
There's an API method to set the size of the chart, found on the chart object and called setSize. chart.setSize(width, height)
see this example on jsfiddleand the reference.
有一个 API 方法来设置图表的大小,在图表对象上找到并称为 setSize。chart.setSize(width, height)
请参阅有关 jsfiddle和参考的此示例。
回答by July
You should add marginBottom:
您应该添加 marginBottom:
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'column',
marginRight: 130,
marginBottom: 70 /* HERE */
},
title: {
text: '@Model.Title',
x: -20
}
回答by Sudhir Bastakoti
Something like this would work:
像这样的事情会起作用:
var height = //get containers original height var new_height = height + (data.length * 10); $("#highcharts-0").css("{height:"+new_height+"}");