PhilJay/MPAndroidChart
 Watch   
 Star   
 Fork   
2 days ago
MPAndroidChart

MPAndroidChart 4.0.1

Fixes and small additions for MPAndroidChart 4.0. A drop-in update from 4.0.0: no API was removed or changed.

implementation("com.github.PhilJay.MPAndroidChart:MPChartLib:v4.0.1")
implementation("com.github.PhilJay.MPAndroidChart:MPChartCompose:v4.0.1") // only for Compose

Fixed

  • A tap inside a bar of a combined chart selects the bar instead of a nearby line point (#5207).
  • In a bar chart whose grouped data sets use different y axes, a tap selects the bar that was touched (#5292).
  • Limit line labels at the edge of the content area are no longer cut off (#5328).
  • Auto scaling also rescales a y axis that is disabled (#5258).
  • Charts can be built on a thread without a Looper, for example with an asynchronous layout inflater (#5241).
  • The default value formatter no longer rebuilds its number format when the number of decimals stays the same (#5217).

New

  • YAxis.labelRotationAngle rotates the y axis labels (#5213).
  • Pie entry labels and values with a line break are drawn as several lines (#5205).
  • PieChart.isRoundedSlicesReversed rounds the slice ends the other way around (#5206).
  • PieChart.isTransparentCircleClippedToSlices draws the translucent ring only over the slices, so the space between slices stays open (#5348).
  • chart.toBitmap(width, height) draws a chart at any size, also one that was never laid out, for example to export an image (#4664).

The guides cover all additions, and CHANGELOG.md lists every change.

4 days ago
MPAndroidChart

MPAndroidChart 4.0.0

MPAndroidChart 4.0 is here: the library rewritten from the ground up in Kotlin, with a Jetpack Compose module. It is the first stable release since 3.1.0.

📖 Guides and documentation: philjay.cc/mpandroidchart · 35 chapters from a first chart to theming, Compose, custom renderers and troubleshooting.

New in 4.0

  • Kotlin first. Properties instead of getter and setter pairs, lambdas for formatters and listeners (chart.onValueSelected { entry, highlight -> }), typed entry payloads, lists instead of arrays. Java callers keep working.
  • Jetpack Compose. The new MPChartCompose module: a composable for every chart type, ChartState to read and drive a chart, and markers written as composables.
  • Animated data changes. animateDataChange(newData) moves every value smoothly to its new one, and animateValue(entry, toY) animates a single value. Every animation takes an onEnd callback, and isAnimating and stopAnimations() are new. In Compose, animateChanges = true animates new data automatically.
  • Empty and loading states. A modern empty state with an outline of the chart type instead of the old yellow text, and isLoading for data that is still on its way. Everything about it can be customized.
  • New styling. Rounded bars and stacked sections, rounded radar corners, a ring around the highlighted point, and highlight lines that can stop at the entry.
  • Robust. Tested against NaN, Infinity, empty data and 100,000 entries, inside RecyclerView and LazyColumn, across rotation and with leak checks. More than 40 reported issues are fixed.

Faster

  • Lines draw about 1.2x faster than in 3.1.0, and bars 1.6x faster with the new isDecimationEnabled, which drops entries that share a pixel column.
  • A zoomed-in bar chart builds only the bars on screen: 2.5 ms per frame with 500 bars in view, whether the data holds 10,000 or 300,000.
  • Line circles that would cover each other are skipped, and crowded candles are thinned out, so 100,000 entries draw in well under a second with default settings.

The performance chapter has all measurements.

Get it

// 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") // only for Compose
}

minSdk 23 · compileSdk 35 (37 for Compose) · Java 17 · Kotlin 2.0 or newer. The getting started guide takes you from here to a first chart.

Upgrading

  • From 3.x: class, package and interface names are unchanged, so imports survive and call sites change. The migration guide and MIGRATION.md cover every step. Projects on the 3.x coordinates keep building untouched.
  • Staying on 3.x? Nothing changes for you. 3.2.0 is the last Java release with every fix from 3.x; coming from 3.1.0 it needs small formatter changes, which its notes list. The code lives on the 3.x branch.
  • From 4.0.0-beta01: scatter shape sizes and ComposeMarker.offset are now in dp, centerTextSizePixels is gone, PieData.dataSet is nullable and LargeValueFormatter.suffix is a list.

CHANGELOG.md lists every change. Thanks to everyone who reported issues and sent pull requests over the years.

4 days ago
MPAndroidChart

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

11 days ago
MPAndroidChart

4.0.0-beta01

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.

2019-03-16 18:53:42
MPAndroidChart

Version 3.1.0

About

This mostly includes bug fixes, but with a few notable differences. The biggest change is bumping MPAndroidChart's minSdkVersion to 14. If you have a lower version, you should stop supporting it and go up to 14 as well.

Please see the current distribution usages, as less than 1% of Android devices are running versions 15 and lower now.

Breaking Changes

  • minSdkVersion has been bumped to 14, read the above.
  • Easing class has been simplified, old methods of getting easing functions are DEPRECATED (35c9fc937ecda0dd2eb1a7b879aa869a48bfad3d)
  • Chart.saveToGallery(name, quality) now saves as a PNG instead of JPG (d67ea48)

Additions

  • Upgraded project to androidX, maven upgraded to 2.1, gradle upgraded to 4.6, android gradle to 3.2.1, android build tools to 28.0.3
  • Example project has been refreshed (d67ea481af1e8528c617dfd404d0c7827b0134b2, 5030b36c86cfa2d076bb6b86fa8fcb37ce58557f)
  • Grid lines can be drawn behind or infront of data (c97b8d531d5584b767d0587805c1c95018cf92d6)
  • Can use pie slice color for value line color (1e6e58d2c026be332d6756b04d85b33cd3d36c2b)
  • BarChart supports gradient colored bars (e4ba3cdc20555b5f7cd793e614ee13406a7605ec)

Fixes

  • Zoom animations fixed (6c54f0b0a91ca87fe39dd63d9095e4f55d6c59ff)
  • Many rendering bugs fixed (43ae497ecf7427587687945496c6a70e65f01fcb, aee6058dbb74f4eb1aae8e88c7562d28a91e1e1c, 92c14db5b4de4efd43c9fd74361886b92111ca9f, 89436221db3d83991f9ecd830f871d4ce7da47a4)
  • Copying data sets fixed (7abc9cd6696f78c77068ffc278793594b33497fe)
2018-10-28 11:56:40
MPAndroidChart

Version 3.1.0 pre-release

Pre-Release Disclaimer

This is a pre-release, which means it's not fully tested. However, many bugs have still been fixed and I highly recommend that you update anyway to get those latest changes. Please open an issue if you are still running into issues with this release so they can be patched up for the final 3.1 release!

About

This mostly includes bug fixes, but with a few notable differences. The biggest change is bumping MPAndroidChart's minSdkVersion to 14. If you have a lower version, you should stop supporting it and go up to 14 as well.

Please see the current distribution usages, as less than 1% of Android devices are running versions 15 and lower now.

Breaking Changes

  • minSdkVersion has been bumped to 14, read the above.
  • Easing class has been simplified, old methods of getting easing functions are DEPRECATED (35c9fc937ecda0dd2eb1a7b879aa869a48bfad3d)
  • Chart.saveToGallery(name, quality) now saves as a PNG instead of JPG (d67ea48)

Additions

  • Upgraded project to androidX, maven upgraded to 2.1, gradle upgraded to 4.6, android gradle to 3.2.1, android build tools to 28.0.3
  • Example project has been refreshed (d67ea481af1e8528c617dfd404d0c7827b0134b2, 5030b36c86cfa2d076bb6b86fa8fcb37ce58557f)
  • Grid lines can be drawn behind or infront of data (c97b8d531d5584b767d0587805c1c95018cf92d6)
  • Can use pie slice color for value line color (1e6e58d2c026be332d6756b04d85b33cd3d36c2b)
  • BarChart supports gradient colored bars (e4ba3cdc20555b5f7cd793e614ee13406a7605ec)

Fixes

  • Zoom animations fixed (6c54f0b0a91ca87fe39dd63d9095e4f55d6c59ff)
  • Many rendering bugs fixed (43ae497ecf7427587687945496c6a70e65f01fcb, aee6058dbb74f4eb1aae8e88c7562d28a91e1e1c, 92c14db5b4de4efd43c9fd74361886b92111ca9f, 89436221db3d83991f9ecd830f871d4ce7da47a4)
  • Copying data sets fixed (7abc9cd6696f78c77068ffc278793594b33497fe)
2017-11-29 22:57:30
MPAndroidChart

Gradle updates

Bump compile & target SDK, gradle changes.

2017-03-23 23:15:16
MPAndroidChart

Bugfixing & Stability Improvements

This release includes bugfixes and minor changes that came up over the past weeks.

2016-11-18 02:01:53
MPAndroidChart

Stability Improvements

This release improves stability and fixes bugs.

2016-10-19 15:08:42
MPAndroidChart

New major release

This is a major release, with a few breaking changes. So please pay attention.

Updates:

  • The Integer x-index is dead. Intoducing: x-values (float). Each entry now has an x and a y.
  • Pie/radar charts do not have a concept of X index anymore
  • Unified XAxis/YAxis features and experience.
  • Unified formatter interfaces for axes.
  • Major refactoring of the Highlight mechanism.
  • Refactored marker mechanism
  • Refactored legend entry mechanism
  • Each dataset can now set its own legend form/size/etc.
  • More demos
  • Many minor bug fixes and improvements

Breaking changes / how to migrate:

  • All dataset constructors have changed - they do not take an array of x-indices anymore.
  • All entry constructors have changed - they take in an X and a Y.
  • Pie and Radar chart entries now have their own classes. So exchange the Entry classes withPieEntry/RadarEntry
  • If you have any old startAtZeroEnabled calls - these have been deprecated for a long time. Replace them with axisMinimum.
  • In general, all functions that accepted x-indices before, now accept an x-value, so you might have to adjust the names a little bit.
  • Where OnChartValueSelectedListener is implemented, update the onValueSelected interface
  • Replace drawSliceTextEnabled with drawEntryLabelsEnabled
  • If you have a custom scatter shape - implement an IShapeRenderer, and put your rendering code in there
  • If you have a custom marker - consider subclassing MarkerView/MarkerImage or implementing IMarker. There are more options than before now...
  • If you have used barSpace before, move to using barWidth