Git Product home page Git Product logo

Comments (4)

Khanhlinhdang avatar Khanhlinhdang commented on May 26, 2024 1

Thank you much sir!
I did it. i create a custom viewbox, custom axis, and put them to a plotitem and then put plotitem into plotwidget. I can fully custom all of them. it is so good.

from pglive.

domarm-comat avatar domarm-comat commented on May 26, 2024

To answer first part of your question. You can get viewbox by calling viewbox = plot.getViewBox(). But if your aim is to modify mouse events, I would suggest to overload LivePlotWidget with your custom event handlers.
Here is an example (getting ViewBox is there as well):

import signal
from threading import Thread
import pglive.examples_pyqt5 as examples
from pglive.sources.data_connector import DataConnector
from pglive.sources.live_candleStickPlot import LiveCandleStickPlot
from pglive.sources.live_plot_widget import LivePlotWidget
from pyqtgraph import QtCore  # type: ignore

"""
In this example candlestick plot is displayed.
"""
class CustomLivePlotWidget(LivePlotWidget):

    def mouseMoveEvent(self, ev: QtCore.QEvent) -> None:
        super().mouseMoveEvent(ev)
        print("Mouse move:", ev.pos())

    def wheelEvent(self, ev):
        super().wheelEvent(ev)
        print("Mouse wheel:", ev.angleDelta())

win = CustomLivePlotWidget(title="Candlestick Plot @ 10Hz")
plot = LiveCandleStickPlot()
win.addItem(plot)

data_connector = DataConnector(plot, max_points=50, update_rate=10)

# Get viewbox
viewbox = plot.getViewBox()
print(viewbox)

win.show()

Thread(target=examples.candle_generator, args=(data_connector,)).start()
signal.signal(signal.SIGINT, lambda sig, frame: examples.stop())
examples.app.exec()
examples.stop()

Regarding second part of the question. I have to have a look at this. I'm not sure if the numpy array is limiting factor here. I would say it's the drawing part itself, as pglive is plotting all items every time plot is redrawn. Maybe there is some way to optimize it by caching some objects. How many candles do you expect to plot in your app?

You may consider using https://github.com/domarm-comat/pglive#plot-speed-optimizations to limit number of candles by using LiveAxisRange.

I will get back to you with this. I'm a bit busy right now, so please be patient :).

from pglive.

domarm-comat avatar domarm-comat commented on May 26, 2024

That's good to hear! You're welcome :).

Do you still have issue with the performance or you manage to optimize it to your liking?

from pglive.

Khanhlinhdang avatar Khanhlinhdang commented on May 26, 2024

I am still doing with my project, I will report and ask you if i have a problem. Thank for your time!

from pglive.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.