Flot中轴的逗号分隔数字

Kyl*_*ndt 11 javascript jquery flot

有没有办法让Flot使轴编号以逗号分隔?

因此,例如,而不是1000000有1,000,000

rus*_*sty 33

您可以使用轴的tickFormatter属性来完成此操作.

xaxis: {
  tickFormatter: function(val, axis) {
    // insert comma logic here and return the string
  }
}
Run Code Online (Sandbox Code Playgroud)

来源: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 }

                    } );
    });
Run Code Online (Sandbox Code Playgroud)