mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
extracted titlesData into a private factory method to enahnce readability.
This commit is contained in:
@ -36,36 +36,7 @@ class RangeOfAqiChart extends StatelessWidget {
|
|||||||
gridData: EnergyManagementChartsHelper.gridData(
|
gridData: EnergyManagementChartsHelper.gridData(
|
||||||
horizontalInterval: 50,
|
horizontalInterval: 50,
|
||||||
),
|
),
|
||||||
titlesData: EnergyManagementChartsHelper.titlesData(context).copyWith(
|
titlesData: _titlesData(context),
|
||||||
leftTitles: AxisTitles(
|
|
||||||
sideTitles: SideTitles(
|
|
||||||
reservedSize: 70,
|
|
||||||
interval: 51,
|
|
||||||
showTitles: true,
|
|
||||||
maxIncluded: true,
|
|
||||||
getTitlesWidget: (value, meta) {
|
|
||||||
String text;
|
|
||||||
if (value >= 300) {
|
|
||||||
text = '300+';
|
|
||||||
} else if (value == 255) {
|
|
||||||
text = '300';
|
|
||||||
} else {
|
|
||||||
text = ((value / 50).round() * 50).toInt().toString();
|
|
||||||
}
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsetsDirectional.only(end: 12),
|
|
||||||
child: Text(
|
|
||||||
text,
|
|
||||||
style: context.textTheme.bodySmall?.copyWith(
|
|
||||||
fontSize: 12,
|
|
||||||
color: ColorsManager.lightGreyColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
borderData: EnergyManagementChartsHelper.borderData(),
|
borderData: EnergyManagementChartsHelper.borderData(),
|
||||||
betweenBarsData: [
|
betweenBarsData: [
|
||||||
BetweenBarsData(
|
BetweenBarsData(
|
||||||
@ -148,4 +119,41 @@ class RangeOfAqiChart extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FlTitlesData _titlesData(BuildContext context) {
|
||||||
|
final titlesData = EnergyManagementChartsHelper.titlesData(context);
|
||||||
|
return titlesData.copyWith(
|
||||||
|
leftTitles: titlesData.leftTitles.copyWith(
|
||||||
|
sideTitles: titlesData.leftTitles.sideTitles.copyWith(
|
||||||
|
reservedSize: 70,
|
||||||
|
interval: 51,
|
||||||
|
maxIncluded: true,
|
||||||
|
getTitlesWidget: (value, meta) {
|
||||||
|
String text;
|
||||||
|
if (value >= 300) {
|
||||||
|
text = '300+';
|
||||||
|
} else if (value == 255) {
|
||||||
|
text = '300';
|
||||||
|
} else {
|
||||||
|
text = ((value / 50).round() * 50).toInt().toString();
|
||||||
|
}
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsetsDirectional.only(end: 12),
|
||||||
|
child: FittedBox(
|
||||||
|
alignment: AlignmentDirectional.centerStart,
|
||||||
|
fit: BoxFit.scaleDown,
|
||||||
|
child: Text(
|
||||||
|
text,
|
||||||
|
style: context.textTheme.bodySmall?.copyWith(
|
||||||
|
fontSize: 12,
|
||||||
|
color: ColorsManager.lightGreyColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user