Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] SVG Export uses RGB colors in SCSS notation #14164

Open
mosc9575 opened this issue Nov 22, 2024 · 2 comments
Open

[BUG] SVG Export uses RGB colors in SCSS notation #14164

mosc9575 opened this issue Nov 22, 2024 · 2 comments

Comments

@mosc9575
Copy link
Contributor

mosc9575 commented Nov 22, 2024

Software versions

Python version : 3.12.4 (tags/v3.12.4:8e8a4ba, Jun 6 2024, 19:30:16) [MSC v.1940 64 bit (AMD64)]
IPython version : 8.25.0
Tornado version : 6.4.1
NumPy version : 1.26.4
Bokeh version : 3.6.1
BokehJS static path : ~/Envs/fbpinn/Lib/site-packages/bokeh/server/static)
node.js version : v20.17.0
npm version : 10.8.2
jupyter_bokeh version : 4.0.5
Operating system : Windows-10-10.0.19045-SP0

Expected behavior

I expect, that I can save a figure to a file as svg and when I open it another program, it is displayed correctly.

Observed behavior

When I save a plot as a figure using the latest version ob bokeh 3.6.1 and open this file in inkscape or in python using reportlab, colored areas are defected. The color is not evaluated correctly and mostly shown in black.

Please notice, that this defect is not visible, if I open the file in a modern browser. Then the newer version is displayed in the correct from.

Reading the source code of the older and the newer versions shows, that the values inside an rgb call is changed. The older was rgb(222,222,222) which looks like valid CSS, while the newer is rgb(222 222 222) which looks like SCSS/SASS.

3.4.3 3.6.1
Image Image
<path fill="rgb(202,178,214)" stroke="rgb(202,178,214)"> <path fill="rgb(202 178 214)" stroke="rgb(202 178 214)">

Example code

import bokeh
from bokeh.io import export_svg
from bokeh.plotting import figure

v = bokeh.__version__

p = figure(title=f"SVG export in {v}", tools="")
p.rect(x=[1, 2, 3], y=[1, 2, 3], width=1, height=1, color="#CAB2D6")
p.output_backend = 'svg'
export_svg(p, filename=f"export_svg_{v}.svg")

Screenshots

Image

@mattpap
Copy link
Contributor

mattpap commented Nov 22, 2024

rgb(222 222 222) which looks like SCSS/SASS.

rgb(R G B) or rgb(R G B / A) is CSS 4 color syntax. I suppose SVG still supports officially only CSS 3 (or lower). If that's the case, and that needs to be confirmed with SVG specification, then we will have to make sure that all generated colors conform to the correct CSS level. Browsers may support newer levels of CSS where programs like Inkscape will not.

@mattpap
Copy link
Contributor

mattpap commented Nov 22, 2024

From https://www.w3.org/TR/SVG2/painting.html#Definitions:

For any value, all color syntaxes defined in CSS Color Module Level 3 must be supported, including rgb(), rgba(), hsl(), hsla(), the extended color keywords and the currentColor value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants