Reusing an existing DataLogger with a different Plot (WPF)

Open
#5,120 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp

Research direction

Start by reviewing the WPF DataLogger and Plot.Add APIs, along with the PlottableList behavior shown in the issue. Determine whether an existing logger can be attached to a second plot while preserving its live data, and define the expected behavior for the original plot and the shared data source.

Written by the indexing model from the issue text.

Description

Hello,

I'm working on a WPF application using ScottPlot 5.0.55 , and I have a situation where I want to reuse a DataLogger that was already created and added to a plot.

For example:

// First plot
var logger = WpfPlot1.Plot.Add.DataLogger();
for (int x = 0; x < 10; x++)
{
    logger.Add(x, Generate.RandomWalker.Next());
}
WpfPlot1.Refresh();

Later, I would like to move or reuse this same logger on another plot, like this:

// Reuse the same logger in a different plot
WpfPlot2.Plot.Add(logger);
WpfPlot2.Refresh();

I also tried adding the logger manually to the PlottableList, but this doesn't seem to work properly:

// is someThing wrong
WpfPlot2.Plot.PlottableList.Add(logger);  
WpfPlot2.Refresh();

WpfPlot1

Image

WpfPlot2

Image

However, it seems there is no direct API to attach an existing DataLogger to a different Plot.
Is there a recommended way to do this? Or would it require recreating the logger and copying its data manually?

Use case: I want to toggle between different views that share the same live data source without duplicating the data unnecessarily.

Thank you!

Dominant language
C#
Stars
6.8k
Forks
1k
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ScottPlot/ScottPlot

All issues in ScottPlot/ScottPlot

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.