How about IPlotElement interface and more interfaces like ILinePen etc.

Aug 26, 2011 at 2:26 AM

All the PlotElement can be rendered on the plot. It's not always relative to the axis. So, I defined it as this:

public interface IPlotElement
    {
        bool IsVisible { get; set; }

        /// <summary>
        /// The border box
        /// </summary>
        OxyRect ScreenRect { get; }
        OxyRect GetScreenRectangle(IRenderContext rc);

        void Render(IRenderContext rc, PlotModel model);

        OxyThickness Margin { get; }
        OxyThickness Padding { get; }
    }

 

The PlotAreaBorderBox, PlotLegend, ChartBorderBox, and any custom PlotElement which needs to stay on the Plot, etc. can using it.

For example:

Index: OxyPlot/PlotModel/PlotModel.Rendering.cs
===================================================================
--- OxyPlot/PlotModel/PlotModel.Rendering.cs    (revision 69705)
+++ OxyPlot/PlotModel/PlotModel.Rendering.cs    (working copy)
@@ -23,15 +23,41 @@
             UpdateAxisTransforms();
             RenderBackgrounds(rc);
             RenderAxes(rc);
+            RenderChartPane(rc);
             RenderAnnotations(rc, AnnotationLayer.BelowSeries);
             RenderSeries(rc);
             RenderAnnotations(rc, AnnotationLayer.OverSeries);
             RenderTitle(rc);
             RenderBox(rc);
+            RenderCustomPlotObject(rc);
             if (IsLegendVisible)
                 RenderLegends(rc, LegendArea);
         }
 
        private void RenderCustomPlotObject(IRenderContext rc)
        {
            foreach (IPlotElement pe in CustomPlotObjects)
            {
                if (!pe.IsVisible)
                    continue;

                pe.Render(rc, this);
            }
        }

 

=================

By the way, is it better to abstract all the propertied like MajorGridlineColor, MajorGridlineStyle, MajorGridlineThickness into an property (like MajorTickline or MajorTicklinePen which implements the pen interface like ILinePen)?

So, we may have these properties:

public ILinePen Axisline { get; set; }
public ILinePen MajorGridline { get; set; }
public ILinePen MinorGridline { get; set; }
public ILinePen ExtraGridline { get; set; }
public TickLinePen MajorTickline { get; set; }
public TickLinePen MinorTickline { get; set; }

 

Here is the ILinePen:

    public interface ILinePen
    {
        OxyColor Color { get; set; }
        LineStyle Style { get; set; }
        double Thickness { get; set; }
        OxyPenLineJoin Join { get; set; }
        double[] DashArray { get; }
        bool IsVisibale { get; }
    }

and some pens:

public class OxyLinePen : ILinePen {}

public class TickLinePen : OxyLinePen {}

If it's valuable, I can submit these patches.

Coordinator
Aug 28, 2011 at 7:45 PM
Edited Aug 28, 2011 at 7:46 PM

thanks for review of the code!

PlotElements: I am not sure if I understand correctly - I see some similarities with the Annotations (which can be placed anywhere on the plot, and may or may not be using axes). Are you thinking that the plot elements should be measured and arranged? Or is it an abstraction for elements that have a border?

Pen: There is already an OxyPen, but I decided to use it only internally, not in the API. I see the advantage with reduced number of properties (particularly in the Axis classes), but wanted to follow the conventions from the WPF API - like System.Windows.Shapes.Path where you have properties for Stroke, StrokeThickness, StrokeDashArray etc. We could add this as an issue in the issue tracker, but I would wait to implement it until there are some positive votes. Here is an example how XAML would look like if you want to change the color of the major grid lines to blue (I know it can be shorter by markup extensions or linking to a resource):

<oxy:LinearAxis>
  <oxy:LinearAxis.MajorGridline>
    <oxy:OxyPen Color="Blue"/>
  </oxy:LinearAxis.MajorGridline>
</oxy:LinearAxis>

vs. how it is today:

<oxy:LinearAxis MajorGridlineColor="Blue"/>
Aug 29, 2011 at 12:50 AM
objo wrote:

thanks for review of the code!

PlotElements: I am not sure if I understand correctly - I see some similarities with the Annotations (which can be placed anywhere on the plot, and may or may not be using axes). Are you thinking that the plot elements should be measured and arranged? Or is it an abstraction for elements that have a border?

Yes, they are alike. I had thought the Annotations must be using axes. I just use PlotElements to render some box around some sub-area. I should take a deep look the Annotations.

Pen: There is already an OxyPen, but I decided to use it only internally, not in the API. I see the advantage with reduced number of properties (particularly in the Axis classes), but wanted to follow the conventions from the WPF API - like System.Windows.Shapes.Path where you have properties for Stroke, StrokeThickness, StrokeDashArray etc. We could add this as an issue in the issue tracker, but I would wait to implement it until there are some positive votes. Here is an example how XAML would look like if you want to change the color of the major grid lines to blue (I know it can be shorter by markup extensions or linking to a resource):

<oxy:LinearAxis>
  <oxy:LinearAxis.MajorGridline>
    <oxy:OxyPen Color="Blue"/>
  </oxy:LinearAxis.MajorGridline>
</oxy:LinearAxis>

vs. how it is today:

<oxy:LinearAxis MajorGridlineColor="Blue"/>

Waiting for somebody to say something.