Skip to content

4.0.0-beta01

Pre-release
Pre-release

Choose a tag to compare

@PhilJay PhilJay released this 19 Sep 20:54
· 0 commits to master since this release

MPAndroidChart is back, rewritten from the ground up in Kotlin, with a Jetpack Compose module and documentation to match.

What's new

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.

How to get it

// 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.

Coming from 3.x

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.

This is a beta

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.