Tomato Lab Graphic Standards

Ask hello@tomatolab.org for access.

Roma, the design system, is open to everyone: Using Roma.

Tomato Lab Graphic Standards

Roma / Data visualization

Chart kit

Edit this page

Charts are not components: each is drawn for its data. What Roma gives them is a kit: a block to put them in, the theme's colors, and two small scripts that draw, redraw and reveal them.

Anatomy

Every chart is one block: a Bold title, a legend when there is more than one series, the plot, and a source line in the muted text color.

<div class="chart" data-chart="bars">          <!-- or data-d3="name" -->
  <h4>Greenhouse pest reports per month</h4>
  <ul class="legend"></ul>
  <div class="plot"></div>
  <p class="source">Source: Tomato Lab greenhouse log (filler data).</p>
</div>

Two scripts

  • charts.js draws the everyday types straight to SVG: bars, area, dots, ring, tree and line. Its data arrays sit at the top of the file. To add a type, write a draw function and a CHARTS entry. See Charts.
  • d3-charts.js is a small kit around d3 v7.9.0 for everything more complex. Register a chart with TL_D3.register('name', function (c) { … }). The function gets d3 (c.d3), the plot (c.host) and its width (c.W), the theme’s colors (c.t), a shared hover readout (c.tip) and whether to skip motion (c.reduce). See Infographics.
<script src="assets/charts.js"></script>
<script src="https://cdn.jsdelivr.net/npm/d3@7.9.0/dist/d3.min.js"></script>
<script src="assets/d3-charts.js"></script>

The chart styles are in roma.css, so a site that loads the stylesheet only needs the scripts it uses.

Color

Charts read their colors from the theme, never from hex values, so every chart works in Light, Dark and Tomato. In order of use:

RoleTokenUse for
Ink--color-text-primaryThe main series, values and lines
Secondary and muted--color-text-secondary, --color-text-mutedSecond series, axis labels, the source line
Accent--c-accent (Tomato; black on the Tomato theme)The one value that stands out
Comparison--c-blue (Water)What the accent is compared against
More series--c-green (Vine), --c-yellow (Burlap)Only past four series

The --c-… properties are set on each .chart in roma.css; change them there to recolor every chart.

Behavior

  • Width. Charts draw at their container’s width and redraw when it changes, so type stays at 11px on phones.
  • Theme. Changing the theme redraws every chart in the new colors.
  • Reveal. A chart draws itself in once, the first time it scrolls into view. With reduced motion, it is simply there.
  • Numbers. Hover or tap any mark for its value. Each chart also carries a text description for screen readers.

Pencil Box has the same kit (DOI_D3, the Department's colors and its own data) plus charts that only suit the Department, such as the attention map and the 3D bar chart.