Cartesian PlotBand Annotation with MVVM

1 Answer 23 Views
Chart
Gerhard
Top achievements
Rank 1
Iron
Iron
Gerhard asked on 26 Feb 2025, 05:54 AM

Hello, I would like to add a “Cartesian PlotBand Annotation” to a “CartesianChart” at runtime.
This should be done in the MVVM environment. For this I would add a list “List<CartesianPlotBandAnnotation>” as a property to my “MainViewModel”. I then fill the individual elements of this list with the corresponding data. The property “Axis” of type “CartesianAxis” must also be specified. Unfortunately, this object is not known to the “MainViewModel”. What is the solution here?

 

 

1 Answer, 1 is accepted

Sort by
0
Stenly
Telerik team
answered on 26 Feb 2025, 09:24 AM

Hello Gerhard,

For an MVVM approach when defining annotations for the RadCartesianChart control, you can utilize its AnnotationsProvider property:

WPF ChartView - AnnotationsProvider - Telerik UI for WPF

This way, when defining a descriptor, you can specify the Axis.

With this being said, could you give this suggestion a try?

Regards,
Stenly
Progress Telerik

Enjoyed our products? Share your experience on G2 and receive a $25 Amazon gift card for a limited time!

Gerhard
Top achievements
Rank 1
Iron
Iron
commented on 27 Feb 2025, 02:27 PM

Thanks for the tip, I must have overlooked something.
I would like to implement a 'PlotBand annotation' for the horizontal axis. This axis is a 'DateTimeContinuousAxis' and I use the same implementation as in the documentation. Unfortunately, the annotation is not displayed.
Stenly
Telerik team
commented on 27 Feb 2025, 05:48 PM

Hello Gerhard,

I prepared a sample project to showcase how to display plot band annotations via the AnnotationsProvider property of RadCartesianChart control, where one of the axes is a DateTimeContinuousAxis. The example follows the MVVM pattern.

The application produces the following result:

With this being said would it be possible to give it a try?

Gerhard
Top achievements
Rank 1
Iron
Iron
commented on 28 Feb 2025, 06:49 AM

The example helped me a lot.
Thank you very much.
Tags
Chart
Asked by
Gerhard
Top achievements
Rank 1
Iron
Iron
Answers by
Stenly
Telerik team
Share this question
or