Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Library for realtime graphs in perl.

by tobbes (Acolyte)
on Oct 17, 2018 at 11:58 UTC ( #1224153=perlquestion: print w/replies, xml ) Need Help??

tobbes has asked for the wisdom of the Perl Monks concerning the following question:

I am not able to find anything to suite my needs. The program needs to recieve data in realtime and plot them on a graph. Idealy the graph should also be interactive, you should be able to click on it and set listeners. I have found a very good module in python here https://matplotlib.org/ but unfortunately the script I am going to extend is written in perl. I have also tried to install Inline::Python without success as I am running windows 10. Does anyone know of a perl library resembling matplotlib?

Replies are listed 'Best First'.
Re: Library for realtime graphs in perl.
by zentara (Archbishop) on Oct 17, 2018 at 12:17 UTC
    Hi, see Tk Realtime data aquisition. It has a simple realtime graph on a Tk::Canvas. You will have to put some of your own work into it, if you want interactivity, but almost anything can be easily added. Read the comments if you are using MSWindows, for how to deal with Window's fileevent problems.

    I'm not really a human, but I play one on earth. ..... an animated JAPH
      Thanks, I will look into it.:)
        You might want to use 127.0.0.1 for the client ip address if testing on a single local machine. The 192.168.0.9 address was just for testing on my local network.
        #my $machine_addr = '192.168.0.9'; my $machine_addr = '127.0.0.1';

        I'm not really a human, but I play one on earth. ..... an animated JAPH
Re: Library for realtime graphs in perl.
by Discipulus (Abbot) on Oct 17, 2018 at 12:07 UTC
    Hello, tobbes,

    fortunately the program you have to extend is in Perl ;=)

    You can try GD::Graph and additionally you can take a look to doughnut charts with gd:graph where marto points to a useful article.

    See also this extract

    For the interactive part.. I suppose you need some web interface to achieve interactivity, or a GUI like a Tk program.

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
      Thanks. I have looked into GD::Graph, but as I have used it to get output you generate an image from it. Now, I will be needing to regenerate this imagefile at least 10 times per second and I am in doubt as to whether perl can generate images at that rate. Also the user should be able to watch the image as the graph is drawn. There are a number of javascript libraries for this (most notably maybe Google::Charts) but alas the users will have no access to the internet. There are other javascript opitons as well which abandoned for reasons I don't recall at the moment :).

        I don't think ten images per second is unreasonable. Of course, it depends on the amount of CPU you can dedicate to it, the complexity of the images, and how efficiently your code is written, but this article talks about GD generating an image in 0.003110 seconds and some digging in the Wayback Machine indicates that those numbers are from over ten years ago; on a modern CPU it should be faster. (The article was a test of the PHP bindings for LibGD, but it's the same underlying C library, so I don't see any reason why the Perl bindings would be significantly slower.)

Re: Library for realtime graphs in perl.
by VinsWorldcom (Prior) on Oct 17, 2018 at 13:53 UTC
Re: Library for realtime graphs in perl.
by Anonymous Monk on Oct 17, 2018 at 14:16 UTC
    "I'm maintaining a full 60 frames per second"

    My DeLorean runs Perl:
    opensource.com/article/18/1/my-delorean-runs-perl
    DeLorean Digital Dashboard, demo mode:
    www.youtube.com/watch?v=2XmBiYQW8ao

    2015 Michael Conrad DeLorean Digital Dashboard:
    www.youtube.com/watch?v=SERH3_gZOTo

    2018 Michael Conrad -
    "Building the Graphics of the DeLorean Digital Dash":
    www.youtube.com/watch?v=FtaBVVm5IBc
Re: Library for realtime graphs in perl.
by zentara (Archbishop) on Oct 22, 2018 at 12:02 UTC
Re: Library for realtime graphs in perl.
by iguanodon (Priest) on Oct 22, 2018 at 13:51 UTC
    Hi tobbes. You mentioned interactive graphs. You might want to look at JavaScript libraries. I have used dygraphs with Perl, for example a Mojolicious app that passes CSV data to dygraphs. There are Link Interaction and Dynamic update examples that might help you.
Re: Library for realtime graphs in perl.
by cavac (Priest) on Oct 22, 2018 at 14:47 UTC

    While not strictly within your requirements, you could one of the many HTML/Javascript based plotting libraries and feed it pseudo-realtime data via websockets. This demo does it, except without the websockets part.

    Or you could code your own webbased solution with HTML5 Canvas and websockets, for which it is also very easy to feed back user interactrion to your backend. While not a graph, a demo of the technology is here on my blog, and a description about interprocess messaging with Net::Clacks to feed data between the webserver and the backend is here: Interprocess messaging with Net::Clacks

    Of course, this is only the way i would have solve, or rather have solved it in the past. And yes, this post is a shameless plug for my very own Net::Clacks ;-)

    perl -e 'use MIME::Base64; print decode_base64("4pmsIE5ldmVyIGdvbm5hIGdpdmUgeW91IHVwCiAgTmV2ZXIgZ29ubmEgbGV0IHlvdSBkb3duLi4uIOKZqwo=");'

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1224153]
Approved by Discipulus
Front-paged by haukex
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2022-12-07 23:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?