antvis/G2

Chart displays incorrect colors for data #6158

ickisIckis posted onGitHub

问题描述

Hello, While working with g2plot, we have observed that the charts display incorrect colors for the data. Although the colors may appear similar, the hex values are different.

重现链接

No response

重现步骤

Open any chart (for example https://g2plot.antv.antgroup.com/en/examples/more-plots/waterfall/#custom-color). Use any color picker from the browser page to select a color, check the hex value, and compare it with the hex value passed to the 'color' property - they are different.

预期行为

The hex value of the displayed color is the same as the one passed to the options.

平台

  • 操作系统: [macOS, Windows]
  • 网页浏览器: [Google Chrome, Firefox]

屏幕截图或视频(可选)

Screenshot 2024-04-02 091403

补充说明(可选)

In our project, we are utilizing web-safe colors, and from this perspective, maintaining the correct hex value of a color is quite important. We verified this using a color picker with a lens, and consistently found it to be incorrect at each point. Additionally, we checked these colors on a plain canvas, where they appeared as the correct colors we had assigned. It seems that the g2plot process may be altering the colors in some way (perhaps through the use of filters?).


It's because of the default theme of G2 will apply fillOpacity to 0.95. You can set the value of this style property to 1 like this:

chart.style('fillOpacity', 1);

DEMO: https://codesandbox.io/p/sandbox/bar-diverging-stacked-7m7g9k?file=%2Findex.js%3A53%2C1-54%2C1

posted by xiaoiver about 1 year ago

Thank you, this is really helps

posted by ickisIckis about 1 year ago

Fund this Issue

$0.00
Funded

Pull requests