Line chart
Line charts illustrate change over time. They’re useful for displaying chronological data.


Anatomy#


Options#
Behaviors#

Noise control#
When there are a large number of data points, it can be difficult to see patterns and analyze trends. Simple controls for table calculations (e.g., rolling averages, percentage change, etc.) make it easier for users to find useful information that would otherwise remain hidden.

Hover#
Hovering on a line surfaces a tooltip. The tooltip shows the date, the name of the dimension item, and its metric value.

Selection#
A chart can be used as a way for users to directly interact with the objects within it. Provide a clear selection indicator and surface relevant actions in a panel, rail, or floating menu.

Focus#
A line chart can be navigated using a keyboard. A blue border is applied to the point in focus.

Loading#
Charts often require time to load, so include a loading state.

Null values#
When data returns null (blank) values, a chart should treat these as zeros.

Empty state#
When there is no data available, a chart should indicate as such and give direction as to how to make data appear there. Do not render an empty chart.

Error state#
There are occasionally errors with fetching data. When this happens, give users a helpful, actionable explanation of what happened and what they can do to fix things. Do not render an empty chart.
Usage guidelines#
Don’t overuse line charts#
Line charts are often used to fill a visual requirement for a report or to abstractly show “data.” Before using them, be sure that your audience is actually looking for answers to time-related questions. If not, pick a more suitable chart type.


Use categorical colors#
Each line should have a unique color. Limit the number of colors (dimension values) to no more than 6, and be sure to include a


Keep sharp lines as is#
It may be tempting to smooth the sharp lines in line charts to be more aesthetically pleasing, but doing so is misleading because it can obscure and alter data points. Spectrum reserves smooth lines to be used for displaying predictive data, where it’s important to communicate a lack of precision.




Don’t use line types#
Don’t use line types to display dimension values. Spectrum reserves line types to represent specific concepts; a solid line represents actual data, while a dashed line represents predicted data.




Don't use shapes#
Shapes carry a high cognitive load and do little to improve accessibility in charts. They should not be used.




Show data points on uneven data#
When data isn’t collected in even increments, it can be useful to show the actual data points on a line. Avoid showing these when they become dense and obscure the underlying data.




Keyboard interactions#
Changelog#
- Updated all colors to 6.0.0
- Chart hover state changed from tooltip to a popover
- Action bar now appears below chart instead of on top of chart
- This component has been added to the website
Design checklist#

All interactive states
Includes all interactive states that are applicable (hover, down, focus, keyboard focus, disabled).

All color themes
Works properly across all four color themes (lightest, light, dark, darkest).

All platform scales
Includes a desktop scale (UWP, macOS, web desktop) and a mobile scale (iOS, Android, web mobile).

Accessible use of color
Color is not used as the only visual means of conveying information (WCAG 2.0 1.4.1).

Accessible contrast for text
Text has a contrast ratio of at least 4.5:1 for small text and at least 3:1 for large text (WCAG 2.0 1.4.3).

Accessible contrast for UI components
Visual information required to identify components and states (except inactive components) has a contrast ratio of at least 3:1 (WCAG 2.1 1.4.11).

Content design
UI language and information design considerations have been incorporated into component design.

Defined options
Includes relevant options (variant, style, size, orientation, optional iconography, decorations, selection, error state, etc.)

Defined behaviors
Includes guidelines for keyboard focus, layout (wrapping, truncation, overflow), animation, interactions, etc.

Usage guidelines
Includes a list of dos and don'ts that highlight best practices and common mistakes.

Writing guidelines
Includes content standards or usage guidelines for how to write or format in-product content for the component.

Internationalization guidelines
Works properly across various locales and includes guidelines for bi-directionality (RTL).

Keyboard interactions
Follows WCAG 2.0 standards for keyboard accessibility guidelines and includes a description of the keyboard interactions.

Design tokens
All design attributes (color, typography, layout, animation, etc.) are available as design tokens.

UI kit
Includes a downloadable XD file that shows multiple options, states, color themes, and platform scales.

Generated UI kit
Includes a downloadable XD file, generated by code using design tokens defined in Spectrum DNA, and shows multiple options, states, color themes, and platform scales.

In Spectrum for Adobe XD plugin
Component is included in the Spectrum for Adobe XD plugin.