Skip to main content

b9

alt

import 'package:d_chart/d_chart.dart';
import 'package:flutter/material.dart';
List<OrdinalData> series1 = [
OrdinalData(domain: 'Week 2', measure: 4300),
OrdinalData(domain: 'Week 3', measure: 4000),
OrdinalData(domain: 'Week 4', measure: 6700),
OrdinalData(domain: 'Week 5', measure: 2800),
];
List<OrdinalData> series2 = [
OrdinalData(domain: 'Week 2', measure: 6000),
OrdinalData(domain: 'Week 3', measure: 4000),
OrdinalData(domain: 'Week 4', measure: 5000),
OrdinalData(domain: 'Week 5', measure: 3000),
];
AspectRatio(
aspectRatio: 16 / 9,
child: DChartBarO(
layoutMargin: LayoutMargin(40, 10, 10, 10),
barLabelValue: (group, data, index) {
return NumberFormat.compactCurrency(
decimalDigits: 0,
symbol: '\$',
).format(data.measure);
},
configRenderBar: ConfigRenderBar(
showBarLabel: true,
barLabelDecorator: BarLabelDecorator(
barLabelPosition: BarLabelPosition.inside,
insideLabelStyle: const LabelStyle(
fontSize: 8,
color: Colors.white,
),
),
barGroupInnerPaddingPx: 0,
radius: 4,
),
domainAxis: const DomainAxis(
showLine: false,
tickLength: 0,
gapAxisToLabel: 12,
labelStyle: LabelStyle(
fontSize: 10,
color: Colors.black54,
),
),
measureAxis: MeasureAxis(
tickLength: 0,
gapAxisToLabel: 8,
tickLabelFormatter: (measure) {
return NumberFormat.compactCurrency(
decimalDigits: 0,
symbol: '\$',
).format(measure);
},
numericTickProvider: const NumericTickProvider(
desiredMinTickCount: 6,
desiredMaxTickCount: 10,
),
labelStyle: const LabelStyle(
fontSize: 10,
color: Colors.black54,
),
),
groupList: [
OrdinalGroup(
id: '1',
data: series1,
color: Colors.lightBlue,
),
OrdinalGroup(
id: '2',
data: series2,
color: Colors.deepPurple,
),
],
),
),