MPAndroidChart, ported class by class to Flutter
MPFlutterChart is an open-source port of MPAndroidChart v4.0.1: the same class names, the same setup code, the same feel. Written in pure Dart, one codebase for Android, iOS, HarmonyOS and the web.
- 8 chart types
- Drag · zoom · fling
- Pure Dart, no native code
- Android · iOS · HarmonyOS · Web
- Apache 2.0
Live demo
This is the example app from the repository, drawn live in your browser by the library. Tap a point, drag, and zoom with a double click or two fingers. The back arrow leads to the full list of examples.
Why MPFlutterChart
MPAndroidChart is one of the most widely used chart libraries on Android. MPFlutterChart is not a look-alike: its source was translated to Dart class by class.
The MPAndroidChart API
LineDataSet, XAxis, ViewPortHandler, Transformer and the rest keep their names and members, so existing code and experience carry over.
Full interaction
Axis charts drag, pinch zoom, double-tap zoom and fling. Pie and radar charts rotate by touch. Highlighting and markers work out of the box.
Pure Dart
Drawn with dart:ui, with no native code or platform channels. It looks the same on every platform and also builds for web and desktop.
HarmonyOS support
The example app ships Android, iOS and HarmonyOS (OpenHarmony Flutter) projects and builds for HarmonyOS as is.
Flutter widgets on top
Widgets such as LineChart and a ChartController sit on top. Listen to the selection with ListenableBuilder and use the charts like any other widget.
Parity you can check
The repository has an API parity tool and golden tests. Every difference from the original, and the reason for it, is listed in MIGRATION.md.
Chart types
Every chart supports axes, legend, description, markers, highlighting, value formatting and animation.
| Chart | Widget | Data |
|---|---|---|
| Line (cubic, stepped, filled) | LineChart | LineData |
| Bar (stacked, grouped) | BarChart | BarData |
| Horizontal bar | HorizontalBarChart | BarData |
| Scatter | ScatterChart | ScatterData |
| Candlestick | CandleStickChart | CandleData |
| Bubble | BubbleChart | BubbleData |
| Pie and donut | PieChart | PieData |
| Radar | RadarChart | RadarData |
Screenshots
Screenshots of the example app on Android. Every chart is drawn by this library.
Quick start
Requires Flutter 3.35 or later (Dart 3.9 or later).
flutter pub add mp_flutter_chart
import 'package:flutter/material.dart' hide Easing; // Material 3 has its own Easing
import 'package:mp_flutter_chart/mp_flutter_chart.dart';
final data = LineData([
LineDataSet([Entry(x: 0, y: 3), Entry(x: 1, y: 5), Entry(x: 2, y: 4)], 'Sales')
..mode = LineDataSetMode.CUBIC_BEZIER,
]);
Widget build(BuildContext context) => SizedBox(
height: 300,
child: LineChart(
data: data,
// chart is MPAndroidChart's LineChart object, with its full API
setup: (chart) => chart.axisRight.isEnabled = false,
),
);
See the README for the full documentation, and MIGRATION.md for the differences from MPAndroidChart.
FAQ
Which charts does MPFlutterChart support?
Eight: line, bar, horizontal bar, scatter, candlestick, bubble, pie and radar charts. CombinedChart is not ported yet.
Does MPFlutterChart support HarmonyOS?
Yes. The library is pure Dart, and the example app has a HarmonyOS project built with the OpenHarmony Flutter SDK.
I know MPAndroidChart. Do I have to learn a new API?
Mostly not. Class and member names match MPChartLib, so existing setup code and experience carry over. The differences are listed in MIGRATION.md.
Can I use MPFlutterChart commercially?
Yes. It is licensed under Apache License 2.0, the same as MPAndroidChart.