Getting startedComponentsDesign tokensThemingTheme synthesizerFrameworksAccessibilityUtilitiesServer renderingBrowser supportContributingChangelogApp ShellAspect GridAuth ShellCenterContainerDashboard GridFloat BarInsetMasonryPage HeaderPage LayoutResizableResponsive SwitcherSectionSettings LayoutSplit PaneStatus BarStickyToolbarAnchor NavBottom NavBreadcrumbBreadcrumb MenuCommand BarDrawerFooterLinkMenubarNavigation MenuPage IndicatorPaginationRailScroll IndicatorScroll SpyScroll To TopSidebarSkip LinkStepper NavTabsTop BarTree ViewAccordionAspect RatioAvatarAvatar GroupCardCarouselCollapsibleColor SwatchCTA BannerDividerEmpty StateFeature CardIconImageImage CompareImage HotspotsInfinite ScrollLightboxMarqueeQR CodeScroll AreaSkeletonSpinnerStackVideoVirtual ListActivity HeatmapAnimated NumberBadgeBar ListChartClockComparisonCountdown TimerData GridDescription ListDiffGaugeJSON TreeKanbanLevel MeterListMeterSparklineStatStepperTagTimelineUptimeValue CardWaveformBlockquoteCode BlockCode GroupGradient TextHighlightKbdKeyboard MapMarkdownNumber FormatProseTerminalTextTime AgoTruncateTypewriterButtonButton GroupCalendarCheckboxChipColor PickerComboboxCopy ButtonDate PickerDate Range PickerField ListFieldsetFile UploadFormHotkeyIcon ButtonImage CropperInline EditInputInput GroupKnobLabelMasked InputMulti SelectNumber InputPassword InputPin InputRadio GroupRange SliderRatingSearchSegmented ControlSelectSignature PadSliderSortable ListSwitch GroupTag InputTextareaTheme ToggleTime PickerToggleTransfer ListTree SelectAlertAnnouncementBannerCommand PaletteConfirmConnection StatusContext MenuConversationDialogDropdown MenuHover CardLoading OverlayNotification PanelPopoverProgressSheetToastTooltip
ARC UIARC Radiant Components
v4.9DocsComponentsTokensSynthesizer
Getting startedFrameworksServer renderingDesign tokensThemingTheme synthesizerTypographyUtilitiesAll componentsAccessibilityBrowser supportChangelogContributingStatsApp ShellAspect GridAuth ShellCenterContainerDashboard GridFloat BarInsetMasonryPage HeaderPage LayoutResizableResponsive SwitcherSectionSettings LayoutSplit PaneStatus BarStickyToolbarAnchor NavBottom NavBreadcrumbBreadcrumb MenuCommand BarDrawerFooterLinkMenubarNavigation MenuPage IndicatorPaginationRailScroll IndicatorScroll SpyScroll To TopSidebarSkip LinkStepper NavTabsTop BarTree ViewAccordionAspect RatioAvatarAvatar GroupCardCarouselCollapsibleColor SwatchCTA BannerDividerEmpty StateFeature CardIconImageImage CompareImage HotspotsInfinite ScrollLightboxMarqueeQR CodeScroll AreaSkeletonSpinnerStackVideoVirtual ListActivity HeatmapAnimated NumberBadgeBar ListChartClockComparisonCountdown TimerData GridDescription ListDiffGaugeJSON TreeKanbanLevel MeterListMeterSparklineStatStepperTagTimelineUptimeValue CardWaveformBlockquoteCode BlockCode GroupGradient TextHighlightKbdKeyboard MapMarkdownNumber FormatProseTerminalTextTime AgoTruncateTypewriterButtonButton GroupCalendarCheckboxChipColor PickerComboboxCopy ButtonDate PickerDate Range PickerField ListFieldsetFile UploadFormHotkeyIcon ButtonImage CropperInline EditInputInput GroupKnobLabelMasked InputMulti SelectNumber InputPassword InputPin InputRadio GroupRange SliderRatingSearchSegmented ControlSelectSignature PadSliderSortable ListSwitch GroupTag InputTextareaTheme ToggleTime PickerToggleTransfer ListTree SelectAlertAnnouncementBannerCommand PaletteConfirmConnection StatusContext MenuConversationDialogDropdown MenuHover CardLoading OverlayNotification PanelPopoverProgressSheetToastTooltip

Chart

Line, area, bar and donut charts drawn in SVG from a plain array of series, with no charting library.

ComponentsChart
datainteractivebeta
<arc-chart>

Overview

Chart draws line, area, grouped or stacked bar, and donut charts from plain JavaScript data, with no charting library. Pass a `series` array of `{ label, data }` objects and a `labels` array of x-axis categories. The component works out a 1/2/5-step y scale, faint horizontal gridlines, abbreviated axis numbers (1.2k, 3.4M) and thin marks in the ARC chart palette. Series take their colors in fixed order from `--chart-1` to `--chart-6`, never cycled. With more than six series, the extras are summed into an "Other" series, flagged in the legend, so no two series share a color. The legend appears for two or more series and not for one. On hover, line and area charts show a vertical crosshair with a tooltip listing every series at that category. Bar and donut charts show a tooltip per mark. The hover targets are invisible full-height columns, one per category, so nobody has to hit a 2px line. Clicking a mark fires `arc-mark-click` with the series index, category index and value. For assistive technology, the chart has a generated `role="img"` summary and a visually hidden `<table>` of the real values.

Guidelines

Do

  • Keep a chart to six series or fewer. Past that, aggregate first or split into small multiples
  • Use type="area" for one dominant series and type="line" to compare trends
  • Stack bars only when the total means something. Use grouped bars to compare series within a category
  • Pass fractions with value-format="percent" (0.24 renders as 24%)
  • Label every series. The labels feed the legend, the tooltip and the data table
  • Use arc-mark-click for drill-down or a detail panel

Don't

  • Don't plot two measures with different scales on one chart. There is one y-axis and no second one
  • Don't use a donut for more than about six segments or for precise comparison. Use bars
  • Don't hide the legend on a multi-series chart unless the series are labeled right next to the lines
  • Don't color marks yourself to carry meaning. The fixed palette keeps each series the same color everywhere
  • Don't use hide-axis where readers need to look up values. It is for compact trend panels
  • Don't give stacked bars negative values. Stacking assumes non-negative data

Features

  • One y-axis, with 1px horizontal gridlines only
  • `value-format` formats values with `Intl.NumberFormat` as number, percent or currency
  • Legend chips are 8px, in the series color
  • Width follows the container via ResizeObserver

Preview

Usage

This component needs JavaScript. Use the Web Component or a framework wrapper.

<arc-chart id="revenue-chart" type="bar" stacked value-format="currency" height="280"></arc-chart>

<script type="module">
  import '@arclux/arc-ui/chart';

  const chart = document.querySelector('#revenue-chart');
  chart.labels = ['Q1', 'Q2', 'Q3', 'Q4'];
  chart.series = [
    { label: 'Subscriptions', data: [42000, 48000, 51000, 62000] },
    { label: 'Services', data: [18000, 16500, 21000, 24000] },
    { label: 'Licensing', data: [9000, 11000, 10500, 14000] }
  ];

  chart.addEventListener('arc-mark-click', (e) => {
    const { seriesIndex, index, value } = e.detail;
    console.log('clicked', seriesIndex, index, value);
  });
</script>

API

currencystring'USD'
ISO 4217 currency code used when value-format="currency".
type'line' | 'area' | 'bar' | 'donut''line'
The chart form. Line and area share the x axis across all series; bar renders grouped columns (or stacked with the stacked attribute); donut renders one segment per series (or per category when a single series is given).
seriesArray<{label:string,data:number[]}>[]
The data that drives the chart. Each entry is one series; all series share the x axis defined by labels. Set as a property, or as a JSON attribute for a chart that is static. Colors are assigned in fixed order from --chart-1 to --chart-6; series beyond six are summed into an "Other" series noted in the legend.
labelsstring[][]
Category labels for the x axis (or donut segment names when a single series is given). Labels that would collide are automatically thinned; every Nth label renders based on available width.
stackedbooleanfalse
Bar type only. Stacks series segments on a shared baseline with 2px surface gaps between segments; only the outermost segment gets the rounded value end. Assumes non-negative data.
hideLegendbooleanfalse
Suppresses the legend. By default the legend renders for two or more series and is omitted for a single series.
hideAxisbooleanfalse
Removes the axis layer (gridlines, y tick labels, and x category labels) for compact trend panels where exact values are read from the tooltip.
heightnumber260
Chart height in pixels. Width is fluid and tracked with a ResizeObserver.
valueFormat'number' | 'percent' | 'currency''number'
How values are formatted in tooltips, the axis, and the accessible data table, via Intl.NumberFormat. Percent expects fractional data (0.24 → 24%). Axis numbers are abbreviated (1.2k, 3.4M).

Events

arc-mark-click
Fired when a mark (bar, stacked segment, line point column, or donut segment) is clicked. detail: { seriesIndex, index, value }. Indices refer to displayed series after any "Other" folding; a folded donut segment reports seriesIndex -1.

See also