载入UTC数据后,Dygraph轴日期过长无法调整

After loading UTC data, Dygraph axis dates are too long and won't adjust

我正在向 Dygraph 提供一些不错的 unix 纪元数据,它显示的轴是这样的:

经过多次摆弄,我无法让它更简洁和动态调整。这是我的代码:

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 的功能,这些功能根据时间间隔选择标签上的详细程度(即,一小时的数据中没有列出月份)?

这是一些数据:

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 是什么)时,您绕过了 dygraphs 的逻辑来确定 x 轴的类型。不幸的是,没有主开关可以说 "this is a date axis" 或 "this is a numeric axis" 所以,如果你想走这条路,你必须自己指定所有的格式化程序:

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

有关完整示例,请参阅 this demo