BarChartRodData constructor
- double? fromY,
- required double toY,
- Color? color,
- Gradient? gradient,
- double? width,
- BorderRadius? borderRadius,
- List<
int> ? borderDashArray, - BorderSide? borderSide,
- BackgroundBarChartRodData? backDrawRodData,
- List<
BarChartRodStackItem> ? rodStackItems,
BarChart renders rods vertically from zero to toY
,
and the x is equivalent to the BarChartGroupData.x value.
It renders each rod using color
, width
, and borderRadius
for rounding corners and also borderSide
for stroke border.
Optionally you can use borderDashArray
if you want your borders to have dashed lines.
This bar draws with provided color
or gradient
.
You must provide one of them.
If you want to have a bar drawn in rear of this rod, use backDrawRodData
,
it uses to have a bar with a passive color in rear of the rod,
for example you can use it as the maximum value place holder.
If you are a fan of stacked charts (If you don't know what is it, google it),
you can fill up the rodStackItems
to have a Stacked Chart.
for example if you want to have a Stacked Chart with three colors:
BarChartRodData(
y: 9,
color: Colors.grey,
rodStackItems: [
BarChartRodStackItem(0, 3, Colors.red),
BarChartRodStackItem(3, 6, Colors.green),
BarChartRodStackItem(6, 9, Colors.blue),
]
)
Implementation
BarChartRodData({
double? fromY,
required this.toY,
Color? color,
this.gradient,
double? width,
BorderRadius? borderRadius,
this.borderDashArray,
BorderSide? borderSide,
BackgroundBarChartRodData? backDrawRodData,
List<BarChartRodStackItem>? rodStackItems,
}) : fromY = fromY ?? 0,
color =
color ?? ((color == null && gradient == null) ? Colors.cyan : null),
width = width ?? 8,
borderRadius = Utils().normalizeBorderRadius(borderRadius, width ?? 8),
borderSide = Utils().normalizeBorderSide(borderSide, width ?? 8),
backDrawRodData = backDrawRodData ?? BackgroundBarChartRodData(),
rodStackItems = rodStackItems ?? const [];