hustcc / echarts-for-react

⛳️ Apache ECharts components for React wrapper. 一个简单的 Apache echarts 的 React 封装。
https://git.hust.cc/echarts-for-react
MIT License
4.51k stars 629 forks source link

How can I customize the item colors in Legend? #168

Closed ikteru closed 6 years ago

ikteru commented 6 years ago

Hello,

I'm trying to change the colors of the bars in my Bar chart. But they're set automatically and I would like to change the color for this Chart ALONE without changing the default color array. And of course since the color of the bar will change, I want the Legend color to change with it!

How can I do that?

Thank you!

hustcc commented 6 years ago

You can generate and build your own theme at here

Then register your own theme.

echarts.registerTheme('my_theme', { // theme object 
  backgroundColor: '#f4cccc'
});

Use your theme in echarts-for-react.

<ReactEcharts
  option={this.getOption()}
  theme={"my_theme"}
/>
jjzjx118 commented 5 years ago

hi,hustcc. 我尝试了注册 theme 的方法,但是没有成功.在 Echarts 的自定义构建工具栏里下载的似乎是整个 option 的配置. 呢么 整个 theme 如果传递构建工具生成的 json 文件,是否和 option 冲突了呢?