Call Render() automatically when plottable content (not count) changes
See original GitHub issueScottPlot Version: 4.1.15
Operating System: Windows 10
Application Type: WinForms
Bug Description: First signal selected renders as expected. Updating a plot with a different signal does not cause the plot to re-render (i.e. first signal continues to be displayed). If I change the number of signals (e.g. I select 2 signals), it does re-render.
Reproducing: See code sample below.
// ListBox control fires this event. Multiple selections allowed. Fires as expected.
private void SignalLb_SelectedIndexChanged(object sender, EventArgs e)
{
var lb = (ListBox)sender;
List<string> selectedSignals = new();
foreach (var item in lb.SelectedItems)
{
var signalName = item.ToString();
selectedSignals.Add(signalName);
}
var rtData = SocketClient.GetRealTimeDataResponse(selectedSignals.ToArray(), 60);
var plot = TrendPlot.Plot;
plot.Clear();
plot.XAxis.DateTimeFormat(true);
plot.Legend(true, ScottPlot.Alignment.UpperLeft);
foreach (var signal in rtData.Values)
{
AddSignalToPlot(signal.Key, signal.Value);
}
plot.Render();
}
private void AddSignalToPlot(string name, Dictionary<DateTime, object> data)
{
var plot = TrendPlot.Plot;
try
{
double[] xs = data.Select(x => x.Key.ToOADate()).ToArray();
double[] ys = data.Select(x => Convert.ToDouble(x.Value)).ToArray();
var scatter = plot.AddScatter(xs, ys, label: name);
}
catch (Exception ex)
{
MessageBox.Show($"Error while plotting signal: {ex.Message}", "Plot Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
python - How to update a plot in matplotlib
I allow the user to specify the units in the time scale (x-axis) and then I recalculate and call this function plots() ....
Read more >Rendering One Million Datapoints with D3 and WebGL
Finally, the D3 selection that renders the chart is wrapped in a redraw function so that it can be called repeatedly whenever the...
Read more >pyvista.Plotter — PyVista 0.38.5 documentation
Plotting object to display vtk meshes or numpy arrays. ... Plotter.add_blurring () ... Clear all callback methods previously registered with render() .
Read more >Advanced Callbacks | Dash for Python Documentation
If a Dash app has multiple callbacks, the dash-renderer requests callbacks to be executed based on whether or not they can be immediately...
Read more >Using Observable
Observable Plot — High level plotting library for exploratory data visualization. The libraries are somewhat special because they are automatically available ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the attention, @swharden ! Using the
Render
call after modifying the plot fixes the behavior for me, as you suggested. I’m not sure of the best way to document it. Also, this is a great addition to the CS community, so thanks for your effort!You are correct, GUIDs/UUIDs are often used as the primary keys in databases (or ID or similar thing in non-relational DBs) because they are considered to be unique, even across tables or servers. There’s a whole debate over integer vs GUID vs string primary keys and their implications, especially around their performance as clustering keys. It’s a google rabbithole that’s come up surprisingly often for me recently.
They’re considered to be unique because they’re 128 bit numbers, so when properly generated the chances of repetition are beyond miniscule.
As for the
CollectionChanged<T>
, that’s nice, I hadn’t known there was a built in class. Probably makes more sense to have it on the object rather than requiring us to remember to keep track of it ourselves.