2014-10-17 22 views
1

我想表明從拉力賽使用快照的一些數據sotre傳遞給德圖所示:限制集會圖表快照店日期期間

storeConfig: { 
         find: { 
          _ItemHierarchy: 153124, //PI Object ID 
          //Release: 9045474054, 
          _TypeHierarchy: 'HierarchicalRequirement', //Burn on stories 
          Children: null, //Only include leaf stories, 
          _ValidTo: { $gte: me._startDateField.value }, 
          _ValidFrom: { $lte: me._endDateField.value } 
         }, 
         fetch: ['ScheduleState', 'PlanEstimate'], 
         hydrate: ['ScheduleState'], 
         sort: { 
          '_ValidFrom': 1 
         } 
        } 

的想法是,我希望圖表只顯示YHE在me._startDateField.value和me._endDateField.value中指定的開始日期和結束日期之間的時段。達到這個目標的方法是什麼?因爲現在圖表顯示的是從一月開始的數據,而不是從開始日期開始。

回答

1

This example將結束日期限制在第二個選項rallydatepicker中,而不是默認爲今天的日期。請參閱自述文件here

Ext.define('CustomApp', { 
    extend: 'Rally.app.App', 
    componentCls: 'app', 
    launch: function() { 
     var that = this; 
     var minDate = new Date(new Date() - 86400000*90); //milliseconds in day = 86400000 
     var datePicker = Ext.create('Ext.panel.Panel', { 
      title: 'Choose start and end dates:', 
      bodyPadding: 10, 
      renderTo: Ext.getBody(), 
      layout: 'hbox', 
      items: [{ 
       xtype: 'rallydatepicker', 
       itemId: 'from', 
       minDate: minDate, 
       handler: function(picker, date) { 
        that.onStartDateSelected(date); 
        } 
       }, 
       { 
       xtype: 'rallydatepicker', 
       itemId: 'to', 
       minDate: minDate, 
       handler: function(picker, date) { 
        that.onEndDateSelected(date); 
       } 
      }] 
     });   
     this.add(datePicker); 
     var panel = Ext.create('Ext.panel.Panel', { 
      id:'infoPanel', 
      componentCls: 'panel' 
     }); 
     this.add(panel); 
    }, 
    onStartDateSelected:function(date){ 
     console.log(date); 
     this._startDate = date; 
    }, 

    onEndDateSelected:function(date){ 
     this._endDate = date; 
     console.log(date); 
     Ext.getCmp('infoPanel').update('showing data between ' + this._startDate + ' and ' + this._endDate); 
    this.defineCalculator(); 
     this.makeChart(); 
    }, 

    defineCalculator: function(){ 
     var that = this; 
     Ext.define("MyDefectCalculator", { 
      extend: "Rally.data.lookback.calculator.TimeSeriesCalculator", 
      getMetrics: function() { 
       var metrics = [ 
        { 
         field: "State", 
         as: "Open", 
         display: "column", 
         f: "filteredCount", 
         filterField: "State", 
         filterValues: ["Submitted","Open"] 
        }, 
        { 
         field: "State", 
         as: "Closed", 
         display: "column", 
         f: "filteredCount", 
         filterField: "State", 
         filterValues: ["Fixed","Closed"] 
        } 
       ]; 
       return metrics; 
      } 
     }); 
    }, 

    makeChart: function(){ 
     if (this.down('#myChart')) { 
       this.remove('myChart'); 
     } 
     var timePeriod = new Date(this._endDate - this._startDate); 

     var project = this.getContext().getProject().ObjectID; 

     var storeConfig = this.createStoreConfig(project, timePeriod); 

     this.chartConfig.calculatorConfig.startDate = Rally.util.DateTime.format(new Date(this._startDate), 'Y-m-d'); 
     this.chartConfig.calculatorConfig.endDate = Rally.util.DateTime.format(new Date(this._endDate), 'Y-m-d'); 
     this.chartConfig.storeConfig = storeConfig; 
     this.add(this.chartConfig); 
    }, 

    createStoreConfig : function(project, interval) { 
     return { 
      listeners : { 
       load : function(store,data) { 
        console.log("data",data.length); 
       } 
      }, 
      filters: [ 
       { 
        property: '_ProjectHierarchy', 
        operator : 'in', 
        value : [project] 
       }, 
       { 
        property: '_TypeHierarchy', 
        operator: 'in', 
        value: ['Defect'] 
       }, 
       { 
        property: '_ValidFrom', 
        operator: '>=', 
        value: interval 
       } 

      ], 
      autoLoad : true, 
      limit: Infinity, 
      fetch: ['State'], 
      hydrate: ['State'] 
     }; 
    }, 
    chartConfig: { 
     xtype: 'rallychart', 
     itemId : 'myChart', 
     chartColors: ['Red', 'Green'], 

     storeConfig: { }, 
     calculatorType: 'MyDefectCalculator', 

     calculatorConfig: { 
     }, 

     chartConfig: { 

      plotOptions: { 
       column: { stacking: 'normal'} 
      }, 
      chart: { }, 
      title: { text: 'Open/Closed Defects'}, 
      xAxis: { 
       tickInterval: 1, 
       labels: { 
        formatter: function() { 
         var d = new Date(this.value); 
         return ""+(d.getMonth()+1)+"/"+d.getDate(); 
        } 
       }, 
       title: { 
        text: 'Date' 
       } 
      }, 
      yAxis: [ 
       { 
        title: { 
         text: 'Count' 
        } 
       } 
      ] 
      } 
    } 

}); 
+0

謝謝尼克!看起來這正是我需要的。 – MyUserName 2014-10-18 16:14:01