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. Image for the cookie policy date

Chart background for certain regions

Hello,

I have an XY-style line chart. My X axis is the year (range: 2010 - 2030) and I want to add a visual distinction on the chart between the past and the future. I was thinking of doing this in 1 of 2 ways:

1) Have a vertical line on the current date separating past and future.
2) Color the background region of the past (2010 - current date) a light gray.

Does anyone know if both these features can be reliably implemented with the Chart control?

Regards,
James

3 Replies

SS Suresh S Syncfusion Team June 11, 2015 01:04 PM UTC

Hi James,

Thanks for contacting Syncfusion support.

We have analyzed your query and achieved your requirement using Chart Striplines and Annotations. For more information regarding stripline, annotations please refer our help documentation link. Also, we have prepared a sample based on this, please download from below location,

Ug link1: http://help.syncfusion.com/ug/wpf/Documents/annotations.htm

Ug link2: http://help.syncfusion.com/ug/wpf/Documents/striplines.htm

Please let us know in case of any query.

Regards,

Suresh S


Attachment: chartcontrol_c01b178c.zip


JA James June 11, 2015 04:58 PM UTC

Thanks for your response Suresh.

This looks like it will achieve what I'm looking for. However I'm not using SfChart here but Chart. I tried using this code but it didn't work:

Axis.StripLines.Add(new ChartStripLine() { Stroke = new Pen(Brushes.Black, 2), IsEnabled = true, Start = StripLineStart, Width = StripLineWidth, Interior = Brushes.LightGray });

I took a look at the sample you attached and noticed that the gridLines and minorGridLines under the Strip line are not visible. Can something be done about that? If not then I'll just settle for using the Annotation but I don't think that is supported in the Chart object (only the SfChart). Please correct me if I'm wrong there.

Thanks again.

James


SS Suresh S Syncfusion Team June 12, 2015 07:08 AM UTC

Hi James,

Thanks for update.

We have analyzed your query and classic chart control supports both Annotations, Striplines and axis gridlines will be visible by default when striplines is placed. For more information regarding this refer our below help documentation link. We have modified the below sample based on this, please download from below location,

Ug link1: http://help.syncfusion.com/ug/wpf/Documents/chartstriplines.htm

Ug link2: http://help.syncfusion.com/ug/wpf/Documents/annotations2.htm

Sample: chart

Please let us know in case of any query.

Regards,

Suresh S


Loader.
Up arrow icon