如何使用 pykcharts 库更改饼图中的颜色?
How To change Color in pie chart with the using of pykcharts library?
我需要使用 pykcharts 库在饼图中使用 10 种不同的颜色。
是否可能因为根据文档他们只提供一个 shade_color
.
完成这个 link http://pykcharts.com/tour/pie
根据文档,您应该能够像这样传递值:
{
"chart_color": ["blue","green","Yellow"]
}
该图表还接受以下任何一项:
Color Names (Eg: "red")
Hex values (Eg: "#B0171F")
RGB values (Eg: "rgb(176,23,31)" )
@Tkingovr chart_color 适用于除一维图表之外的所有图表。您可以将 shade_color 用于一维图表 https://github.com/pykih/PykCharts.js/wiki/Colors#shade-color
@KIRANJOSHI
var selector = "pieContainer", // selector of your chart
colors = ["red","blue","green","yellow","orange"];
setTimeout(function() {
d3.selectAll("#" + selector + "_svg path.pie")
.attr("fill",function(d, i) {
return colors[i];
});
},1000);
setTimeout 是必需的,因为图表可能需要一些时间来呈现,并且当前版本中没有规定 运行 一段代码完成图表呈现。
我需要使用 pykcharts 库在饼图中使用 10 种不同的颜色。
是否可能因为根据文档他们只提供一个 shade_color
.
完成这个 link http://pykcharts.com/tour/pie
根据文档,您应该能够像这样传递值:
{
"chart_color": ["blue","green","Yellow"]
}
该图表还接受以下任何一项:
Color Names (Eg: "red")
Hex values (Eg: "#B0171F")
RGB values (Eg: "rgb(176,23,31)" )
@Tkingovr chart_color 适用于除一维图表之外的所有图表。您可以将 shade_color 用于一维图表 https://github.com/pykih/PykCharts.js/wiki/Colors#shade-color
@KIRANJOSHI
var selector = "pieContainer", // selector of your chart
colors = ["red","blue","green","yellow","orange"];
setTimeout(function() {
d3.selectAll("#" + selector + "_svg path.pie")
.attr("fill",function(d, i) {
return colors[i];
});
},1000);
setTimeout 是必需的,因为图表可能需要一些时间来呈现,并且当前版本中没有规定 运行 一段代码完成图表呈现。