line graph with unique x values

Thread is closed for posting
2 posts, 0 answers
  1. Dan
    Dan avatar
    1 posts
    Member since:
    Jun 2011

    Posted 12 Sep 2011 Link to this post

    Hi,

    I have been working with the chart control to make a line chart with x & y values from an external data source. The x values may be very unevenly spaced decimals values or negative numbers, so I need to set the items on this axis from code. Can someone give me a good example of how to do this?

    I have a poorly functioning example below. Unfortunately, this example graphs both values as two lines.
    protected void Page_Load(object sender, EventArgs e)
    {
        List<MyObject> myList = new List<MyObject>();
     
        myList.Add(new MyObject { yValue = 3, xValue = -20 });
        myList.Add(new MyObject { yValue = -1, xValue = -10 });
        myList.Add(new MyObject { yValue = -5, xValue = 3 });
        myList.Add(new MyObject { yValue = 1, xValue = 5 });
        myList.Add(new MyObject { yValue = 8, xValue = 6.5 });
        myList.Add(new MyObject { yValue = 4, xValue = 7 });
        myList.Add(new MyObject { yValue = 3, xValue = 10 });
        myList.Add(new MyObject { yValue = 7, xValue = 15 });
     
        RadChart1.PlotArea.XAxis.IsZeroBased = false;
        RadChart1.DataSource = myList;
        RadChart1.PlotArea.XAxis.DataLabelsColumn = "xValue";
         
        RadChart1.DataBind();
    }
     
    public class MyObject
    {
        public double yValue { get; set; }
        public double xValue { get; set; }
    }

    Thank you for you help!
    Dan
  2. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 15 Sep 2011 Link to this post

    Hi Dan,

    If you would like to set the text of the labels along the axis from code, please take a look at the following article:

    http://www.telerik.com/help/aspnet-ajax/radchart-how-to-add-axis-labels-programmatically.html

    I hope this gets you started properly.

    Regards,
    Yavor
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top