所以我多次调用下面的代码,但问题是条形图的仓位大小是固定在我放置的第一个数据上的,一切都在按其应有的方式变化,但仓位的大小却没有改变。
barChart
.width(1080)
.height(138)
.margins({top: 10, right: 10, bottom: 20, left: 50})
.dimension(key_map[$(this).text()].Dim)
.group(key_map[$(this).text()].Group)
.colors(['#6baed6'])
.x(d3.scale.ordinal().domain(key_map[$(this).text()].Dim))
.xUnits(dc.units.ordinal)
.elasticY(true)
.yAxis().ticks(4);
barChart.elasticX(true).filterAll();dc.redrawAll(); 发布于 2020-03-16 12:20:30
感谢@戈登,我终于想通了。
尽管我调用的是elasticX(true);,但键的数组被忽略了,所以我最终调用了chart.focus([all_the_keys_from_the group]);,它现在工作得很好。
barChart
.dimension(key_map[$(this).text()].Dim)
.group(key_map[$(this).text()].Group)
.x(d3.scale.ordinal().domain(key_map[$(this).text()].Dim))
.xUnits(dc.units.ordinal)
.elasticX(true);
var focus_keys = [];
key_map[$(this).text()].Group.all().forEach(element => {
focus_keys.push(element.key);
});
barChart.focus(focus_keys);
barChart.filterAll(); dc.redrawAll(); https://stackoverflow.com/questions/60634965
复制相似问题