Skip to main content

2.7.1

Watch

  • new property:
    • onUpdatedListener
    • onChangedListener
  • upgrade dart sdk to 3.4.3 or flutter 3.22.2
  • upgrade community_chart to 1.0.4
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),
];

String label = '';


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(() {});
// print('changed: ${data.toMap()}');
},
onUpdatedListener: (data) {
print('updated: ${data.toMap()}');
},
groupList: [
NumericGroup(
id: 'id',
data: numericList,
chartType: ChartType.bar,
),
],
),
),
],
),
);
}
}