【问题标题】:NVD3.JS Angular Directives - Display dateNVD3.JS Angular 指令 - 显示日期
【发布时间】:2014-09-08 07:26:13
【问题描述】:

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

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

我必须去修改指令本身还是有办法直接改变显示?

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

谢谢!

【问题讨论】:

    标签: angularjs date nvd3.js


    【解决方案1】:

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

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

    然后,在您的迷你图指令中:

    xtickformat = "xtickformat()"  
    

    【讨论】:

      猜你喜欢
      • 2014-02-14
      • 2012-12-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多