Search code examples
colorspie-chartecharts

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


Solution

  • 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 : [ 
        ...
      ]
    }