1

我正在尝试为 Rally 创建一个自定义应用程序。

Iteration defects by severity and below is my code.

var startdate;
var enddate;
var iterationid;
Ext.define('CustomApp', {
    extend: 'Rally.app.App',
    componentCls: 'app',
    launch: function() {
        var that = this;
        that.getCurrentIteration(function(iterations){
             console.log("getting iteration object");
             startdate = _.map(iterations,function(i){return i.get("StartDate")});
             enddate = _.map(iterations,function(i){return i.get("EndDate")});
             iterationid = _.map(iterations,function(i){return i.get("ObjectID")});
             that._load();
        });
    },

     getCurrentIteration:function ( callback ) {
        var today = Rally.util.DateTime.toIsoString(new Date());
        Ext.create('Rally.data.wsapi.Store', {
            model: 'Iteration',
            autoLoad: true,
            context : {
                projectScopeDown : false   
            },
            filters: [
                {
                    property: 'EndDate', operator: '>=', value: today
                },
                {
                    property: 'StartDate', operator: '<=', value: today
                }
            ],
            listeners: {
                load: function(store, data, success) {
                    callback(data);
                }
            },
            fetch: true
        });
    },

    _load:function(){
        this.defineCalculator();
        this.makeChart();
   },    

    defineCalculator: function(){
        var that = this;
        Ext.define("MyDefectCalculator", { 
            extend: "Rally.data.lookback.calculator.TimeSeriesCalculator",
            getMetrics: function () {
                var metrics = [
                   {
                        field: "Severity",
                        as: "Catastrophic",
                        display: "column",
                        f: "filteredCount",
                        filterField: "Severity",
                        filterValues: ["1 - Catastrophic"]
                   },
                    {
                        field: "Severity",
                        as: "Severe",
                        display: "column",
                        f: "filteredCount",
                        filterField: "Severity",
                        filterValues: ["2 - Severe"]
                    },
                     { 
                        field: "Severity",
                        as: "Non - Critical",
                        display: "column",
                        f: "filteredCount",
                        filterField: "Severity",
                        filterValues: ["3 - Non - Critical"]
                     },
                      {
                        field: "Severity",
                        as: "Minor",
                        display: "column",
                        f: "filteredCount",
                        filterField: "Severity",
                        filterValues: ["4 - Minor"]
                      },
                       {
                        field: "Severity",
                        as: "Enhancement",
                        display: "column",
                        f: "filteredCount",
                        filterField: "Severity",
                        filterValues: ["5 - Enhancement"]
                       }
                ];  
                return metrics;
            }
        });
    },

    makeChart: function(){
        if (this.down('#myChart')) {
                this.remove('myChart');
        }
        console.log(enddate[0])
        var timePeriod = new Date(enddate[0] - startdate[0]);
        var dayMilliSeconds = enddate[0].getTime() - 86400000; 
        var adjustedEnddate = new Date(dayMilliSeconds);
        var project = this.getContext().getProject().ObjectID;
        var storeConfig = this.createStoreConfig(project,timePeriod,iterationid);
        this.chartConfig.calculatorConfig.startDate = startdate[0];
        this.chartConfig.calculatorConfig.endDate = adjustedEnddate;
        this.chartConfig.storeConfig = storeConfig;
        this.add(this.chartConfig); 
    },

    createStoreConfig : function(project,validFrom,iterationid1) {
        return {
            listeners : { 
                load : function(store,data) {
                    console.log("data",data.length);
                }
            },

            filters: [
                {
                    property: '_ProjectHierarchy',
                    operator : 'in',
                    value : [project] 
                },
                {
                    property: 'Iteration',
                    operator: 'in',
                    value: iterationid1
                },
                {
                    property: '_TypeHierarchy',
                    operator: 'in',
                    value: ['Defect']
                },
                 {
                    property: '_ValidFrom',
                    operator: '>',
                    value: validFrom
                }
            ],
            autoLoad : true,
            limit: Infinity,
            fetch: ['Severity'],
            hydrate: ['Severity']
        };
    },
     chartConfig: {
        xtype: 'rallychart',
        itemId : 'myChart',
        chartColors: ['Red', 'Green', 'Yellow', 'Balck' , 'Brown'],

        storeConfig: { },
        calculatorType: 'MyDefectCalculator',

        calculatorConfig: {
        },

        chartConfig: {

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

});

我现在正在获取数据,并设法将其显示在图表上,但问题是数据甚至显示未来日期,即我当前的迭代是从 13 到 26,理想情况下它应该显示 13、14 的数据和 15 是今天,但它显示了所有日期.. 任何人都可以帮助我在缺少逻辑的地方限制这一点。

Thanks,
Surender
4

0 回答 0