Jump to content
Software FX Community

Clearing Default Data and Showing Multiple Lines


bobt
 Share

Recommended Posts

I am using the ChartFX 8 WPF Beta.  I have two questions about data binding.

1) How do I remove or clear the default data that shows up with the chart? Even if I have not bound data to the chart, there is still data, but upon object inspection using the debugger, I did not see the values in the Chart.Data or Chart.Points properties.

2) Why does the Bar gallery naturally show multiple series, but the Line gallery does not?  I am adding multiple SeriesAttribute object to the Chart.Series collection at run time upon notification of OnDataContextChanged.  The same code snippet below works for the Bar gallery, but not the Line gallery.  What should I do differently?

Many thanks.

 for (int j = 0; j < argCurveFamily.Curves.Count; j++)

{

SeriesData sd = argCurveFamily.Curves[j];SeriesAttributes sa = new SeriesAttributes();

MyChart.Series.Add(sa);

sa.ItemsSource = sd.Points;

sa.BindingPath = "Y";

sa.BindingPathX =

"X";

} 

Link to comment
Share on other sites

1) You can remove our random data or your own data doing this

chart1.Series.Clear();chart1.ItemsSource =

null;

2) Bar can also show multiple series but we do not support X values in bars by default, you can see this by commenting out the BindingPathX setting. We have a new build where you can optionally turn on X support for bars, to do this you have to specify a single width your bars will have. If you want to use this functionality please drop an email to wpf at softwarefx dot com.

Regards,

JuanC

Link to comment
Share on other sites

I tried calling a Reset() method with the 2 lines of code you suggested; however, manually setting ItemsSource to null forces the whole chart to be blank, although I subsequently add the data through the SeriesAttributeCollection property. 

Interestingly, ItemsSource is already null so resetting this dependency property to null is refiring some background events that white out other default properties.

Thoughts?

Link to comment
Share on other sites

Can you explain more your scenario?

- What do you want to see when your window/page is displayed? empty chart?

-At what point are you ready to pass data to the chart? Window Constructor? OnLoaded? Timer?

Also if you could post a small sample app it would make it easier for us to either duplicate the issues you are experiencing or suggest changes.

Regards,

JuanC

post-5152-13922406328344_thumb.jpg

Link to comment
Share on other sites

I appreciate your follow up. 

I was able to solve the problem by _not_ setting the Chart.Series.Count before adding the series themselves.  I simply call Chart.Series.Clear() as you suggested.  Data is passed to the chart during the OnDataContextChanged dependency properties event.

Thanks,

Bishr

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...