NVD3.JS Angular Directives - 显示日期

时间:2014-09-08 07:26:13

标签: angularjs date nvd3.js

我正在使用Nvd3角度指令(http://cmaurer.github.io/angularjs-nvd3-directives/),更具体地说是迷你图(http://cmaurer.github.io/angularjs-nvd3-directives/sparkline.chart.html

我想将日期显示为日期和时间。月,而不是时间戳。

我是否必须修改指令本身或有没有办法直接更改显示?

在函数中,如果我尝试将d [0]更改为新日期(d [0]),则不显示日期,因为我猜该指令不能再对日期进行排序。

谢谢!

1 个答案:

答案 0 :(得分:0)

这似乎没有记载,但你可以这样做:

    var timeFormat = '%b %e %H:%M';
    $scope.xtickformat = function() {
        return function(d) {
            return d3.time.format.utc(timeFormat)(new Date(d));
        }
    }

然后,在你的迷你线指令中:

xtickformat = "xtickformat()"