fl_chart
FL Chart is a highly customizable Flutter chart library that supports Line Chart, Bar Chart, Pie Chart, Scatter Chart, and Radar Chart.
Top Related Projects
📊 Interactive JavaScript Charts built on SVG
Simple HTML5 Charts using the <canvas> tag
JavaScript 3D Library.
Bring data to life with SVG, Canvas and HTML. :bar_chart::chart_with_upwards_trend::tada:
Redefined chart library built with React and D3
Open-source JavaScript charting library behind Plotly and Dash
Quick Overview
FL Chart is a highly customizable Flutter chart library that supports line, bar, pie, scatter, and radar charts. It offers a wide range of features and customization options, allowing developers to create visually appealing and interactive charts in their Flutter applications.
Pros
- Highly customizable with numerous styling options
- Supports multiple chart types in a single library
- Smooth animations and touch interactions
- Active development and community support
Cons
- Learning curve for complex customizations
- Limited built-in theming options
- Some advanced features may require additional implementation
- Documentation could be more comprehensive for certain scenarios
Code Examples
- Creating a basic line chart:
LineChart(
LineChartData(
lineBarsData: [
LineChartBarData(
spots: [
FlSpot(0, 3),
FlSpot(1, 1),
FlSpot(2, 4),
FlSpot(3, 2),
],
isCurved: true,
color: Colors.blue,
),
],
),
)
- Implementing a bar chart with custom colors:
BarChart(
BarChartData(
barGroups: [
BarChartGroupData(
x: 0,
barRods: [
BarChartRodData(y: 8, colors: [Colors.red]),
BarChartRodData(y: 10, colors: [Colors.green]),
BarChartRodData(y: 14, colors: [Colors.blue]),
],
),
],
),
)
- Creating a pie chart with sections:
PieChart(
PieChartData(
sections: [
PieChartSectionData(
color: Colors.blue,
value: 40,
title: '40%',
),
PieChartSectionData(
color: Colors.green,
value: 30,
title: '30%',
),
PieChartSectionData(
color: Colors.red,
value: 30,
title: '30%',
),
],
),
)
Getting Started
-
Add FL Chart to your
pubspec.yaml
:dependencies: fl_chart: ^0.62.0
-
Import the package in your Dart file:
import 'package:fl_chart/fl_chart.dart';
-
Use the desired chart widget (e.g.,
LineChart
,BarChart
,PieChart
) in your Flutter app and customize it according to your needs.
Competitor Comparisons
📊 Interactive JavaScript Charts built on SVG
Pros of apexcharts.js
- Wider range of chart types and customization options
- Better documentation and community support
- Cross-platform compatibility (works with various frameworks)
Cons of apexcharts.js
- Larger file size and potentially slower performance
- Steeper learning curve due to more complex API
- Requires additional setup for Flutter integration
Code Comparison
fl_chart:
LineChart(
LineChartData(
lineBarsData: [
LineChartBarData(spots: [FlSpot(0, 3), FlSpot(1, 1), FlSpot(2, 4)]),
],
),
)
apexcharts.js:
var options = {
series: [{
data: [3, 1, 4]
}],
chart: {
type: 'line'
}
};
var chart = new ApexCharts(document.querySelector("#chart"), options);
chart.render();
Summary
fl_chart is a Flutter-specific charting library, offering good performance and easy integration for Flutter projects. It has a simpler API but fewer chart types and customization options.
apexcharts.js is a more comprehensive charting library with extensive features and cross-platform support. It offers more chart types and customization but may be overkill for simple Flutter projects and requires additional setup for Flutter integration.
Choose fl_chart for Flutter-specific projects with basic charting needs, and apexcharts.js for more complex, cross-platform charting requirements.
Simple HTML5 Charts using the <canvas> tag
Pros of Chart.js
- Wider ecosystem and community support
- More extensive documentation and examples
- Supports a broader range of chart types out-of-the-box
Cons of Chart.js
- Requires JavaScript knowledge, not native to Flutter
- May have performance issues with large datasets
- Less customizable for Flutter-specific UI requirements
Code Comparison
Chart.js (JavaScript):
new Chart(ctx, {
type: 'bar',
data: {
labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'],
datasets: [{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3]
}]
}
});
fl_chart (Dart/Flutter):
BarChart(
BarChartData(
titlesData: FlTitlesData(show: true),
borderData: FlBorderData(show: false),
barGroups: [
BarChartGroupData(x: 0, barRods: [BarChartRodData(y: 8)]),
BarChartGroupData(x: 1, barRods: [BarChartRodData(y: 10)]),
BarChartGroupData(x: 2, barRods: [BarChartRodData(y: 14)]),
],
),
)
While Chart.js offers a more established ecosystem and broader chart options, fl_chart provides native Flutter integration and potentially better performance for mobile apps. Chart.js is ideal for web applications, whereas fl_chart is tailored for Flutter projects, offering seamless integration with Flutter widgets and state management.
JavaScript 3D Library.
Pros of three.js
- More comprehensive 3D rendering capabilities, suitable for complex 3D scenes and animations
- Larger community and ecosystem, with extensive documentation and examples
- Supports a wide range of 3D features like lighting, textures, and physics simulations
Cons of three.js
- Steeper learning curve due to its complexity and extensive feature set
- Larger file size and potentially higher performance overhead for simple visualizations
- Not specifically designed for data visualization or charting
Code Comparison
three.js (3D scene setup):
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
fl_chart (Line chart setup):
LineChart(
LineChartData(
gridData: FlGridData(show: false),
titlesData: FlTitlesData(show: false),
borderData: FlBorderData(show: true),
lineBarsData: [
LineChartBarData(spots: [FlSpot(0, 3), FlSpot(2.6, 2), FlSpot(4.9, 5), FlSpot(6.8, 3.1), FlSpot(8, 4)]),
],
),
)
Bring data to life with SVG, Canvas and HTML. :bar_chart::chart_with_upwards_trend::tada:
Pros of d3
- Highly flexible and powerful, allowing for complex and custom visualizations
- Extensive ecosystem with numerous plugins and extensions
- Widely adopted and well-documented, with a large community
Cons of d3
- Steeper learning curve due to its low-level nature
- Requires more code to create basic charts compared to fl_chart
- Not specifically designed for Flutter, requiring additional setup for mobile use
Code Comparison
d3 (JavaScript):
const svg = d3.select("body").append("svg")
.attr("width", 400)
.attr("height", 200);
svg.append("rect")
.attr("width", 400)
.attr("height", 200)
.attr("fill", "blue");
fl_chart (Dart):
LineChart(
LineChartData(
gridData: FlGridData(show: false),
titlesData: FlTitlesData(show: false),
borderData: FlBorderData(show: false),
lineBarsData: [
LineChartBarData(spots: [
FlSpot(0, 3),
FlSpot(2.6, 2),
FlSpot(4.9, 5),
FlSpot(6.8, 3.1),
FlSpot(8, 4),
FlSpot(9.5, 3),
FlSpot(11, 4),
]),
],
),
)
d3 offers more flexibility but requires more code for basic charts, while fl_chart provides a simpler API for common chart types in Flutter applications.
Redefined chart library built with React and D3
Pros of recharts
- Built for React, offering seamless integration with React applications
- Extensive documentation and a larger community, providing better support
- More chart types and customization options out of the box
Cons of recharts
- Limited to React applications, not suitable for other frameworks
- Larger bundle size compared to fl_chart
- Steeper learning curve for developers new to React ecosystem
Code Comparison
fl_chart:
LineChart(
LineChartData(
lineBarsData: [
LineChartBarData(
spots: [FlSpot(0, 3), FlSpot(1, 1), FlSpot(2, 4)],
isCurved: true,
),
],
),
)
recharts:
<LineChart data={data}>
<XAxis dataKey="name" />
<YAxis />
<Line type="monotone" dataKey="value" stroke="#8884d8" />
</LineChart>
Both libraries offer declarative ways to create charts, but fl_chart uses a more object-oriented approach, while recharts leverages React's component-based structure. fl_chart is designed for Flutter applications, making it a better choice for mobile-first development, while recharts excels in web-based React applications with its extensive features and ecosystem integration.
Open-source JavaScript charting library behind Plotly and Dash
Pros of plotly.js
- More comprehensive and feature-rich, offering a wider range of chart types and customization options
- Better suited for complex data visualization and scientific/statistical plotting
- Extensive documentation and community support
Cons of plotly.js
- Larger file size and potentially heavier performance impact
- Steeper learning curve due to its extensive API and options
- May be overkill for simple charting needs
Code Comparison
plotly.js:
Plotly.newPlot('myDiv', [{
x: [1, 2, 3, 4],
y: [10, 15, 13, 17],
type: 'scatter'
}], {
margin: { t: 0 }
});
fl_chart:
LineChart(
LineChartData(
lineBarsData: [
LineChartBarData(
spots: [
FlSpot(1, 10),
FlSpot(2, 15),
FlSpot(3, 13),
FlSpot(4, 17),
],
),
],
),
)
Both libraries offer ways to create charts, but plotly.js provides a more declarative approach with a single function call, while fl_chart uses a more object-oriented structure. plotly.js is JavaScript-based and can be used in various environments, whereas fl_chart is specifically for Flutter applications.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Our Financial Heroes
Your financial support acts as fuel for fl_chart's development. Support here.
Overview
FL Chart is a highly customizable Flutter chart library that supports Line Chart, Bar Chart, Pie Chart, Scatter Chart, and Radar Chart.
Chart Types
LineChart | BarChart | PieChart |
---|---|---|
Read More | Read More | Read More |
ScatterChart | RadarChart | Coming Soon |
---|---|---|
Read More | Read More |
Banner designed by Soheil Saffar, and samples inspired from David Kovalev, Ricardo Salazar, Dmitro Petrenko, Ghani Pradita, MONUiXD. Thank you all!
Let's get started
First of all, you need to add the fl_chart
in your project. In order to do that, follow this guide.
Then you need to read the docs. Start from here.
We suggest you to check samples source code.
- You can read about the animation handling here
Sample1 | Sample2 | Sample3 |
---|---|---|
Donation
Your donation motivates me to work more on the fl_chart and resolve more issues. There are multiple ways to donate me:
- You can be my sponsor on GitHub (This is the most reliable way to donate me)
- You can buy me a coffee!
- Or if you are a fan of crypto, you can donate me Bitcoins here:
1L7ghKdcmgydmUJAnmYmMaiVjT1LoP4a45
Contributing
:beer: Pull requests are welcome!
Don't forget that open-source
makes no sense without contributors. No matter how big your changes are, it helps us a lot even it is a line of change.
There might be a lot of grammar issues in the docs. It's a big help to us to fix them if you are fluent in English.
Check out CONTRIBUTING.md, which contains a guide for those who want to contribute to the FL Chart.
Reporting bugs and issues are contribution too, yes it is.
Below are the people who has contributed to the FL Chart. We hope we have your picture here soon.
Top Related Projects
📊 Interactive JavaScript Charts built on SVG
Simple HTML5 Charts using the <canvas> tag
JavaScript 3D Library.
Bring data to life with SVG, Canvas and HTML. :bar_chart::chart_with_upwards_trend::tada:
Redefined chart library built with React and D3
Open-source JavaScript charting library behind Plotly and Dash
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot