The MultiBar
is a type of BarGroup
which can accept multiple yValue
s and tells the Widget to draw a Group of Bars, each of height representing their own yValue
.
Code Sample Result
Copy ...
import 'package:chart_it/chart_it.dart' ;
class TestBarCharts extends StatefulWidget {
const TestBarCharts ({ Key ? key}) : super(key : key);
@override
State < TestBarCharts > createState () => _TestBarChartsState ();
}
class _TestBarChartsState extends State < TestBarCharts > {
@override
Widget build ( BuildContext context) {
return BarChart (
... // any chart configs
data : BarSeries (
barData : < BarGroup > [
MultiBar (
xValue : 1 ,
yValues : [
BarData (yValue : 18 ),
BarData (yValue : 27 ),
],
),
MultiBar (
xValue : 2 ,
yValues : [
BarData (yValue : 46 ),
BarData (yValue : 24 ),
],
),
MultiBar (
xValue : 3 ,
yValues : [
BarData (yValue : 29 ),
BarData (yValue : 39 ),
],
),
],
),
);
}
}
Above example will display three bar groups, each consisting of two bars!
By default, MultiBar
s will arrange all the bars in a series
manner. You can also provide some padding spacing between each bar in the group.
Code Sample Result
Copy ...
import 'package:chart_it/chart_it.dart' ;
class TestBarCharts extends StatefulWidget {
const TestBarCharts ({ Key ? key}) : super(key : key);
@override
State < TestBarCharts > createState () => _TestBarChartsState ();
}
class _TestBarChartsState extends State < TestBarCharts > {
@override
Widget build ( BuildContext context) {
return BarChart (
... // any chart configs
data : BarSeries (
barData : < BarGroup > [
MultiBar (
arrangement : BarGroupArrangement .series,
spacing : 10.0 ,
xValue : 1 ,
yValues : [
BarData (yValue : 18 ),
BarData (yValue : 27 ),
],
),
MultiBar (
arrangement : BarGroupArrangement .series,
spacing : 50.0 ,
xValue : 2 ,
yValues : [
BarData (yValue : 46 ),
BarData (yValue : 24 ),
],
),
MultiBar (
arrangement : BarGroupArrangement .series,
spacing : 10.0 ,
xValue : 3 ,
yValues : [
BarData (yValue : 29 ),
BarData (yValue : 39 ),
],
),
],
),
);
}
}
To arrange the Bars in a vertical stack, change the enum value for the arrangement
field to BarGroupArrangement.stack
.
Code Sample Result
Copy ...
MultiBar (
arrangement : BarGroupArrangement .stack,
xValue : 1 ,
yValues : [
BarData (yValue : 18 ),
BarData (yValue : 27 ),
],
),
...
When Group Arrangement is stack
, any spacing
value provided will be ignored.
Class Properties
Name Type Required Default Value BarGroupArrangement.series
Last updated 11 months ago