我在 dc.js 上工作,我画了 pieChart
pieChart.width(300)
.height(200)
.transitionDuration(1500)
.dimension(startValue)
.group(startValueGroup, "StartValue")
.radius(100)
.minAngleForLabel(0.5)
.legend(dc.legend().x(230).y(0))
.title(function(d) {
return d.key + ": " + d.value;
})
.renderTitle(true)
.on("filtered", function (chart) {
dc.events.trigger(function () {
//console.log(total_payment);
});
});
现在,我想设置特定的 x 轴值。目前,饼图采用定义宽度和高度的中心位置。这意味着它占据了 (150,100) 的位置。我想将此位置更改为 (100, 100)。
如何根据上述代码更改 x 轴的位置?
最佳答案
您不能直接在 dc 选项中设置此值,但您可以在呈现图表后修改这些值。假设“饼图”是您将饼图渲染到的 DOM 元素的 ID,您可以这样做
d3.select("#pie > svg > g").attr("transform", "translate(100,100)");
关于d3.js - dc.js pieChart 设置特定的 x 轴值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21017601/