2012-02-01 86 views
2

如何在圖表頂部創建更多空間?jQuery在頂部添加更多空間

現在我得到這樣的:

但我想這一點:

enter image description here

這是我的JS代碼:

$("table.chart").each(function() { 
    var colors = []; 
    $("table.chart thead th:not(:first)").each(function() { 
     colors.push($(this).css("color")); 
    }); 
    $(this).graphTable({ 
     series: 'columns', 
     position: 'replace', 
     width: '100%', 
     height: '200px', 
     colors: colors 
    }, { 
     xaxis: { 
      tickSize: 1 
     } 
    }); 
}); 
+0

您可以增加y軸的最大值,請參閱http://stackoverflow.com/questions/4690413/flot-library-setting-up-y-axis-to-min-0-and-max-24 – pritaeas 2012-02-01 12:02:30

+0

它不可能是alpxy 20px或someting與高度?因爲最大你可以說400,但如果someting有一個700的值... – Maanstraat 2012-02-01 12:06:01

回答

10

調整y軸的autoscaleMargin屬性。從API:

的「autoscaleMargin」是有點深奧:它的利潤率 的是,縮放算法將增加,以避免最遠點 對電網邊界最終分數。請注意,僅當 最小值或最大值未明確設置時才應用此邊距。如果指定了餘量,則該圖將進一步將軸終點延伸至最接近的整數刻度 。對於x軸,默認值爲「null」,對於大多數情況下,軸的默認值爲0.02。

聽起來像是從默認的0.02上升起來會做你想做的。

+0

Thnx隊友! :-)。 – Maanstraat 2012-02-01 18:16:25

+1

Thnaks的提示。我還發現,在這種情況下不允許指定最小/最大值,因爲這將覆蓋邊距設置。 – AntonSack 2013-09-26 09:59:33

0

我有這樣的添加JS文件現在我從頂部獲得了一些空間......這不是詭異的,而是有些東西。 :-)

yaxis: { 
    max: null 
}