Dragon Charts Flutter is a lightweight, declarative, and highly customizable charting library for Flutter. It provides a simple yet powerful way to create various types of charts, with a focus on ease of use and flexibility.
- Lightweight: Minimal dependencies and optimized for performance.
- Declarative: Define charts using a declarative API that makes customization straightforward.
- Customizable: Highly customizable with support for different line types, colors, and more.
- Expandable: Designed with a modular architecture to easily add new chart types.
Pub is the recommended way to install this package, but you can also install it from GitHub.
Run this command:
flutter pub add dragon_charts_flutter
dependencies:
dragon_charts_flutter:
git:
url: https://github.com/your_username/dragon_charts_flutter.git
ref: main # or a specific tag/branch/commit
Then, run flutter pub get
to install the package.
Here is a simple example to get you started:
import 'dart:async';
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:dragon_charts_flutter/dragon_charts_flutter.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: BlocProvider(
create: (_) => ChartBloc(),
child: const ChartScreen(),
),
);
}
}
class ChartScreen extends StatelessWidget {
const ChartScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Custom Line Chart with Animation')),
body: Padding(
padding: const EdgeInsets.all(32),
child: BlocBuilder<ChartBloc, ChartState>(
builder: (context, state) {
return CustomLineChart(
domainExtent: const ChartExtent.tight(),
elements: [
ChartGridLines(isVertical: false, count: 5),
ChartAxisLabels(
isVertical: true,
count: 5,
labelBuilder: (value) => value.toStringAsFixed(2)),
ChartAxisLabels(
isVertical: false,
count: 5,
labelBuilder: (value) => value.toStringAsFixed(2)),
ChartDataSeries(data: state.data1, color: Colors.blue),
ChartDataSeries(
data: state.data2,
color: Colors.red,
lineType: LineType.bezier),
],
tooltipBuilder: (context, dataPoints) {
return ChartTooltip(
dataPoints: dataPoints, backgroundColor: Colors.black);
},
);
},
),
),
);
}
}
Represents a data point in the chart.
x
:double
- The x-coordinate of the data point.y
:double
- The y-coordinate of the data point.
Represents a series of data points to be plotted on the chart.
data
:List<ChartData>
- The list of data points.color
:Color
- The color of the series.lineType
:LineType
- The type of line (straight or bezier).
The main widget for displaying a line chart.
elements
:List<ChartElement>
- The elements to be drawn on the chart.tooltipBuilder
:Widget Function(BuildContext, List<ChartData>)
- The builder for custom tooltips.domainExtent
:ChartExtent
- The extent of the domain (x-axis).rangeExtent
:ChartExtent
- The extent of the range (y-axis).backgroundColor
:Color
- The background color of the chart.
- ✅ Initial release with support for line charts.
- Add pie charts support.
- Improve documentation and add more examples.
- Add bar charts support.
- Implement interactive legends.
- Add scatter plots support.
- Enhance performance for large datasets.
- Full documentation and stable release.
- Add support for exporting charts as images.
Dragon Charts Flutter is an excellent solution for your charting needs because:
- Lightweight: It has minimal dependencies and is optimized for performance, making it suitable for both small and large projects.
- Declarative: The declarative API makes it easy to define and customize charts, reducing the complexity of your code.
- Customizable: The library is highly customizable, allowing you to create unique and visually appealing charts tailored to your application's needs.
- Expandable: The modular architecture enables easy addition of new chart types and features, ensuring the library can grow with your requirements.
Contributions are welcome! Please read the contributing guidelines first.
This project is licensed under the MIT License - see the LICENSE file for details.