Echarts 更改饼图颜色类型:饼图

huangapple go评论49阅读模式
英文:

Echarts change color for type: pie

问题

I use this kind of chart - https://echarts.apache.org/examples/en/editor.html?c=dataset-link
If I add to the first item for series color red (line:22), so the code looks like:

{
type: 'line',
color: 'red',
smooth: true,
seriesLayoutBy: 'row',
emphasis: { focus: 'series' }
},

It changes the color only in the chart but not in the pie, thank you for solution

我使用这种类型的图表 - https://echarts.apache.org/examples/en/editor.html?c=dataset-link
如果我在第一个系列的项目中添加红色(第22行),那么代码如下所示:

{
type: 'line',
color: 'red',
smooth: true,
seriesLayoutBy: 'row',
emphasis: { focus: 'series' }
},

这只会改变图表中的颜色,而不会影响饼图,感谢您的解决方案。

英文:

I use this kind of chart - https://echarts.apache.org/examples/en/editor.html?c=dataset-link
If I add to the first item for series color red (line:22), so the code looks like:

{
type: 'line',
color: 'red',
smooth: true,
seriesLayoutBy: 'row',
emphasis: { focus: 'series' }
},

It changes the color only in the chart but not in the pie, thank you for solution

答案1

得分: 1

改变全局颜色调色板,而不是为每个系列更改颜色。

以下是基于您提供的示例的示例:

option = {
  ...
  //设置全局颜色调色板
  color: ['#c23531', '#2f4554', '#61a0a8', '#d48265', '#91c7ae',
  '#749f83', '#ca8622', '#bda29a', '#6e7074', '#546570', '#c4ccd3'],
  series: [
    ...
  ]
}
英文:

Change the global color palette instead of changing colors for each series.

Here is an example based on the one you gave.

option = {
  ...
  //Set the global color palette
  color: ['#c23531','#2f4554','#61a0a8','#d48265','#91c7ae',
  '#749f83','#ca8622','#bda29a','#6e7074','#546570','#c4ccd3'],
  series : [ 
    ...
  ]
}

huangapple
  • 本文由 发表于 2023年2月16日 03:47:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/75464779.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定