Configure chart (C#)

Thread is closed for posting
2 posts, 0 answers
  1. Martin
    Martin avatar
    12 posts
    Member since:
    Jul 2010

    Posted 14 Mar 2011 Link to this post

    I am sure this is pretty simple but I can't seem to find the answer on here.

    I have a stored procedure that returns 3 columns (MonthID, MonthLabel, Totals), I have bound this using a dataset to a RadChart in the code behind but it renders all the values.

    My stored procedure returns:
    MonthID        MonthLabel        Totals
    1                    Jan                     2
    2                    Feb                    9
    etc, etc


    How can I configure the control to show Totals(Y axis) and MonthLabel(X axis)

    Many thanks
  2. Martin
    Martin avatar
    12 posts
    Member since:
    Jul 2010

    Posted 15 Mar 2011 Link to this post

    Taken ages but I've managed to figure this out, answer below in case anyone has the same problem.

    //Remove unwanted series
    EnquiriesChart.Series.RemoveAt(0);
     
    //Set chart properties
    EnquiriesChart.ChartTitle.TextBlock.Text = "Enquiries " + YearDDL.SelectedItem.Value;
    EnquiriesChart.Width = 914;
    EnquiriesChart.PlotArea.XAxis.AxisLabel.TextBlock.Text = "Months";
    EnquiriesChart.PlotArea.XAxis.AxisLabel.TextBlock.Appearance.TextProperties.Color = System.Drawing.ColorTranslator.FromHtml("#666666");
    EnquiriesChart.PlotArea.XAxis.AxisLabel.Visible = true;
    EnquiriesChart.PlotArea.EmptySeriesMessage.TextBlock.Text = "No data for the year selected.";
     
    //Set X-Axis to show months
    EnquiriesChart.PlotArea.XAxis.AutoScale = false;
    EnquiriesChart.PlotArea.XAxis.AddRange(1, 12, 1);
    EnquiriesChart.PlotArea.XAxis[0].TextBlock.Text = "Jan";
    EnquiriesChart.PlotArea.XAxis[1].TextBlock.Text = "Feb";
    EnquiriesChart.PlotArea.XAxis[2].TextBlock.Text = "Mar";
    EnquiriesChart.PlotArea.XAxis[3].TextBlock.Text = "Apr";
    EnquiriesChart.PlotArea.XAxis[4].TextBlock.Text = "May";
    EnquiriesChart.PlotArea.XAxis[5].TextBlock.Text = "Jun";
    EnquiriesChart.PlotArea.XAxis[6].TextBlock.Text = "Jul";
    EnquiriesChart.PlotArea.XAxis[7].TextBlock.Text = "Aug";
    EnquiriesChart.PlotArea.XAxis[8].TextBlock.Text = "Sep";
    EnquiriesChart.PlotArea.XAxis[9].TextBlock.Text = "Oct";
    EnquiriesChart.PlotArea.XAxis[10].TextBlock.Text = "Nov";
    EnquiriesChart.PlotArea.XAxis[11].TextBlock.Text = "Dec";
     
    //Set Y-Axis scale
    EnquiriesChart.PlotArea.YAxis.AutoScale = false;
    EnquiriesChart.PlotArea.YAxis.MinValue = 0;
    EnquiriesChart.PlotArea.YAxis.MaxValue = 50;
    EnquiriesChart.PlotArea.YAxis.Step = 5;
Back to Top