Skip to main content

l9

alt

import 'package:d_chart/d_chart.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
List<TimeData> series1 = [
TimeData(domain: DateTime(2023, 10, 1), measure: 0),
TimeData(domain: DateTime(2023, 10, 4), measure: 65),
];
List<TimeData> series2 = [
TimeData(domain: DateTime(2023, 10, 1), measure: 0),
TimeData(domain: DateTime(2023, 10, 2), measure: 27),
TimeData(domain: DateTime(2023, 10, 3), measure: 35),
TimeData(domain: DateTime(2023, 10, 4), measure: 65),
];
AspectRatio(
aspectRatio: 16 / 9,
child: DChartLineT(
flipVertical: true,
dashPattern: (group, timeData, index) {
if (group.id == '1') return [6];
return [];
},
configRenderLine: ConfigRenderLine(
strokeWidthPx: 2.5,
),
layoutMargin: LayoutMargin(46, 10, 20, 10),
domainAxis: DomainAxis(
lineStyle: LineStyle(
color: Colors.grey.shade300,
),
tickLength: -6,
tickLineStyle: const LineStyle(
color: Colors.black45,
thickness: 2,
),
gapAxisToLabel: 10,
tickLabelFormatterT: (domain) {
return DateFormat('MMM d').format(domain);
},
labelStyle: const LabelStyle(
color: Colors.black54,
),
),
measureAxis: MeasureAxis(
useGridLine: true,
gridLineStyle: LineStyle(
color: Colors.grey.shade300,
dashPattern: [4],
),
numericTickProvider: const NumericTickProvider(
desiredTickCount: 5,
),
tickLength: 0,
gapAxisToLabel: 12,
tickLabelFormatter: (measure) {
return '${measure!.toInt()}%';
},
labelStyle: const LabelStyle(
color: Colors.black54,
),
),
groupList: [
TimeGroup(
id: '1',
data: series1,
color: Colors.grey.shade400,
),
TimeGroup(
id: '2',
data: series2,
color: Colors.red,
),
],
),
),