Skip to content

Version 3.2.0

Choose a tag to compare

@PhilJay PhilJay released this 26 Sep 08:21
· 1 commit to master since this release
9c7275a

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-SNAPSHOT or a recent master commit: yes, switch to v3.2.0 now. It is exactly the code you use today, and master moves 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 ValueFormatter no 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

  • ValueFormatter is gone. Implement IValueFormatter for values and IAxisValueFormatter for 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 by new PercentFormatter() together with pieChart.setUsePercentValues(true).
  • Gradients moved to bars. setGradientColor(start, end) and setGradientColors(...) now live on BarDataSet, where setGradientColors takes Fill objects; getGradientColor() becomes getFill(index).
  • IPieDataSet.isUsingSliceColorAsValueLineColor() is now isUseValueColorForLineEnabled().
  • Custom renderers: drawValue receives the formatter and entry again: drawValue(Canvas, IValueFormatter, value, entry, dataSetIndex, x, y, color).

New

  • Fill for bar colors: solid colors, gradients and drawables, via BarDataSet.setFills(...). GradientColor remains as a deprecated subclass of Fill.
  • Combined charts: highlightValue(x, dataSetIndex, dataIndex) highlights an entry inside one of the combined data objects.
  • Pie charts: PieDataSet.setHighlightColor(...), and setUseValueColorForLine(true) to draw each value line in its slice color.
  • Axes: setAxisMinLabels / setAxisMaxLabels to change the allowed label count range, and YAxis.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() replace getValues() / 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.
  • onChartScale is 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.