Skip to main content

l8

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, 2), measure: 80000),
TimeData(domain: DateTime(2023, 10, 2), measure: 80000),
TimeData(domain: DateTime(2023, 10, 2), measure: 70000),
TimeData(domain: DateTime(2023, 10, 3), measure: 70000),
TimeData(domain: DateTime(2023, 10, 4), measure: 70000),
TimeData(domain: DateTime(2023, 10, 4), measure: 60000),
TimeData(domain: DateTime(2023, 10, 5), measure: 60000),
TimeData(domain: DateTime(2023, 10, 6), measure: 60000),
TimeData(domain: DateTime(2023, 10, 6), measure: 70000),
TimeData(domain: DateTime(2023, 10, 7), measure: 70000),
TimeData(domain: DateTime(2023, 10, 8), measure: 70000),
TimeData(domain: DateTime(2023, 10, 8), measure: 80000),
TimeData(domain: DateTime(2023, 10, 9), measure: 80000),
TimeData(domain: DateTime(2023, 10, 10), measure: 80000),
TimeData(domain: DateTime(2023, 10, 10), measure: 70000),
TimeData(domain: DateTime(2023, 10, 11), measure: 70000),
TimeData(domain: DateTime(2023, 10, 12), measure: 70000),
TimeData(domain: DateTime(2023, 10, 12), measure: 50000),
TimeData(domain: DateTime(2023, 10, 13), measure: 50000),
];
List<TimeData> series2 = [
TimeData(domain: DateTime(2023, 10, 1, 2), measure: 20000),
TimeData(domain: DateTime(2023, 10, 2), measure: 20000),
TimeData(domain: DateTime(2023, 10, 2), measure: 30000),
TimeData(domain: DateTime(2023, 10, 3), measure: 30000),
TimeData(domain: DateTime(2023, 10, 4), measure: 30000),
TimeData(domain: DateTime(2023, 10, 4), measure: 50000),
TimeData(domain: DateTime(2023, 10, 5), measure: 50000),
TimeData(domain: DateTime(2023, 10, 6), measure: 50000),
TimeData(domain: DateTime(2023, 10, 6), measure: 40000),
TimeData(domain: DateTime(2023, 10, 7), measure: 40000),
TimeData(domain: DateTime(2023, 10, 8), measure: 40000),
TimeData(domain: DateTime(2023, 10, 8), measure: 30000),
TimeData(domain: DateTime(2023, 10, 9), measure: 30000),
TimeData(domain: DateTime(2023, 10, 10), measure: 30000),
TimeData(domain: DateTime(2023, 10, 10), measure: 50000),
TimeData(domain: DateTime(2023, 10, 11), measure: 50000),
TimeData(domain: DateTime(2023, 10, 11), measure: 40000),
TimeData(domain: DateTime(2023, 10, 12), measure: 40000),
TimeData(domain: DateTime(2023, 10, 12), measure: 40000),
TimeData(domain: DateTime(2023, 10, 13), measure: 40000),
];
AspectRatio(
aspectRatio: 16 / 9,
child: DChartLineT(
configRenderLine: ConfigRenderLine(
strokeWidthPx: 2.5,
),
layoutMargin: LayoutMargin(40, 10, 20, 10),
domainAxis: DomainAxis(
showLine: false,
tickLength: 0,
gapAxisToLabel: 10,
tickLabelFormatterT: (domain) {
return DateFormat('MMM d').format(domain);
},
labelStyle: const LabelStyle(
color: Colors.black54,
fontSize: 10,
),
),
measureAxis: MeasureAxis(
useGridLine: true,
gridLineStyle: LineStyle(
color: Colors.grey.shade300,
dashPattern: [4],
),
numericTickProvider: const NumericTickProvider(
desiredTickCount: 5,
),
tickLength: 0,
gapAxisToLabel: 10,
tickLabelFormatter: (measure) {
return NumberFormat.compactCurrency(
symbol: '',
decimalDigits: 0,
).format(measure);
},
labelStyle: const LabelStyle(
color: Colors.black54,
fontSize: 10,
),
),
groupList: [
TimeGroup(
id: '1',
data: series1,
color: Colors.green,
),
TimeGroup(
id: '2',
data: series2,
color: Colors.red,
),
],
),
),