Is there a way on echarts to get the series colors

Solution 1:

The Echarts uses a built-in palette based on the theme. The easiest way to get a set of colors is this:

myChart.getOption().color

To get the colors that are mapped to the series, you can do the following:

myChart.getModel().getSeries().map(s => {
  return {
    seriesIndex: s.seriesIndex,
    seriesColor: myChart.getVisual({
      seriesIndex: s.seriesIndex
    }, 'color')
  }
})

And the result will be something like this:

[
   {
      "seriesIndex":0,
      "seriesColor":"#5470c6"
   },
   {
      "seriesIndex":1,
      "seriesColor":"#91cc75"
   },
   {
      "seriesIndex":2,
      "seriesColor":"#fac858"
   },
   {
      "seriesIndex":3,
      "seriesColor":"#ee6666"
   },
   {
      "seriesIndex":4,
      "seriesColor":"#73c0de"
   }
]