Overview
Gradients in amCharts 5 allow you to fill chart elements with smooth color transitions instead of solid colors. The library provides two types of gradients: linear gradients (straight color transitions) and radial gradients (circular color transitions).Linear Gradients
Basic Linear Gradient
Create a linear gradient with color stops:/home/daytona/workspace/source/src/.internal/core/render/gradients/LinearGradient.ts:31-112
Gradient Rotation
Control the direction of the gradient using therotation property (in degrees):
/home/daytona/workspace/source/src/.internal/core/render/gradients/LinearGradient.ts:12-20
Multiple Color Stops
Add multiple color stops for complex gradients:/home/daytona/workspace/source/src/.internal/core/render/gradients/LinearGradient.ts:74-108
Radial Gradients
Basic Radial Gradient
Create a radial gradient that radiates from a center point:/home/daytona/workspace/source/src/.internal/core/render/gradients/RadialGradient.ts:40-126
Positioning Radial Gradients
Control the center position of the gradient:/home/daytona/workspace/source/src/.internal/core/render/gradients/RadialGradient.ts:20-29
Custom Radius
/home/daytona/workspace/source/src/.internal/core/render/gradients/RadialGradient.ts:15-18
Gradient Stops
Color Stop Properties
Each gradient stop can have multiple properties:/home/daytona/workspace/source/src/.internal/core/render/gradients/LinearGradient.ts:85-106
Automatic Offset Calculation
If you don’t specify offsets, they’re calculated automatically:/home/daytona/workspace/source/src/.internal/core/render/gradients/LinearGradient.ts:79-83
Opacity in Stops
/home/daytona/workspace/source/src/.internal/core/render/gradients/LinearGradient.ts:85-89
Color Manipulation in Stops
Lighten or brighten colors within the gradient:/home/daytona/workspace/source/src/.internal/core/render/gradients/LinearGradient.ts:95-103
Applying Gradients
To Series Fill
To Series Stroke
To Labels
Apply gradients to text labels (since v5.10.1):/home/daytona/workspace/source/src/.internal/core/render/Label.ts:37-42
To Backgrounds
Gradient Targets
Setting a Gradient Target
Make gradients span across multiple elements:/home/daytona/workspace/source/src/.internal/core/render/gradients/Gradient.ts:17-21
Combining with Other Effects
Gradient with Opacity
Gradient with Stroke
Dynamic Gradients
Changing Gradients Based on Data
Animated Gradients
Animate gradient rotation:Best Practices
Limit Color Stops
Limit Color Stops
Use 2-4 color stops for optimal performance:
Reuse Gradient Instances
Reuse Gradient Instances
Create gradients once and reuse them across multiple elements:
Consider Direction
Consider Direction
Match gradient direction to data flow:
Use Radial for Circular Charts
Use Radial for Circular Charts
Radial gradients work best with pie charts and gauge charts:
Related
Colors
Learn about color manipulation and color sets
Patterns
Apply repeating patterns instead of gradients