I have points of the form (x,y) and I need to plot these points on a graph(line graph).The graph needs to be continuous and not discrete.This I need to do in C# using some API for graphs and not by graphics library.Please suggest how to do and If possible please share the code as well.
2 Answers
If you can use standard Chart control from Windows Forms, then this code:
chart1.ChartAreas[0].Axes[0].Title = "N";
chart1.ChartAreas[0].Axes[1].Title = "FIB(N)";
chart1.Series[0].ChartType = SeriesChartType.Line;
chart1.Series[0].MarkerStyle = MarkerStyle.Circle;
chart1.Series[0].LegendText = "Fibonacci numbers";
Tuple<int,int> t = Tuple.Create(0,1);
for(int i = 1; i <= 30; i++){
chart1.Series[0].Points.Add(new DataPoint(i, t.Item1));
t = Tuple.Create(t.Item2, t.Item1 + t.Item2);
}
This will draw Fibonacci Sequence continuous XY graph.
Comments
If you can use WPF then check out Dynamic Data Display. They even have a demo of a continuous graph that re-scales as it goes along.