Skip to content

Commit aa556e4

Browse files
committed
edited time for imageViewer
1 parent 5bd0f74 commit aa556e4

File tree

1 file changed

+111
-73
lines changed

1 file changed

+111
-73
lines changed

lib/widgets/congestionPointView.dart

Lines changed: 111 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -67,47 +67,66 @@ class CongestionPointView extends StatelessWidget {
6767
),
6868
),
6969
),
70-
Container(
71-
height: 200,
72-
child: LineChart(
73-
LineChartData(
74-
minY: 0,
75-
maxY: 1,
76-
gridData: FlGridData(show: false),
77-
titlesData: FlTitlesData(
78-
leftTitles: AxisTitles(
79-
sideTitles: SideTitles(showTitles: true),
80-
),
81-
bottomTitles: AxisTitles(
82-
sideTitles: SideTitles(
83-
showTitles: true,
84-
getTitlesWidget: (value, meta) {
85-
final index = value.toInt();
86-
if (index >= 0 && index < data.length) {
87-
final formattedTime = _formatToHour(data[index].ratedOn);
88-
return Text(formattedTime);
89-
}
90-
return const SizedBox.shrink();
91-
},
70+
Padding(
71+
padding: const EdgeInsets.symmetric(horizontal: 16.0),
72+
child: Container(
73+
height: 200,
74+
child: LineChart(
75+
LineChartData(
76+
minY: 0,
77+
maxY: 1,
78+
gridData: FlGridData(show: false),
79+
titlesData: FlTitlesData(
80+
leftTitles: AxisTitles(
81+
sideTitles: SideTitles(
82+
showTitles: true,
83+
interval: 0.5,
84+
getTitlesWidget: (value, meta) {
85+
// Display y-axis values as percentages
86+
if (value == 0) return Text('0%');
87+
if (value == 0.5) return Text('50%');
88+
if (value == 1) return Text('100%');
89+
return const SizedBox.shrink();
90+
},
91+
),
92+
),
93+
rightTitles: AxisTitles(
94+
sideTitles: SideTitles(showTitles: false), // Hide right y-axis labels
95+
),
96+
topTitles: AxisTitles(
97+
sideTitles: SideTitles(showTitles: false), // Hide top labels
98+
),
99+
bottomTitles: AxisTitles(
100+
sideTitles: SideTitles(
101+
showTitles: true,
102+
getTitlesWidget: (value, meta) {
103+
final index = value.toInt();
104+
if (index >= 0 && index < data.length) {
105+
final formattedTime = _formatToHour(data[index].ratedOn);
106+
return Text(formattedTime);
107+
}
108+
return const SizedBox.shrink();
109+
},
110+
),
92111
),
93112
),
113+
borderData: FlBorderData(show: true),
114+
lineBarsData: [
115+
LineChartBarData(
116+
spots: data
117+
.asMap()
118+
.entries
119+
.map((entry) => FlSpot(
120+
entry.key.toDouble(), entry.value.value.toDouble()))
121+
.toList(),
122+
isCurved: true,
123+
color: Colors.red,
124+
belowBarData: BarAreaData(show: false),
125+
),
126+
],
94127
),
95-
borderData: FlBorderData(show: true),
96-
lineBarsData: [
97-
LineChartBarData(
98-
spots: data
99-
.asMap()
100-
.entries
101-
.map((entry) => FlSpot(
102-
entry.key.toDouble(), entry.value.value.toDouble()))
103-
.toList(),
104-
isCurved: true,
105-
color: Colors.red,
106-
belowBarData: BarAreaData(show: false),
107-
),
108-
],
109128
),
110-
),
129+
)
111130
)
112131
]);
113132
}
@@ -129,45 +148,64 @@ class CongestionPointView extends StatelessWidget {
129148
),
130149
),
131150
),
132-
Container(
133-
height: 150,
134-
child: BarChart(
135-
BarChartData(
136-
minY: 0,
137-
maxY: 1,
138-
barGroups: data
139-
.asMap()
140-
.entries
141-
.map((entry) => BarChartGroupData(
142-
x: entry.key,
143-
barRods: [
144-
BarChartRodData(
145-
toY: entry.value.value.toDouble(),
146-
color: Colors.blue),
147-
],
148-
))
149-
.toList(),
150-
titlesData: FlTitlesData(
151-
leftTitles: AxisTitles(
152-
sideTitles: SideTitles(showTitles: true),
153-
),
154-
bottomTitles: AxisTitles(
155-
sideTitles: SideTitles(
156-
showTitles: true,
157-
getTitlesWidget: (value, meta) {
158-
final index = value.toInt();
159-
if (index >= 0 && index < data.length) {
160-
final formattedDate =
161-
_formatToDayMonth(data[index].ratedOn);
162-
return Text(formattedDate);
163-
}
164-
return const SizedBox.shrink();
165-
},
151+
Padding(
152+
padding: const EdgeInsets.symmetric(horizontal: 16.0),
153+
child: Container(
154+
height: 150,
155+
child: BarChart(
156+
BarChartData(
157+
minY: 0,
158+
maxY: 1,
159+
barGroups: data
160+
.asMap()
161+
.entries
162+
.map((entry) => BarChartGroupData(
163+
x: entry.key,
164+
barRods: [
165+
BarChartRodData(
166+
toY: entry.value.value.toDouble(),
167+
color: Colors.blue),
168+
],
169+
))
170+
.toList(),
171+
titlesData: FlTitlesData(
172+
leftTitles: AxisTitles(
173+
sideTitles: SideTitles(
174+
showTitles: true,
175+
interval: 0.5,
176+
getTitlesWidget: (value, meta) {
177+
// Display y-axis values as percentages
178+
if (value == 0) return Text('0%');
179+
if (value == 0.5) return Text('50%');
180+
if (value == 1) return Text('100%');
181+
return const SizedBox.shrink();
182+
},
183+
),
184+
),
185+
rightTitles: AxisTitles(
186+
sideTitles: SideTitles(showTitles: false), // Hide right y-axis labels
187+
),
188+
topTitles: AxisTitles(
189+
sideTitles: SideTitles(showTitles: false), // Hide top labels
190+
),
191+
bottomTitles: AxisTitles(
192+
sideTitles: SideTitles(
193+
showTitles: true,
194+
getTitlesWidget: (value, meta) {
195+
final index = value.toInt();
196+
if (index >= 0 && index < data.length) {
197+
final formattedDate =
198+
_formatToDayMonth(data[index].ratedOn);
199+
return Text(formattedDate);
200+
}
201+
return const SizedBox.shrink();
202+
},
203+
),
166204
),
167205
),
168206
),
169207
),
170-
),
208+
)
171209
)
172210
]);
173211
}
@@ -185,7 +223,7 @@ class CongestionPointView extends StatelessWidget {
185223
future: fetchGraphRatings(
186224
cameraId,
187225
'hour', // groupby
188-
DateTime.now().subtract(Duration(hours: 10)),
226+
DateTime.now().subtract(Duration(hours: 8)),
189227
DateTime.now()),
190228
builder: (context, snapshot) {
191229
if (snapshot.connectionState == ConnectionState.waiting) {

0 commit comments

Comments
 (0)