我有這個對象'cp'。它有一些屬性,如標籤和arcSettings。每當我初始化這個對象,並調用方法'graph()'它說調用javascript對象自己的屬性
Uncaught TypeError: Cannot read property '0' of undefined
我做錯了什麼?
function cp() {
this.labels = [{
"pointThickness": 0.8,
"distance": 8,
"textDistance": 7,
"strokeColor": "#888",
"strokeWidth": 0.5,
"textColor": "#777",
"pointColor": "#888",
"textSize": 4,
//"interval":100,
//"precision":2,
"num": 10,
"startValue": 0,
"endValue": 300
}
];
this.arcSettings = [
{
"totalArcAngle":300,
"startAngle":(-this.totalArcAngle/2),
"endAngle":(this.totalArcAngle/2),
"progressValue":200,
"radius":150,
"thickness":30,
"displayValue":this.progressValue
}
];
}
cp.prototype.getOneUnit = function() {
return oneUnit = (this.arcSettings[0].totalArcAngle)/(this.label[0].endValue - this.label[0].startValue);
}
cp.prototype.graph= function(){
var oneUnit = this.getOneUnit();
}
var cp = new cp();
cp.graph();