b3
import 'package:d_chart/d_chart.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
List<TimeData> series1 = [
TimeData(domain: DateTime(2024, 10, 20), measure: 3),
TimeData(domain: DateTime(2024, 10, 21), measure: 2),
TimeData(domain: DateTime(2024, 10, 22), measure: 4),
TimeData(domain: DateTime(2024, 10, 23), measure: 6),
TimeData(domain: DateTime(2024, 10, 24), measure: 3.8),
TimeData(domain: DateTime(2024, 10, 25), measure: 1.8),
TimeData(domain: DateTime(2024, 10, 26), measure: 1.2),
];
AspectRatio(
aspectRatio: 16 / 9,
child: DChartBarT(
fillColor: (group, timeData, index) {
return DateFormat.E().format(timeData.domain).substring(0, 1) == 'W'
? Colors.deepPurple
: null;
},
configRenderBar: ConfigRenderBar(
barGroupInnerPaddingPx: 0,
radius: 6,
),
domainAxis: DomainAxis(
showLine: false,
tickLength: 0,
gapAxisToLabel: 12,
labelStyle: LabelStyle(
color: Colors.grey.shade400,
fontWeight: FontWeight.bold,
fontSize: 14,
),
tickLabelFormatterT: (domain) {
return DateFormat.E().format(domain).substring(0, 1);
},
),
measureAxis: const MeasureAxis(
noRenderSpec: true,
),
groupList: [
TimeGroup(
id: '1',
data: series1,
color: Colors.deepPurple.shade50,
),
],
),
),