4.0.0-beta01
MPAndroidChart is back, rewritten from the ground up in Kotlin, with a Jetpack Compose module and documentation to match.
A Kotlin API that feels like Kotlin. Every getter and setter pair is a property, boolean flags read isXxxEnabled, and formatters and listeners are functional interfaces, so a lambda is enough: chart.onValueSelected { entry, highlight -> }. Colors, labels and draw orders are lists instead of arrays, entries carry a typed payload, and notifyDataSetChanged() alone recalculates and redraws.
Jetpack Compose. A new MPChartCompose module: one composable per chart type, ChartState for reading and driving a chart from Compose, and ComposeMarker for markers written as composables.
Faster with large data. Bars are clipped to the viewport, points are reduced to what a pixel column can actually show, entry lookup goes through the x value instead of walking the set, and the shared object pools no longer grow on every frame.
New styling. Rounded bars and rounded corners on every section of a stacked bar, rounded polygon corners on radar charts, a ring and halo around the highlighted point of a line chart, and highlight lines that can stop at the entry instead of crossing the whole chart.
Sharper axes and labels. X axis labels keep a label's width apart instead of overlapping, value labels are decided per data set from what is actually in view, and forced labels respect the axis granularity.
More than 40 reported issues fixed, plus six community pull requests ported. CHANGELOG.md has the full list.
Documentation. 35 chapters of guides at philjay.cc/mpandroidchart/docs, KDoc on every public class, function and property, and a generated API reference for MPChartLib and MPChartCompose.
// settings.gradle.kts
dependencyResolutionManagement {
repositories {
maven("https://jitpack.io")
}
}
// build.gradle.kts
dependencies {
implementation("com.github.PhilJay.MPAndroidChart:MPChartLib:v4.0.0-beta01")
implementation("com.github.PhilJay.MPAndroidChart:MPChartCompose:v4.0.0-beta01") // only for Compose
}
minSdk 23, compileSdk 35, Java 17 and Kotlin 2.0 or newer. Java callers need no Kotlin at all. The Compose module needs compileSdk 37, because Compose itself does.
The class, package and interface names are unchanged, so imports survive and the call sites change. MIGRATION.md lists every change with before and after code, and the migration guide walks through them.
Nothing here disturbs an existing project: 4.0 publishes under a new coordinate, so com.github.PhilJay:MPAndroidChart:v3.1.0 keeps resolving exactly as it does today, and master still carries the 3.x sources.
The API can still change before 4.0.0, so pin this version rather than tracking the newest one. Feedback and bug reports are very welcome.
Version 3.1.0
This mostly includes bug fixes, but with a few notable differences. The biggest change is bumping MPAndroidChart's minSdkVersion to 14. If you have a lower version, you should stop supporting it and go up to 14 as well.
Please see the current distribution usages, as less than 1% of Android devices are running versions 15 and lower now.
minSdkVersionhas been bumped to14, read the above.Easingclass has been simplified, old methods of getting easing functions are DEPRECATED (35c9fc937ecda0dd2eb1a7b879aa869a48bfad3d)Chart.saveToGallery(name, quality)now saves as a PNG instead of JPG (d67ea48)
- Upgraded project to
androidX, maven upgraded to2.1, gradle upgraded to4.6, android gradle to3.2.1, android build tools to28.0.3 - Example project has been refreshed (d67ea481af1e8528c617dfd404d0c7827b0134b2, 5030b36c86cfa2d076bb6b86fa8fcb37ce58557f)
- Grid lines can be drawn behind or infront of data (c97b8d531d5584b767d0587805c1c95018cf92d6)
- Can use pie slice color for value line color (1e6e58d2c026be332d6756b04d85b33cd3d36c2b)
- BarChart supports gradient colored bars (e4ba3cdc20555b5f7cd793e614ee13406a7605ec)
- Zoom animations fixed (6c54f0b0a91ca87fe39dd63d9095e4f55d6c59ff)
- Many rendering bugs fixed (43ae497ecf7427587687945496c6a70e65f01fcb, aee6058dbb74f4eb1aae8e88c7562d28a91e1e1c, 92c14db5b4de4efd43c9fd74361886b92111ca9f, 89436221db3d83991f9ecd830f871d4ce7da47a4)
- Copying data sets fixed (7abc9cd6696f78c77068ffc278793594b33497fe)
Version 3.1.0 pre-release
This is a pre-release, which means it's not fully tested. However, many bugs have still been fixed and I highly recommend that you update anyway to get those latest changes. Please open an issue if you are still running into issues with this release so they can be patched up for the final 3.1 release!
This mostly includes bug fixes, but with a few notable differences. The biggest change is bumping MPAndroidChart's minSdkVersion to 14. If you have a lower version, you should stop supporting it and go up to 14 as well.
Please see the current distribution usages, as less than 1% of Android devices are running versions 15 and lower now.
minSdkVersionhas been bumped to14, read the above.Easingclass has been simplified, old methods of getting easing functions are DEPRECATED (35c9fc937ecda0dd2eb1a7b879aa869a48bfad3d)Chart.saveToGallery(name, quality)now saves as a PNG instead of JPG (d67ea48)
- Upgraded project to
androidX, maven upgraded to2.1, gradle upgraded to4.6, android gradle to3.2.1, android build tools to28.0.3 - Example project has been refreshed (d67ea481af1e8528c617dfd404d0c7827b0134b2, 5030b36c86cfa2d076bb6b86fa8fcb37ce58557f)
- Grid lines can be drawn behind or infront of data (c97b8d531d5584b767d0587805c1c95018cf92d6)
- Can use pie slice color for value line color (1e6e58d2c026be332d6756b04d85b33cd3d36c2b)
- BarChart supports gradient colored bars (e4ba3cdc20555b5f7cd793e614ee13406a7605ec)
- Zoom animations fixed (6c54f0b0a91ca87fe39dd63d9095e4f55d6c59ff)
- Many rendering bugs fixed (43ae497ecf7427587687945496c6a70e65f01fcb, aee6058dbb74f4eb1aae8e88c7562d28a91e1e1c, 92c14db5b4de4efd43c9fd74361886b92111ca9f, 89436221db3d83991f9ecd830f871d4ce7da47a4)
- Copying data sets fixed (7abc9cd6696f78c77068ffc278793594b33497fe)
Gradle updates
Bump compile & target SDK, gradle changes.
Bugfixing & Stability Improvements
This release includes bugfixes and minor changes that came up over the past weeks.
Stability Improvements
This release improves stability and fixes bugs.
New major release
This is a major release, with a few breaking changes. So please pay attention.
Updates:
- The Integer
x-indexis dead. Intoducing: x-values (float). Each entry now has anxand ay. - Pie/radar charts do not have a concept of X index anymore
- Unified XAxis/YAxis features and experience.
- Unified formatter interfaces for axes.
- Major refactoring of the Highlight mechanism.
- Refactored marker mechanism
- Refactored legend entry mechanism
- Each dataset can now set its own legend form/size/etc.
- More demos
- Many minor bug fixes and improvements
Breaking changes / how to migrate:
- All dataset constructors have changed - they do not take an array of x-indices anymore.
- All entry constructors have changed - they take in an X and a Y.
- Pie and Radar chart entries now have their own classes. So exchange the Entry classes with
PieEntry/RadarEntry - If you have any old
startAtZeroEnabledcalls - these have been deprecated for a long time. Replace them withaxisMinimum. - In general, all functions that accepted x-indices before, now accept an x-value, so you might have to adjust the names a little bit.
- Where
OnChartValueSelectedListeneris implemented, update theonValueSelectedinterface - Replace
drawSliceTextEnabledwithdrawEntryLabelsEnabled - If you have a custom scatter shape - implement an
IShapeRenderer, and put your rendering code in there - If you have a custom marker - consider subclassing
MarkerView/MarkerImageor implementingIMarker. There are more options than before now... - If you have used
barSpacebefore, move to usingbarWidth
New MPAndroidChart v3.0b
- Elimination of the "x-index" concept (each
Entrynow has afloatx- and y-coordinate) - Change of the
Entryconstructor fromEntry(float y, int xIndex)toEntry(float x, float y) XAxisandYAxisconcept is now similar (XAxisno longer represented byStrings)- Separation of the Realm.io support to a separate repository
- Bugfixes and stability improvement
- Many more...
Currently, the documentation is not up to date and still refers to versions prior to 3.0 - please have a look a the example project to figure out how the new API works. An update of the docs will follow soon.
Please also note that this is a "beta" release that might contain bugs that require fixing. A stable release 3.0 will be out within the next few weeks. If you are certain that you discovered a new issue with this new version, please let me know.
Bugfixes, new features
- New: Horizontal cubic bezier lines for Line chart (through
modeproperty) - New: Allow transparent color in circle hole color (Line chart)
- New:
circleHoleRadiusproperty for more control over line chart circles - New:
PieChartvalues outside of chart (connected with lines) - New:
highlightFullBarfor highlighting all values on an x-index at once - New: Allow setting
xValson existing Data objects - New: Allow bubble sizes to not be normalized against the dataset max
- New: Added material color template
- New: Flag to control whether we draw a limit line's labels
- New: Exploded the Legend-Position enum to support more combinations
- New: Allow drawing borders for bars in a Bar chart
- Improved: Highlighting when multiple values on x-index present (bubble chart, combined chart)
- Fixed: We are now taking into account the
extraoffsets for Pie/Radar chart view - Fixes regarding MarkerView
- Improvements to Demo, now keeping dataset styling when changin dataset size
- General bugfixes