more cleanup

This commit is contained in:
Andrei Stoica 2024-11-14 14:10:51 -05:00
parent b6fe1841aa
commit 99c9c0d4e5
2 changed files with 21 additions and 7 deletions

View File

@ -40,11 +40,8 @@ class _MyHomePageState extends State<MyHomePage> {
),
body: Padding(
padding: const EdgeInsets.all(20),
child: RotatedBox(
quarterTurns: 1,
child: MyBarChart(),
),
),
);
}
}
@ -91,8 +88,18 @@ class MyBarChart extends StatelessWidget {
.map((d) => BarChartGroupData(
x: data.indexOf(d),
barRods: [
BarChartRodData(toY: d.year.toDouble(), color: Colors.orange),
BarChartRodData(toY: d.gpa.toDouble(), color: Colors.indigo)
BarChartRodData(
toY: d.year.toDouble(),
width: 40,
borderRadius: BorderRadius.all(Radius.circular(5)),
color: Colors.orange,
),
BarChartRodData(
toY: d.gpa.toDouble(),
width: 40,
borderRadius: BorderRadius.all(Radius.circular(5)),
color: Colors.indigo,
)
],
))
.toList();
@ -122,7 +129,10 @@ class MyBarChart extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BarChart(_chartData());
return RotatedBox(
quarterTurns: 1,
child: BarChart(_chartData()),
);
}
}
@ -135,6 +145,8 @@ class ChartData {
static List<ChartData> exampleData() {
return [
ChartData(name: "John", gpa: 2, year: 1),
ChartData(name: "Jane", gpa: 3, year: 2),
ChartData(name: "John Doe", gpa: 2, year: 1),
ChartData(name: "Jane Doe", gpa: 3, year: 2),
ChartData(name: "Doe", gpa: 4, year: 3),

View File

@ -59,6 +59,8 @@ class ChartData {
return [
ChartData(name: "John", gpa: 2, year: 1),
ChartData(name: "Jane", gpa: 3, year: 2),
ChartData(name: "John Doe", gpa: 2, year: 1),
ChartData(name: "Jane Doe", gpa: 3, year: 2),
ChartData(name: "Doe", gpa: 4, year: 3),
];
}