-
Notifications
You must be signed in to change notification settings - Fork 981
Closed
Labels
Help WantedScott won't do this soon, but PRs from the community are welcome!Scott won't do this soon, but PRs from the community are welcome!⚠️ HIGH PRIORITY
Description
Issue: When running a Datastream the Graph cannot be zoomed into further than the largest plotted data. Even though it has long dissapeared from the visible Data. (could there be a way to discharge the first data set in the DataStreamer Points arg?
ScottPlot Version: 5.0.23
Code Sample:
using ScottPlot;
namespace FinalFinal
{
public partial class Form1 : Form
{
private BackgroundWorker UIWorker;
public new List<double> dataX;
public new List<double> dataY;
public bool firstCon = false;
public ScottPlot.Plottables.DataStreamer StreamX;
public ScottPlot.Plottables.DataStreamer StreamY;
public Int32 AverageX1;
public Int32 AverageY1;
public int DisplayX1 = 0;
public int DisplayY1 = 0;
public Form1()
{
InitializeComponent();
if (firstCon == false)
{
initvoid();
}
UIWorker.DoWork += UIWorker_DoWork;
}
private void initvoid()
{
UIWorker = new BackgroundWorker();
StreamX = formsPlot1.Plot.Add.DataStreamer(100000);
StreamY = formsPlot1.Plot.Add.DataStreamer(100000);
dataX = new List<double>();
dataY = new List<double>();
firstCon = true;
StreamY.ViewScrollLeft();
StreamX.ViewScrollLeft();
}
public void NewRealtimeData(Int32 X1, Int32 Y1)
{
// DISPLAYX1 AND DISPLAYY1 ARE JUST TWO VALUES WHICH I MEASURE WITH A SENSOR
// Add X1 value to dataX list
dataX.Add(DisplayX1);
dataY.Add(DisplayY1);
//If dataX list is full, add it to the Streamer
if (dataX.Count >= 1000 && !UIWorker.IsBusy) // Adjust the threshold as needed
{
UIWorker.RunWorkerAsync();
}
}
private void UIWorker_DoWork(object sender, DoWorkEventArgs e)
{
if (IsHandleCreated)
{
Invoke(new Action(() =>
{
if (chkX.Checked)
{
StreamX.AddRange(dataX.ToArray()); // Add dataX list to Streamer
}
if (chkY.Checked)
{
StreamY.AddRange(dataY.ToArray());
}
formsPlot1.Refresh();
}));
}
dataX.Clear(); // Clear dataX list after adding to Streamer
dataY.Clear();
}
}
}This is a gif of what I mean (please ignore the two lines "Alarm")

Also I have a question regarding this / similar :
I want to display the X/Y Points in a scatter Plot. How can I only show the 100 newest points and discard the older ones?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Help WantedScott won't do this soon, but PRs from the community are welcome!Scott won't do this soon, but PRs from the community are welcome!⚠️ HIGH PRIORITY