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
400
Others wedge not showing in PieChart3D
posted

I have a problem where if I set the UltraChart.PieChart3D.ColumnIndex to a value other than -1 (the default) or to the column index of the first numeric column in my datatable, the Others wedge isn't drawn in the pie. It seems like a UltraChart bug to me.

I have a DataTable with 3 columns (String, Double, Double). By default, the pie chart uses the 1st column as the labels and charts the 2nd column. If I use the PieChart3D.ColumnIndex (or PieChart3D.SetDataColumnIndex method) to chart the 3rd column instead, the pie is drawn as if the Others wedge had 0 value.

I can work around this by swaping the 2nd and 3rd columns, but wanted to check to see if there was something simpler that I had missed.

Here's code for a form that demonstrates the problem:

    public partial class Form1 : Form
    {
        private const String PIE_CHART_LABEL_MULTILINE = "<ITEM_LABEL>\n<DATA_VALUE:#,##0.00>\n<PERCENT_VALUE:#0.00>%";
        private Infragistics.Win.UltraWinChart.UltraChart ultraChart1;

        public Form1()
        {
            this.SuspendLayout();

            ultraChart1 = new Infragistics.Win.UltraWinChart.UltraChart();
            ultraChart1.Dock = DockStyle.Fill;
            this.Controls.Add(ultraChart1);

            this.ResumeLayout();

            this.Load += new EventHandler(Form1_Load);
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            DataTable dataTable = new DataTable();
            DataColumn textCol = new DataColumn("Text", typeof(String));
            DataColumn numCol1 = new DataColumn("Num1", typeof(Double));
            DataColumn numCol2 = new DataColumn("Num2", typeof(Double));
            dataTable.Columns.AddRange(new DataColumn[ { textCol, numCol1, numCol2 });

            dataTable.Rows.Add(new object[ { "A", -1, 20 });
            dataTable.Rows.Add(new object[ { "B", 10, 50 });
            dataTable.Rows.Add(new object[ { "C", -15, 10 });
            dataTable.Rows.Add(new object[ { "D", 51, 4 });
            dataTable.Rows.Add(new object[ { "E", 31, 5 });
            dataTable.Rows.Add(new object[ { "F", -21, 120 });
            dataTable.Rows.Add(new object[ { "G", 81, 60 });
            dataTable.Rows.Add(new object[ { "H", 21, 30 });

            ultraChart1.DataSource = dataTable;
            ultraChart1.ChartType = Infragistics.UltraChart.Shared.Styles.ChartType.PieChart3D;
            ultraChart1.Legend.Visible = true;
            ultraChart1.PieChart3D.Labels.FormatString = PIE_CHART_LABEL_MULTILINE;
            ultraChart1.Tooltips.FormatString = PIE_CHART_LABEL_MULTILINE;
            ultraChart1.PieChart3D.OthersCategoryPercent = 10.0;

            // Leave this at the default value of -1 or set it to 1 and the Others wedge is drawn.
            //
            // Set it to anything else and the Others wedge isn't drawn and:
            // - Others shows up in the legend
            // - Percentages in the Tooltip are correct (taking Others into account)
            // - Percentages in the Labels are wrong (they ignore the value of the Others)
            //
            // I've worked around it by using DataColumn.SetOrdinal() to move the column I want to
            // chart into the position of the first numeric column.
            ultraChart1.PieChart3D.ColumnIndex = 2;
            // ultraChart1.PieChart3D.SetDataColumnIndex(2);

            ultraChart1.DataBind();
        }
    }
 

--yale 

Parents
No Data
Reply
  • 26458
    Offline posted

    As a workaround, you can use chart.Data.IncludeColumn(1, false) to exclude your first numeric column. This way you still get data from the second column without having to use ColumnIndex.

Children
No Data