我将extjs 4.2.4更改为5.0.0,我有这个错误。
未捕获的TypeError:无法读取未定义的属性“height” SubSectionColumn.js _dc = 1451369036732:262
loadSprites: function() {
var chart = Ext.getCmp(this.identifier);
//var xAxisPositionArray = [55,95,135,175];
var xAxisPositionArray = new Array();//[55,95,175];
var yAxisStart = 0;
var xAxisHeight = chart.surface.height
var sprite;
var fromPosition;
var toPosition;
var width;
var noOfBars;
var sectionWidth = 0;
var newWidthValue = 0;
var tmp;
var chart = Ext.getCmp(this.identifier);
var storeLen =this.storeValue.getCount();
var teststore =this.storeValue;
var maxVal = 0;
for (var i =0; i<storeLen; i++){
tmp = parseFloat(teststore.data.items[i].get('data1'));
if (tmp >maxVal){
maxVal=tmp;
}
}
if(maxVal>0){
width = this.widthValue;
noOfBars = this.storeLength;//5;
sectionWidth = parseInt(parseInt(width)/parseInt(noOfBars));
for(var j=0;j<noOfBars;j++){
newWidthValue = parseInt(newWidthValue) + parseInt(sectionWidth);
xAxisPositionArray[j] = newWidthValue;
}
var gridArray = this.gridLineArrayVal.split(",");
for(var i=0;i<xAxisPositionArray.length;i++){
fromPosition = parseInt(xAxisPositionArray[i]);
toPosition = fromPosition+1;
sprite = Ext.create('Ext.draw.Sprite', {
type: 'path',
path: "M"+fromPosition+" " + yAxisStart +"L"+toPosition+" "+xAxisHeight+" Z", //if the value is "M100 40 L150 40", it's ok.
"stroke-width": (gridArray[i]=='dotted' || gridArray[i]=='line')?"0.4":"0",
"stroke-dasharray":(gridArray[i]=='dotted')?"4,4,2.5,4,4,4":"",
//"stroke-dasharray":"20,20",
stroke: "#9f9f9f",
//style:{cursor: 'pointer'},
surface: chart.surface
});
sprite.show(true);
};
maxVal=parseFloat(maxVal)*(0.10)+parseFloat(maxVal); //Math.round(maxVal)+1;
chart.axes.getAt(0).maximum = maxVal;
}
}
答案 0 :(得分:0)
chart.surface
显然未定义,因为您正在尝试访问height
媒体资源。
在ExtJS 5中,有两个可能与此相关的重大变化。首先,他们收紧了配置属性。许多现在都是前缀,并且不能通过旧名称访问。相反,你应该使用(之前应该使用过)访问者方法 - 例如chart.getSurface()
第二:ExtJs 4中使用的图表库已被弃用,并已被Sencha Charts取代。这带来了一些重要的API更改。
如果没有更多细节,很难说根本原因是什么,但错误肯定是由于缺乏对surface
属性的访问权限。