Custom draw axis labels

Sep 10, 2013 at 9:20 PM
Hello all,

I really appreciate the possibility to have four y-axes using the PositionTier property (two axes on the left and two on the right)
My problem is that the user can not tell to which axis a specific series is bound.

Does anyone have experience how to solve this?

A friend suggested I should have small, colored squares behind the axis titles to indicate the associated series.
But this would require that I custom draw the axis titles? Any idea how to do this?

thanks in advance!
Nicolas
Sep 10, 2013 at 9:41 PM
Edited Sep 11, 2013 at 12:33 PM
I think the easiest solution is a variation of your friend's suggestion. But instead marking the axes, distinguish the series with different styles: you can choose from LineStyle (Solid, Dot, Dash, and combinations), LineThickness, Color, and Markers. You could also use the Title to indicate which axis owns the Series. To make things clearer for the user you should add a custom Legend with indications. Other solution could be to create two Lists of OxyColors with Red/Blue tones (for example). Then choose appropriate color for your axes. Good luck.
Sep 11, 2013 at 7:21 PM
@nicolasr75: interesting question!

It is possible to subclass the axis and override the rendering, but I see the HorizontalAndVerticalAxisRenderer need some refactoring to make it easier (the RenderAxisTitle method is not overridable).

@everytimer: good suggestion, note also that the color of the axis title can be set to match the series that use the axis

See also
https://oxyplot.codeplex.com/workitem/9192
Sep 11, 2013 at 7:35 PM
Many thanks to you both!

@everytimer: very interesting ideas, I will think about them and do some tests with it...

@objo: so you say it is in principle possible to render the axis myself? Could you give me a hint which classes in which files implement the original rendering?
Maybe an intermediate solution would be to duplicate the code in my derived class. By the way: this is for maximally four vertical axes and currently only for WPF.

Nicolas
Sep 11, 2013 at 7:43 PM
Override the Render method. You see the current implementation in Axis.cs
Your derived class will work on all platforms.
Sep 11, 2013 at 7:52 PM
Thanks for the quick reply (and of course for this awesome component!)
Nicolas
Sep 11, 2013 at 8:14 PM
I submitted some changes that should make it easier to override the axis rendering classes. Note that these classes should be refactored later and then you may need to do some changes in your code (that's why I try to keep the public/protected API to a minimum...)
Sep 11, 2013 at 11:04 PM
Edited Sep 11, 2013 at 11:05 PM
Thanks for the changes.

For a first try I have derived special implementations from LinearAxis and HorizontalAndVerticalRenderer.
I have overridden the Render methods and call the base classes methods. After that I call my rendering code for colored rectangles that represent the associated series. I had to use Reflection to get at some internal properties of the Axis class though.
This seems to work fine for now!

thanks again for your help!