Add professional legends to your charts with automatic positioning and dark mode support
.legend()
, you get intelligent symbol generation, smart positioning, and full dark mode compatibility.
.legend()
position
parameter:
LegendPosition.topLeft
LegendPosition.topRight
(default)LegendPosition.bottomLeft
LegendPosition.bottomRight
LegendPosition.top
LegendPosition.bottom
LegendPosition.left
LegendPosition.right
Chart Type | Symbol | Description | |
---|---|---|---|
Bar Charts | ◼ Square | Solid colored squares for categorical bars | |
Line Charts | ━ Line | Horizontal line segments matching chart lines | |
Scatter Plots | ● Circle | Circular symbols for point data | |
Area Charts | ━ Line | Line symbols representing area boundaries | |
Bubble Charts | ● Circle | Circular symbols for bubble data |
theme.axisColor
for perfect contrast in any theme.Parameter | Type | Default | Description |
---|---|---|---|
position | LegendPosition | topRight | Legend placement |
backgroundColor | Color? | null | Legend background color |
textStyle | TextStyle? | null | Text styling (inherits color from theme) |
symbolSize | double | 12.0 | Size of legend symbols |
itemSpacing | double | 8.0 | Space between legend items |
spacing | double | 12.0 | Space between legend and chart |
borderRadius | double | 4.0 | Background border radius |
Mobile Optimization
LegendPosition.bottom
for mobile layoutsVisual Design
Data Clarity
Accessibility
color
parameter in your .mapping()
call.Legend not appearing
color
parameter in your .mapping()
call:Legend text too dark in dark theme
Legend overlapping chart content