Documentation 35 chapters in 8 parts
Guides
Every part of the library in 35 chapters, with Kotlin examples checked against the current source. Start at the top or jump to what you need.
Basics
The axes
2The axis
The settings that both axes share: which parts are drawn, how many labels there are, how the value range is chosen, and the lines you can put on top.
3The x axis
Where the horizontal axis sits, how its labels are drawn, and the recipes for names, dates and edge padding.
4The y axis
The two vertical axes of a chart: which one a data set plots against, where their labels sit, and how their value range is padded.
Data
5Setting data
How to build entries, data sets and a data object for every chart type, from a single line to a combined chart.
6Setting colors
How a chart decides what color to paint each entry with, from a single line color to per-bar gradients and value label colors.
7Formatting values
How to control the text of the values drawn next to the entries and of the labels on the axes.
8Highlighting values
How a value gets selected, how to select one from code, what the resulting Highlight object holds, and how to style the indicator that marks it.
Styling
9General styling
The settings every chart type shares: the background, the text shown while there is no data, the space around the drawing area, the paints the chart draws with, and how to save it as an image.
10Chart specific styling
What each chart type adds on top of the settings all charts share, from bar shadows and the pie hole to the web of a radar chart and the draw order of a combined chart.
11The legend
How the chart builds its legend from the data sets, how to place and style it, and how to replace the computed entries with your own.
12The description
The small label drawn in the bottom right corner of a chart's content area, and the handful of properties that place and style it.
13Theming a chart
How to keep one look for every chart in your app in a palette object and a few extension functions, and how to switch it between dark and light.
Motion and viewport
14Interaction with the chart
Every touch gesture a chart understands, how to switch each one off, and the listeners that tell you what the user did.
15Dynamic and realtime data
How to add and remove entries and data sets while a chart is on screen, what to call afterwards, and how to keep a fast feed drawing smoothly.
16Modifying the viewport
Everything that decides which part of the data is on screen: zoom, scroll, the limits on both, the offsets around the content area, and how to read the current state back.
17Animations
Building the chart up over time with animateX, animateY and animateXY, the easing curves that shape them, spinning round charts, and animating the viewport.
18Markers
The popup drawn at a highlighted value: the composable marker of the Compose module, MarkerView from a layout, MarkerImage from a drawable, and the IMarker interface behind them all.
Classes in depth
19The ChartData class
The base class behind LineData, BarData and the rest: the list of data sets, the cached ranges over them, and the lookups and broadcast styling every data object shares.
20ChartData subclasses
What each data class adds on top of ChartData, from the bar width to the five slots of a combined chart.
21The DataSet class
The styling and behaviour every data set shares, from the legend label to the entry lookups and the cached value ranges.
22DataSet subclasses
What each chart type's data set adds on top of the shared settings, from line modes and bar corners to candle colors and pie value lines.
23The ViewPortHandler
The object behind every chart that knows the chart size, the rectangle the data is drawn in, and the zoom and drag state, with the limits that keep all three sane.
24The fill formatter
How a line data set decides where its filled area ends, what the default does, and how to fill to zero, to an axis edge or to a value of your own.
25Custom data sets
How to write your own data set class, what the renderers actually read from it, and how far you can go before you have to touch a renderer.
26Custom renderers
The classes that paint a chart onto its canvas, how a chart wires them up, and how to replace one with your own.
Integration
27Jetpack Compose
The MPChartCompose module wraps every chart view in a composable, so you can pass data as state, read the selection back, and drive zoom and animation from Compose.
28Calling the library from Java
What the Kotlin API looks like from a Java caller: property accessors, default arguments, lambdas, generics and the few places where Java needs a longer spelling.
29Charts in lists and scrolling screens
How to put a chart into a LazyColumn, a recycled row, a fragment or a scrolling screen without rebuilding data on every frame or fighting the parent for the gesture.
30R8 and ProGuard
What a minified release build needs for the chart library, which is almost nothing, and the few rules your own formatters and markers may still want.
In practice
31Performance with large data
What a chart actually spends its time on when it draws, which settings buy the most of it back, and how to measure instead of guess.
32Accessibility
What a screen reader can and cannot get from a chart, and the things you can do about it.
33Troubleshooting
Concrete symptoms you may hit with a chart, what causes each one in the library, and what to change.
34Migrating from 3.x
What to change in an app written against MPAndroidChart 3.x when you move it to the Kotlin rewrite.
35Miscellaneous
The useful corners of the library that do not belong to any one chart type: unit conversion, number formatting, saving an image, the pooled geometry classes, sorting, logging and what to do with a very large data set.