Flot: Show units on axes?

In flot, is there a way I can get the axes to show $ 10, $ 20, etc., and not just 10, 20?

I checked the documentation , but I see no way, but it seems like this is a common requirement - especially since you can't (easily) label the axes.

+5
source share
1 answer

You are looking for the "tickFormatter" option in the API .

For instance:

var data1 = [[0,3],[10,1],[20,2],[40,8],[50,10]];

someFunc = function(val, axis){
   return "$" + val
}

plot = $.plot($("#placeholder"),
    [{ data: data1}], {
      xaxis: { tickFormatter: someFunc }
    });

It produces:

enter image description here

+14
source

All Articles