2014-12-04 60 views
0

中製作diffrenet顏色柱狀圖如何爲extjs中的不同顏色製作不同的顏色,我嘗試使用主題來實現。但它不能正常工作,因此我在yfield串聯參數中傳遞兩個參數。我附上工作示例,因爲我還附上了您的參考的樣本截圖。能否請你幫我弄明白 截圖如何在extjs 4

enter image description here

您可以參考以下鏈接做參考

<code> http://jsfiddle.net/sunith_123/f83v0kbb/8/</code> 

回答

1

刪除您的主題,請嘗試以下渲染器,而不是爲你的圖表系列:

series: [{ 
      type: 'column', 
      axis: 'left', 
      highlight: false, 
      xField: 'name', 
      yField: ['rocCCI', 'rocCI'], 
      renderer: function(sprite, record, attr, index, store) { 
       var color = ['orange', 
          'peachpuff', 
          'green', 
          'greenyellow'][index%4]; 
       return Ext.apply(attr, { 
        fill: color 
       }); 
      } 

     }] 

您會得到以下結果 enter image description here

渲染器正在循環4色陣列(使用index%4作爲關鍵字)。您可以擴展此數組以添加更多顏色 - 或者使索引計算更加智能,以根據當前記錄呈現選擇顏色。

唯一的缺點是關鍵顏色不正確 - 但他們永遠不會使用這種顏色格式!