royben/RealTimeGraphX

Are there any beginner friendly tutorials available?

Dirt-e opened this issue · 2 comments

As a beginner, I managed to get the demo project running, but what do I have to do to use these graphs in my own (WPF) project? Do I have to add a reference somewhere? Or copy some files into my project folders?
Those graphs look nice for sure, and I would love to use them, but is there a beginner friendly tutorial somewhere? Help is much appreciated :-)

i just copied over all of the classes in the RealTimeGraphX project over to mine, and the same with the RealTimeGraphX.WPF stuff. then i copied over the WpfGraphControl from the RealTimegraphX.WPF.Demo, linked everything together again by changing the namespaces for everything (you could leave them as they are, but i prefer not to use multiple projects). and finally, in my MainWindow i just copied over the code in the RealTimeGraphX.WPF.Demo.MainWindow. you obviously need a viewmodel for the mainwindow in order to bind the controller, so i made a MainViewModel and the code in that came from RealTimeGraphX.WPF.Demo.MainWindowVM.cs.

overall though, if you want to plot normal points, do Controller.PushData(XPos, YPos);. if you want a time graph, create a StopWatch, start it, and then (asynchronously, using Task.Run if you want) create a while (true) loop and call the Controller.PushData(stopWatch.Elapsed, YPos).

this is most of my code (located in the MainViewModel):
``public MainViewModel()
{
Controller = new WpfGraphController<TimeSpanDataPoint, DoubleDataPoint>();
Controller.Range.MinimumY = 0;
Controller.Range.MaximumY = 1024;
Controller.Range.MaximumX = TimeSpan.FromSeconds(10);
Controller.Range.AutoY = true;

Controller.DataSeriesCollection.Add(new WpfGraphDataSeries()
{
    Name = "Serial Values",
    Stroke = Color.FromRgb(11, 99, 205)
});
PlotLoopRunning = true;
StartPlotting();

}

private Stopwatch GraphStopWatch = new Stopwatch();
private bool PlotLoopRunning;
public void StartPlotting()
{
PlotLoopRunning = true;
GraphStopWatch = new Stopwatch();
GraphStopWatch.Start();

Task.Factory.StartNew(() =>
{
    while (PlotLoopRunning)
    {
        var y = System.Windows.Forms.Cursor.Position.Y;

        Controller.PushData(GraphStopWatch.Elapsed, y);

        Thread.Sleep(30);
    }
});

}

public void StopPlotting()
{
PlotLoopRunning = false;
GraphStopWatch.Stop();
}``

Thanks a lot for the help! I will give this a try.