forked from imaNNeo/fl_chart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbar_chart_sample3.dart
126 lines (124 loc) · 4.09 KB
/
bar_chart_sample3.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import 'package:fl_chart/fl_chart.dart';
import 'package:flutter/material.dart';
class BarChartSample3 extends StatefulWidget {
@override
State<StatefulWidget> createState() => BarChartSample3State();
}
class BarChartSample3State extends State<BarChartSample3> {
@override
Widget build(BuildContext context) {
return AspectRatio(
aspectRatio: 1.7,
child: Card(
elevation: 0,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(4)),
color: const Color(0xff2c4260),
child: BarChart(
BarChartData(
alignment: BarChartAlignment.spaceAround,
maxY: 20,
barTouchData: BarTouchData(
enabled: false,
touchTooltipData: BarTouchTooltipData(
tooltipBgColor: Colors.transparent,
tooltipPadding: const EdgeInsets.all(0),
tooltipBottomMargin: 8,
getTooltipItem: (
BarChartGroupData group,
int groupIndex,
BarChartRodData rod,
int rodIndex,
) {
return BarTooltipItem(
rod.y.round().toString(),
TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
);
},
),
),
titlesData: FlTitlesData(
show: true,
bottomTitles: SideTitles(
showTitles: true,
getTextStyles: (value) => const TextStyle(
color: Color(0xff7589a2), fontWeight: FontWeight.bold, fontSize: 14),
margin: 20,
getTitles: (double value) {
switch (value.toInt()) {
case 0:
return 'Mn';
case 1:
return 'Te';
case 2:
return 'Wd';
case 3:
return 'Tu';
case 4:
return 'Fr';
case 5:
return 'St';
case 6:
return 'Sn';
default:
return '';
}
},
),
leftTitles: SideTitles(showTitles: false),
),
borderData: FlBorderData(
show: false,
),
barGroups: [
BarChartGroupData(
x: 0,
barRods: [
BarChartRodData(y: 8, colors: [Colors.lightBlueAccent, Colors.greenAccent])
],
showingTooltipIndicators: [0],
),
BarChartGroupData(
x: 1,
barRods: [
BarChartRodData(y: 10, colors: [Colors.lightBlueAccent, Colors.greenAccent])
],
showingTooltipIndicators: [0],
),
BarChartGroupData(
x: 2,
barRods: [
BarChartRodData(y: 14, colors: [Colors.lightBlueAccent, Colors.greenAccent])
],
showingTooltipIndicators: [0],
),
BarChartGroupData(
x: 3,
barRods: [
BarChartRodData(y: 15, colors: [Colors.lightBlueAccent, Colors.greenAccent])
],
showingTooltipIndicators: [0],
),
BarChartGroupData(
x: 3,
barRods: [
BarChartRodData(y: 13, colors: [Colors.lightBlueAccent, Colors.greenAccent])
],
showingTooltipIndicators: [0],
),
BarChartGroupData(
x: 3,
barRods: [
BarChartRodData(y: 10, colors: [Colors.lightBlueAccent, Colors.greenAccent])
],
showingTooltipIndicators: [0],
),
],
),
),
),
);
}
}