Skip to content

Scales Reference ​

Configure axis, color, and other scales for your charts.


What are Scales? ​

Scales map data values to visual properties:

  • Position scales (x, y) map data to coordinates
  • Color scales map data to colors
  • Size scales (r) map data to dot radius
yaml
scales:
  x:
    type: time
  y:
    domain: [0, 100]
  color:
    scheme: "tableau10"

Scale Types ​

Quantitative (numbers) ​

TypeDescription
linearLinear interpolation (default for numbers)
logLogarithmic scale
sqrtSquare root scale
powPower scale
symlogSymmetric log (handles negative values)

Temporal (dates) ​

TypeDescription
timeLocal time
utcUTC time

Categorical (discrete values) ​

TypeDescription
bandEqual-width bands (default for bar charts)
pointPoints at band centers
ordinalCategorical mapping

Classification ​

TypeDescription
quantileEqual-count bins
quantizeEqual-range bins
thresholdCustom threshold bins

Common Options ​

domain ​

Set the input range:

yaml
scales:
  y:
    domain: [0, 100]      # Fixed range

  color:
    domain: ["A", "B", "C"]  # Explicit categories

range ​

Set the output range:

yaml
scales:
  y:
    range: [400, 0]       # Inverted (SVG coordinates)

  color:
    range: ["red", "blue", "green"]  # Custom colors

nice ​

Round domain to nice values:

yaml
scales:
  y:
    nice: true           # Auto-round to nice numbers
    nice: 5              # Round to 5 ticks

zero ​

Force zero in domain:

yaml
scales:
  y:
    zero: true           # Always start at 0

reverse ​

Reverse the scale direction:

yaml
scales:
  y:
    reverse: true

Position Scales (x, y) ​

Linear Scale ​

yaml
scales:
  y:
    type: linear
    domain: [0, 100]
    nice: true

Log Scale ​

yaml
scales:
  y:
    type: log
    domain: [1, 1000000]

Time Scale ​

yaml
scales:
  x:
    type: time
    domain: ["2024-01-01", "2024-12-31"]

Band Scale (categorical) ​

yaml
scales:
  x:
    type: band
    padding: 0.2         # Space between bars

Color Scales ​

Color Schemes ​

Use built-in color schemes:

yaml
scales:
  color:
    scheme: "tableau10"

Categorical schemes:

SchemeColorsDescription
category1010D3 default
paired12Paired colors
set19ColorBrewer
set28ColorBrewer
set312ColorBrewer
tableau1010Tableau default
observable1010Observable default

Sequential schemes:

SchemeDescription
bluesLight to dark blue
greensLight to dark green
redsLight to dark red
purplesLight to dark purple
orangesLight to dark orange
greysLight to dark grey
viridisPerceptually uniform
plasmaPerceptually uniform
warmWarm colors
coolCool colors

Diverging schemes:

SchemeDescription
rdbuRed to blue
rdylgnRed-yellow-green
brbgBrown-blue-green
piygPink-yellow-green
prgnPurple-green
puorPurple-orange
spectralRainbow

Custom Colors ​

Map specific values to colors:

yaml
scales:
  color:
    domain: ["Success", "Warning", "Error"]
    range: ["#22c55e", "#f59e0b", "#ef4444"]

Sequential Color ​

For continuous data:

yaml
scales:
  color:
    type: linear
    scheme: "blues"
    domain: [0, 100]

Radius Scale (r) ​

For bubble charts:

yaml
scales:
  r:
    type: sqrt          # Area proportional to value
    domain: [0, 1000]
    range: [2, 40]      # Min and max radius

Opacity Scale ​

yaml
scales:
  opacity:
    type: linear
    domain: [0, 100]
    range: [0.2, 1]

Facet Scales (fx, fy) ​

For faceted charts:

yaml
facet:
  x: category
scales:
  fx:
    padding: 0.1

Axis Configuration ​

Configure axis appearance within scales:

yaml
scales:
  x:
    label: "Date"
    ticks: 6
    tickFormat: "%b %Y"

  y:
    label: "Revenue ($)"
    tickFormat: ",.0f"
    percent: true        # Format as percentage

Tick Format Specifiers ​

FormatExampleOutput
.0f1234"1234"
,.0f1234"1,234"
.2f3.14159"3.14"
.1%0.45"45.0%"
$,.0f1234"$1,234"
%b %YDate"Jan 2024"
%Y-%m-%dDate"2024-01-15"

Complete Example ​

yaml
type: scatter
data:
  file: data/companies.csv
x: revenue
y: profit
r: employees
color: industry
scales:
  x:
    type: log
    label: "Revenue ($M)"
    tickFormat: "$,.0f"
    nice: true
  y:
    type: linear
    label: "Profit Margin (%)"
    domain: [-20, 40]
    tickFormat: ".0%"
  r:
    type: sqrt
    range: [3, 30]
  color:
    scheme: "tableau10"
title: "Company Performance"

Tips ​

Auto-detection: DataGlass usually detects the right scale type automatically. Only configure when you need specific behavior.

Nice values: Use nice: true to get clean axis tick values like 0, 25, 50, 75, 100 instead of 0, 23, 46, 69, 92.

Log scales: Log scales can't handle zero or negative values. Filter your data or use symlog.

Color accessibility: Use tableau10 or observable10 for colorblind-friendly palettes.


See Also ​

Released under the MIT License. Built by Boundary Lab.