GiovineItalia / Compose.jl

Declarative vector graphics
http://giovineitalia.github.io/Compose.jl/latest/
Other
248 stars 81 forks source link

Cairo backend and svgclass() #339

Open Mattriks opened 5 years ago

Mattriks commented 5 years ago

I'm opening this issue here, because I can demonstrate the issue using Compose. Note that there are some examples in Gadfly where this issue does currently occur (e.g. Geom.boxplot):

ctx = compose(context(), fill(["deepskyblue", "gold"]), 
    (context(), rectangle([0.2, 0.7],[0.35],[0.1],[0.3]))
)
cs = fill(["deepskyblue","deepskyblue","gold"])
ctx2 = compose(ctx, (context(),  cs,
    (context(), circle([0.25,0.25,0.75], [0.1,0.9,0.1], [0.01])))
)
ctx3 = compose(ctx, (context(),  cs,
    (context(), circle([0.25,0.25,0.75], [0.1,0.9,0.1], [0.01]),  svgclass("marker")))
)
draw(PNG(), hstack(ctx2, ctx3))
# issue also occurs with draw(PNG(), ctx3)

comp_png01

If you wanted to draw in PNG only, there would be no need to include the svgclass("marker") in the above the code. But if you want users to be able to plot to PNG & SVG then its important to include svgclass() e.g. in Gadfly. In the above code there are two issues:

  1. The code is written in a clunky style. Its better and it makes sense to include forms and their properties in the same context like this: ctx3 = compose(ctx, (context(), circle([0.25,0.25,0.75], [0.1,0.9,0.1], [0.01]), cs, svgclass("marker"))). The circles will then appear in their correct color - problem solved!
  2. Of course, one may entertain the idea that the problem can somehow be fixed in Compose (rather than in Gadfly) ... but can it?

My thoughts are that point 1 is as important as point 2. Making sure that forms and their properties are in the same context will fix some issues in Gadfly now.

bjarthur commented 5 years ago

curiously, the problem is data dependent. see https://github.com/GiovineItalia/Gadfly.jl/issues/1273, which is fixed by https://github.com/GiovineItalia/Gadfly.jl/pull/1281

Mattriks commented 5 years ago

The issue outlined in GiovineItalia/Gadfly.jl#1273 is not the same as the issue above. The issue above is not data dependent and only affects the Cairo backends. The issue in GiovineItalia/Gadfly.jl#1273 is data-dependent and affects SVG and Cairo backends.

However, the solution to both issues may be related.