我试图使用angular.js nvd3 [1]显示实时线图 . 它应该绘制高度与时间的关系 .

我遇到的问题是让x轴正确显示时间数据数组 . 这就是它的样子:

http://i.imgur.com/PQeskpf.png

这是我试图显示的数据:

$scope.chart1data = [
      {
          "key": "Altitude",
          "values": [{x:"2013-03-04_12:00:00",y:50},{x:'2013-03-04_13:00:00',y:1000}]
      }
  ];

图表选项:

$scope.chart1options = {
      chart: {
          type: 'lineChart',
          height: 350,
          x: function(d){ return d.x; },
          y: function(d){ return d.y; },
          useInteractiveGuideline: true,
          dispatch: {
              stateChange: function(e){ console.log("stateChange"); },
              changeState: function(e){ console.log("changeState"); },
              tooltipShow: function(e){ console.log("tooltipShow"); },
              tooltipHide: function(e){ console.log("tooltipHide"); }
          },
          xAxis: {
              axisLabel: 'Time',
              tickformat: function(d) {
                  return d3.time.format('%Y-%m-%d_%H:%M:%S')(new Date(d))
              }
          },
          yAxis: {
              axisLabel: 'Altitude (m)',
              tickFormat: function(d){
                  return d3.format('.02f')(d);
              },
              axisLabelDistance: 100
          }
      }
  };

如果有人知道如何让x轴显示每个数据点的月/日 - 时:分钟,并按时间缩放,我真的可以使用一些帮助!

[1] http://krispo.github.io/angular-nvd3/#/quickstart