开发者

flot: Show units on axes?

开发者 https://www.devze.com 2023-04-12 08:51 出处:网络
In flot, is there any way I can get the axes to show $10, $20 etc, rather than just 10, 20? I\'ve checked the documentation but don\'t see a way, but it seems lik开发者_C百科e to be a common requirem

In flot, is there any way I can get the axes to show $10, $20 etc, rather than just 10, 20?

I've checked the documentation but don't see a way, but it seems lik开发者_C百科e to be a common requirement - especially since you can't (easily) label the axes.


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

For example:

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 }
    });

Produces:

flot: Show units on axes?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号