2013-10-21 90 views
1

OK我有一個flot堆疊條形圖顯示一些信息,現在除了xaxis以外,這一切都很完美。Flot xaxis Ticks沒有顯示

目前,我不希望它顯示的數據顯示它只顯示每隔一列的列號。

下面是我爲x軸代碼:

var options = { 
    series: {stack: 0, 
      lines: {show: false, steps: false }, 
      bars: {show: true, barWidth: 0.5, align: 'center',},}, 
    xaxis: {ticks: [[1,' Yesterday'], [2,'Two'], [3,'Three'], [4,'Four'], [5,'Five'], [6,'Six'], [7,'Seven'], [8,'Eight'], [9,'Nine'], [10,'Ten'], [11,'Eleven'], [12,'Twelve'], [13,'Thirteen'], [14,'fourteen']]}, 
    xaxis: { tickColor: 'transparent' } 
}; 

$.plot($(css_id), data, options); 
}); 

這裏是配置部分:

xaxis: { 
       show: true, // null = auto-detect, true = always, false = never 
       position: "bottom", // or "top" 
       mode: null, // null or "time" 
       color: "#990000", // base color, labels, ticks 
       tickColor: null, // possibly different color of ticks, e.g. "rgba(0,0,0,0.15)" 
       transform: null, // null or f: number -> number to transform axis 
       inverseTransform: null, // if transform is set, this should be the inverse function 
       min: null, // min. value to show, null means set automatically 
       max: null, // max. value to show, null means set automatically 
       autoscaleMargin: null, // margin in % to add if auto-setting min/max 
       ticks: null, // either [1, 3] or [[1, "a"], 3] or (fn: axis info -> ticks) or app. number of ticks for auto-ticks 
       tickFormatter: null, // fn: number -> string 
       labelWidth: null, // size of tick labels in pixels 
       labelHeight: null, 
       reserveSpace: null, // whether to reserve space even if axis isn't shown 
       tickLength: null, // size in pixels of ticks, or "full" for whole line 
       alignTicksWithAxis: null, // axis number or null for no sync 

       // mode specific options 
       tickDecimals: null, // no. of decimals, null means auto 
       tickSize: null, // number or [number, "unit"] 
       minTickSize: null, // number or [number, "unit"] 
       monthNames: null, // list of names of months 
       timeformat: null, // format string to use 
       twelveHourClock: false // 12 or 24 time in time mode 
      }, 

我試圖改變幾乎一切,看着不同的崗位,但似乎沒有任何更改值。我可以做簡單的事情,如改變顏色等,所以我想知道如果我有什麼問題。

任何建議,將不勝感激。

感謝

+0

謝謝你的選擇! – Tebe

回答

3

你已經增加了一倍你的x軸的配置,所以第二個覆蓋第一。

此:

xaxis: {ticks: [[1,' Yesterday'], [2,'Two'], [3,'Three'], [4,'Four'], [5,'Five'], [6,'Six'], [7,'Seven'], [8,'Eight'], [9,'Nine'], [10,'Ten'], [11,'Eleven'], [12,'Twelve'], [13,'Thirteen'], [14,'fourteen']]}, 
xaxis: { tickColor: 'transparent' } 

應該是:

xaxis: { 
    ticks: [[1,' Yesterday'], [2,'Two'], [3,'Three'], [4,'Four'], [5,'Five'], [6,'Six'], [7,'Seven'], [8,'Eight'], [9,'Nine'], [10,'Ten'], [11,'Eleven'], [12,'Twelve'], [13,'Thirteen'], [14,'fourteen']], 
    tickColor: 'transparent' 
}, 
+0

謝謝你,完美工作,永遠不會發現這麼多的讚賞,有趣,儘管有人指出它是有道理的。 –