Refreshing a rallychart

2019-09-04 12:25发布

I have a Rally SDK 2.0p5 app that displays a chart. When the user selects an option, the data will be updated and I would like to refresh the chart. But instead of redrawing, it will place a new chart beneath. What is the proper syntax?

                // Configure and Add the chart
                this.add(
                    {
                        xtype: 'rallychart',
                        height: 400,
                        id: 'chart',
                        chartConfig: {
                            chart: {
                            },
                            title: {
                                text: 'My Chart',
                                align: 'center'
                            },
                            xAxis: [
                                {
                                    categories: ['M0','M1','M2','M3','M4','M5'],
                                    title: {
                                        text: 'Interval'
                                    }
                                }
                            ],
                            yAxis: {
                                title: {
                                    text: yText
                                }
                            },
                            series: [ { type: 'column',
                                        name: yText,
                                        data: mCount } ],
                            plotOptions : {
                                column: {
                                    color: '#F00'
                                },
                                series : {
                                    animation : {
                                        duration : 2000,
                                        easing : 'swing'
                                    }
                                }
                            }
                        }
                    }
                );

标签: rally
2条回答
2楼-- · 2019-09-04 12:45

You need to remove the 1st chart before adding the new one.

redrawChart: function() {
    this.remove('#chart');
    this.add({...});
}
查看更多
闹够了就滚
3楼-- · 2019-09-04 13:04

It's often better to just update the chart in place. HighCharts is the charting library that's included in the App SDK. HighCharts will even animate your changes. Cool!!! Look here for the list of methods that operate on charts. You can add series, change data, change axis limits, control the zoom, etc.

查看更多
登录 后发表回答