使用 App SDK 2.0 中的新数据更新图表 [英] Updating a chart with new data in App SDK 2.0

查看:23
本文介绍了使用 App SDK 2.0 中的新数据更新图表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用图表来可视化 TimeboxScopedApp 中的数据,并且我想在范围更改时更新数据.使用 remove() 然后按照此处所述重绘图表的更强力的方法让我得到一个叠加的正在加载..."掩码,但其他方式有效.使用 Highchart 原生 redraw() 方法的自然方法是我的偏好,只是我不知道如何访问实际的 Highchart 对象而不是 App SDK 包装器.

I am using a chart to visualize data in a TimeboxScopedApp, and I want to update the data when scope changes. The more brute-force approach of using remove() then redrawing the chart as described here leaves me with an overlaid "Loading..." mask, but otherwise works. The natural approach of using the Highchart native redraw() method would be my preference, only I don't know how to access the actual Highchart object and not the App SDK wrapper.

这是代码的相关部分:

var chart = Ext.getCmp('componentQualityChart');
if (chart) {
    var chartCfg = chart.getChartConfig();
    chartCfg.xAxis.categories = components;
    chart.setChartConfig(chartCfg);
    chart.setChartData(data);
    chart.redraw(); // this doesn't work with the wrapper object
} else { // draw chart for the first time

如何使用新数据重新绘制图表?

How do I go about redrawing the chart with the new data?

推荐答案

假设 chart (componentQualityChart) 是 Rally.ui.chart.Chart 的一个实例,你可以像这样访问 HighCharts 实例:

Assuming chart (componentQualityChart) is an instance of Rally.ui.chart.Chart, you can access the HighCharts instance like this:

var highcharts = chart.down('highchart').chart;

// Now you have access to the normal highcharts interface, so
// you could change the xAxis
highcharts.xAxis[0].setCategories([...], true);

// Or you could change the series data
highcharts.series[0].data.push({ ... });  //Add a new data point

// Or pretty much anything else highcharts lets you do

这篇关于使用 App SDK 2.0 中的新数据更新图表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆