oxyplot / oxyplot-xamarin

OxyPlot for Xamarin.Mac and Xamarin.Forms
MIT License
64 stars 59 forks source link

Can we add gradient color to the area series fill color in oxyplot #105

Closed PavaniTatikonda27 closed 4 years ago

PavaniTatikonda27 commented 4 years ago

Steps to reproduce

  1. Trying to add gradient color to the area series using Oxyplot in xamarin forms.

Platform: Xamarin Forms

Expected behaviour

Need to show gradient color in the area series.

Need to achieve the below View :

Screenshot 2020-06-26 at 7 53 12 AM

Actual behaviour

We can only add solid colors to the fill color in area series. Could we make any tweaks to look similar to the graident color.

This is the Actual color with solid Color :

Screenshot 2020-06-29 at 12 08 07 PM
VisualMelon commented 4 years ago

Thank you for the clear example images. This is presently not support in the library.

It would be possible to implement such support, but historically OxyPlot has tended to avoid features that don't directly related to plot interpretability, and I don't think gradients are considered a good way to communicate information (e.g. what can the gradient tell you that the line doesn't already?). Obviously this is somewhat subjective (smoothed lines and interpolated heatmaps, for instance, are both features I would avoid).

PavaniTatikonda27 commented 4 years ago

We are trying to achieve the fill area of the area series with a gradient color instead of solid color as it is more visually pleasing rather than solid colors, other than that it doesn't tell anything more.

Could we make any tweaks to achieve the above look ?

Any suggestions are welcome and thanks for the comment @VisualMelon

VisualMelon commented 4 years ago

I'm afraid I can't really suggest anything apart from partially implementing the feature and shipping your own copy of the library with big changes.

To implement this properly, brush types would need to be defined, the fill parameters and members everywhere would need to be replaced, and the appropriate render contexts would need to be modified. This could probably be done in a way that doesn't break existing code (it would be binary breaking) (and wouldn't be hard to do if you were only implementing it for one platform) but I'm afraid this isn't a feature I personally would invest in unless it got the go-ahead from the project owner. (That said, this would help with supporting something like hatching, which can be useful in e.g. printed documented).

Without modifying the library, I think this would be very painful. You could try extending the xamarin implementation of the appropriate IRenderContext (and possibly the presentation end, as it probably isn't swappable) and area series types, to implement it as a one-off, but I have no real familiarly with Xamarin or OxyPlot-Xamarin so I don't know if it's practical.

objorke commented 4 years ago

@VisualMelon Yes, OxyPlot is opinionated and has been trying to follow the style and design principles of Edward Tufte, Stephen Few et al. https://oxyplot.readthedocs.io/en/latest/guidelines/design.html I don't think gradients should be implemented in this library!

VisualMelon commented 4 years ago

@objorke thanks for the link: somehow I couldn't find that document (I knew it existed) when I was writing the other comments.