Open source · Android · Kotlin

Every chart your Android app needs.

Line, bar, pie, scatter, candlestick, bubble, radar and combined charts with zooming, dragging, highlighting, markers and animations. A property based Kotlin API, a Jetpack Compose module and one dependency line to get going.

38kGitHub stars 9kforks Apache 2.0license 2014maintained since

Nine chart types, one way of working

Entries hold the values, a data set holds one series and its styling, the data object holds all series of a chart. Learn it once for the line chart and you know it for all of them. Every card below is a screenshot of the example app's Design section, drawn by the library.

Scatter plots, full width lines, cubic and stepped lines, half pies, negative stacks, realtime data and more are in the example app.

Built for real apps

Touch that feels nativeDrag, pinch to zoom, double tap, fling with deceleration, tap to highlight, rotate pies and radars.
Style everythingAxes, grid, legend, limit lines, value formatters, colors, dash patterns, fills and gradients, all as properties.
Markers and highlightsShow a view or a composable at the selected entry, with listeners for selection and gestures.
AnimationsAnimate along x, y or both with thirty easing curves, or animate zoom and scrolling.
Fast with big dataThirty thousand points on a line chart render smoothly thanks to buffered drawing and viewport culling.
Typed payloadsAttach your own objects to entries and get them back typed from selections and lookups.
Documented APIEvery class, function and property carries documentation with units, defaults and side effects.
Save and shareRender any chart to a bitmap or straight into the gallery.

Jetpack Compose, first class

Every chart type has a composable with the same name. Pass data as state, configure once in setup, and read selection and viewport back through rememberChartState. Markers are composables, previews work, and state survives configuration changes.

val state = rememberChartState()
LaunchedEffect(lineData) { state.animateX(500) }

LineChart(
    data = lineData,
    modifier = Modifier.fillMaxWidth().height(300.dp),
    state = state,
    marker = { entry, _ -> Text("${entry.y}") },
    setup = { axisRight.isEnabled = false },
)
Text("Selected: ${state.selectedEntry?.y}")
A line chart, a pie chart and a bar chart driven by Compose state

Documentation

Get started

Add the JitPack repository and one dependency, put a chart in a layout or a composable, and give it data.

1. Add the dependency

// settings.gradle.kts
dependencyResolutionManagement {
    repositories {
        maven("https://jitpack.io")
    }
}

// build.gradle.kts
dependencies {
    implementation("com.github.PhilJay.MPAndroidChart:MPChartLib:v4.0.0")
    implementation("com.github.PhilJay.MPAndroidChart:MPChartCompose:v4.0.0")
}

2. Show a chart

val entries = listOf(Entry(0f, 4f), Entry(1f, 8f), Entry(2f, 6f))
val set = LineDataSet(entries, "Sales").apply {
    color = Color.BLUE
    lineWidth = 2f
    mode = LineDataSet.Mode.CUBIC_BEZIER
}
chart.data = LineData(set)
chart.animateX(500)

Requires minSdk 23. Apache License 2.0. Questions go to Stack Overflow, bugs to GitHub issues.