Jqplot show only few x axis ticks

荒凉一梦 提交于 2019-12-02 07:11:11

问题


I have to create a bar graph which shows a graph for 30 days. So I will show total 30 bars on the chart. But it looks very congested on the x axis. Is there a way where I can show only 6 x-axis ticks and not all the 30 x axis ticks?


回答1:


I know that this is an old question but I need some solution too so here it is:
When you use jqplot to print bars you can't say it how many ticks it should print because it prints only related values so you have to print all ticks. My solution is not nice but it works. Just print ticks with empty label. For example:

axes: {
      xaxis: {
             min:1,
             max: 30,
             ticks: [[1,""],[2,""],[3,""],[4,""],[5,"5"],
                    [6,""],[7,""],[8,""],[9,""],[10,"10"],
                    [11,""],[12,""],[13,""],[14,""],[15,"15"],
                    [16,""],[17,""],[18,""],[19,""],[20,"20"],
                    [21,""],[22,""],[23,""],[24,""],[25,"25"],
                    [26,""],[27,""],[28,""],[29,""],[30,"30"]]
            }
        }



回答2:


By using ticks option of axies, you can specify exactly which ticks you want to show.

Link to the doc : http://www.jqplot.com/docs/files/jqplot-core-js.html#Axis.ticks



来源:https://stackoverflow.com/questions/13261043/jqplot-show-only-few-x-axis-ticks

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