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.

Trying to set series data programatically with WPF chart

Thread ID:

Created:

Updated:

Platform:

Replies:

97308 Nov 16,2010 04:49 PM Nov 19,2010 12:10 AM WPF 3
loading
Tags: Chart
John Fairbanks
Asked On November 16, 2010 04:49 PM

Why doesn't this work? The axes don't scale and the line never plots... I'm lost...

CODE BEHIND:

public class TimePoint
{
public DateTime X { get; set; }
public DateTime Y { get; set; }
}

public void AddSeries()
{
ObservableCollection points = new
ObservableCollection();

points.Add(new TimePoint{X = new DateTime(2010, 1, 1), Y = 5 });
points.Add(new TimePoint{X = new DateTime(2010, 1, 2), Y = 15 });
points.Add(new TimePoint{X = new DateTime(2010, 1, 3), Y = 5 });
points.Add(new TimePoint{X = new DateTime(2010, 1, 4), Y = 35 });
points.Add(new TimePoint{X = new DateTime(2010, 1, 5), Y = 5 });

ChartSeries s = new ChartSeries(ChartTypes.FastLine);
s.StrokeThickness = 2;
s.BindingPathX = "X";
s.BindingPathsY = new List { "Y" };
s.DataSource = points;
chart1.Areas[0].Series.Add(s);
}


XAML:






DateTimeInterval="1.00:00:00" ValueType="DateTime" />












Senthilkumar N [Syncfusion]
Replied On November 18, 2010 12:31 AM

Hi John,

Thanks for choosing Syncfusion products.

The Definition of value type for Y Property is set as DateTime. But it is initialized as integer in ObservableCollection. This makes the chart not rendered. I have modified your code like following:

The modified sample code snippet is:

public class TimePoint
{
public DateTime X { get; set; }
public int Y { get; set; }
}

I have attached a sample illustrating this and the sample can be obtained from the following location.

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=97308163757423.zip

Let me know if you have any queries.

Regards,
Senthilkumar



John Fairbanks
Replied On November 18, 2010 10:12 AM

I knew I must be doing something stupid! Thanks! :-)


Senthilkumar N [Syncfusion]
Replied On November 19, 2010 12:10 AM

Hi John,

We are glad to hear that your problem has been resolved. Please do not hesitate to open a new support incident if you ever need further assistance from us.

Thanks for choosing Syncfusion Products.

Regards,
Senthilkumar



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.

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.

;