有没有办法让 Flot 使轴编号以逗号分隔?
例如,用 1,000,000 代替 1000000
您可以通过使用轴的tickFormatter 属性来做到这一点。
xaxis: {
tickFormatter: function(val, axis) {
// insert comma logic here and return the string
}
}
Source: http://people.iola.dk/olau/flot/API.txt http://people.iola.dk/olau/flot/API.txt(在“自定义轴”下)
该页面有一个用逗号格式化数字的功能:http://www.mredkj.com/javascript/nfbasic.html http://www.mredkj.com/javascript/nfbasic.html
以 y 轴为例:
$(function () {
var plotarea = $("#plotarea");
$.plot( plotarea , [data], {
xaxis: {mode: "time", timeformat: "%m/%d %H:%M:%S"},
yaxis: {tickFormatter: function numberWithCommas(x) {
return x.toString().replace(/\B(?=(?:\d{3})+(?!\d))/g, ",");
}
},
points: { show: true },
lines: { show: true, fill: true }
} );
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)