Search code examples
javascriptchartsplotflotr

Capturing the Last Value inside Javascript


I am extremely sorry for the meaningless header for this Thread .

I have a question (So the reason i posted this :) )

    xaxis: {noTicks: 8, tickFormatter: function(n)
    {
    alert(n);
    }

Hi , the above function is from the charting API (Flotr API) As per the above code , the alert gets displayed 8 times (Because noofticks/labels is 8)

Is it possible to capture the last alert (That is when n is 8 ) where 8 is the noofTicks Value .

All this i need is basically to make the last value of an array to show on X axis .

Please advice .


Solution

  • xaxis: {
             noTicks: 8, 
             tickFormatter: function(n){
               if (n === 8) {alert(n);}
             }
           }
    

    Now xasis.tickFormatter(xasis.noTicks) should do it.