加载UTC数据后,Dygraph轴日期过长,无法调整 [英] After loading UTC data, Dygraph axis dates are too long and won't adjust

查看:67
本文介绍了加载UTC数据后,Dygraph轴日期过长,无法调整的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Dygraph提供一些不错的unix历元数据,并且显示了这样的轴:

I'm feeding Dygraph some nice unix epoch data, and it's showing the axes like this:

经过很多摆弄之后,我无法让它变得更加简洁和动态调整。这是我的代码:

I can't get it to be more terse and dynamically adjusted, after much fiddling. Here's my code:

var graph = new Dygraph(
           document.getElementById('plot' + formNum),
           fileURL, // path to CSV file
            {
                legend:'always',
                title: "Activity of " + station + ".BK." + fullChannel + dateString,
                valueParser: function(x){
                    return x*1000;
                },
                ticker: Dygraph.dateTicker
            }

为什么这么长?我该如何更改它们并仍然利用Dygraph的功能来选择标签上的详细程度(即没有月份)

Why are they so long? How can I change them and still take advantage of Dygraph's features that choose the level of detail on the label (i.e., no month listed on an hour's worth of data) depending on the time interval?

以下是一些数据:

1420498200.06954,425
1420498201.06954,425
1420498202.06954,424
1420498203.06954,425
1420498204.06954,425
1420498205.06954,425
1420498206.06954,426
1420498207.06954,426

有何想法?

推荐答案

当您覆盖 xValueParser 时(我不确定 valueParser 是),您可以绕过笔形图的逻辑来确定x轴的类型。不幸的是,没有总开关说这是日期轴或这是数字轴,因此,如果您想走这条路,则必须自己指定所有格式化程序:

When you override xValueParser (I'm not sure what valueParser is), you bypass dygraphs' logic for determining the type of the x-axis. Unfortunately, there's no master switch to say "this is a date axis" or "this is a numeric axis" so, if you want to go down this road, you'll have to specify all the formatters yourself:

new Dygraph(div, data, {
    ticker: Dygraph.dateTicker,
    axes: {
        x: {
            axisLabelFormatter: Dygraph.dateAxisLabelFormatter,
            valueFormatter: Dygraph.dateValueFormatter
        }
    }
})

请参见此演示完整示例。

这篇关于加载UTC数据后,Dygraph轴日期过长,无法调整的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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