简体   繁体   English

如何在D3PIE中更改饼图的颜色

[英]How to change colors of the pie chart in d3pie

I am trying to modify the following code I saw online that uses the d3pie js. 我想修改下面的代码,我在网上看到,使用d3pie JS。 I can't seem to figure out how to change the colors? 我似乎无法弄清楚如何更改颜色? I am super new to Javascript and would like to use this chart on my website.... 我是Java语言的超级新手,并且想在我的网站上使用此图表。

g.append("path")
        .attr("id", function(d, i) { return pie.cssPrefix + "segment" + i; })
        .attr("fill", function(d, i) {
            var color = colors[i];
            if (pie.options.misc.gradient.enabled) {
                color = "url(#" + pie.cssPrefix + "grad" + i + ")";
            }
            return color;
        })

Any clues? 有什么线索吗? Kinda don't understand much :( Kinda不太了解:(

"data": {
    "content": [
        {
            "label": "Programación",
            "value": 6000,
            "color": "#82ccfb"
        },
        {
            "label": "Blogging",
            "value": 20,
            "color": "#FF0000"
        },
        {
            "label": "Ilustración / Arte",
            "value": 60,
            "color": "#395197"
        },
        {
            "label": "Diseño Gráfico",
            "value": 50,
            "color": "#457cda"
        },
        {
            "label": "Rotulación",
            "value": 20,
            "color": "#b0dae1"
        },
        {
            "label": "Agricultura",
            "value": 10,
            "color": "#062831"
        },
        {
            "label": "Diseño Web",
            "value": 80,
            "color": "#FF0000"
        }
    ]
},

It's at the end of the file in js. 它在js文件的末尾。 At the line number 2215. Check it. 在2215行。检查它。 I change some colors. 我改变一些颜色。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM