nvD3,折线图,D3,角度

时间:2014-06-06 14:35:34

标签: angularjs d3.js linechart nvd3.js

任何人都可以帮助我的折线图没有正确绘图吗?我已将代码的数据放在:http://jsfiddle.net/madasuk/U9KH5/4/ 任何人都可以帮助正确绘制它吗?图中的线条混乱,工具提示也没有出现?

   function addLineChart(){
        var chart;
        nv.addGraph(function() {
          chart = nv.models.lineChart()
          .options({
            margin: {left: 100, bottom: 100},
          //  x: function(d,i) { return i},
            x : (function(d,i) { 
              return new Date(d.x);
            }),
            showXAxis: true,
            showYAxis: true,
            transitionDuration: 250
          })
          ;

          // chart sub-models (ie. xAxis, yAxis, etc) when accessed directly, return themselves, not the parent chart, so need to chain separately
          chart.xAxis
            .axisLabel("Time (s)")
          //  .tickFormat(d3.format(',.1f'));
          .tickFormat(function(d) {
              return d3.time.format('%m/%d/%y')(new Date(d))
            });

          chart.yAxis
            .axisLabel('Voltage (v)')
            .tickFormat(d3.format(',.2f'))
          //  .tickFormat(d3.format(',g'));
            ;


          d3.select('#chart1 svg')
            .datum(cumulativeMSIData())
            .call(chart);

          //TODO: Figure out a good way to do this automatically
          nv.utils.windowResize(chart.update);
          //nv.utils.windowResize(function() { d3.select('#chart1 svg').call(chart) });

          chart.dispatch.on('stateChange', function(e) { nv.log('New State:', JSON.stringify(e)); });

          return chart;
        });


    }

0 个答案:

没有答案
相关问题