Version
5.4.3
Link to Minimal Reproduction
Steps to Reproduce
click
Current Behavior
Init echart with theme and no theme the color in chart is different
var myChart = echarts.init(chartDom, 'dark');
var myChart = echarts.init(chartDom);
Expected Behavior
The chart color when using theme the same as not using theme
var myChart = echarts.init(chartDom);
Environment
- OS:
- Browser:
- Framework:
Any additional comments?
No response
3条答案
按热度按时间slsn1g291#
I made a minimal Reproduction from your example.
As you can see in there the part
{..., color: ['#1890ff']}
is the issue. Acolor
property is not documented onsetOption
but it seems to set the color for all items in the plot. When using a theme this value is most likely overridden by the theme default values after it was initially set. Thats why its working with the "dark" theme.If you remove the mentioned line the colors are equal for both themes:
rggaifut2#
I made a minimal Reproduction from your example.
As you can see in there the part
{..., color: ['#1890ff']}
is the issue. Acolor
property is not documented onsetOption
but it seems to set the color for all items in the plot. When using a theme this value is most likely overridden by the theme default values after it was initially set. Thats why its working with the "dark" theme.If you remove the mentioned line the colors are equal for both themes:
Yes, this is a reasonable explanation.
But I think the expected behavior should be
the chart color when using theme, the same as not using theme
.option.color
priority higher thantheme
lf3rwulv3#
Currently the configured
color
option will be merged into the specifiedcolor
in the theme options, instead of the whole replacement. For thecolor
array, you only define 1 color, which is less than the number of theme color, so it finally only replaced the first color. (But I also feel that the merge strategy is a bit strange in this case)