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
1060
What Chart to Use ?
posted

I have a 2 column datatable..

First Column is the Item

Second Column is the QuantitySold

 

This is to display a top 50 products sold...

I want it to look

 

Product 1  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Product 2 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Product 3 xxxxxxxxxxxxxxxxxxxxxxxxxxx

Product 4 xxxxxxxxxxxxxxxxxxxxxxxx

 

etc....

 

the xxxxx representing the column bar which would be longer if I sold more items.

 

What chart type should I use...

And How do i use the first column as the labels ?

 

thanks

Parents
No Data
Reply
  • 2406
    Verified Answer
    posted

    Hi,

    You need the Bar chart type:

    http://help.infragistics.com/NetAdvantage/WinForms/2010.1/CLR2.0/?page=Chart_Working_with_2D_Bar_Chart_Data.html

    Here is a sample code, demonstrating your desired behavior:

    public partial class Form1 : Form
    {
        UltraChart ultraChart1;
        public Form1()
        {
            InitializeComponent();
            ultraChart1 = new UltraChart();
            ultraChart1.ChartType = Infragistics.UltraChart.Shared.Styles.ChartType.BarChart;
            ultraChart1.Axis.Y.Labels.ItemFormat = AxisItemLabelFormat.None;
            ultraChart1.DataSource = GetTable();
            ultraChart1.DataBind();

            this.Controls.Add(ultraChart1);
        }

       
        private DataTable GetTable()
        {       
            DataTable mydata = new DataTable();
            //Define the columns and their names
            mydata.Columns.Add("Item", typeof(string));
            mydata.Columns.Add("QuantitySold", typeof(int));

            //Add the rows of data
            mydata.Rows.Add(new Object[] { "Product 1", 125 });
            mydata.Rows.Add(new Object[] { "Product 2", 15 });
            mydata.Rows.Add(new Object[] { "Product 3", 1 });
            mydata.Rows.Add(new Object[] { "Product 4", 25 });

            return mydata;
        }       
    }

     

Children