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.
Thank you for you help!
Dan
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