oxyplot / oxyplot-avalonia

A cross-platform plotting library for .NET. This package targets Avalonia apps.
https://oxyplot.github.io/
MIT License
278 stars 47 forks source link

LineSeries Opacity not being applied #32

Closed alessandrofrancesconi closed 2 years ago

alessandrofrancesconi commented 3 years ago

Setting opacity to LineSeries does not produce any change:

<oxy:LineSeries Color="#75a2ea" MarkerType="Circle" MarkerSize="2" Opacity="0.7" ...

Is this the right way to draw a semitransparent line?

VisualMelon commented 3 years ago

I'm not sure where the Opacity property comes from (I presume it's because Series extends ItemsControl) but it is ignored by oxyplot-avalonia. The only way to set the opacity would be to specify it as part of the Color (e.g. "#b375a2ea").

Given the property is there, it could make sense to apply it, though I'm not sure how it should interact with the opacity in the color.

VisualMelon commented 2 years ago

Reply to myself:

Given the property is there, it could make sense to apply it, though I'm not sure how it should interact with the opacity in the color.

I don't think this is viable without support in the core library. Automatic colors are not known at the time the opacity would be known, so it would be a partial solution at best. I think it would only create confusion if the behaviour was different between when the color is specified and when it is left as automatic.

It would be possible to add support in Core by recording the alpha component in one of the 'unused' components in the Automatic value, or by adding an explicit Opacity property. The former would be weird but probably quite simple; the latter would introduce redundancy.

As such, I'll close this for now: it remains that the only way to make a line translucent is to set its color explicitly, or to make the PlotModel.DefaultColors translucent.