ChartTheme class
Theme-aware chart styling configuration.
This class provides comprehensive theming for all chart types, including colors, typography, spacing, and visual effects. Themes are designed to work seamlessly with Material Design 3 and support both light and dark modes.
Features
- Light and dark theme presets
- Automatic theme inference from Material theme
- Customizable colors, fonts, and spacing
- Copy-with method for easy customization
- Professional gradient color palettes
Example
// Use preset theme
final theme = ChartTheme.light();
// Customize theme
final customTheme = ChartTheme.light().copyWith(
backgroundColor: Colors.grey[100],
borderRadius: 24.0,
xAxisLabelRotation: LabelRotation.diagonalDown, // Rotate X-axis labels
);
// Infer from Material theme
final autoTheme = ChartTheme.fromMaterialTheme(Theme.of(context));
See also:
- ThemeData for Material theme
Constructors
-
ChartTheme({required Color backgroundColor, required Color textColor, required Color gridColor, required Color axisColor, required List<
Color> gradientColors, double shadowElevation = 4.0, double borderRadius = 16.0, bool showGrid = true, bool showAxis = true, bool showLegend = true, bool showTooltip = true, int xAxisLabelRotation = 0, int yAxisLabelRotation = 0, TextStyle? axisLabelStyle, TextStyle? tooltipStyle, EdgeInsets padding = const EdgeInsets.fromLTRB(40, 20, 20, 40)}) -
const
- ChartTheme.dark()
-
Create dark theme with enhanced colors.
factory
- ChartTheme.fromMaterialTheme(ThemeData theme)
-
Create theme from Material Theme.
factory
- ChartTheme.light()
-
Create light theme with enhanced colors.
factory
Properties
- axisColor → Color
-
final
- axisLabelStyle → TextStyle?
-
Text style for axis labels.
final
- backgroundColor → Color
-
final
- borderRadius → double
-
final
-
gradientColors
→ List<
Color> -
final
- gridColor → Color
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- padding → EdgeInsets
-
Padding around the chart content.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shadowElevation → double
-
final
- showAxis → bool
-
final
- showGrid → bool
-
final
- showLegend → bool
-
final
- showTooltip → bool
-
final
- textColor → Color
-
final
- tooltipStyle → TextStyle?
-
Text style for tooltips.
final
- xAxisLabelRotation → int
-
Rotation angle for X-axis labels in degrees.
final
- yAxisLabelRotation → int
-
Rotation angle for Y-axis labels in degrees.
final
Methods
-
copyWith(
{Color? backgroundColor, Color? textColor, Color? gridColor, Color? axisColor, List< Color> ? gradientColors, double? shadowElevation, double? borderRadius, bool? showGrid, bool? showAxis, bool? showLegend, bool? showTooltip, int? xAxisLabelRotation, int? yAxisLabelRotation, TextStyle? axisLabelStyle, TextStyle? tooltipStyle, EdgeInsets? padding}) → ChartTheme - Creates a copy of this theme with the given fields replaced.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited