I have a c# xaml project and I want to create a plot that depicts real time a fuction an output variable. I want to plot every time the new value of a variable in fact and demostrate it in a diagram in xaml. How can I do so? I am using .NET 4.5. I tried to followed the answer below. I created the following code:
private void AddChart(List<float> scores)
{
// Draw sine chart:
polyline = new Polyline { Stroke = Brushes.Black };
for (int i = 0; i < scores.Count; i++)
{
var y = scores[i];
polyline.Points.Add(CorrespondingPoint(new Point(i, y)));
}
canvas.Children.Add(polyline);
}
private Point CorrespondingPoint(Point pt)
{
var result = new Point
{
X = (pt.X - xmin) * canvas.Width / (xmax - xmin),
Y = canvas.Height - (pt.Y - ymin) * canvas.Height
/ (ymax - ymin)
};
return result;
}
AddChart take as an input a list of scores which every time that the function is called is updated and plot it. However it doesnt seem to work like this. Could anyone help on this? How can I add axis in the plot?