2013-07-26 38 views
4

我正在使用圖表來顯示TimeboxScopedApp中的數據,並且我想在範圍更改時更新數據。使用remove()然後重新繪製圖表here的更強力方法留給我一個疊加的「加載...」掩碼,但其他方式工作。使用Highchart原生redraw()方法的自然方法將是我的首選,但我不知道如何訪問實際的Highchart對象而不是App SDK包裝器。使用App SDK 2.0中的新數據更新圖表

下面的代碼的相關部分:

var chart = Ext.getCmp('componentQualityChart'); 
if (chart) { 
    var chartCfg = chart.getChartConfig(); 
    chartCfg.xAxis.categories = components; 
    chart.setChartConfig(chartCfg); 
    chart.setChartData(data); 
    chart.redraw(); // this doesn't work with the wrapper object 
} else { // draw chart for the first time 

如何去重新繪製圖表用新的數據?

回答

3

假設圖表(componentQualityChart)是Rally.ui.chart.Chart一個實例,可以像這樣訪問HighCharts實例:

var highcharts = chart.down('highchart').chart; 

// Now you have access to the normal highcharts interface, so 
// you could change the xAxis 
highcharts.xAxis[0].setCategories([...], true); 

// Or you could change the series data 
highcharts.series[0].data.push({ ... }); //Add a new data point 

// Or pretty much anything else highcharts lets you do 
+0

你應該告訴hicharts這裏有什麼東西嗎?或者,也許給一個JSFiddle例子?不幸的是,對我而言,它不起作用,因爲chart.down('highchart')。圖表是空的。 – MyUserName

1

使用_unmask()刪除重疊 「中..」 掩模

if (this.down('#myChart')) { 
    this.remove('myChart'); 
} 
this.add(
        { 
         xtype: 'rallychart', 
         height: 400, 
         itemId: 'myChart', 
         chartConfig: { 
          //.... 
         },    
         chartData: { 
          categories: scheduleStateGroups, 
          series: [ 
           { 
            //... 
           } 
          ] 
         } 
        } 
       ); 
     this.down('#myChart')._unmask();