简体   繁体   English

Sencha图表:未捕获的TypeError:对象[object Object]没有方法'getDirection'

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

Morning, 早上,

I am using Sencha Touch 2.3, Sencha Cmd 4.0.2.67 我正在使用Sencha Touch 2.3,Sencha Cmd 4.0.2.67

Unfortunately, I do not know enough about Sencha to be able to explain and diagnose my problem, so please forgive any omissions. 不幸的是,我对Sencha的了解不足,无法解释和诊断我的问题,因此请原谅任何遗漏。

When I try to run my app, which creates several gauges and bar charts, before any charts have been drawn, the app crashes and console.log give the following error message: 当我尝试运行创建多个仪表图和条形图的应用程序时,在绘制任何图表之前,该应用程序崩溃并且console.log给出以下错误消息:

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

It says the error is on line 683 of chart.series.Series.js, which looks like this (this is how it came out of the box): 它说错误在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); } }

I have checked axis.Axis.js, and I can see that line 543 has the following: 我检查了axis.Axis.js,可以看到第543行包含以下内容:
getDirection: function () { return this.getChart().getDirectionForAxis(this.getPosition()); },

console.log(axes[i]) shows the following: 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 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

My app generates both gauges AND bar charts. 我的应用程序同时生成了仪表和条形图。 If I disable the gauges then I no longer get this error. 如果禁用压力表,则不会再出现此错误。 So, the problem lies with the function which creates my gauges. 因此,问题出在创建我的仪表的功能上。 Here it is: 这里是:

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']  
}]  
}; 


                            `

Can someone please advise me how to correct. 有人可以告诉我如何纠正。

从量规上拆下轴似乎已经解决了这个问题,但是现在我遇到了另一个问题:-(

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 谷歌图表甘特图中的空 GetSelection() 对象 - Empty GetSelection() Object in Google Charts' Gantt Chart 类型错误:“模块”object 在 plotly 中不可调用 - TypeError: 'module' object is not callable in plotly 必须将哪种Java对象传递给Google Charts趋势线? - What kind of Java object must be passed to Google Charts trendline? &#39;Figure&#39;对象没有属性&#39;vbar&#39; - 'Figure' object has no attribute 'vbar' 带有TypeError的Python问题:“ int”对象不可下标 - Python issue with TypeError: 'int' object is not subscriptable 使用 Charts Reactjs 创建一个 for 循环以在渲染中显示来自 API 的数据对象 - Make a for loop to show data object from API in render using Charts Reactjs 我可以从更高级别的“图表”对象访问较低级别的散景“绘图”界面吗? - Can I access the lower level bokeh 'plotting' interface from a higher level 'charts' object? 使用对象文字表示法时,水平轴标签未出现在Google图表中 - Horizontal axis labels not appearing in Google charts when using object literal notation Google Charts - 如何为列表对象属性的每个不同值制作 1 行 - Google Charts - How to make 1 line for each distinct value of a list object property sencha触摸和图表 - sencha touch and charts
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM