Skip to main content

2.8.0

Watch

  • bar label styling / decoration move to Config Render Bar
  • restructure/segmentation styling, formatter and decorator for each chart
  • new point decorator
  • remove unused property in some chart type
  • fontweight and lineheight on Label Style
  • tickLabelFormatter for domain type Numeric and Time
  • numeric tick provider to manage tick on axis
import 'package:d_chart/d_chart.dart';
import 'package:flutter/material.dart';

class DChartPage extends StatefulWidget {
const DChartPage({super.key});


State<DChartPage> createState() => _DChartPageState();
}

class _DChartPageState extends State<DChartPage> {
get numericList => [
NumericData(domain: 1, measure: 3),
NumericData(domain: 2, measure: 5),
NumericData(domain: 3, measure: 9),
NumericData(domain: 4, measure: 6.5),
];


Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text(
"D'Chart",
style: TextStyle(
fontWeight: FontWeight.w400,
fontSize: 14,
color: Colors.black,
),
),
),
body: ListView(
children: [
AspectRatio(
aspectRatio: 16 / 9,
child: DChartComboN(
barLabelValue: (group, data, index) {
return data.measure.toString();
},
configRenderPoint: ConfigRenderPoint(
showPointLabel: true,
pointLabelDecorator: PointLabelDecorator(
labelFormatterN: (data) {
return '${data.measure.round()} kg';
},
),
),
configRenderBar: ConfigRenderBar(
showBarLabel: true,
barLabelDecorator: BarLabelDecorator(
labelAnchor: BarLabelAnchor.middle,
insideLabelStyle: const LabelStyle(
color: Colors.blue,
fontSize: 20,
fontWeight: FontWeight.bold,
lineHeight: 1,
),
),
),
measureAxis: const MeasureAxis(
numericTickProvider: NumericTickProvider(
desiredTickCount: 5,
),
),
domainAxis: DomainAxis(
tickLabelFormatterN: (domain) {
return '${domain!.round()} cm';
},
numericTickProvider: const NumericTickProvider(
zeroBound: true,
desiredTickCount: 10,
),
labelStyle: const LabelStyle(
color: Colors.blue,
fontSize: 20,
fontWeight: FontWeight.bold,
lineHeight: 1,
),
),
groupList: [
NumericGroup(
id: 'id',
data: numericList,
chartType: ChartType.scatterPlot,
),
],
),
),
],
),
);
}
}