Skip to content

Fields, Axes & Legends

This page documents the types used to describe data fields and chart guides within an OlliVisSpec.

OlliFieldDef

A field definition describes a column in the dataset.

ts
interface OlliFieldDef {
  field: string;
  label?: string;
  type?: MeasureType;
  timeUnit?: OlliTimeUnit;
  bin?: boolean;
}
PropertyTypeRequiredDescription
fieldstringyesThe key in each datum. Must match a property in OlliDatum.
labelstringnoHuman-readable label. Used in descriptions and dialogs instead of the raw field name.
typeMeasureTypenoThe measurement type. Auto-inferred from data if omitted.
timeUnitOlliTimeUnitnoTemporal granularity. Affects how date values are formatted.
binbooleannoWhether the field's values represent bin edges. Affects how ranges are displayed.

MeasureType

ts
type MeasureType = 'quantitative' | 'ordinal' | 'nominal' | 'temporal';
TypeMeaningSortingExample
quantitativeContinuous numericNumericTemperature, price
ordinalOrdered categoriesBy data orderEducation level
nominalUnordered categoriesBy data orderCountry, color
temporalDate/timeChronologicalDate, month

Type inference examines the data column: if all values are Date instances, the type is temporal; if all are numbers, quantitative; otherwise nominal.

OlliTimeUnit

ts
type OlliTimeUnit = 'year' | 'month' | 'day' | 'date' | 'hours' | 'minutes' | 'seconds';

When set, temporal values are formatted at this granularity. For example, timeUnit: 'month' formats dates as month names.

OlliGuide

The base guide type. All guides associate a field with a visual channel.

ts
interface OlliGuide {
  field: string;
  title?: string;
  channel?: string;
}
PropertyTypeRequiredDescription
fieldstringyesThe data field this guide represents.
titlestringnoDisplay title. Falls back to the field's label, then the field name.
channelstringnoThe visual channel (e.g., 'x', 'color').

OlliAxis

An axis guide, extending OlliGuide.

ts
interface OlliAxis extends OlliGuide {
  axisType: 'x' | 'y';
  scaleType?: string;
  ticks?: OlliValue[];
}
PropertyTypeRequiredDescription
axisType'x' | 'y'yesWhich axis this represents.
scaleTypestringnoThe scale type (e.g., 'linear', 'log', 'band').
ticksOlliValue[]noExplicit tick values. Used to define bin boundaries for quantitative/temporal fields.

When ticks is provided, the lowerer uses them as bin edges instead of computing bins from the data. This lets adapters pass through the exact tick marks from the rendered chart.

OlliLegend

A legend guide, extending OlliGuide.

ts
interface OlliLegend extends OlliGuide {
  channel: 'color' | 'opacity' | 'size';
}

The channel property is required and must be one of 'color', 'opacity', or 'size'.

How guides map to tree nodes

Each guide in axes, legends, or guides becomes a groupby node in the inferred tree structure when structure is omitted:

  • An OlliAxis with axisType: 'x' produces a node with role xAxis.
  • An OlliAxis with axisType: 'y' produces a node with role yAxis.
  • An OlliLegend produces a node with role legend.
  • A generic OlliGuide produces a node with role guide.

The children of each guide node are the distinct values (or bin ranges) of the guide's field.

Next

Released under the BSD-3-Clause License.