Draft
Conversation
Author
|
Any input and/or feedback very much appreciated! |
Contributor
|
Thanks for this PR! uPlot is a great choice for high-performance charting, and this is a solid start. We tested the element successfully with the following code: from nicegui import ui
from nicegui.elements.uplot.uplot import UPlot
import math
x_data = list(range(100))
y_data = [math.sin(i * 0.1) for i in range(100)]
chart = UPlot({
'width': 800,
'height': 400,
'title': 'Sine Wave',
'series': [{}, {'stroke': 'red', 'label': 'sin(x)'}],
}, data=[x_data, y_data])
@ui.button('Add Point').on_click
def add_point():
x_data.append(len(x_data))
y_data.append(math.sin(len(y_data) * 0.1))
chart.update_data([x_data, y_data])
ui.run()A few things we noticed while looking at the code:
Looking forward to seeing this evolve! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
This PR introduces support for uPlot, a high-performance, memory-efficient 2D plotting library. This was originally requested in #2669, but also motivated by issues related to large dataset plotting such as #3340. Compared to other plotting libraries, it has a smaller memory footprint and less overhead on rendering, which makes it ideal for processing large datasets at high refresh rates.
Implementation
The core implementation wraps uPlot as a NiceGUI element, based on uplot-vue, which exposes uPlot's config and data update mechanisms.
The design anticipates plugin support, with plans to add Wheel Zoom & Drag and legend-as-a-tooltip plugins .
The update logic should be structured to allow zoom/drag state to persist across data updates, as demonstrated in #2669 .
Some important technical considerations include keeping the API simple and extensible, down sampling support, plugin support and implementing tests.
Progress