question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is it possible to use ScottPlot with Data Binding on plottables?

See original GitHub issue

I couldn’t find anywhere if it is possible.

I’ve used Syncfusion SfChart before, and it is possible to bind the the chart with it’s series collection, for exemple: <chart:SfChart x:Name="SfChart1" Series="{Binding SeriesCollection}" >

Thant would be amazing to do something similar with ScottPlot, so whenever I update a plottable, the chart updates. <WpfPlot Name="wpfPlot1" Plottables={Binding PlottablesCollection} />

Also, if there is any material about using ScottPlot with mvvm pattern, I would appreciate.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
StendProgcommented, Jul 28, 2020

The last question about this, you said about declaring xs[] and ys[] in my ViewModel, not in my View.xaml.cs (code behind). In my ViewModel I’m unnable to interact with wpfPlot and it’s Plottable.

You can create WpfPlot in ViewModel:

public class SomeViewModel: INotifyPropertyChange
{
    public WPFPlot plotControl {get;set;} 
    public SomeViewModel()
    {
       plotControl = new WPFPlot();
       plotControl.Width = ... // manual setup control
    }
}

and bind it in you view:

<ContentControl Content={Binding plotControl}>

It’s bad pattern bring control to VM, but it should work.

I checked the GrovingData demo but I couldn’t find it’s source code.

https://github.com/swharden/ScottPlot/blob/master/src/ScottPlot.Demo.WPF/WpfDemos/LiveDataGrowing.xaml.cs

0reactions
swhardencommented, Aug 9, 2020

Hey @eduhza, thanks for raising this issue, and @StendProg for your insightful comments along the way.

@StendProg described the state of ScottPlot very well, and I’ll just add a couple comments for additional context.

MVVM pattern is very common in the .NET word (and is used by many .NET charting libraries, especially for WPF) but ScottPlot’s API was designed to mimic that of matplotlib (a very popular charting library for Python) which uses sequential method calls to load data with numerous optional arguments for style customization.

ScottPlot was designed to make it as easy as possible to create plots from console applications (with WinForms and WPF controls provided as lite wrappers to provide interactivity in GUI environments). As @StendProg noted, adapting it to fit MVVM would be pretty difficult to do well. The best way to go, for now, is for the programmer to control data updates and rendering manually.

@eduhza if you have more questions along the way let us know! Similarly, if your tests reveal interesting findings feel free to share them here. I’ll close this issue for now, but thanks again for opening it initially.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ScottPlot does not plot when data template is used
1 Answer. Scott Plot is not implemented as a proper WPF control that supports data-binding and MVVM.
Read more >
Plot Data with ScottPlot
ScottPlot is a free and open-source interactive plotting library for .NET. It has user controls for Windows Forms, WPF, Avalonia, ...
Read more >
Data wrangling and visualization in the tidyverse
Use summarize , group_by , and tally to split a data frame into groups of ... Use the ggplot() function and bind the...
Read more >
sas.plottools package — SasView 3.0.0 documentation
Our solution is to provide parametric styles, in which a number of different classes of object (e.g., reflectometry data, reflectometry theory) representing ...
Read more >
Plotly.NET Plotly.NET
CSharp , native C# bindings that make the usage of Plotly.NET more idiomatic from C#. This is work in progress. Missing charts and/or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found