Jqplot只显示几个x轴刻度 [英] Jqplot show only few x axis ticks

查看:163
本文介绍了Jqplot只显示几个x轴刻度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

这是一个古老的问题,但我也需要一些解决方案,所以它是这样的:

当您使用 jqplot 打印酒吧时,您不能说它它应该打印多少个滴答,因为它只打印相关的值,所以你必须打印所有的滴答。我的解决方案不好,但它的工作原理。只需打印空白标签的蜱。例如:

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


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?

解决方案

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

这篇关于Jqplot只显示几个x轴刻度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆