I am having a problem with a table in DC.js. Every odd numbered row is extra. The table should just output two columns. The first column is state and the second is an amount called fund. But as you can see in the image there is an extra row which only displays a number, the same number which is in the right column of every even row.
The JS code,
<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>
The 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>
I tried adding, (which I got from here)
.showGroups(false)
but I get in the console,
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
Thanks,