Charts - Responsive

Adapt chart configuration to different container sizes with font and layout scaling and custom breakpoint rules.

#Usage

import { ChartCanvas, ChartResponsive, ChartSvg } from '@primeui/vue-chart';
<ChartSvg>
    <ChartResponsive />
    <!-- series and axes -->
</ChartSvg>

Charts fill their container by default. ChartResponsive adds intelligent scaling on top: font sizes, padding, tick labels, and legend position adapt across four container-width tiers. Use rules to define custom breakpoints and configuration overrides.

#Basic

Add ChartResponsive to enable adaptive scaling. By default the chart adjusts font sizes, padding, tick label sizes, data label rotation, and legend position based on the chart container width. No configuration needed.

Loading Demo...

#Auto-Adaptive Scaling

The built-in auto-adaptive system scales chart elements across four tiers based on container width. All font values scale proportionally when a global fontSize is set on ChartSvg or ChartCanvas.

Elementxs (≤300px)sm (≤500px)md (≤700px)lg (>700px)
Chart title font12px13px14px17px
Caption font10px11px12px13px
Chart padding6px8px10px10px
Tick label font10px11px12px12px (cartesian only)
Legend item font10px11px12px13px
Data label font10px10px11px12px
Data label rotation-90°-90°0°0° (cartesian only)
Legend repositioned to bottom✓✓--

Set disableAutoAdaptive to true to turn off all scaling and lock to lg tier defaults.

#Custom Rules

Set rules to define condition-based prop overrides. Each rule specifies pixel conditions (maxWidth, minWidth, maxHeight, minHeight) and a props object mapping feature names to their override values. All matching rules are applied. Last rule wins on conflicting keys.

<ChartResponsive
    :rules="[
        {
            maxWidth: 500,
            props: {
                legend: { enabled: false },
                title: { fontSize: 12 }
            }
        },
        {
            maxWidth: 300,
            props: {
                xAxis: { visible: false },
                yAxis: { visible: false },
                dataLabels: { enabled: false }
            }
        }
    ]"
/>
Loading Demo...

#Custom Breakpoints

Set breakpoints to override the container width thresholds used by the auto-adaptive system. Override only the necessary breakpoints. Unset ones keep their defaults.

<ChartResponsive :breakpoints="{ xs: 250, sm: 450, md: 650 }" />
Loading Demo...

#Hiding Elements at Small Sizes

Use rules to hide the legend, tooltip, or data labels at small container sizes, or to remove axes entirely to maximize the plot area. Axis hiding is layout-aware. The plot area expands to fill the reclaimed space rather than leaving a gap.

Loading Demo...

#Mobile Dashboard

Real dashboards usually combine multiple panels, not one isolated chart. This mobile commerce example uses a revenue/conversion combo chart, a traffic donut, and regional support bars. Each panel owns ChartResponsive rules that hide legends or axes as the container shrinks, while the outer CSS grid collapses to one column without horizontal window overflow.

Loading Demo...

#API

#ChartResponsive

PropTypeDefaultDescription
rulesResponsiveRule[]-Condition-based prop overrides evaluated against chart container dimensions
breakpointsPartial<ResponsiveBreakpoints>-Override tier thresholds used by the auto-adaptive system
disableAutoAdaptivebooleanfalseDisable font and layout scaling. Locks to lg tier defaults

#ChartSvg / ChartCanvas

PropTypeDefaultDescription
scaleWithRootFontbooleantrueScale chart text with the user's root font size. Set false if the app already derives fontSize from the root font, or the scale applies twice

#ResponsiveRule

FieldTypeDescription
maxWidthnumberApply when chart container width is ≤ this value
minWidthnumberApply when chart container width is ≥ this value
maxHeightnumberApply when chart container height is ≤ this value
minHeightnumberApply when chart container height is ≥ this value
propsRecord<string, Record<string, unknown>>Feature prop overrides. Keys are feature names ('legend', 'title', 'axes', etc.), values are that feature's props

All conditions are optional and AND'd together. A rule applies only when all specified conditions are met. Multiple matching rules are all applied with last-rule-wins on key conflicts.

#Wired Rule Overrides

Only specific key/property combinations are consumed by the responsive engine. Other keys are accepted without error but have no effect.

KeyPropertyEffect
'legend'enabled: falseHides the legend and reclaims its reserved layout space
'title'fontSize: numberOverrides the title font size
'caption'fontSize: numberOverrides the caption font size
'tooltip'enabled: falseSuppresses the floating tooltip
'dataLabels'enabled: falseDisables all data labels
'xAxis'visible: falseRemoves all X axes from layout. Plot area expands to fill reclaimed space
'yAxis'visible: falseRemoves all Y axes from layout. Plot area expands to fill reclaimed space
'xAxis'showTicks: falseHides X-axis tick marks while preserving labels and reserved layout space
'yAxis'showTicks: falseHides Y-axis tick marks while preserving labels and reserved layout space

#ResponsiveBreakpoints

Container width thresholds in pixels for the auto-adaptive tier system. Override any subset. Unset breakpoints keep their defaults.

FieldDefaultTier below this threshold
xs300'xs'
sm500'sm'
md700'md'
(above md)-'lg'