3
votes

I'm using DevExpress for WinForms (the free one) and I'm using a 3D pie chart. I already have a chart using the Windows version and all I do is pass four variables as the values the chart needs in the series. Here's the code I use currently.

double[] yValues = { bottom, bmid, tmid, top};
string[] xNames = { "Greater than 200", "Between 200-100", "Between 100-50",                "Below 50" };

chart1.Series[0].Points.DataBindXY(xNames, yValues);

Now, I've made a DevExpress chart and tried to use:

   Devchart1.series[0].points   

but points.databind does not exist. Does anyone know how I bind the data like I have using WinForms?

UPDATE Here's some more things I tried (commented out).

        double[] yValues = { bottom, bmid, tmid, top};
        string[] xNames = { "Greater than 200", "Between 200-100", "Between 100-50", "Below 50" };

        chart1.Series[0].Points.DataBindXY(xNames, yValues);

        DataTable chartTable = new DataTable("Table1");

        // Add two columns to the table.
        chartTable.Columns.Add("Names", typeof(string));
        chartTable.Columns.Add("Value", typeof(Int32));
        chartTable.Rows.Add("Below 50", top);
        chartTable.Rows.Add("Between 50-100", tmid);
        chartTable.Rows.Add("Between 100-200", bmid);
        chartTable.Rows.Add("Greater than 200", top);

        Series series1 = new Series("Series1", ViewType.Pie3D);

        chartControl2.Series.Add(series1);

        series1.DataSource = chartTable;
        series1.ArgumentScaleType = ScaleType.Qualitative;
        series1.ArgumentDataMember = "names";
        series1.ValueScaleType = ScaleType.Numerical;
        series1.ValueDataMembers.AddRange(new string[] { "Value" });
        //((Pie3DSeriesView)series1.View). = true;
        //((pie)chartControl2.Diagram).AxisY.Visible = false;
        chartControl2.Legend.Visible = false;

        // Dock the chart into its parent and add it to the current form.
        chart1.Dock = DockStyle.Fill;

::UPDATE2:: heres what happens with this code with values 101, 22, 20 and 15. enter image description here

1

1 Answers

3
votes

DevExpress Series has DataSource property for binding.

Check this article. Hope it helps

UPDATE: I use your code and it seems to work fine

        DataTable chartTable = new DataTable("Table1");

        // Add two columns to the table.
        chartTable.Columns.Add("Names", typeof(string));
        chartTable.Columns.Add("Value", typeof(Int32));
        chartTable.Rows.Add("Below 50", 10);
        chartTable.Rows.Add("Between 50-100", 10);
        chartTable.Rows.Add("Between 100-200", 10);
        chartTable.Rows.Add("Greater than 200", 10);

        Series series1 = new Series("Series1", ViewType.Pie3D);

        //chartControl1.Series.Clear();
        chartControl2.Series.Add(series1);

        series1.DataSource = chartTable;
        series1.ArgumentScaleType = ScaleType.Qualitative;
        series1.ArgumentDataMember = "names";
        series1.ValueScaleType = ScaleType.Numerical;
        series1.ValueDataMembers.AddRange(new string[] { "Value" });
        //((Pie3DSeriesView)series1.View). = true;
        //((pie)chartControl2.Diagram).AxisY.Visible = false;
        chartControl2.Legend.Visible = false;

enter image description here