Reusable charts in barycentric coordinates
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

D3 Ternary Plot

Soil types

Modal Mineralogy

An extensible charting library focused on producing accurate and pleasing ternary diagrams for all manner of barycentric coordinate systems. It depends only on d3. Here are some examples:


Get the code, either by downloading lib/ternary.js from this repository, cloning the module, or installing via npm from this repository url (npm install git+

Simply include the script after d3 as such

<script charset="UTF-8" src=""></script>
<script type="text/javascript" src="<module-url>/lib/ternary.js"></script>

and you're off to the races.

The API makes extensive use of d3 shorthands:

function resize(t) {,window.innerHeight);

var ternary = d3.ternary.plot()
  .call(d3.ternary.vertexLabels(["Wo", "Fs", "En"]))

I am very happy to receive ideas for API improvement.

Future work

  • Clean up and generalize graticule API
  • Add an option to install via bower
  • List package on npm if desired
  • Add support for different scales per-axis (i.e. a zoomed view of part of the barycentric coordinate space)
  • Add support for partial coordinate systems (e.g. the pyroxene quadrilateral)


Several projects have served as a starting point for this work. Thanks especially to:


The source code is currently written in coffeescript. The only development dependency is the coffee CLI program, which can be installed using npm install -g coffee-script. After this setup, the library can be compiled from source using make, or make watch for continuous re-compilation.