Put only integers in x and y axis of bar and line graphs - Flot

做~自己de王妃 提交于 2019-12-04 15:34:05

问题


In Flot.js, bar graphs and line graphs have numbers as the coordinates in the x and y axis by default.

How can you make the coordinates such that the numbers are only integers or at least only the integers are visible?


回答1:


Check out the minTickSize option from the documentation:

Alternatively, you can specify that you just don't want ticks at a size less than a specific tick size with "minTickSize".

So in your graph options, you would specify it like this:

$.plot($('#placeholder'),data,{
   //your options,
   xaxis: {
      minTickSize: 1
   }
});

See it working here: http://jsfiddle.net/ryleyb/g2CTz/




回答2:


Looks like more recent versions of Flotr use a different option to control this since the original answer:

    xaxis: {
        tickDecimals: 0
    }

Just supply an integer with the number of decimals to show.

NB: This is for Flotr2.



来源:https://stackoverflow.com/questions/12908222/put-only-integers-in-x-and-y-axis-of-bar-and-line-graphs-flot

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!