2016-09-26 5 views
1

각도 nvd3을 사용하여 선형 차트를 표시하기 위해 다음 구성을 사용하고 있습니다. 문제는 가장자리 근처에 단 하나의 점이있는 경우 차트를 표시하는 동안 표시가 나타나지 않는 한 표시되지 않습니다.nvd3 라인 차트에 단일 포인트가 표시되지 않음

$scope.options = { 
     chart: { 
      type: 'lineChart', 
      forceY:[0],    
      height: 450, 
      margin : { 
       top: 30, 
       right: 70, 
       bottom: 68, 
       left: 90 
      }, 
      x: function(d){ return d[0]; }, 
      y: function(d){ return d[1]; }, 
      useInteractiveGuideline: false, 
      xDomain: [moment($scope.calenderStartDate).valueOf(), moment($scope.calenderEndDate).valueOf()],    
      lines:{ 
          dispatch: { 
           elementClick: function(e){ 
            console.log(e); 
            handleDataForTable(e.point.x,e.series.key); 
            $scope.api.refresh(); 
           }, 
           elementMouseout: function(){} 
          } 
       }, 
      xScale: d3.time.scale().clamp(true), 
      xAxis: { 
       tickFormat: function(d){ 
        return d3.time.format('%d-%b-%y')(new Date(d)) 
       },      
       rotateLabels:-30 

      }, 

     legend: { 
       vers: 'furious' 
     }, 
     showLegend:false, 
      yAxis: { 
       axisLabel: 'No of Bookings', 
       tickFormat: function(d){ 
        return d3.format('d')(d); 
       } 
      }, 
      callback: function(chart){ 
       console.log("!!! lineChart callback !!!"); 
      }, 
      defined:function(d) { return !isNaN(d[1]); } 
     }, 
     title: { 
      enable: false, 
      text: 'Title for Line Chart' 
     }, 
     subtitle: { 
      enable: false, 
      text: '', 
      css: { 
       'text-align': 'center', 
       'margin': '10px 13px 0px 7px' 
      } 
     }, 
     caption: { 
      enable: false, 
      html: '', 
      css: { 
       'text-align': 'justify', 
       'margin': '10px 13px 0px 7px' 
      } 
     } 
    };   

}

답변

2

데이터의 길이가 1 다음과 같이 $ scope.options.chart.forceY에서 forceY을 삭제하는 경우 :

삭제 $의 scope.options.chart [ 'forceY' ]

차트는 d3에 의해 올바르게 렌더링됩니다. 문제는 d3에서 single point가 렌더링되지 않으면 'forceY'옵션을 사용할 때입니다. 호버링에 의해 그래프에서 포인트를 찾아야합니다. 데이터의 길이가 1 일 때 'forceY'를 삭제하면 그래프가 제대로 렌더링됩니다 d3에서 제공되는 기본 렌더링 옵션을 사용하여 단일 점 표시 및 Y 축으로 0과 2를 나타내는 공백 (1보다 큰 값)을 표시합니다.

관련 문제