echarts 曲线重复颜色的解决办法 echarts 曲线重复颜色的解决办法 echarts 曲线重复颜色的解决办法 generateColor() { let color = ""; let r = Math.floor(Math.random() * 256); let g = Math.floor(Math.random() * 256); let b = Math.floor(Math.random() * 256); color = `rgb(${r},${g},${b})`; return color; } this.lineObjData.forEach(element => { nameList.push(element.name); element.itemStyle = { color: this.generateColor() }; }); this.lineCharts.setOption({ tooltip: { trigger: "axis" }, grid: { containLabel: true }, toolbox: { feature: { saveAsImage: {} } }, legend: { y: "bottom", x: "center", data: nameList }, xAxis: { type: "category", boundaryGap: false, data: this.lineDate }, yAxis: { type: "value" }, series: this.lineObjData });