flutter_data_graph 0.0.1+1
flutter_data_graph: ^0.0.1+1 copied to clipboard
Interactive numeric line charts for Flutter Web using Dygraph.js with a Flutter-friendly API.
A Flutter package that brings Dygraph.js line graphs into your Flutter apps via Dart/JS interop.
It provides a Flutter-friendly API for building interactive, high-performance numeric line charts without writing JavaScript yourself.
β¨ Features #
- π Interactive line graphs powered by Dygraph.js
- π¨ Dart-first configuration objects (
GraphConfiguration
,SeriesConfiguration
,AxisConfiguration
, etc.) - π Mouseover highlighting, zooming, and panning
- π·οΈ Legends, custom tags, and extra horizontal lines
- π― Rich callback support (click, zoom, highlight, underlay drawing, etc.)
- π Optimized for Flutter Web
- π’ Numeric-only datasets (see Limitations)
π¦ Installation #
Add the package to your pubspec.yaml
:
dependencies:
flutter_data_graph: ^0.0.1
Then run:
flutter pub get
π Getting Started #
Minimal example using numeric data:
import 'package:flutter/material.dart';
import 'package:flutter_data_graph/flutter_data_graph.dart';
class MyGraphPage extends StatelessWidget {
const MyGraphPage({super.key});
@override
Widget build(BuildContext context) {
final data = <List<num>>[
[0, 5],
[1, 8],
[2, 6],
[3, 10],
[4, 7],
];
return Scaffold(
appBar: AppBar(title: const Text('Data Graph Example')),
body: Center(
child: DataGraph(
data: data,
config: GraphConfiguration(
xLabel: 'Index',
series: [
SeriesConfiguration(
name: 'My Series',
color: '#2196f3',
strokeWidth: 2,
),
],
),
),
),
);
}
}
π§© Example: Reference Line & Zoom Callback #
final config = GraphConfiguration(
xLabel: 'X',
minY: 0,
maxY: 15,
series: const [
SeriesConfiguration(
name: 'Sensor A',
color: Color(0xFFFF5722),
strokeWidth: 2,
),
],
extraLines: const [
ExtraLineConfiguration(
yValue: 8,
color: Color(0xFF00C853),
strokeWidth: 2,
strokePattern: [20, 20],
),
],
zoomCallback: (minX, maxX, ranges) {
debugPrint('Zoomed to: $ranges');
},
);
π οΈ Contributing #
Contributions are welcome! Feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (git checkout -b feature/amazing-feature)
- Commit your changes (git commit -m 'Add some amazing feature')
- Push to the branch (git push origin feature/amazing-feature)
- Open a Pull Request
π License #
MIT License. See LICENSE for details.
π Acknowledgements #
- Built on top of the excellent Dygraph.js.