Jqplot只显示几个x轴刻度

时间:2012-11-06 23:25:22

标签: javascript graph jqplot bar-chart

我必须创建一个条形图,显示30天的图表。所以我将在图表上显示总共30个柱。但它在x轴上看起来非常拥挤。有没有办法只显示6个x轴刻度而不是所有30个x轴刻度?

1 个答案:

答案 0 :(得分:2)

我知道这是一个老问题,但我也需要一些解决方案,所以这里是:
当您使用jqplot打印条形图时,您无法说明它应打印多少个刻度线,因为它只打印相关值,因此您必须打印所有刻度线。我的解决方案并不好,但它有效。只需打印带有空标签的刻度线。例如:

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"]]
            }
        }