Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
478
Mark today on chart with CategoryDateTimeXAxis
posted

I have several charts which use a CategoryDateTimeXAxis to display historical and forecast sales data. I would like to place a marker (such as a red vertical line) on these charts to indicate the current date (and hence the boundary between historical data and forecast data). I think I should be able to do this using a CrosshairLayer with a fixed CursorPosition - however, I can't see how to calculate the cursor position that is equivalent to a particular date. Any suggestions?

Parents
No Data
Reply
  • 34810
    Verified Answer
    Offline posted

    Hello Gregorach,

    Rather than utilizing the CrosshairLayer with a fixed CursorPosition, I would recommend utilizing the ValueOverlay in the XamDataChart. This allows you to draw a vertical or horizontal line at a point of your choosing in the chart, and you can read about use of ValueOverlays here: https://ko.infragistics.com/help/wpf/datachart-series-value-overlay.

    In this case, you would define a ValueOverlay and point its Axis property at your CategoryDateTimeXAxis as this will designate that you want a vertical line. The Value in this case would be the Ticks of DateTime.Today, and so I would recommend that you define a DateTime property on your view model that is set to DateTime.Today and bind the Value of the ValueOverlay to <propertyName>.Ticks.

    I have attached a sample project to demonstrate the above. I hope this helps.

    Please let me know if you have any other questions or concerns on this matter.

    Sincerely,
    Andrew
    Associate Developer

    DataChartTodayMarker.zip
Children