This is currently my code:
private void AddEventTimeOverlay()
{
ValueOverlay overlay = new ValueOverlay();
CategoryDateTimeXAxis xaxis = (CategoryDateTimeXAxis)MChart.Axes.First((axis) => axis.Name.Equals("SharedXAxis"));
overlay.Axis = xaxis;
double scaledx = xaxis.GetScaledValue(eventTime.Ticks, MChart.WindowRect, GetViewportRect(xaxis));
overlay.Name = "EventTimeOverlay";
overlay.Value = scaledx;
overlay.Thickness = 2;
overlay.Brush = new SolidColorBrush(Colors.Magenta);
//overlay.Axis = (NumericYAxis)MChart.Axes.First((axis) => axis.Name.Equals("SharedYAxis"));
//overlay.Value = 0.21;
//overlay.Thickness = 2;
//overlay.Brush = new SolidColorBrush(Colors.Purple);
MChart.Series.Add(overlay);
}
private Rect GetViewportRect(Axis axis)
double top = 0;
double bottom = axis.ActualHeight;
double left = 0;
double right = axis.ActualWidth;
double width = right - left;
double height = bottom - top;
if (width > 0.0 && height > 0.0)
return new Rect(left, top, width, height);
return Rect.Empty;
For some reason, no overlay is showing up for me. I'm not sure if the problem is the DateTime to Double value conversion, or if there's something else going on. When I try to display a horizontal valueOverlay, it shows up fine (I tested using the code that is commented out).
Suggestions?
Hello,
Thank you for your post. I have been looking into it and I can suggest you see this forum post:
https://es.infragistics.com/community/forums/f/ultimate-ui-for-wpf/75441/using-datetimecategoryxaxis-with-valueoverlay
where it is explained how to achieve the functionality you want.
Hope this helps you.
Did you ever resolve this, trying to do the same.
I tried that but for some reason it's not working out for me.
I'll have to refresh on what you should do here. But I believe you should be setting the value of the overlay directly to the ticks. The overlay should handle scaling the value for you.