€: Oops, I accidently wrote this in the wrong forum. I'm sorry.
Hello there,
I'm using C#, .NET Framework 4.8 (WPF) and I would like to know how to get a sub graph or range of a given graph?
Let's say, I build a graph of 20 points, where:
X = {0,1,...,19}
Y = random numbers in a range of (-20,20)
The graph would start on {0,-12}, and continues with {1,13}, {2,9}, ..., {19,0}.
I would like to get a sub graph in the range between 5 and 15, where {5,2} might be the new start point and ends on {15,-6}.
That is my idea:
public List<Coordinates> GetSubGraph(int startPos, int endPos) {
List<Coordinates> subGraph = new List<Coordinates>();
for(int i = startPos; i < endPos; i++) {
Coordinates c = LineGraph.ElementAt(i);
subGraph.Add(c);
}
return subGraph;
}
followed by:
// clear old graph
chartX.Series.Clear();
// this shall create the new graph
chartX.Series.Add(new LineSeries() {
ItemsSource = ViewModel.GetSubGraph(5, 15)
});
// refreshing
chartX.Refresh();
There're no errors on runtime, however, the graph won't be displayed as expexted.
I only see a "graph" from 5 to 15, where each Y point is fixed on 1.
What do I miss?
Thank you (:
[Modified 2 years ago]