1

查看 Api 2.0p5 和图表。

我正在寻找吞吐量图表的变体,基本上有......

  • 过去 12 个月在底部
  • 图表左侧的总数
  • 故事和缺陷计数的堆叠列
  • 故事点穿过的脊线,点的次要 y 轴

所以到目前为止,我的所有这些都在我的拉力赛应用程序中工作,除了我所有的号码目前都是硬编码的。我如何才能将这些信息正确地放入我的图表中?

我看到了一个使用商店的例子,但看起来很古怪而且老实说,我不知道我在哪里看到它来尝试和复制。

代码如下,如果有人有想法或想法,我将不胜感激:

    <!DOCTYPE html>
    <html>

    <head>
        <meta http-equiv="refresh" content="240" />
        <title>Throughput Chart</title>
        <script type="text/javascript" src="https://rally1.rallydev.com/apps/2.0p5/sdk.js?debug=true"></script>
        <script type="text/javascript">

      Rally.onReady(function () {

        Ext.create('Ext.Container', {
              items: [
                  {
                      xtype: 'rallychart',
                      height: 400,
                        series: [{
                            name: 'Defect Count',
                            data: [2, 2, 3, 2, 1, 4, 2, 3, 5, 3, 5, 4]
                        }, {
                            name: 'Story Count',
                            data: [3, 4, 4, 2, 5, 3, 4, 5, 6, 3, 4, 8]
                        }, {
                            name: 'Story Points',
                            color: '#89A54E',
                            type: 'spline',
                            yAxis: 1,
                            data: [55, 34, 50, 31, 44, 61, 55, 22, 50, 48, 34, 44]
                        }],
                      chartConfig: {
                        chart: {
                            type: 'column'
                            },
                            title: {
                              text: 'Kanban State Counts',
                              align: 'center'
                            },
                         xAxis: {
                                categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
                            },
                        yAxis: [{
                        title: {
                                text: 'Count'
                            },
                        stackLabels: {
                            enabled: true,
                            style: {
                                fontWeight: 'bold',
                            }
                        }
                    }, 
                    {
                        opposite: true,
                        title: {
                            text: 'Story Points'
                        }
                }],
                      }
                  }
              ],
              renderTo: Ext.getBody().dom
          });

    });   
        </script>



        <style type="text/css">
        </style>
    </head>
    <body>
    </body>
    </html>
4

1 回答 1

2

这是一个在 WsapiDataStore 中使用用户故事数据的基本示例。该代码仅按 ScheduleState 汇总 Stories 并将计数添加到 Ext.data.store。然后应用程序使用 Rally.ui.chart.ChartView 组件在条形图中按计划状态显示故事计数。

<!DOCTYPE html>
<html>
<head>
    <title>ChartExample</title>

    <script type="text/javascript" src="https://rally1.rallydev.com/apps/2.0p5/sdk.js"></script>

    <script type="text/javascript">
        Rally.onReady(function() {
            Ext.define('CustomApp', {
                extend: 'Rally.app.App',
                componentCls: 'app',

                launch: function() {
                    Ext.create('Rally.data.WsapiDataStore', {
                        model: 'UserStory',
                        autoLoad: true,
                        listeners: {
                            load: this._onDataLoaded,
                            scope: this
                        }
                    });
                },

                _onDataLoaded: function(store, data) {
                    var records = [];
                    var scheduleStateGroups = ["Defined","In-Progress","Completed","Accepted"]

                    // State count variables
                    var definedCount = 0;
                    var inProgressCount = 0;
                    var completedCount = 0;
                    var acceptedCount = 0;

                    // Loop through returned data and group/count by ScheduleState
                    Ext.Array.each(data, function(record) {
                        //Perform custom actions with the data here
                        //Calculations, etc.

                        scheduleState = record.get('ScheduleState');

                        switch(scheduleState)
                        {
                            case "Defined":
                                definedCount++;
                                break;
                            case "In-Progress":
                                inProgressCount++;
                                break;
                            case "Completed":
                                completedCount++;
                                break;
                            case "Accepted":
                                acceptedCount++;
                        }
                    });

                    //Create a store containing the chart data
                    var scheduleStateStore = Ext.create('Ext.data.Store', {
                        fields: ['KanbanState', 'ObjectID_Count'],
                        data: {
                            rows: [
                                {ScheduleState: 'Defined', ObjectCount: definedCount},
                                {ScheduleState: 'InProgress', ObjectCount: inProgressCount},
                                {ScheduleState: 'Completed', ObjectCount: completedCount},
                                {ScheduleState: 'Accepted', ObjectCount: acceptedCount}
                            ]
                        },
                        proxy: {
                            type: 'memory',
                            reader: {
                                type: 'json',
                                root: 'rows'
                            }
                        }
                    });

                    // Configure and Add the chart
                    this.add(
                        {
                            xtype: 'rallychart',
                            height: 400,
                            series: [
                                {
                                    type: 'column',
                                    dataIndex: 'ObjectCount',
                                    name: 'Count',
                                    visible: true
                                }
                            ],
                            store: scheduleStateStore,
                            chartConfig: {
                                chart: {
                                },
                                title: {
                                    text: 'User Story Schedule State Counts',
                                    align: 'center'
                                },
                                xField : 'ScheduleState',
                                xAxis: [
                                    {
                                        categories: scheduleStateGroups,
                                        title: {
                                            text: 'ScheduleState'
                                        }
                                    }
                                ],
                                yAxis: {
                                    title: {
                                        text: 'Count'
                                    }
                                },
                                plotOptions : {
                                    column: {
                                        color: '#F00'
                                    },
                                    series : {
                                        animation : {
                                            duration : 2000,
                                            easing : 'swing'
                                        }
                                    }
                                }
                            }
                        }
                    );
                }
            });
            Rally.launchApp('CustomApp', {
                name: 'ChartExample'
            });
        });
    </script>

    <style type="text/css">
        .app {
             /* Add app styles here */
        }
    </style>
</head>
<body></body>
</html>
于 2012-12-17T01:05:24.557 回答