Reputation: 71
From getValuePerTick()
how do I access maxValue
and numberOfTicks
? Trying my hand at my first JavaScript program and having some trouble. Thanks!
var TChart = Object.extend(
{
init: function(canvasName)
{
// ...
this.config = {
gutter: {
top: 25,
right: 100,
bottom: 50,
left: 0
},
scale: {
maxValue: 3.3,
numberOfTicks: 10,
getValuePerTick: function() {
return (maxValue / numberOfTicks);
}
}
};
// ...
}
});
Upvotes: 0
Views: 47
Reputation: 2560
Simply with this.
prefix
return (this.maxValue / this.numberOfTicks);
Upvotes: 0
Reputation: 388316
Since maxValue
and numberOfTicks
are properties of the object, you need to use member notation to access it
this.config = {
gutter: {
top: 25,
right: 100,
bottom: 50,
left: 0
},
scale: {
maxValue: 3.3,
numberOfTicks: 10,
getValuePerTick: function() {
return (this.maxValue / this.numberOfTicks);
}
}
};
Upvotes: 4