Proposal for modified layering

Mar 8, 2012 at 9:50 PM
Edited Mar 8, 2012 at 9:55 PM

I am very impressed of how easy an implementation of oxyplot is possible.

Many of my plots use a DateTime axis and I am used to change a monolor background to a background wth colored areas which represent the months for example (see the following example).

To implement this I created a new Annotation class "FreeAnnotation" and added two methods in order to be able to draw rectangles an text. This works fine but the annotation can only be added as "BelowSeries" oder "AboveSeries". So when drawing a rectangle as a BelowSerie then a grid ist hidden because it is drawn before the annotation.

So I changed the drawing order in "PlotModel.Rendering.cs from

this.RenderBackgrounds(rc);           
this.RenderAxes(rc, AxisLayer.BelowSeries);            
this.RenderAnnotations(rc, AnnotationLayer.BelowSeries);            
this.RenderSeries(rc);

to

this.RenderBackgrounds(rc);           
this.RenderAnnotations(rc, AnnotationLayer.BelowSeries);            
this.RenderAxes(rc, AxisLayer.BelowSeries);            
this.RenderSeries(rc);

But this is not a good solution because it has to be done with each new release.

My proposal is

  • to change the drawing sequence of the two layers (RenderAnnotations(rc, AnnotationLayer.BelowSeries) and RenderAxes(rc, AxisLayer.BelowSeries) or
  • to add additional postitions of the annotation layer (like "BelowAxes" or "AsBackGround" or "AboveBackGround") or
  • to to add something like a "zIndex" whose initial values represent the order of the respective layer but it is a value which can be changed by program.
Coordinator
Mar 9, 2012 at 7:20 AM

I suggest we add "BelowAxes" to the AnnotationLayer enum and change to

this.RenderBackgrounds(rc);           
this.RenderAnnotations(rc, AnnotationLayer.BelowAxes);            
this.RenderAxes(rc, AxisLayer.BelowSeries);            
this.RenderAnnotations(rc, AnnotationLayer.BelowSeries);            
this.RenderSeries(rc);

This should not change the behaviour for existing plots

Coordinator
Mar 12, 2012 at 5:30 AM

I added "BelowAxis" to the AnnotationLayer enumeration. Included an example in the AnnotationExamples in the ExampleLibrary/ExampleBrowser.

Mar 27, 2012 at 3:55 PM

ffiala, I'm doing a similar thing myself.   Could you please share your "freeannotation" class?