nvd3 x轴日期格式使用mongodb ISOdate

时间:2015-11-18 03:17:17

标签: angularjs mongodb nvd3.js angularjs-nvd3-directives

我在我的应用程序中使用Angularjs-nvd3-directives图表。 来自mongodb的数据格式为:

[[" 2012-11-02T20:01:00.000Z" 11],[" 2012-11-02T20:01:00.000Z" 12],[& #34; 2012-11-03T20:02:00.000Z" 13],[" 2012-11-01T20:03:00.000Z" 11],[" 2012-11 -02T20:04:00.000Z" 12],[" 2012-11-03T20:05:00.000Z" 13]]

我看到的所有示例都使用Unix时间戳,例如:

[[1025409600000,0],[1028088000000,-6.3382185140371],[1030766400000,-5.9507873460847]]

使用Unix时间戳时,适用于X轴日期的功能是:

$scope.xAxisTickFormatFunction = function() {
     return function(d) {
         return d3.time.format('%x')(new Date(d));
             };
         };

我应该写什么功能以便我可以使用iso日期。 我希望每分钟在X轴上显示值

1 个答案:

答案 0 :(得分:0)

您应该将Date对象而不是ISO Dates返回到图表中(因为这就是预期的结果)。在将数据输入图表之前,您应该先进行处理

std::unique_ptr<Location> uniqueLocation = getLocation();
std::string s = toJson(*uniqueLocation);
相关问题