Version 3.2.0
The last release of the Java 3.x line. It packages everything merged into master since 3.1.0 as a stable, pinned version.
implementation 'com.github.PhilJay:MPAndroidChart:v3.2.0'Same coordinates as before, Java API, minSdk 14.
Should you upgrade?
- On
master-SNAPSHOTor a recentmastercommit: yes, switch tov3.2.0now. It is exactly the code you use today, andmastermoves to the Kotlin rewrite with 4.0.0. - On 3.0.x: yes. The formatter API is the same as in 3.0.x, and you get the fixes and additions below.
- On 3.1.0: only if you are ready to adjust your formatters. 3.2.0 goes back to the formatter interfaces of 3.0.x, so code that extends
ValueFormatterno longer compiles (see below). Staying on 3.1.0 is fine, and 4.0.0 is the way forward.
Breaking changes compared to 3.1.0
ValueFormatteris gone. ImplementIValueFormatterfor values andIAxisValueFormatterfor axes instead, as in 3.0.x:xAxis.setValueFormatter((value, axis) -> "M" + (int) value); dataSet.setValueFormatter((value, entry, dataSetIndex, viewPortHandler) -> value + " kg");
PercentFormatter(PieChart)is replaced bynew PercentFormatter()together withpieChart.setUsePercentValues(true).- Gradients moved to bars.
setGradientColor(start, end)andsetGradientColors(...)now live onBarDataSet, wheresetGradientColorstakesFillobjects;getGradientColor()becomesgetFill(index). IPieDataSet.isUsingSliceColorAsValueLineColor()is nowisUseValueColorForLineEnabled().- Custom renderers:
drawValuereceives the formatter and entry again:drawValue(Canvas, IValueFormatter, value, entry, dataSetIndex, x, y, color).
New
Fillfor bar colors: solid colors, gradients and drawables, viaBarDataSet.setFills(...).GradientColorremains as a deprecated subclass ofFill.- Combined charts:
highlightValue(x, dataSetIndex, dataIndex)highlights an entry inside one of the combined data objects. - Pie charts:
PieDataSet.setHighlightColor(...), andsetUseValueColorForLine(true)to draw each value line in its slice color. - Axes:
setAxisMinLabels/setAxisMaxLabelsto change the allowed label count range, andYAxis.setLabelXOffset(...). - Drawing:
setClipDataToContent(false)lets data draw outside the content rectangle. - No data text:
setNoDataTextAlignment(...)aligns it left, center or right. - Data sets:
getEntries()/setEntries()replacegetValues()/setValues(), which stay as deprecated aliases. - Filtering:
ApproximatorN.reduceWithDouglasPeucker(points, resultCount)reduces a line to a target number of points.
Fixed
- A crash with solid colors in bar charts (#4802).
- An index out of bounds crash in stacked bar charts.
- Axis labels that disappeared while zooming in, and a race around the label interval.
- A pie slice without highlight enabled was hidden when highlighted.
- An unexpected dashed line during linear line animations.
- Bubbles drawn with the color of the wrong entry, and the wrong axis used for legend spacing in horizontal bar charts.
- The axis dependency is now respected in combined charts, and horizontal bar charts get correct negative offsets.
onChartScaleis now called after a double tap zoom.- The legend height now includes its last line of labels.
- Clearing a data set now resets its min and max.
- The project builds with current Android Studio versions (#5456).
What's next
MPAndroidChart 4.0.0 follows right after this release: a complete rewrite in Kotlin with a Jetpack Compose module, new coordinates and extensive guides at philjay.cc/mpandroidchart. Projects on 3.x are not affected until they choose to migrate, and the migration guide walks through every step. The 3.x code stays available on the 3.x branch.
Thanks to everyone who contributed fixes and features to 3.x: @danielgindi, @oatrice, @duchampdev, @UrielFrankel, @nathan-fiscaletti and many others.