Skip to content

DataLogger: use List<Coordinates> instead of IList<Coordinates> and document Data.RemoveRange()#4460

Merged
swharden merged 11 commits intoScottPlot:mainfrom
Fruchtzwerg94:data_logger_limit_option
Nov 8, 2024
Merged

DataLogger: use List<Coordinates> instead of IList<Coordinates> and document Data.RemoveRange()#4460
swharden merged 11 commits intoScottPlot:mainfrom
Fruchtzwerg94:data_logger_limit_option

Conversation

@Fruchtzwerg94
Copy link
Contributor

DataLogger does not allow to limit its points which means its points will increase forever.
Added two functions allowing to limit by X or length manually.

@swharden
Copy link
Member

swharden commented Nov 8, 2024

Hi @Fruchtzwerg94, thanks for this suggestion! I will modify this PR to adapt a similar but alternative implementation of this functionality, and will also document its use in the cookbook 👍

// setup a logger that will grow as data is added
var logger = myPlot.Add.DataLogger();

// add ten values
logger.Add(Generate.RandomSample(10));

// remove the oldest five values
for (int i=0; i<5; i++)
{
    logger.Data.Coordinates.RemoveAt(0);
}

image

@swharden swharden changed the title Option to limit DataLogger points by X or length DataLogger: document how to remove points Nov 8, 2024
@swharden swharden enabled auto-merge (squash) November 8, 2024 16:04
@swharden swharden disabled auto-merge November 8, 2024 16:04
@swharden swharden changed the title DataLogger: document how to remove points DataLogger: use List<Coordinates> instead of IList<Coordinates> and document Data.RemoveRange() Nov 8, 2024
@swharden swharden enabled auto-merge (squash) November 8, 2024 16:04
@swharden swharden merged commit ee21c32 into ScottPlot:main Nov 8, 2024
@Fruchtzwerg94
Copy link
Contributor Author

Hi @swharden ,

awesome, thanks for bringing it in so fast. A minor thing: Since DataLogger.HasNewData is private, it can't be set after items changed. Adding a way to set it would be nice as well. I can prepare a PR for it but I assume its faster for you just to bring in a minor change here without a PR.

Thanks,
Philipp

@swharden
Copy link
Member

swharden commented Nov 8, 2024

I can prepare a PR for it but I assume its faster for you just to bring in a minor change here without a PR

Actually if you're up for making a PR, I'd appreciate it! I can merge that from the browser (or even my phone) and don't have to keep switching branches on my local desktop setup 😄

@Fruchtzwerg94
Copy link
Contributor Author

See: #4470

@dlampa
Copy link
Contributor

dlampa commented Nov 13, 2024

How is one supposed to initialize a DataLogger with a CircularBuffer after this change? Is the CircularBuffer now obsolete?

@swharden
Copy link
Member

How is one supposed to initialize a DataLogger with a CircularBuffer after this change? Is the CircularBuffer now obsolete?

This is a good question! I opened up a new issue #4507 to track discussion of this topic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants