Skip to content

Style & Formatting

Styles define reusable visual themes for charts. ChartML includes built-in color palettes and supports custom themes with typography, grid lines, and chart defaults.


Style Component

yaml
type: style
version: 1
name: corporate_theme

colors: ["#4285f4", "#ea4335", "#fbbc04", "#34a853"]

grid:
  x: false
  y: true
  color: "#e0e0e0"
  opacity: 0.5
  dashArray: "2,2"

height: 400

showDots: false
strokeWidth: 2

fonts:
  title:
    family: "Inter, sans-serif"
    size: 18
    weight: 600
    color: "#202124"
  axis:
    family: "Inter, sans-serif"
    size: 12
    color: "#5f6368"
  dataLabel:
    family: "Inter, sans-serif"
    size: 11
    weight: 500

Properties

PropertyDescription
nameUnique identifier for referencing
colorsArray of color values for multi-series charts
gridGrid line configuration (x/y visibility, color, opacity, dashArray)
heightDefault chart height in pixels
showDotsShow dots on line charts
strokeWidthLine thickness
legendLegend configuration (position, orientation)
fonts.titleTitle font (family, size, weight, color)
fonts.axisAxis label font
fonts.dataLabelData label font

Built-in Color Palettes

Three professionally-designed 12-color palettes optimized for data visualization:

autumn_forest (Default)

Improved BI palette with accessibility focus. Best for general-purpose dashboards and mixed data types.

spectrum_pro

Inspired by Tableau with warmer tones. Best for professional presentations and warm color schemes.

horizon_suite

Inspired by Looker with deeper saturation. Best for high-contrast displays and vibrant visualizations.

Automatic Fallback Colors

  • 1-12 series: Uses the base 12-color palette
  • 13-24 series: Generates 12 additional desaturated variants
  • 25+ series: Cycles through the combined 24-color palette

For charts with >12 categories, consider filtering to top categories or grouping smaller ones into "Other".


Using Styles in Charts

Reference by Name

yaml
type: chart
version: 1
style: corporate_theme
data: sales_data
visualize:
  type: line
  columns: month
  rows: revenue
  # Inherits colors, grid, height, fonts from corporate_theme

Inline Override (Deep Merge)

Override specific properties while keeping everything else from the referenced style:

yaml
type: chart
version: 1
style: corporate_theme
data: sales_data
visualize:
  type: bar
  columns: region
  rows: revenue
  style:
    height: 600           # Override just height
    grid:
      color: "#ff0000"    # Override just grid color
    # Colors, fonts, other grid props still from corporate_theme

Deep merge means you only override what you specify — all other properties are inherited.


Number Formatting

ChartML uses d3-format for number formatting.

Common Formats

FormatExampleDescription
$,.0f$1,234Currency, thousands separator, no decimals
$,.2f$1,234.56Currency, 2 decimals
,.0f1,234Thousands separator, no decimals
,.2f1,234.56Thousands separator, 2 decimals
.1%12.3%Percentage, 1 decimal
.0%12%Percentage, no decimals
~s1.2K, 3.4M, 5.6BSI-prefix notation
.2e1.23e+4Scientific notation
+,.0f+1,234Always show sign

Where to Apply Formats

yaml
# Axis tick labels
axes:
  rows:
    format: "$,.0f"

# Data labels on marks
rows:
  field: revenue
  dataLabels:
    show: true
    format: "$,.0f"

# Metric card value
visualize:
  type: metric
  format: "$,.0f"

# Table column
columns:
  - field: revenue
    format: "$,.0f"

Date Formatting

ChartML uses d3-time-format for date formatting.

Common Date Formats

FormatExampleDescription
%Y-%m-%d2025-03-15ISO date
%b %YMar 2025Abbreviated month + year
%B %d, %YMarch 15, 2025Full date
%m/%d03/15Month/day
%bMarAbbreviated month

Chart Height Defaults

Chart TypeDefault Height
metric120px
bar, line, area, scatter, pie, doughnut400px
table300px

Override with visualize.style.height:

yaml
visualize:
  style:
    height: 500