gpt4 book ai didi

css - DC.js 表数据显示不需要的额外行

转载 作者:行者123 更新时间:2023-11-28 16:10:44 25 4
gpt4 key购买 nike

我在 DC.js 中遇到表格问题。每个奇数行都是额外的。该表应该只输出两列。第一列是状态,第二列是称为基金的金额。但正如您在图像中看到的那样,有一个额外的行只显示一个数字,与每个偶数行的右列中的数字相同。

enter image description here

JS代码,

<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>

我尝试添加,(我从 here 得到的)

.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 中这是可行的,

.dc-table-group {
display:none
}

当然表格的奇数行显示分组。

有用的相关帖子:

Hide group rows of dc.dataTable

dc datatable without grouping the rows

关于css - DC.js 表数据显示不需要的额外行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38399099/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com