Sencha touch 2 Sencha Touch旋转木马中的谷歌图表问题
我在sencha旋转木马中有一个google gauge图表,该图表在一个时间间隔内更新。起初,当旋转木马绘制它的作品很好。但问题是,当我进行旋转木马滑动并再次返回时,图表会导致错误 以下是视图:Sencha touch 2 Sencha Touch旋转木马中的谷歌图表问题,sencha-touch-2,google-visualization,Sencha Touch 2,Google Visualization,我在sencha旋转木马中有一个google gauge图表,该图表在一个时间间隔内更新。起初,当旋转木马绘制它的作品很好。但问题是,当我进行旋转木马滑动并再次返回时,图表会导致错误 以下是视图: Ext.define('GGraphSencha.view.Main', { extend: 'Ext.Carousel', xtype: 'main', name: 'mainview', config: { fullscreen: true,
Ext.define('GGraphSencha.view.Main', {
extend: 'Ext.Carousel',
xtype: 'main',
name: 'mainview',
config: {
fullscreen: true,
items: [{
xtype: 'panel',
id: 'gaugegraph'
},
{
xtype: 'panel',
html: 'line 1'
},
{
xtype: 'panel',
html: 'line 2'
},
{
xtype: 'panel',
html: 'line 2'
},
{
xtype: 'panel',
html: 'line 2'
}]
}
});
这是控制器:
Ext.define('GGraphSencha.controller.Main', {
extend: 'Ext.app.Controller',
config: {
refs: {
mainview: {
xtype: 'mainview',
selector: 'mainview',
autoCreate: true
},
gauge: 'gaugegraph',
},
control: {
}
},
getDataForGauge: function() {
return [['', Math.round(Math.random() * 100) + 1]];
},
gaugeData: null,
gaugeChart: null,
interval: null,
getOptionsForGauge: function() {
return {
//width: 500 ,
height: 170,
greenFrom: 0,
greenTo: 30,
redFrom: 60,
redTo: 100,
yellowFrom: 30,
yellowTo: 60,
minorTicks: 5
};
},
launch: function() {
var me = this;
setTimeout(function() {
me.drawGauge();
}, 1000);
this.interval = setInterval(function() {
me.updateGauge();
}, 5000);
},
drawGauge: function() {
var data = new google.visualization.DataTable();
this.gaugeData = data;
this.gaugeData.addColumn('string', 'Label');
this.gaugeData.addColumn('number', 'Value');
this.gaugeData.addRows(this.getDataForGauge());
this.gaugeChart = new google.visualization.Gauge(document.getElementById('gaugegraph'));
this.gaugeChart.draw(this.gaugeData, this.getOptionsForGauge());
},
updateGauge: function() {
this.gaugeData.setValue(0, 1, Math.round(Math.random() * 100 + 1));
this.gaugeChart.draw(this.gaugeData, this.getOptionsForGauge());
}
});
请帮我解决一些问题
谢谢……有什么错误?您应该将图表逻辑放在视图中,而不是控制器中。并且只在绘制视图时更新图表。没有必要在“谢谢”中结束您的所有问题……,您以后是否可以避免这样做?