Skip to content
patricksurryPublic

About

A flexible framework for steam gauge instrument panels

Resources

Stars

42 stars

Watchers

1 watching

Forks

Repository files navigation

G3: a flexible framework for steam gauge instrument panels

G3 is a flexible Javascript framework for building steam gauge instrument panels that display live external metrics from flight (or other) simulators like X-Plane and Microsoft FS2020. Here's a screenshot with some of the included flight gauges (or try this live demo):

flight panel screenshot

TL;DR

Keywords: G3 D3 Javascript SVG flight simulator gauges instruments control panel metrics telemetry dashboard visualization dataviz XPlane FS2020

G3's goal is to provide a lightweight, browser-based solution for building steam-gauge control panels using simple hardware atop a commodity LCD display, powered by an affordable single-board computer like the Pi. One of my original inspirations was this awesome Cessna setup. G3 could also be useful for interactive data visualizations and dashboards.

The name G3 is a tortured backronym for "generic gauge grammar"—and has an aircraft connection—but was mainly chosen in homage to D3. It's part of a quixotic pandemic project to build a DHC-2 Beaver simpit. Although there are plenty of alternatives for creating instrument panels, I decided it would be fun to roll my own based on pure Javascript with SVG using D3. After several iterations, I ended up very close to the pattern suggested by Mike Bostock several years ago in Towards reusable charts.

The iconic Omega Speedmaster watch, mimicked by the example omegaSpeedmaster gauge below (see live demo), showcases G3's flexibility to create complex, working gauges that look good:

speedmaster screenshot

Installing

You can skip installing altogether and just refer to a standalone copy of the module distribution from an NPM CDN like these:

https://unpkg.com/@patricksurry/g3/dist/g3-contrib.min.js

https://cdn.jsdelivr.net/npm/@patricksurry/g3/dist/g3-contrib.min.js

You can also set up an npm project, by creating a project directory and installing G3:

npm install @patricksurry/g3

If you prefer a local standalone copy, you can download any of g3[-contrib][.min].js directly from unpkg or jsDelivr (right-click and "Save As"). The base g3 package provides the API to define gauges and assemble them into control panels, and the g3-contrib package adds a bunch of predefined gauges and panels that you can use or modify. The .min versions are minified to load slightly faster, but harder to debug. Choosing g3-contrib.js is probably a good start. See Contributing if you want to hack on G3.

Getting started

Check things are working by creating a minimal HTML file called gallery.html that shows all the contributed gauges, animated with fake metrics:

<html>
    <body>
        <script src="https://unpkg.com/@patricksurry/g3/dist/g3-contrib.min.js"></script>
        <script>
g3.gallery.contrib('body');
        </script>
    </body>
</html>

Serve it locally with something like python -m http.server and browse to http://localhost:8000/gallery.html.

Then follow the tutorial to build your own panel, display real metrics from a simulator, and design a new gauge. The cookbook has short recipes for common problems.

Contributing

If you want to extend G3, improve the documentation, or just add your own examples back into the package, you should start by forking and cloning the git repo followed by npm install. Check the issue tracker if you're looking for something to play with.

Check the unit tests after any changes with npm run test. The same type check, lint, tests and build run in CI on every pull request (see .github/workflows/ci.yml). Ensure new code is tested using npm test -- --coverage. The test suite also verifies that every contributed gauge has a JSDoc description, matches its deterministic SVG snapshot in tests/contrib/*.svg, and is documented in doc/CONTRIB.md. After adding or modifying a contributed gauge in src/contrib/, run npm run docs to regenerate the SVG snapshots and doc/CONTRIB.md.

You can test changes interactively by serving directly from the src/ tree using Vite. Use npm run start to launch the gauge gallery panel from src/index.html in your browser. (Note this HTML script uses module style imports unlike the production distribution.)

You can build the bundled package and TypeScript declarations into dist/ by typing npm run build (dist/ is git-ignored and built automatically on npm publish via the prepack script). Once you're happy with your changes, make a pull request. When I want to publish a new release, I also bump the version in package.json, then merge and tag in github and finally publish with something like:

git tag v0.1.20
git push origin --tags
npm login
npm publish --access public

Resources

API

See doc/API.md, and doc/COOKBOOK.md for short recipes.

About

A flexible framework for steam gauge instrument panels

Resources

Stars

42 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages