2016-07-15 3 views
1

DC.js의 테이블에 문제가 있습니다. 홀수 열은 모두 여분입니다. 테이블은 단지 두 개의 컬럼을 출력해야합니다. 첫 번째 열은 주이며 두 번째 열은 기금이라고하는 금액입니다. 그러나 이미지에서 볼 수 있듯이 모든 짝수 행의 오른쪽 열에있는 숫자 만 표시하는 추가 행이 있습니다.DC.js 테이블 데이터에 원하지 않는 여분의 행이 표시됩니다.

enter image description here

JS 코드 (I는 here에서 얻은)

<script> 
    var text = '['; 
    var obj; 
    url = "/funding"; 
    d3.json(url, function(error, json_response) { 
     for (var item in json_response['proposals']) { 
     item = parseInt(item); 
     fund = json_response['proposals'][item]['totalPrice']; 
     state = json_response['proposals'][item]['state']; 
     obj = '{ "state":' + '"' + state + '"' + ', "fund":' + fund + '}'; 
     text += obj + ','; 
     } 
     text = text.substring(0, text.length - 1); 
     text += ']'; 
     data = JSON.parse(text); 
     cf = crossfilter(data); 

     stateDim = cf.dimension(function(d) { 
     return d.state; 
     }); 
     fundDim = stateDim.group().reduceSum(function(d) { 
     return d.fund; 
     }); 

     datatable = dc.dataTable("#tablechart"); 
     datatable 
     .dimension(stateDim) 
     .group(function(d) { 
      return d.fund; 
     }) 
     .columns([ 
      function(d) { 
      return d.state; 
      }, 
      function(d) { 
      return d.fund; 
      } 
     ]); 

     dc.renderAll(); 
    }); 
    </script> 

HTML,

<div class="table-responsive"> 
        <table id="tablechart" class="table table-bordered table-hover table-striped"> 
         <thead> 
         <tr class="header"> 
          <th>State</th> 
          <th>Funding($)</th> 
         </tr> 
         </thead> 
        </table> 
        </div> 

제가 첨가하려고

.showGroups(false) 

하지만 난

Uncaught TypeError: datatable.dimension(...).group(...).showGroups is not a function 
(anonymous function) @ (index):388 
(anonymous function) @ d3.min.js:1 
t @ d3.min.js:1 
i @ d3.min.js:1 

감사합니다,이 작동하는 CSS에서

+1

는'showGroups'는 아직 베타 버전 2.0 기능입니다. 실제로이 기능이 너무 깊숙이 구워 져야한다는 것은 짜증 스럽습니다. 그러나 도서관은 데모에서 성장했고 많은 것들이 결코 일반화되도록 설계되지 않았습니다. – Gordon

답변