Browse documentation

Charts

Show trends, categories, proportions, and relationships from simple Ruby data.

Import

Load the optional component layer before using the examples below.

Ruby
require "zaniah/ui"

Parts and relationships

Use pie or donut charts for parts of a whole and scatter charts for point relationships. Provide a meaningful label for the chart.

API summary

Constructor options and behaviors are drawn from the component reference.

ComponentConstructor and methodsVariants or behavior
Sparkline(values, width:, height:, color:, label:)line + tooltip
LineChart, BarChart, StackedBarChart, AreaChart(series, width:, height:, colors:, label:); AreaChart(stacked:)shared axes, ticks, grid lines, color-keyed legend, tooltip
PieChart, DonutChart(data, width:, height:, colors:, label:)slices, shared color-keyed legend, tooltip
ScatterChart(series, width:, height:, colors:, label:)shared axes, ticks, grid lines, color-keyed legend, nearest-point tooltip

Accessibility

Charts expose an image role. Provide a descriptive label and an adjacent data summary for important values.

ComponentSemantic role
Sparklineimage
LineChart, BarChart, StackedBarChart, AreaChartimage
PieChart, DonutChartimage
ScatterChartimage