Proposal for modified layering

Oystein Bjorke fa 10 anys 0
This discussion was imported from CodePlex

ffiala wrote at 2012-03-08 22:50:

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.

objo wrote at 2012-03-09 08:20:

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


objo wrote at 2012-03-12 06:30:

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


ChevyCP wrote at 2012-03-27 17:55:

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