Vega-Lite Defaults & Style Guide
This style guide is designed to help anyone building data visualizations using Vega-Lite create consistent, clear, and visually aligned with the Relevant application.
To make it easier to follow these guidelines, new Vega-Lite views include base styles by default in their JSON config:
"config": {
"axis": {
"labelFont": "Roboto",
"labelFontSize": 12,
"labelPadding": 4,
"titleFont": "Nunito Sans",
"titleFontSize": 14,
"titlePadding": 16,
"gridColor": "#EEEEEE"
},
"legend": {
"labelFont": "Nunito Sans",
"labelFontSize": 12,
"titleFont": "Nunito Sans",
"titleFontSize": 14
},
"title": {
"font": "Nunito Sans",
"fontSize": 14,
"offset": 16
},
"mark": {
"color": "#1367EC"
},
"line": {
"interpolate": "monotone"
},
"bar": {
"cornerRadiusEnd": 0
}
}
Axis titles and axis labels
Axis titles and labels provide context and clarity for your charts. They should be concise, legible, and consistently styled. The typography, sizing, and spacing of axis titles and labels are all added by default to the config section.
Note: In Vega-Lite, labels are the words that appear next to tick marks, and titles are the name of each axis (or the chart itself).
Guidelines
- Chart titles: Avoid using them. The tab name or dashboard tile name usually serves as this purpose. If you must include a chart title, use clear, descriptive text.
- Axis titles: Use axis titles where it adds clarity. Avoid overwhelming the user with unnecessary information; exercise discretion.
- Font: Use Nunito Sans for all chart titles and legend typography.
- Font size:
- Titles: 14px
- Labels: 12px
- Spacing: ensures items have breathing room
- Label padding: 4px
- Title padding: 16px
Colors
Colors help convey meaning and make charts visually clear. Consistent use of colors across charts ensures readability and accessibility.
Guidance
- Single series: use the Relevant blue (
#1367EC) for visualizations with one data series - Comparison series: use the Relevant blue (
#1367EC) and the accent blue (#A7C4FA) when you want to compare two sets of data. - Semantic colors: use the following colors as they pass accessibility guidelines for color blind users. Use the Chrome dev tools to emulate different visions. Pro-tip: try not to use just color to indicate meaning - reinforce with text, labels, or icons.
#50A6A4#A0DED9#FFE97C#F2A85C#E85B47#9B1C26
- Categorical / multiple series: use the default Vega color scheme (
category10) for charts with fewer than 10 categories. For more, consider grouping smaller categories into “Other” or usecategory20.
Sample code
By default, charts will assume a single series and use the Relevant blue. Use these code snippets within the encoding field to include other colors.
Single series
"color": {"value": "#1367EC"}
Comparison series
Replace the domain values (e.g. primary_series) with categories you want to compare.
"color": {
"scale": {
"domain": ["primary_series", "secondary_series"],
"range": ["#1367EC", "#A7C4FA"]
}
}
Semantic colors
Replace the domain values (e.g. Good) with your desired data points.
"color": {
"scale": {
"domain": ["Great", "Good", "Moderate", "Poor", "Bad", "Terrible"],
"range": ["#50A6A4", "#A0DED9", "#FFE97C", "#F2A85C", "#E85B47", "#9B1C26"]
}
}
Categorical
"color": {
"scale": {"scheme": "category10"}
}
Formatting
Consistent formatting ensures data is easy to read and interpret. This includes numbers, dates, and other axis or tooltip values.
Guidelines
- Numbers:
- Use commas for thousands (e.g.
1,234) - Show 0-2 decimal places depending on scale and context
- Use commas for thousands (e.g.
- Dates:
- Use
%-m/%-d/%Y(e.g.1/15/2025) for full dates - Use
%b %Y(e.g.Jan 2025) for month/year dates - Use
%Y(e.g.2025) for year
- Use
- Percentages:
- Show 0-2 decimal places depending on scale and context
- Always include the percent symbol (
%)
- General guidance:
- Round numbers and simplify formats where possible to make charts easy to read at a glance
- Keep formatting consistent across charts in the same report or dashboard
- Use the same format in tooltips as you do on axes to reduce confusion
Sample code
Use these snippets to apply formatting. Typically, these are nested with an x or y field within the encoding section. Note: You need to ensure you also specify formatting in the tooltip. Vega-Lite does not apply it globally.
Numbers
Whole numbers
"axis": {"format": ","}
Two decimal places
"axis": {"format": ",.2f"}
Dates
Full date
"axis": {"format": "%-m/%-d/%Y"}
Month and year
"axis": {"format": "%b %Y"}
Year
"axis": {"format": "%Y"}
Percentages
Whole number
"axis": {"format": ".0%"}
One decimal place
"axis": {"format": ".1%"}
Marks and interpolation
This section is about the appearance of chart elements such as bars, lines, points and ticks. Thoughtful use of these properties can make charts more readable and visually appealing.
Guidelines
- Line interpolation: use
monotone(smooth curves) for line charts unless otherwise requested or there is a good reason, like discrete steps are needed. - Bar charts: square corners are used to remain consistent with other in-app charts.
- Points: consider including points on lines. They should be visible but not overpower the mark.
- In general, use these guidelines to enhance readability and visual ‘friendliness’ of your visuals rather than as strict rules.
Data labels vs tooltips
Tooltips are preferred. Use data labels only when the chart is meant for print, you need to highlight specific value, hovering isn’t practical because marks are small, or someone requests them.