I have a chart, all working fine except for I need to have the x-axis labels 'follow' the y-axis zero crossing.
I have been playing with the label margins and can offset the label to the left or right of the gridline
<DVC:LinearAxis.AxisLabelStyle>
<Style TargetType="{x:Type DVC:AxisLabel}">
<Setter Property="Margin" Value="25,0,0,0" />
</Style>
</DVC:LinearAxis.AxisLabelStyle>
I haven't got a clue how to move the label up the chart so that it appears in the middle. I will bind to value for determining the exact location but I can't even work out how to move the label in the vertical plane.
Any help or pointers much appreciated.
Thanks.
After lots of trial and error and reading articles I have finally put together a really simple and elegant solution.
I have bound the margin property of the
AxisLabel
to theActualHeight
of the chart area and used aMultiValueConverter
to create the correct margin values.XAML
MarginConverter.cs
Range is the maximum and minimum y values when I draw the graph and then bound to a property on the VM.
This is a surprisingly elegant solution to what I thought was going to be quite hacky. As the view is resized, the labels are repositioned with new dimensions.