Search code examples
winformsdevexpressxtrareport

XRChart Pie Chart from 2 values


I am creating a DevExpress XtraReport - report.

I have a grouped table with similar values to this:

Model | Passed | Failed | Total | 
Test1 |   4    |   5    |   9
Test3 |   2    |   1    |   3

Now I want to convert this data to a PieChart.

What I want to do is Create two labels, named Passing and failing. And bind my data to each of these. But that seems to be impossible.

XRChart will only allow me to create static Labels with no option to bind to it, or create a series with dynamically selected labels based on the grouping instead of the columns.

Meaning I can easily get Test1.Total vs Test3.Total

But not Test1.Passed vs Test1.Failed and Test3.Passed vs Test3.Failed

How can this even be hard, I must be missing something.


Solution

  • Assuming that you want to display separate Pie with test results for every row in your data source collection ("Test1", "Test2"), you will need to change the data structure to make it compatible with the "Series Template" feature supported by the DevExpress charting component (see the https://documentation.devexpress.com/XtraReports/4575/Examples/Use-Charts-Grids-and-Custom-Controls/How-to-Create-a-Report-with-a-Chart-Bound-to-Data-Using-Series-Templates article for additional information). For instance, the following data schema will allow you to generate two Pie charts:

    SeriesDataMember ArgumentDataMember ValueDataMembers (see the XRChart.SeriesDataMember, XRChart.SeriesTemplate.ArgumentDataMember and XRChart.SeriesTemplate.ValueDataMembers properties)

    Test1        Passed         4
    Test1         Failed         5
    Test2         Passed         2
    Test2         Failed         1
    

    See also: https://documentation.devexpress.com/WindowsForms/6063/Controls-and-Libraries/Chart-Control/Examples/Creating-Charts/Data-Representation/How-to-Change-the-Display-Format-for-Series-Labels-of-a-Pie-Chart.

    You can also contact DevExpress Support Team directly by submitting a ticket using their Support Center portal.