gpt4 book ai didi

javascript - flot:在轴上显示单位?

转载 作者:数据小太阳 更新时间:2023-10-29 05:47:08 25 4
gpt4 key购买 nike

在 flot 中,有什么方法可以让坐标轴显示 $10、$20 等,而不仅仅是 10、20?

我检查过 the documentation但看不到办法,但这似乎是一个普遍的要求 - 特别是因为你不能(轻松地)标记轴。

最佳答案

您正在寻找 API 中的“tickFormatter”选项.

例如:

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

产生:

enter image description here

关于javascript - flot:在轴上显示单位?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7743824/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com