echarts icon indicating copy to clipboard operation
echarts copied to clipboard

多个圆环时的颜色渲染问题

Open WebsonLeo opened this issue 10 years ago • 1 comments

问题简述 (One-line summary)

在绘制圆环时,比如说我需要绘制十个圆环,每个圆环两种颜色,其中一种是固定的灰色,另外一种按照option中的colorList或者默认的colorList中的颜色顺序进行绘制(并且colorList的长度等于10)。在echarts2中可以正常的绘制出颜色不同的十个圆环,但是在echarts3中,十个圆环的后五个和前五个颜色出现了重复

版本及环境 (Version & Environment)

  • ECharts 版本 (3.1.2):
  • 浏览器类型和版本 (Chrome, 49.0.2623.87 m):
  • 操作系统类型和版本 (windows7 专业版):

重现步骤 (Steps to reproduce)

1.设置option,同时绘制多个圆环(即多个series) 2.每个series中有两个data,其中一个data的itemStyle的color为固定颜色,写死在series中,另外一个data的颜色不进行设置,由echarts本身按照传入的colorList进行绘制。 3.设置colorList,颜色的长度要等于series的长度,这样可以较为明显的看出颜色的重复问题 4.setOption,得到绘图结果

期望结果 (Expected behaviour)

期望是能够得到按照colorList顺序进行绘制的十个不同颜色的圆环

可能哪里有问题 (What went wrong)

可能是在进行颜色渲染的时候,把我写死的颜色渲染的data也算了进去,因为看最终图形渲染的颜色和colorList中颜色的对应关系正好是1,3,5,7,9这个样子

ECharts配置项 (ECharts option)

option = {
"legend": {
            "show": true,
            "selectedMode": false,
            "textStyle": {
                "color": "#666666",
                "fontSize": "12",
                "fontFamily": "微软雅黑",
                "fontWeight": "normal"
            },
            "orient": "horizontal",
            "x": "center",
            "y": "bottom",
            "data": [{
                "name": "99  memorysdfwegwdf",
                "icon": "emptyCircle"
            }, {
                "name": "50  memorydasdgwedfsd",
                "icon": "emptyCircle"
            }, {
                "name": "50  diskdsdfsdgwewdfefwer",
                "icon": "emptyCircle"
            }, {
                "name": "50  dfsdsdfgwegsdfsdfwef",
                "icon": "emptyCircle"
            }, {
                "name": "50  netsdsdfsgwefgwe",
                "icon": "emptyCircle"
            }, {
                "name": "50  cpuswefsdgsdfsf",
                "icon": "emptyCircle"
            }, {
                "name": "50  cpusdfsadfgwer",
                "icon": "emptyCircle"
            }, {
                "name": "50  disksdfwergewdsdf",
                "icon": "emptyCircle"
            }, {
                "name": "50  dfssdgehdfdsgv",
                "icon": "emptyCircle"
            }, {
                "name": "50  netsxcgfdfbdfsdgfd",
                "icon": "emptyCircle"
            }]
        },
        "tooltip": "",
        "series": [{
            "type": "pie",
            "avoidLabelOverlap": false,
            "hoverAnimation": false,
            "center": ["10%", "20%"],
            "radius": ["50px", "65px"],
            "x": "0%",
            "labelLine": {
                "normal": {
                    "show": false
                }
            },
            "label": {
                "normal": {
                    "show": true,
                    "position": "center",
                    "formatter": "{c}",
                    "textStyle": {
                        "fontSize": 43,
                        "fontFamily": "Arial",
                        "fontWeight": "bold"
                    }
                },
                "emphasis": {
                    "show": true,
                    "position": "center",
                    "formatter": "{c}",
                    "textStyle": {
                        "fontSize": 43,
                        "fontFamily": "Arial",
                        "fontWeight": "bold"
                    }
                }
            },
            "symbolSize": 3,
            "data": [{
                "name": "99  memorysdfwegwdf",
                "value": 99,
                "itemStyle": {
                    "normal": {
                        "color": ""
                    }
                }
            }, {
                "name": "other",
                "value": 1,
                "label": {
                    "normal": {
                        "show": false
                    },
                    "emphasis": {
                        "show": false
                    }
                },
                "itemStyle": {
                    "normal": {
                        "color": "#e5e5e5"
                    },
                    "emphasis": {
                        "color": "#e5e5e5"
                    }
                }
            }]
        }, {
            "type": "pie",
            "avoidLabelOverlap": false,
            "hoverAnimation": false,
            "center": ["30%", "20%"],
            "radius": ["50px", "65px"],
            "x": "0%",
            "labelLine": {
                "normal": {
                    "show": false
                }
            },
            "label": {
                "normal": {
                    "show": true,
                    "position": "center",
                    "formatter": "{c}",
                    "textStyle": {
                        "fontSize": 43,
                        "fontFamily": "Arial",
                        "fontWeight": "bold"
                    }
                },
                "emphasis": {
                    "show": true,
                    "position": "center",
                    "formatter": "{c}",
                    "textStyle": {
                        "fontSize": 43,
                        "fontFamily": "Arial",
                        "fontWeight": "bold"
                    }
                }
            },
            "symbolSize": 3,
            "data": [{
                "name": "50  memorydasdgwedfsd",
                "value": 50,
                "itemStyle": {
                    "normal": {
                        "color": ""
                    }
                }
            }, {
                "name": "other",
                "value": 50,
                "label": {
                    "normal": {
                        "show": false
                    },
                    "emphasis": {
                        "show": false
                    }
                },
                "itemStyle": {
                    "normal": {
                        "color": "#e5e5e5"
                    },
                    "emphasis": {
                        "color": "#e5e5e5"
                    }
                }
            }]
        }, {
            "type": "pie",
            "avoidLabelOverlap": false,
            "hoverAnimation": false,
            "center": ["50%", "20%"],
            "radius": ["50px", "65px"],
            "x": "0%",
            "labelLine": {
                "normal": {
                    "show": false
                }
            },
            "label": {
                "normal": {
                    "show": true,
                    "position": "center",
                    "formatter": "{c}",
                    "textStyle": {
                        "fontSize": 43,
                        "fontFamily": "Arial",
                        "fontWeight": "bold"
                    }
                },
                "emphasis": {
                    "show": true,
                    "position": "center",
                    "formatter": "{c}",
                    "textStyle": {
                        "fontSize": 43,
                        "fontFamily": "Arial",
                        "fontWeight": "bold"
                    }
                }
            },
            "symbolSize": 3,
            "data": [{
                "name": "50  diskdsdfsdgwewdfefwer",
                "value": 50,
                "itemStyle": {
                    "normal": {
                        "color": ""
                    }
                }
            }, {
                "name": "other",
                "value": 50,
                "label": {
                    "normal": {
                        "show": false
                    },
                    "emphasis": {
                        "show": false
                    }
                },
                "itemStyle": {
                    "normal": {
                        "color": "#e5e5e5"
                    },
                    "emphasis": {
                        "color": "#e5e5e5"
                    }
                }
            }]
        }, {
            "type": "pie",
            "avoidLabelOverlap": false,
            "hoverAnimation": false,
            "center": ["70%", "20%"],
            "radius": ["50px", "65px"],
            "x": "0%",
            "labelLine": {
                "normal": {
                    "show": false
                }
            },
            "label": {
                "normal": {
                    "show": true,
                    "position": "center",
                    "formatter": "{c}",
                    "textStyle": {
                        "fontSize": 43,
                        "fontFamily": "Arial",
                        "fontWeight": "bold"
                    }
                },
                "emphasis": {
                    "show": true,
                    "position": "center",
                    "formatter": "{c}",
                    "textStyle": {
                        "fontSize": 43,
                        "fontFamily": "Arial",
                        "fontWeight": "bold"
                    }
                }
            },
            "symbolSize": 3,
            "data": [{
                "name": "50  dfsdsdfgwegsdfsdfwef",
                "value": 50,
                "itemStyle": {
                    "normal": {
                        "color": ""
                    }
                }
            }, {
                "name": "other",
                "value": 50,
                "label": {
                    "normal": {
                        "show": false
                    },
                    "emphasis": {
                        "show": false
                    }
                },
                "itemStyle": {
                    "normal": {
                        "color": "#e5e5e5"
                    },
                    "emphasis": {
                        "color": "#e5e5e5"
                    }
                }
            }]
        }, {
            "type": "pie",
            "avoidLabelOverlap": false,
            "hoverAnimation": false,
            "center": ["90%", "20%"],
            "radius": ["50px", "65px"],
            "x": "0%",
            "labelLine": {
                "normal": {
                    "show": false
                }
            },
            "label": {
                "normal": {
                    "show": true,
                    "position": "center",
                    "formatter": "{c}",
                    "textStyle": {
                        "fontSize": 43,
                        "fontFamily": "Arial",
                        "fontWeight": "bold"
                    }
                },
                "emphasis": {
                    "show": true,
                    "position": "center",
                    "formatter": "{c}",
                    "textStyle": {
                        "fontSize": 43,
                        "fontFamily": "Arial",
                        "fontWeight": "bold"
                    }
                }
            },
            "symbolSize": 3,
            "data": [{
                "name": "50  netsdsdfsgwefgwe",
                "value": 50,
                "itemStyle": {
                    "normal": {
                        "color": ""
                    }
                }
            }, {
                "name": "other",
                "value": 50,
                "label": {
                    "normal": {
                        "show": false
                    },
                    "emphasis": {
                        "show": false
                    }
                },
                "itemStyle": {
                    "normal": {
                        "color": "#e5e5e5"
                    },
                    "emphasis": {
                        "color": "#e5e5e5"
                    }
                }
            }]
        }, {
            "type": "pie",
            "avoidLabelOverlap": false,
            "hoverAnimation": false,
            "center": ["10%", "55%"],
            "radius": ["50px", "65px"],
            "x": "0%",
            "labelLine": {
                "normal": {
                    "show": false
                }
            },
            "label": {
                "normal": {
                    "show": true,
                    "position": "center",
                    "formatter": "{c}",
                    "textStyle": {
                        "fontSize": 43,
                        "fontFamily": "Arial",
                        "fontWeight": "bold"
                    }
                },
                "emphasis": {
                    "show": true,
                    "position": "center",
                    "formatter": "{c}",
                    "textStyle": {
                        "fontSize": 43,
                        "fontFamily": "Arial",
                        "fontWeight": "bold"
                    }
                }
            },
            "symbolSize": 3,
            "data": [{
                "name": "50  cpuswefsdgsdfsf",
                "value": 50,
                "itemStyle": {
                    "normal": {
                        "color": ""
                    }
                }
            }, {
                "name": "other",
                "value": 50,
                "label": {
                    "normal": {
                        "show": false
                    },
                    "emphasis": {
                        "show": false
                    }
                },
                "itemStyle": {
                    "normal": {
                        "color": "#e5e5e5"
                    },
                    "emphasis": {
                        "color": "#e5e5e5"
                    }
                }
            }]
        }, {
            "type": "pie",
            "avoidLabelOverlap": false,
            "hoverAnimation": false,
            "center": ["30%", "55%"],
            "radius": ["50px", "65px"],
            "x": "0%",
            "labelLine": {
                "normal": {
                    "show": false
                }
            },
            "label": {
                "normal": {
                    "show": true,
                    "position": "center",
                    "formatter": "{c}",
                    "textStyle": {
                        "fontSize": 43,
                        "fontFamily": "Arial",
                        "fontWeight": "bold"
                    }
                },
                "emphasis": {
                    "show": true,
                    "position": "center",
                    "formatter": "{c}",
                    "textStyle": {
                        "fontSize": 43,
                        "fontFamily": "Arial",
                        "fontWeight": "bold"
                    }
                }
            },
            "symbolSize": 3,
            "data": [{
                "name": "50  cpusdfsadfgwer",
                "value": 50,
                "itemStyle": {
                    "normal": {
                        "color": ""
                    }
                }
            }, {
                "name": "other",
                "value": 50,
                "label": {
                    "normal": {
                        "show": false
                    },
                    "emphasis": {
                        "show": false
                    }
                },
                "itemStyle": {
                    "normal": {
                        "color": "#e5e5e5"
                    },
                    "emphasis": {
                        "color": "#e5e5e5"
                    }
                }
            }]
        }, {
            "type": "pie",
            "avoidLabelOverlap": false,
            "hoverAnimation": false,
            "center": ["50%", "55%"],
            "radius": ["50px", "65px"],
            "x": "0%",
            "labelLine": {
                "normal": {
                    "show": false
                }
            },
            "label": {
                "normal": {
                    "show": true,
                    "position": "center",
                    "formatter": "{c}",
                    "textStyle": {
                        "fontSize": 43,
                        "fontFamily": "Arial",
                        "fontWeight": "bold"
                    }
                },
                "emphasis": {
                    "show": true,
                    "position": "center",
                    "formatter": "{c}",
                    "textStyle": {
                        "fontSize": 43,
                        "fontFamily": "Arial",
                        "fontWeight": "bold"
                    }
                }
            },
            "symbolSize": 3,
            "data": [{
                "name": "50  disksdfwergewdsdf",
                "value": 50,
                "itemStyle": {
                    "normal": {
                        "color": ""
                    }
                }
            }, {
                "name": "other",
                "value": 50,
                "label": {
                    "normal": {
                        "show": false
                    },
                    "emphasis": {
                        "show": false
                    }
                },
                "itemStyle": {
                    "normal": {
                        "color": "#e5e5e5"
                    },
                    "emphasis": {
                        "color": "#e5e5e5"
                    }
                }
            }]
        }, {
            "type": "pie",
            "avoidLabelOverlap": false,
            "hoverAnimation": false,
            "center": ["70%", "55%"],
            "radius": ["50px", "65px"],
            "x": "0%",
            "labelLine": {
                "normal": {
                    "show": false
                }
            },
            "label": {
                "normal": {
                    "show": true,
                    "position": "center",
                    "formatter": "{c}",
                    "textStyle": {
                        "fontSize": 43,
                        "fontFamily": "Arial",
                        "fontWeight": "bold"
                    }
                },
                "emphasis": {
                    "show": true,
                    "position": "center",
                    "formatter": "{c}",
                    "textStyle": {
                        "fontSize": 43,
                        "fontFamily": "Arial",
                        "fontWeight": "bold"
                    }
                }
            },
            "symbolSize": 3,
            "data": [{
                "name": "50  dfssdgehdfdsgv",
                "value": 50,
                "itemStyle": {
                    "normal": {
                        "color": ""
                    }
                }
            }, {
                "name": "other",
                "value": 50,
                "label": {
                    "normal": {
                        "show": false
                    },
                    "emphasis": {
                        "show": false
                    }
                },
                "itemStyle": {
                    "normal": {
                        "color": "#e5e5e5"
                    },
                    "emphasis": {
                        "color": "#e5e5e5"
                    }
                }
            }]
        }, {
            "type": "pie",
            "avoidLabelOverlap": false,
            "hoverAnimation": false,
            "center": ["90%", "55%"],
            "radius": ["50px", "65px"],
            "x": "0%",
            "labelLine": {
                "normal": {
                    "show": false
                }
            },
            "label": {
                "normal": {
                    "show": true,
                    "position": "center",
                    "formatter": "{c}",
                    "textStyle": {
                        "fontSize": 43,
                        "fontFamily": "Arial",
                        "fontWeight": "bold"
                    }
                },
                "emphasis": {
                    "show": true,
                    "position": "center",
                    "formatter": "{c}",
                    "textStyle": {
                        "fontSize": 43,
                        "fontFamily": "Arial",
                        "fontWeight": "bold"
                    }
                }
            },
            "symbolSize": 3,
            "data": [{
                "name": "50  netsxcgfdfbdfsdgfd",
                "value": 50,
                "itemStyle": {
                    "normal": {
                        "color": ""
                    }
                }
            }, {
                "name": "other",
                "value": 50,
                "label": {
                    "normal": {
                        "show": false
                    },
                    "emphasis": {
                        "show": false
                    }
                },
                "itemStyle": {
                    "normal": {
                        "color": "#e5e5e5"
                    },
                    "emphasis": {
                        "color": "#e5e5e5"
                    }
                }
            }]
        }]
}

其他信息 (Other comments)

echarts2中的效果(忽略label的问题,因为两个版本label设置不同): image echarts3中的效果: image

WebsonLeo avatar Mar 10 '16 01:03 WebsonLeo

我也遇见相同的问题,临时救急的办法是准备10种颜色,每种重复输入, 比如:红,红,黄,黄,蓝,蓝etc. 其实后跟的颜色根本没有用,就是占位而已。

Hongmei225 avatar May 19 '16 15:05 Hongmei225