user1751287
user1751287

Reputation: 501

chartjs custom y axis values, different text for each one

I am trying to change numeric values within y axis with custom text ones. I tried using loop but it takes only the first one.

callback:function(value) { 
    var value = ["January", "February", "March", "April", "May"];
    for(i = 0; i < value.length; i++){
        return value[i];
    }

}

here is FIDDLE with the sample graph

maybe case of something ?

Upvotes: 2

Views: 1816

Answers (1)

Rajaprabhu Aravindasamy
Rajaprabhu Aravindasamy

Reputation: 67207

Try to return value from the array properly,

callback:function(value) { 
  var x = ["January", "February", "March", "April", "May", "June", "July"];
  return x[value | 0];                  
}

DEMO

Upvotes: 3

Related Questions