0

早晨,

我正在使用 Sencha Touch 2.3,Sencha Cmd 4.0.2.67

不幸的是,我对 Sencha 的了解不够,无法解释和诊断我的问题,所以请原谅任何遗漏。

当我尝试运行创建多个仪表和条形图的应用程序时,在绘制任何图表之前,应用程序崩溃并且 console.log 给出以下错误消息:

Uncaught TypeError: Object [object Object] has no method 'getDirection'

它说错误出现在 chart.series.Series.js 的第 683 行,看起来像这样(这就是它开箱即用的方式):

for (i = 0, ln = axes.length; i < ln; i++) { axis = axes[i]; if (!directionMap[axis.getDirection()]) {// <-- line 683 directionMap[axis.getDirection()] = [axis]; } else { directionMap[axis.getDirection()].push(axis); } }

我检查了axis.Axis.js,我可以看到第543行有以下内容:
getDirection: function () { return this.getChart().getDirectionForAxis(this.getPosition()); },

console.log(axes[i])显示以下内容: Class {titleStyle: Class, labelStyle: Class, gridStyle: Class, initConfig: function, initialConfig: Object…} _chart: Class _fields: Array[0] _labels: Array[0] _margin: 10 _maximum: 10 _minimum: 0 _position: "gauge" _steps: 10 _title: false axisId: "ext-axis-12" config: objectClass eventDispatcher: Class getEventDispatcher: function () { getObservableId: function () { getUniqueId: function () { gridStyle: Class id: "ext-chart-axis-gauge-1" initConfig: function (){} initialConfig: Object labelStyle: Class managedListeners: Object observableId: "#ext-chart-axis-gauge-1" titleStyle: Class usedSelectors: Array[1] __proto__: Object

我的应用程序同时生成仪表和条形图。如果我禁用仪表,那么我将不再收到此错误。所以,问题在于创建我的仪表的功能。这里是:

var gaugeTitle = thetabs[tt].Entries[tt2].Title;
var currentValue = (thetabs[tt].Entries[tt2].CurrentValue > 0)?thetabs[tt].Entries[tt2].CurrentValue:0;  
var baseValue = thetabs[tt].Entries[tt2].BaseValue;  
var centreValue = thetabs[tt].Entries[tt2].CentreValue;  
var generated = thetabs[tt].Entries[tt2].Generated;  
var gaugeData = thetabs[tt].Entries[tt2];// this data populates the gauge store  

// now we create a store for the gauge  
var gaugeStore = Ext.create('Ext.data.Store', {  
storeId: 'gaugeStore',  
fields: [{'name':'BaseValue','type':'int'},  
{'name':'CentreValue','type':'int'},  
{'name':'CurrentValue','type':'int'},  
{'name':'Generated'},  
{'name':'Title'},  
{'name':'Type'}],  
data: gaugeData  
});  

gaugeStore.setData(gaugeData);  // Use the add function to add records or model instances.

// set the maximum value on the gauge, then round it to whole number    
var gaugemax = (thetabs[tt].Entries[tt2].CentreValue>10)?  thetabs[tt].Entries[tt2].CentreValue*2:10;  

// ensure gauge max is never less than currentValue  
if(gaugemax < currentValue){  
gaugemax =  currentValue+(currentValue*.1); // use 110% of currentValue   
}  
// show whole numbers only  
gaugemax = Math.round(gaugemax/10)*10;   

//set gauge colour  
gaugeColor = setGaugeColour(siteName);  

/// new gauge  
var chartgx = {  
cls: 'thegauge',  
itemId: 'gauge'+tt2,  
xtype: 'chart',  
shadow: true,  
store: gaugeStore,  
width : 'auto',  
animate: true,  
insetPadding: 50,  
axes: [{  
type: 'gauge',  
position: 'gauge',  
minimum: 0,  
maximum: gaugemax,  
steps: 10,  
margin: 10  
}],  

series: [{  
type: 'gauge',  
minimum: 0,  
maximum: gaugemax,  
steps: 10,  
margin: 10,  
angleField: 'CurrentValue',  
donut: 30,  
colorSet:[gaugeColor,'#e1e1e1']  
}]  
}; 


                            `

有人可以告诉我如何纠正。

4

1 回答 1

0

从仪表上移除轴似乎已经解决了这个问题,但现在我看到了另一个:-(

于 2014-03-20T11:00:35.657 回答