[英]Comma Separated Numbers For an Axis in Flot
有沒有辦法讓Flot使軸編號以逗號分隔?
因此,例如,而不是1000000有1,000,000
您可以使用軸的tickFormatter屬性來完成此操作。
xaxis: {
tickFormatter: function(val, axis) {
// insert comma logic here and return the string
}
}
來源: http : //people.iola.dk/olau/flot/API.txt (在“自定義軸”下)
此頁面具有使用逗號格式化數字的功能: http : //www.mredkj.com/javascript/nfbasic.html
例如yaxis:
$(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 }
} );
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.