2012-04-29 11 views
0

私はFLOTの棒グラフを実装しようとしていますが、私はいくつかの問題FLOTのyaxsisと色

最初はyaxsis minを設定すると最大で動作するようには思えないが、グラフはまだのみから行くことであることを持っています0 - 14.

2番目私は各バーの色と名前を個別に設定する方法はわかりません。

これは私が持っているものである

var d2 = [{ 
    "label": "Face", 
    "data": [[0 , "3"], [5, "13"]] 
}, 
{ 
    "label": "Telephone", 
    "data": [[1, "400"], [6, "337"]] 
}, 
{ 
    "label": "Web", 
    "data": [[2, "1304"], [7, "843"]] 

}]; 





var options = { 

    yaxes: {min: 0, max: 25000}, 

    xaxis: { 
     tickSize: [1], 
     autoscaleMargin: .10, 
     show: false 
    }, 


    series: { 
     lines: { show: false}, 
     bars: { 
      show: true, 
      barWidth: 0.9, 
      align: 'center', 
      multiplebars:true,    
      }, 

     points: { 
      show: true 
     } 
    } 


}; 



$.plot($('#graph1'), d2, options); 

誰もがこれらの問題を解決する方法を知っていますか?

おかげ

答えて

4

あなたはそれぞれのバーに別の名前と色をしたいなら、あなたは、データセットの一部としてバー設定を構成する必要があります。 minmaxのためにあなたがそれらを設定しないとどうなるか、機能していないとして

$.plot($("#placeholder"), data1, options); 

var data1 = [ 
     { 
      label: "Face", 
      data: [[0 , 3], [5, 13]], 
      bars: { 
       show: true, 
       barWidth: 0.9, 
       fill: true, 
       lineWidth: 1, 
       order: 1, 
       fillColor: "#AA4643" 
      }, 
      color: "#AA4643" 
     }, 
     { 
      label: "Telephone", 
      data: [[1, "400"], [6, "337"]], 
      bars: { 
       show: true, 
       barWidth: 0.9, 
       fill: true, 
       lineWidth: 1, 
       order: 2, 
       fillColor: "#89A54E" 
      }, 
      color: "#89A54E" 
     }] 

次に、このようにそれらをグラフ?軸がデータに正しく適合していますか?

+0

助けてくれてありがとうございます。minとmaxでエラーが見つかりました –