feat: support auto computing dark mode #1093
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
Currently, dark mode is a manually configured theme in Apache ECharts. It's troublesome to make another theme and making it consistant with the light theme as well as adjusting to make sure there is enough contrast between the foreground and the background.
In this PR, I propose a method to convert to dark mode without extra designing and developing.
Solution
The basic idea is to convert colors automatically into dark mode.
(TODO) I'm making more research on the algorithm, but for now, this PR simply inverse the lightness of the color and desaturate a little in dark mode. Even this simple algorithm works well enough.
Result
Here are some result of auto converted charts from the default Apache ECharts theme.
Discussion
Current implementation demostrates that auto converting algorithm is possible. We should probably improve the default light theme design (current theme doesn't has enough contrast in some cases like axis splitLine or uses too saturated colors in dataZoom) so that it looks well in both light and dark mode.
I'd suggest not supporting customizing dark theme for each options until many developers raised up such requirement after this feature releases, because otherwise it will bring in more complexity. In most cases, if developers want to customize the dark theme, they can opt-out the auto dark mode feature and set a customized dark theme as they do now.
TODO