This is a migrated thread and some comments may be shown as answers.

line graph with unique x values

1 Answer 45 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Iron
Dan asked on 12 Sep 2011, 09:57 PM
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

1 Answer, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 15 Sep 2011, 07:44 AM
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
Tags
Chart (Obsolete)
Asked by
Dan
Top achievements
Rank 1
Iron
Answers by
Yavor
Telerik team
Share this question
or