We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

ChartSeriesAnnotation and DateTime Axis

Thread ID:

Created:

Updated:

Platform:

Replies:

116331 May 15,2014 01:08 PM UTC Jul 14,2014 12:19 PM UTC WPF 9
loading
Tags: Chart
Domenico Mozzone
Asked On May 15, 2014 01:08 PM UTC

Hi,
I'm evaluating Chart control (v 12.1.0.43). 
My need is to add may simple line serie composed by two points each. The xAxis must be of DateTime type.
For each pwo-points line serie I have to display near each point some additional information, a short string and the time in the HH:mm format. In the middle of the serie segment I have to draw two other strings.

I tried to use a Line ChartSerie for each couple of point; my intention was to add a ChartSeriesAnnotation for each additional information to display, but I saw that ChartSeriesAnnotation ctor takes only the X coordinate as double. How can I manage the customer requirement to have a DateTime X Axis? 

Thanks in advance

Best regards

Domenico Mozzone




Karthikeyan V [Syncfusion]
Replied On May 17, 2014 06:03 PM UTC

Hi Domenico,

 

Thanks for using the Syncfusion products.

 

We have analysed the reported requirement. You can achieve your requirement with convert datetime value to double and assign the convert value to X property.

 

Code snippet [C#]:

 

SeriesAnnotation.X = DateTime.FromOADate(xValue);

 

Please let us know if you require further assistance on this.

 

Thanks,

Karthikeyan V.


Karthikeyan V [Syncfusion]
Replied On May 17, 2014 06:10 PM UTC

Hi Domenico,

 

Please ignore the previous update.

 

We have analysed the reported requirement. You can achieve your requirement with convert datetime value to double and assign the convert value to X property.

 

Code snippet [C#]:

 

SeriesAnnotation.X = Convert.ToDouble(new DateTime(2014,5,4));

 

Please let us know if you require further assistance on this.

 

Thanks,

Karthikeyan V.


Domenico Mozzone
Replied On July 8, 2014 10:46 AM UTC

Hi,
the conversion you suggested throws an invalid cast exception.
I used the method ToOADate() but the result is quite strange ad you can see from attached screenshot
Best regards
Domenico

Domenico Mozzone
Replied On July 8, 2014 10:47 AM UTC

Hi,
the conversion you suggested throws an invalid cast exception.
I used the method ToOADate() but the result is quite strange ad you can see from attached screenshot
Best regards
Domenico

Attachment: Cattura4_99aa3b44.zip

Suresh S [Syncfusion]
Replied On July 9, 2014 12:49 PM UTC

Hi Domenico,


Sorry for the inconvenience caused.


We have analyzed the reported issue, we are not able to reproduce the issue. We have prepared the sample based on your query. Please download it from the given below location.  


Please let us know if you require further assistance on this.


Regards,

Suresh S


Attachment: DateTimeAnnotation_d8575f90.zip

Domenico Mozzone
Replied On July 9, 2014 01:19 PM UTC

Hi Suresh,
thank you for your reply; please find in attachment your modified example that reporoduce my issue.
I suspect that the problem is that I have to build some charts programmatically in order to add them to Pages to be shown in a Frame.
I do not know how many pages and  charts I have to build so I have a method that instantiate a new Chart as following
var chartToHost = new Chart();
then foreach Series with annotations I need:
var serie = new ChartSerie();
...
serie.Annotations = new AnnotationsCollection();

to add an annotation I do (for example)
serie.Annotations.Items.Add(new ChartSeriesAnnotation
                                                   {
                                                       X = viewModel.DataModel[3].Year.ToOADate(),
                                                       Y = 22,
                                                       Description = "Syncfusion",
                                                   });
The result is quite strange as you can see in my example
Where is my mistake?
How can I add charts and related series with annotations programmatically?

Best regards

Domenico


Attachment: DateTimeAnnotation_b95795c9.zip

Suresh S [Syncfusion]
Replied On July 11, 2014 11:40 AM UTC

Hi Domenico,

 

Thanks for your response. We have analyzed the reported issue. While initializing the ChartSeriesAnnotation, the required AnnotationShape have to be given as shown in the below code snippet. If you are not using AnnotationShape then, the Template property of ChartSeriesAnnotation should be used and bind the description if only text is to be displayed.  

 

Code Snippet [C#]:

this.ChartSerieA.Annotations.Items.Add(new ChartSeriesAnnotation

                                                   {

                                                       X = viewModel.DataModel[3].Year.ToOADate(),

                                                       Y = 22,

                                                       Description = "Syncfusion",

                                                       AnnotationShape = AnnotationShapes.HorizontalLine,

                                                   });

 

Please let us know if you require further assistance on this.

 

Regards,

Suresh S


Domenico Mozzone
Replied On July 11, 2014 11:58 AM UTC

Hi Suresh,
thank you for the solution.
The last question. I'd like to use annotations to put information on a particular kind of timetable rail chart with many annotations for each simple segment serie. The question is about Smart labeling. Do it work on annotations related to the same serie and to other serie?
Now we are using another library to draw this kind of chart, and I'm investigating if Syncfusion chart is faster to plot smart labels.
Thank you
Domenico

Suresh S [Syncfusion]
Replied On July 14, 2014 12:19 PM UTC

Hi Domenico,


Thanks for your response. We have prepared the sample based on your query. Please download it from the given below location.


Please let us know if you require further assistance on this.


Regards,

Suresh S


Attachment: DateTimeAnnotation_a183d5c1.zip

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;