[英]Colour not rendering properly Pie Chart d3
I am working on a pie chart today in D3 (fun!).我今天正在 D3 中制作饼图(有趣!)。
Alright, the issue I am having is the colours aren't being assigned properly.好的,我遇到的问题是颜色分配不正确。
Here's the jsfiddle:这是jsfiddle:
https://jsfiddle.net/zh34ud25/5/ https://jsfiddle.net/zh34ud25/5/
Most(?) relevant code:大多数(?)相关代码:
var color = d3.scale.ordinal()
.range(["#71b2b9", "#dcdcdc"]);
color.domain(d3.keys(dataUnbilledRevenue[0].values[0]).filter(function(key) {
if (key === 'Unbilled_Revenue'
|| key === 'Billed_Revenue') {
return key
}
}));
// This returns the data into two separate objects which can be graphed.
// In this case, Amount and Quantity.
var datasets = color.domain().map(function(name) {
return {
name: name,
values: dataUnbilledRevenue.map(function(d) {
return {
Value: +d.values[0][name]
};
})
};
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.