Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1285
Code Behind Samples
posted

Hi

I am trying to convert some legacy code from your Silverlight xamWebChart to the WPF xmDataChart and am having problems due mainly to the lack of real world examples.

All our charts are rendered in code (no XAML) and I have succeeded in getting the Line Charts and the Column Charts working based on your DataTable example.

I cannot however get the Stacked Column Chart or the Pie Chart working based on a DataTable data source - can you provide any examples of these being created in code please?

Many thanks

Andrew Hunot

Parents
No Data
Reply
  • 34430
    Verified Answer
    Offline posted

    Hello Andrew,

    To begin, I would recommend that you take a look at the two following articles in our online documentation that show how to create a StackedColumnSeries programmatically in WPF:http://help.infragistics.com/doc/WPF/2016.1/CLR4.0/?page=DataChart_Category_Stacked_Column_Series.html.

    It doesn't appear at the moment that our online documentation has a programmatic example for the XamPieChart, but the concept to take away from it is that you currently need to set the ItemsSource, LabelMemberPath, and ValueMemberPath properties of the XamPieChart for it to work. This can be seen here: http://help.infragistics.com/doc/WPF/2016.1/CLR4.0/?page=PieChart_Data_Binding.html.

    The above documentation articles do not show usage with a DataTable, but the main idea is that the ItemsSource of the XamPieChart and the ItemsSource of the CategoryXAxis and StackedColumnSeries both expect a derivation of IEnumerable. The DataTable itself does not derive from this interface, but the DataView exposed by the DataTable's DefaultView property does, and so if you set the ItemsSource to your table's DefaultView in this case, everything should work normally.

    To demonstrate this, I have created a sample project where I create both a XamPieChart and a XamDataChart with a StackedColumnSeries purely in C# code. This sample project is attached.

    I hope this helps. Please let me know if you have any other questions or concerns on this matter.

    Sincerely,
    Andrew
    Associate Developer

    XamDataChartPieTableDemo.zip
Children