import 'package:d_chart/d_chart.dart';
import 'package:flutter/material.dart';
class DChartPage extends StatefulWidget {
const DChartPage({super.key});
@override
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),
];
String label = '';
@override
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: [
Text(
label,
style: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20,
color: Colors.blue,
),
),
const SizedBox(height: 20),
AspectRatio(
aspectRatio: 16 / 9,
child: DChartComboN(
onChangedListener: (data) {
label = '${data.domain}: ${data.measure} cm';
setState(() {});
},
onUpdatedListener: (data) {
print('updated: ${data.toMap()}');
},
groupList: [
NumericGroup(
id: 'id',
data: numericList,
chartType: ChartType.bar,
),
],
),
),
],
),
);
}
}