2017-01-17 189 views
0

在我的應用程序中,我使用highchart作爲報告purpose.I設置div高度和寬度爲100%,但要隱藏的數據。所以我需要基於highchart數據自動設置div寬度和高度是可能的? 在下面的圖表我有40點用戶的數據,但在圖偶數用戶數據被丟失,即用戶2,USER4,user6 enter image description here基於Highchart數據動態設置div寬度和高度

+0

我這裏有一個例子,做什麼你問 - 你可能需要適應從高度到寬度,但概念是相同的:http://jsfiddle.net/jlbriggs/kpu5d1qf/看到這個答案的信息:http://stackoverflow.com/questions/39894055/dynamic-height-of- 39895506#39895506 – jlbriggs

+0

爲了讓所有x軸標籤都可見,請將xAxis.labels.step設置爲1. http://jsfiddle.net/4qc92zmz/4/ – morganfree

回答

1
$(function() 
{ 
(function(H) 
{ 
H.wrap(H.Axis.prototype, 'setAxisSize', function(proceed) 
{ 
var chart = this.chart, 
staticScale = this.options.staticScale,height,diff; 
var defaultWidth=20; 
// For each series destroy trackball 
if (staticScale !== undefined) { 
var widthDiff; 
if (chart.xAxis[0].max !== null) 
{ 
widthDiff = chart.xAxis[0].max * defaultWidth; 
} 
height = (this.max - this.min) * staticScale; 
diff = height - chart.plotHeight; 
chart.plotHeight = height; 
if (Math.abs(diff) >= 1 && chart.xAxis[0].max !== null) { 

chart.setSize(
chart.chartWidth + widthDiff, 
chart.chartHeight + diff, 
!chart.hasRendered 
); 
} 
} 
proceed.call(this); 
}); 
}(Highcharts)); 
相關問題