代码之家  ›  专栏  ›  技术社区  ›  Kamal

我试图在图表中添加一个版本下拉列表,并在选择新版本时重新加载,但没有

  •  0
  • Kamal  · 技术社区  · 10 年前

    所以我试图修改示例累积流程图 here 因此它有一个发布下拉列表,使其仅显示与给定发布相关的信息。我的问题是,当从发布下拉列表中选择一个新版本时,图形不会自动重新加载,因此它实际上从未显示与所选版本相关的信息。我想我已经正确地实现了监听器,但我不确定,所以我想知道是否有人能告诉我为什么会发生这种情况,以及如何解决它。谢谢!我的代码如下:

    <!DOCTYPE html>
    <html>
    <head>
        <title>Historical Summary</title>
    
        <script type="text/javascript" src="/apps/2.0rc3/sdk.js"></script>
    
        <script type="text/javascript">
            Rally.onReady(function() {
                Ext.define('Rally.example.CFDCalculator', {
                    extend: 'Rally.data.lookback.calculator.TimeSeriesCalculator',
                    config: {
                        stateFieldName: 'ScheduleState',
                        stateFieldValues: ['Defined', 'In-Progress', 'Completed', 'Accepted']
                    },
    
                    constructor: function(config) {
                        this.initConfig(config);
                        this.callParent(arguments);
                    },
    
                    getMetrics: function() {
                        return _.map(this.getStateFieldValues(), function(stateFieldValue) {
                            return  {
                                as: stateFieldValue,
                                groupByField: this.getStateFieldName(),
                                allowedValues: [stateFieldValue],
                                f: 'groupByCount',
                                display: 'area'
                            };
                        }, this);
                    }
                });
    
                Ext.define('Rally.example.CFDChart', {
                    extend: 'Rally.app.App',
    
                    requires: [
                        'Rally.example.CFDCalculator'
                    ],
    
                    launch: function() {
                        this.add({
                            xtype: 'rallyreleasecombobox',
                            fieldLabel: 'Filter by Release:',
                            project: this.getContext().getProject(),
                            //value: Rally.util.Ref.getRelativeUri(this.getContext().getRelease()),
                            listeners: {
                                select: this._onSelect,
                                ready: this._onLoad,
                                scope: this
                            }
                        });
                    },
    
                    _onLoad: function() {
                            this.add({
                                xtype: 'rallychart',
    
                                storeType: 'Rally.data.lookback.SnapshotStore',
                                storeConfig: this._getStoreConfig(),
                                calculatorType: 'Rally.example.CFDCalculator',
                                calculatorConfig: {
                                    stateFieldName: 'ScheduleState',
                                    stateFieldValues: ['Defined', 'In-Progress', 'Completed', 'Accepted']
                                },
                                chartConfig: this._getChartConfig()
                                //context: this.getContext();
                            });
                    },
    
                    _onSelect: function() {
                            var histChart = this.down('rallychart');
    
                            histChart.refresh({
                                storeConfig: {
                                    filters: [this._getOwnerFilter()]
                                }
                            });
                    },
    
                    _getOwnerFilter: function() {
                        //var userCombo = this.down('rallyusersearchcombobox');
                            var releaseValue = this.down('rallyreleasecombobox');
                            return {
                                property: 'Release',
                                operator: '=',
                                value: releaseValue.getValue()
                            };
                    },
    
    
    
                    /**
                     * Generate the store config to retrieve all snapshots for stories and defects in the current project scope
                     * within the last 30 days
                     */
                    _getStoreConfig: function() {
                        return {
                            find: {
                                _TypeHierarchy: { '$in' : [ 'HierarchicalRequirement', 'TestSet' ] },
                                Children: null,
                                _ProjectHierarchy: this.getContext().getProject().ObjectID,
                                _ValidFrom: {'$gt': Rally.util.DateTime.toIsoString(Rally.util.DateTime.add(new Date(), 'day', -30)) }
                            },
                            fetch: ['ScheduleState'],
                            hydrate: ['ScheduleState'],
                            sort: {
                                _ValidFrom: 1
                            },
                            context: this.getContext().getDataContext(),
                            limit: Infinity
                        };
                    },
    
                    /**
                     * Generate a valid Highcharts configuration object to specify the chart
                     */
                    _getChartConfig: function() {
                        return {
                            chart: {
                                zoomType: 'xy'
                            },
                            title: {
                                text: 'Project Cumulative Flow: User Stories & Test Sets'
                            },
                            xAxis: {
                                tickmarkPlacement: 'on',
                                tickInterval: 1,
                                title: {
                                    text: 'Date'
                                }
                            },
                            yAxis: [
                                {
                                    title: {
                                        text: 'Count'
                                    }
                                }
                            ],
                            plotOptions: {
                                series: {
                                    marker: {
                                        enabled: false
                                    }
                                },
                                area: {
                                    stacking: 'normal'
                                }
                            }
                        };
                    }
                });
    
    
                Rally.launchApp('Rally.example.CFDChart', {
                  name: 'Historical summary: test cases, stories, and defects'
                });
            });
        </script>
    
        <style type="text/css">
    
        </style>
    </head>
    <body></body>
    </html>
    
    1 回复  |  直到 10 年前
        1
  •  0
  •   nickm    10 年前

    在第行出现“UncaughtTypeError:undefined不是函数”的代码错误

    histChart.refresh
    

    我修改了ProjectCumulativeFlow的示例,以通过Release过滤。完整代码在此 github repo .

    而不是延伸 Rally.app.App ,我扩展了 Rally.app.TimeboxScopedApp . SnapshotStore可以按版本进行筛选,但需要ObjectID。

    这是 find :

    find: {
         _TypeHierarchy: { '$in' : [ 'HierarchicalRequirement', 'Defect' ] },
         Release: this.getContext().getTimeboxScope().record.data.ObjectID, 
         Children: null,
         _ProjectHierarchy: this.getContext().getProject().ObjectID
    }
    

    要在选择发布后更新应用程序,请检查图表是否已存在(如果存在,请销毁它):

    onScopeChange: function() {
            if (this.down('#mychart')) {
            this.down('#mychart').destroy();
        }
            this.add({
                xtype: 'rallychart',
                itemId: 'mychart',
                storeType: 'Rally.data.lookback.SnapshotStore',
                storeConfig: this._getStoreConfig(),
                calculatorType: 'Rally.example.CFDCalculator',
                calculatorConfig: {
                    stateFieldName: 'ScheduleState',
                    stateFieldValues: ['Defined', 'In-Progress', 'Completed', 'Accepted']
                },
                chartConfig: this._getChartConfig()
            });
        },