Area Chart
Area Charts are ideal for showing changes over time or the magnitude of multiple datasets stacked together. They combine the smoothness of line charts with the visual impact of filled areas.
Usage
Copy the following helper functions into your Reflex application.
import reflex as rx tooltip = { "is_animation_active": False, "separator": "", "cursor": False, "item_style": { "color": "currentColor", "display": "flex", "paddingBottom": "0px", "justifyContent": "space-between", "textTransform": "capitalize", }, "label_style": { "color": rx.color("slate", 10), "fontWeight": "500", }, "content_style": { "background": rx.color_mode_cond("oklch(0.97 0.00 0)", "oklch(0.14 0.00 286)"), "borderColor": rx.color("slate", 5), "borderRadius": "5px", "fontFamily": "IBM Plex Mono,ui-monospace,monospace", "fontSize": "0.875rem", "lineHeight": "1.25rem", "fontWeight": "500", "letterSpacing": "-0.01rem", "minWidth": "8rem", "width": "175px", "padding": "0.375rem 0.625rem ", "position": "relative", }, } def info(title: str, size: str, subtitle: str, align: str): return rx.vstack( rx.heading(title, size=size, weight="bold"), rx.text(subtitle, size="1", color=rx.color("slate", 11), weight="medium"), spacing="1", align=align, ) def get_tooltip(): """Standard tooltip for all charts.""" return rx.recharts.graphing_tooltip(**tooltip) def get_cartesian_grid(): """Standard cartesian grid for charts.""" return rx.recharts.cartesian_grid( horizontal=True, vertical=False, class_name="opacity-25" ) def get_x_axis(data_key: str): """Standard X axis configuration.""" return rx.recharts.x_axis( data_key=data_key, axis_line=False, tick_size=10, tick_line=False, custom_attrs={"fontSize": "12px"}, interval="preserveStartEnd", )
Examples
Below are examples demonstrating how these components and charts can be used.
Basic
A minimal example showing a single series with a smooth gradient fill.
Area Chart
Showing total visitors for the last 6 months
Trending up by 5.2% this month
January - June 2024
Linear
Displays data using straight line segments between points.
Area Chart - Linear
Showing total visitors for the last 6 months
Trending up by 5.2% this month
January - June 2024
Step
Renders the chart with stepped transitions, ideal for discrete intervals.
Area Chart - Step
Showing total visitors for the last 6 months
Trending up by 5.2% this month
January - June 2024
Stacked
Visualizes multiple data series stacked on top of each other for cumulative comparison.
Area Chart - Stacked
Showing total visitors for the last 6 months
Trending up by 5.2% this month
January - June 2024
Dynamic
Demonstrates how data or series can update interactively in real-time.
Area Chart - Dynamic
Showing total visitors for the last 6 months
Trending up by 5.2% this month
January - June 2024
Legend
Adds a built-in legend for easy series identification.
Area Chart - Legend
Showing total visitors for the last 6 months
Trending up by 5.2% this month
January - June 2024
Axes
Shows full control over axis configuration, labels, and styling.
Area Chart - Axes
Showing total visitors for the last 6 months
Trending up by 5.2% this month
January - June 2024
Custom Legends
Implements a user-defined legend layout for better presentation control.
Desktop
Mobile
Step with Gradient
Combines stepped transitions with a smooth color gradient for visual emphasis.
Area Chart - Step with Gradient
Showing total visitors for the last 6 months
Trending up by 5.2% this month
January - June 2024
Custom Legend and Axes
A complete example with custom legends, axes, and advanced styling combined.
Area Chart - Stacked with Legend and Custom Axes
Showing total visitors for the last 6 months
Mobile
Desktop
Trending up by 5.2% this month
January - June 2024