2013-02-22 58 views
2

我使用海軍報庫顯示條形圖與海軍報JS按類別分組的多個條形圖和我這樣需要按一定的價值:如何繪製

| 
|   +----+  +----+  
|   | |  | |  
|   | |  | |  
|   | |  | |  
| +----+ | |  | |  
| | | | |  | |  
| | | | |  | |  
| | | | |  | |  
|-+----+---+----+--------+----+---- 
    val 1 val2   val3 
    category #1  category #2 

感謝謝爾蓋·G.爲Ascii :)

我有變量d1,d2,d3分別爲條1,2和3的值(按類別排序)。 現在的問題是: 如何添加滴答下面的類別? 對不起,我的糟糕的「谷歌翻譯」英語,非常感謝!

代碼:

$.plot(
    $("#placeholder"), 
    [ 

      { 
     label: labelChart, 
     data: d1, 
     color: '#92d5ea', 
     bars: { 
      show: true, 
      barWidth: 0.5, 
      align: "center", 
      order:2 
     }, 

     multiplebars:true 
    }, 
    { 
     label: labelChart, 
     data: d2, 
     color: '#92d5ea', 
     bars: { 
      show: true, 
      barWidth: 0.5, 
      align: "center", 
      order:3 
     }, 

     multiplebars:true 
    }, 
    { 
     label: labelChart, 
     data: d3, 
     color: '#92d5ea', 
     bars: { 
      show: true, 
      barWidth: 0.5, 
      align: "center", 
      order:3 
     }, 

     multiplebars:true 
    } 


    ], 
    { 
     xaxis: { 
      ticks: ticksData 
     }, 

     yaxis: { 
      min:0 
     } 
    } 
); 
+1

這爲我工作:http://www.pikemere.co.uk/blog/tutorial-flot-how-to-create-bar-charts/ – 2014-08-24 21:15:30

回答

-4

使用類插件,如this example證明。

+1

對不起,我不得不downvote,因爲這並沒有回答這個問題。在這個例子中,每個類別給出一個值。但問題是如何使用類別並列繪製多個系列圖,大概是並排的。 – 2013-11-08 14:51:13

+0

@DerekHenderson你是對的;我顯然誤解了這個問題。刪除我的答案。 – DNS 2013-11-14 03:32:19

+2

這對我有效:http://www.pikemere.co.uk/blog/tutorial-flot-how-to-create-bar-charts/ – 2014-08-24 21:14:58