2015-09-27 32 views
1

我是新來的海軍報。我有這樣的條形圖: enter image description here海軍報條形圖 - 如何創建非堆疊起來重視

,這裏是我使用它的代碼:

$.getJSON('chartBar.json', function(graphDataBar){ 

    $.plot($('#graph-bars'), graphDataBar, { 
     series: { 
      bars: { 
       show: true, 
       barWidth: .1, 
       align: 'right' 


      }, 
      shadowSize: 0 
     }, 
     grid: { 
      color: '#646464', 
      borderColor: 'transparent', 
      borderWidth: 20, 
      hoverable: true 
     }, 
     xaxis: { 
      tickColor: 'transparent', 
      ticks: [[6,'Week 48'],[7,'Week 49'],[8,'Week 50'],[9,'Week 51'],[10,'Week 52']], 
      min: 5.5, 
      max: 10.5, 
      mode: 'time', 
     timeformat: "%b %d", 
     minTickSize: [1, "day"], 
     tickSize: [1, "day"], 
     autoscaleMargin: .10 
     }, 
     yaxis: { 
      tickSize: 5 
     } 
    }); 

我已經盡力用x軸內部的性質,但似乎沒有任何幫助。 我知道有一種方法可以做到這一點,我見過的例子如This之一。 但它似乎沒有工作。 什麼我試着在這裏獲得成功是這個 enter image description here

除了我見過的其他樣品#2像This 但它仍然沒有工作了。我不知道我是否看到了這種錯誤的方式,或者如果我需要使用時間戳來使其工作,但我做錯了方式。

任何人都可以向我解釋,該解決方案將如何工作?我想了解它爲未來的條形圖

預先感謝您

+0

你需要一個並排端插件這樣的:https://github.com/pkoltermann/SideBySideImproved – Raidri

+0

您發佈數據的任何機會(chartBar.json文件)? –

回答

0

我做了一個假設,即JSON數據是一樣的在你的另一個問題here所以道歉,如果不是這種情況。

我創建了一個小提琴here演示「非堆疊條形」使用下面的JSON數據:

[ 
    {  
     "data": [ [6, 520], [7, 600], [8, 850], [9, 900], [10, 300] ], 
     "color": "#F02626", 
     "points": { "fillColor": "#F02626", "radius": 6 }, 
     "lines": { "fillColor": "#CCF8FF"} 
    }, 
    { 
     "data": [ [6, 300], [7, 400], [8, 550], [9, 750], [10, 200] ], 
     "color": "#26F041", 
     "points": { "radius": 10, "fillColor": "#26F041" } 
    }, 
    { 
     "data": [ [6, 200], [7, 150], [8, 380], [9, 400], [10, 100] ], 
     "color": "#20AEFA", 
     "points": { "radius": 6, "fillColor": "#20AEFA"} 
    } 
] 

它使用orderBars plugin。以獲得條的鍵,會出現由方(而非垂直)是設置series.bars.order屬性1側:

series: { 
    bars: { 
     ... 
     order: 1 
    } 
},