I am having the below function which represents X axis of a Chart.
Currently, in this function, 'n' has many iterations which pre开发者_运维知识库sent 0, 25, 50, depending upon the values selected dynamically.
Is there any possibility by which we can know if this is the last iteration of n?
xaxis: {showLabels: true, noTicks: 7,tickFormatter: function(n)
{
var k = n;
if(k==7) // This is not working
return NewdateData[NewdateData.length-1];
else
return NewdateData[k];
}
Reducing your function to a minimum works well comparing n
with this.noTicks
:
var xaxis = {showLabels: true, noTicks: 7,tickFormatter: function(n){
return n === this.noTicks;
}};
console.log(xaxis.tickFormatter(1)); //false
console.log(xaxis.tickFormatter(7)); //true
Are you calling it the same way, ... .xaxis.tickFormatter(...)
?
精彩评论