Can the ECharts pie chart determine the color based on the name of the source?

at present, a certain module in the project uses a pie chart, which is mainly divided into positive, negative and neutral.
requirements are positive green, negative red, and neutral blue.
but the color in ECharts is assigned according to the area of the pie chart. Can
determine the color of the pie block according to its name?

Thank you for your answer first. I tried it in everyone"s way at work today, but there is still a problem that is not quite the same as what you have described.
the data of the chart is given in the background. The code is as follows. Although I know that the color is controlled by color, the data is given in chartData []. There are name and value attributes in chartData. How do you associate it with color?

var self = this;
option = {
    backgroundColor: "",
    tooltip: {
        ...                        
        }
    },
    legend:{
        orient:"vertical",
        data:self.legendData,
        icon: "rect",
        right: "5%",
        top:"80%",
        textStyle:{
            color:"-sharp888",
            fontSize:"14"
        },
        itemWidth: 12,
        itemHeight: 12
    },
    grid:{
        ...
    },
    color:["-sharp45ba59","-sharp5b8de0","-sharpee6d61"],
    series : [
        {
        type:"pie",
        param:self.param,
        data:self.chartData
        ...
        }
    ]
};
Mar.28,2021

echarts has many configurable functions. You can take a look at
http://echarts.baidu.com/opti.

in his development document.

Pie chart color setting

var colors = {
    '':'-sharp00ff00',
    '':'-sharpff0000',
    '':'-sharp0000ff'
}
itemStyle:{
    color:colors[..name]
}

what you said upstairs is important to the itemStyle attribute


itemStyle can be set at multiple levels. This can be achieved by directly setting the itemStyle of the element in the data.

such as
data: [{name: positive, value:10,itemStyle: {color:'green'}}, {name: negative, value:10,itemStyle: {color:'red'}}]

Menu