2011-12-23 27 views
0

我似乎有一個傳奇udating圖例不更新

當數據更改stor餅圖更新但傳說沒有。

但是,當我們重置餅圖時,我們得到了一次更新,因爲我在交互中使用重置選項。

我不知道爲什麼圖例不是第一次更新的確切問題。

當我爲商店使用硬代碼值時,圖例在第一個自身得到更新。對於動態值,只有圖例沒有更新。

請參考我的代碼一些部分,

PieChart = new Ext.chart.Chart({ 

           cls: 'pie1', 

           theme: 'Demo', 

           store: store1 
           shadow: true, 

           animate: true, 

    legend: { 
    position: 'top' 

    // dock: false 
}, 
    interactions: [ { 

        type: 'reset', 
        confirm: true 
        }], 


series: 
    [ { 

     type: 'pie', 

     renderer: function(sprite, storeItem, barAttr, m, store11) { 

      barAttr.fill = colors1[m % colors1.length]; 

      return barAttr; 

     }, 

     field: 'data1', 

     showInLegend: true, 

     highlight: false, 

     donut: 15, 

     listeners: { 

      'labelOverflow': function(label, item) { 

       item.useCallout = true; 

      } 

     }, 

     callouts: { 

      renderer: function(callout, storeItem) { 

       callout.label.setAttributes({ 

        text: storeItem.get('Horizontal') 

       }, true); 

      }, 

      filter: function() { 

       return false; 

      }, 

      box: { 

       //no config here. 

      }, 

      lines: { 

       'stroke-width': 2, 

       offsetFromViz: 10 

      }, 

      label: { 

       font: 'italic 14px Arial' 

      }, 

      styles: { 

       font: '14px Arial' 

      } 

     }, 

     label: { 

      field: 'Horizontal', 

      display: 'rotate', 

      font: '5px Arial' 

     } 

    }] 

任何想法?

+4

這裏幾乎沒有任何信息提供任何答案!你能提供有關使用的餅圖組件的信息,返回的數據的格式/結構,執行此特定部分的代碼片段等? – techfoobar 2011-12-23 13:10:06

回答

0

我得到這個使用下面的代碼而得到的數據保存到店

var hrPieChart = hrPanel.items.getAt(0); 
      hrPieChart.legend = new Ext.chart.Legend({ 
       chart: hrPieChart, 
       position: 'top', 
        dock: false 
      }); 
      var fieldNames = []; 
      hStore.each(function(rec) { 
       fieldNames.push(rec.get('data1')); 
      }); 
      hrPieChart.series.getAt(0).yField = fieldNames; 
      hrPieChart.redraw(false); 
0

要更新圖表的圖例在煎茶觸摸(圖表V1.0.0)解決了,你只需要加載你的存儲和然後在回調中執行updateStore()

var updateLegend = function(){ 
    store.getProxy.url = 'someData.json'; // Omit if new data is from original source. 
    store.load({ 
     callback: function(records, options, success){ 
      if (success === true){ 
       var legend = chart.legend; 
       legend.view.updateStore(); 
      } 
     } 
    }); 
}