简体   繁体   中英

flot: Show units on axes?

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 like 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:

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM