Git Product home page Git Product logo

Comments (4)

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

Thanks for using pglive!

I've created new pull request Designer example, which includes example for both PyQt5 and 6 designers.
Have a look and if it works for Your project, I will merge it into main branch.

In short: promote QWidget to LivePlotWidget and set header file to pglive.sources.live_plot_widget

from pglive.

optio50 avatar optio50 commented on May 23, 2024

Thanks for the additional examples.
I had difficulty applying the graph to the promoted widget, but that's likely due to me being brand new to PYQT.
I have never used pyqtgraph before so my experience is limited.
What I did instead of using a promoted widget is create an empty layout.
In the code I placed the widget into that empty layout. Seems to work for me.
9 lines of code was all it took.
Thanks for this super cool chart. I have 5 charts in a tab widget and it really make's the program an excellent tool.

Do you see any issue with making max points 24 hours with a update of 1 second intervals?
At that rate do you think the program can run for extended (days?) periods of time?
How are those accumulated point's stored?

from pglive.

optio50 avatar optio50 commented on May 23, 2024

Well, I did eventually figure it out. However, The previous method of the empty layout seems preferable to me.
Maybe because I dont convert the .ui file to a .py file. I load the .ui. in the main window .py file.
No need to promote the widget. just add it to the empty layout.

Chart Solar Watts

    watts_plot = LiveLinePlot(pen="orange")

    # Data connectors for each plot
    self.watts_connector = DataConnector(watts_plot, max_points=86400) # 24 hours in seconds

    # Setup bottom axis with TIME tick format
    # use Axis.DATETIME to show date
    bottom_axis = LiveAxis("bottom", **{Axis.TICK_FORMAT: Axis.TIME})

    # Create plot itself. Skip this if using promoted widget
    self.Solar_graph_Widget = LivePlotWidget(title="Solar Watts 24 Hrs", axisItems={'bottom': bottom_axis})  
    
    # Show grid
    self.Solar_graph_Widget.showGrid(x=True, y=True, alpha=0.3)
    
    # Set labels
    #self.Solar_graph_Widget.setLabel('bottom', 'Datetime', units='*')
    self.Solar_graph_Widget.setLabel('left', 'Watts')
    
    # Add Line
    self.Solar_graph_Widget.addItem(watts_plot)
    
    # Add chart to Empty Layout made in Qt Designer. # skip this if using promoted widget
    self.Chart_Watts_Layout.addWidget(self.Solar_graph_Widget) 

    # Place in the update function
    timestamp = time.time()
    self.watts_connector.cb_append_data_point(SolarWatts, timestamp)

from pglive.

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

I see. I always use pyuic converter to produce .py files from templates. But it's a matter of preference.
Adding widgets programmatically is much more convenient. Using Frames or Layouts with Designer as a placeholder for widgets is usually the best approach and easier to implement than promoting widgets.

Regarding Your other questions:
Number of points displayed depends on multiple factors. I think the safe bet would be to always set maximum displayed points per plot (as You already does). Try to set some limit which makes sense, usually big number of values are anyway hard to read by the user.
More limiting factor is update rate. With more parallel plots You should decrease update freq, 100Hz should be Your max.
In Your example code Your update rate is 1Hz which should be handled without issues.

Accumulated points are stored in deque. So if You set max_points=86400, this will create two deques for x and y. When max points is reached, first point is then discarded from the deque. So it's safe to run it for extended period of time.

As things are working for You now, I will merge it and close this issue.
Feel free to suggest another improvements and good luck with Your project :).

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.