如何在HighChart中每月设置PointIntervals [英] How to set PointIntervals per month in HighChart

查看:101
本文介绍了如何在HighChart中每月设置PointIntervals的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用HighCharts绘制每月创建的用户数。我设法在x轴上显示月份,我将pointInterval设置如下

I used HighCharts to plot number of users created on a monthly basis. I managed to show month in x-axis and i set pointInterval as below


pointInterval:24 * 3600 * 1000 * 31

pointInterval :24 * 3600 * 1000 * 31

但这是盲目给出的,它不会正确地绘制点数。我需要在每个月的第1点绘制积分。但是上述间隔有助于每月绑定点数而不是每月的第1天。这个示例描述了我的问题。工具提示给出了清晰的想法。
这是我的代码

But this was given blindly and it won't plot points correctly. I need to plot points 1st of every month. But the above interval helps to bind points on monthly basis not at the 1st day of month. This example describes my issue. Tooltip gives the clear idea. Here is my code

series: [{
        type: 'area',
        name: 'CDP Created',
        pointInterval: 24 * 3600 * 1000 * 31,
        pointStart: Date.UTC(2005, 0, 01),          
        dataGrouping: {
            enabled: false
        },
        data: [0, 0, 0, 0, 0, 0, 0, 148.5, 216.4, 194.1, 95.6, 54.4]

    }]

无论如何设置pointInterval取决于月份。因为如果我简单地给出如上所述的pointInterval,它将每31天计算一次。当月份有28天或30天时,这会产生问题。如何实现它。
同样调整容器div的宽度会使x轴值无法正确显示。
提前致谢

Is there anyway to set pointInterval depends on month. Because if i simply given pointInterval as above it will calculate every 31 days. This creates problem when the month has 28 or 30 days. How to acheive it. Also adjusting the width of the container div makes x-axis values not displaying properly. Thanks in advance

推荐答案

不幸的是,这是不可能的 - pointInterval 只是按给定数量递增,因此不可能有不规则值。但是,您可以直接设置x值,请参阅: http://jsfiddle.net/kUBdb/2/

Unfortunately it's not possible - pointInterval just increments by given number, so irregular value is not possible. However, you can set directly x-value, see: http://jsfiddle.net/kUBdb/2/

关于JS的好处是

Date.UTC(2007, 10, 10) == Date.UTC(2005,34, 10)

返回是的,所以你可以逐月自由增量。

returns true, so you can freely increment month by one.

这篇关于如何在HighChart中每月设置PointIntervals的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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