2

I'd like to be able to control bar colors based on xAxis/category label name, throughout multiple charts, while using the dataset.source option of feeding data.

I'm guessing the solution might involve using visualMap?

customColors = {
 x1: '#123',
 x2: '#456',
 x3: '#789',
 ...
}

enter image description here

1 Answer 1

0

I don't think visualMap is the way to do this, you probably want to set the colors in series:
https://echarts.apache.org/en/option.html#series-bar.data.itemStyle.color
or define a color palette:
https://echarts.apache.org/en/option.html#color

Echarts should color the chart by series by default:
https://echarts.apache.org/en/option.html#series-bar.colorBy

2
  • itemStyle.color is the effect I'm trying to achieve, just that I'm piping the data via dataset.source, not through the axis.data / series.data option, like here
    – pax
    Commented Apr 26, 2022 at 8:36
  • Try defining a color palette then ("color" option) or define a "color" attribute in dataset objects
    – rajniszp
    Commented Apr 27, 2022 at 9:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.