#graph #plot #graphics #data-points

rt-graph

A real-time graphing experiment written in Rust

8 releases

0.3.4 Oct 30, 2020
0.3.3 Oct 23, 2020
0.3.1 Sep 28, 2020
0.2.0 Sep 26, 2020
0.1.1 Sep 24, 2020

#200 in Visualization

MIT license

52KB
1K SLoC

rt-graph

A real-time graphing experiment written in Rust.

Screenshot

Many other graphing tools do not efficiently update the display when new data is added, for example redrawing the whole screen when only a few pixels of new data are added.

This crate tries to do the minimum incremental work required to update the graph when new data is added: draw the few pixels of new data, and scroll the graph with efficient large copies, which can and should be accelerated by GPU hardware.

As a result of this design rt-graph easily copes with 30k new points per second, at 60 FPS, using just 3% CPU (tested on a Lenovo T460 laptop from 2016 with 2.4 GHz Intel Core i5-6300U, running Ubuntu 18.04.5).

Source repository: https://github.com/fluffysquirrels/rt-graph-rs/ (issues and pull requests are welcome!)

Documentation: https://docs.rs/rt-graph

Crate: https://crates.io/crates/rt-graph

Prerequisites

First install GTK 3 dependencies.

On OS X with brew try: brew install gtk+3

On Ubuntu try: sudo apt-get install libgtk-3-dev

Run an example

Clone the source repository from https://github.com/fluffysquirrels/rt-graph-rs/ then try to run an example with some simulated data:

cargo run --package "example-simple" --release

You can scroll back and forth with the scrollbar under the graph, or go back to following the latest data by clicking the "Follow" button, and zoom in and out with the buttons. Click on the graph to show an information bar underneath it with the raw data where you clicked.

Build your own application

To use your own data implement the DataSource trait and pass an instance of your struct to the ConfigBuilder::data_source() method while building a Graph or GraphWithControls.

rt-graph uses GTK (via the gtk-rs Rust bindings) for its UI and is designed to be embedded into any gtk::Container in your application.

GTK 3 documentation: https://developer.gnome.org/gtk3/stable/index.html

gtk-rs (Rust GTK bindings) documentation: https://gtk-rs.org/docs-src/

Changelog

0.3.4

  • Swap B and R color channels, they were backwards.

0.3.3

  • Add .show and .hide methods to Graph.
  • A hidden Graph ticks less frequently (1Hz), reducing CPU usage dramatically.
  • Graph::tick() does less when no data is ingested from a DataSource.

0.3.2

  • Add .show and .hide methods to GraphWithControls.

0.3.1

  • Fix panic when clicking on a graph with no data points.
  • Add NullDataSource.

0.3.0

  • Flip y axis so increasing values are higher on the screen.
  • Make Store private.
  • Add per-item documentation for all public items.
  • Replace naked u16 and u32 usage with type aliases Value and Time.

0.2.0

  • Refactor out Graph, GraphWithControls, so consumers can write their own controls.

0.1.1

  • Add more content to the README, including a screenshot.

Dependencies

~19–28MB
~505K SLoC