Skip to main content

l6

alt

import 'package:d_chart/d_chart.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
List<TimeData> series1 = [
TimeData(domain: DateTime(2024, 1), measure: 10),
TimeData(domain: DateTime(2024, 2), measure: 20),
TimeData(domain: DateTime(2024, 3), measure: 30),
TimeData(domain: DateTime(2024, 4), measure: 50),
TimeData(domain: DateTime(2024, 5), measure: 75),
TimeData(domain: DateTime(2024, 6), measure: 55),
TimeData(domain: DateTime(2024, 7), measure: 65),
TimeData(domain: DateTime(2024, 8), measure: 58),
TimeData(domain: DateTime(2024, 9), measure: 88),
TimeData(domain: DateTime(2024, 10), measure: 50),
TimeData(domain: DateTime(2024, 11), measure: 40),
TimeData(domain: DateTime(2024, 12), measure: 48),
];
List<TimeData> series2 = [
TimeData(domain: DateTime(2024, 1), measure: 20),
TimeData(domain: DateTime(2024, 2), measure: 24),
TimeData(domain: DateTime(2024, 3), measure: 40),
TimeData(domain: DateTime(2024, 4), measure: 60),
TimeData(domain: DateTime(2024, 5), measure: 35),
TimeData(domain: DateTime(2024, 6), measure: 65),
TimeData(domain: DateTime(2024, 7), measure: 75),
TimeData(domain: DateTime(2024, 8), measure: 38),
TimeData(domain: DateTime(2024, 9), measure: 58),
TimeData(domain: DateTime(2024, 10), measure: 60),
TimeData(domain: DateTime(2024, 11), measure: 50),
TimeData(domain: DateTime(2024, 12), measure: 78),
];
AspectRatio(
aspectRatio: 16 / 9,
child: DChartLineT(
configRenderLine: ConfigRenderLine(
strokeWidthPx: 2.5,
),
layoutMargin: LayoutMargin(40, 10, 20, 10),
domainAxis: DomainAxis(
showLine: false,
useGridLine: true,
gridLineStyle: LineStyle(
color: Colors.grey.shade200,
),
tickLength: 0,
gapAxisToLabel: 10,
tickLabelFormatterT: (domain) {
return DateFormat('MMM').format(domain);
},
labelStyle: const LabelStyle(
color: Colors.grey,
fontSize: 10,
),
),
measureAxis: MeasureAxis(
useGridLine: true,
gridLineStyle: LineStyle(
color: Colors.grey.shade200,
),
numericTickProvider: const NumericTickProvider(
desiredTickCount: 10,
),
tickLength: 0,
gapAxisToLabel: 10,
tickLabelFormatter: (measure) {
return measure!.toInt().toString().padLeft(2, '0');
},
labelStyle: const LabelStyle(
color: Colors.grey,
fontSize: 10,
),
),
groupList: [
TimeGroup(
id: '1',
data: series1,
color: Colors.blue,
),
TimeGroup(
id: '2',
data: series2,
color: Colors.deepPurple,
),
],
),
),