├── demo ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── dimens.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── anim │ │ │ │ ├── move_left_in_activity.xml │ │ │ │ ├── move_left_out_activity.xml │ │ │ │ ├── move_right_in_activity.xml │ │ │ │ └── move_right_out_activity.xml │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ └── layout │ │ │ │ └── activity_main.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── github │ │ │ └── mikephil │ │ │ └── demo │ │ │ └── MainActivity.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── github │ │ │ └── mikephil │ │ │ └── demo │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── github │ │ └── mikephil │ │ └── demo │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── MPChartLib ├── .gitignore ├── ic_launcher-web.png ├── .settings │ └── gradle │ │ └── org.springsource.ide.eclipse.gradle.core.prefs ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── github │ │ │ │ └── mikephil │ │ │ │ └── charting │ │ │ │ ├── interfaces │ │ │ │ ├── dataprovider │ │ │ │ │ ├── BubbleDataProvider.java │ │ │ │ │ ├── CandleDataProvider.java │ │ │ │ │ ├── ScatterDataProvider.java │ │ │ │ │ ├── LineDataProvider.java │ │ │ │ │ ├── BarDataProvider.java │ │ │ │ │ ├── CombinedDataProvider.java │ │ │ │ │ ├── BarLineScatterCandleBubbleDataProvider.java │ │ │ │ │ └── ChartInterface.java │ │ │ │ └── datasets │ │ │ │ │ ├── IBarLineScatterCandleBubbleDataSet.java │ │ │ │ │ ├── IBubbleDataSet.java │ │ │ │ │ ├── IRadarDataSet.java │ │ │ │ │ ├── IScatterDataSet.java │ │ │ │ │ ├── ILineScatterCandleRadarDataSet.java │ │ │ │ │ ├── ILineRadarDataSet.java │ │ │ │ │ ├── IBarDataSet.java │ │ │ │ │ ├── ICandleDataSet.java │ │ │ │ │ └── IPieDataSet.java │ │ │ │ ├── highlight │ │ │ │ ├── IHighlighter.java │ │ │ │ ├── PieHighlighter.java │ │ │ │ ├── Range.java │ │ │ │ └── PieRadarHighlighter.java │ │ │ │ ├── exception │ │ │ │ └── DrawingDataSetNotCreatedException.java │ │ │ │ ├── animation │ │ │ │ └── EasingFunction.java │ │ │ │ ├── listener │ │ │ │ ├── OnDrawLineChartTouchListener.java │ │ │ │ ├── OnChartValueSelectedListener.java │ │ │ │ ├── OnDrawListener.java │ │ │ │ └── OnChartGestureListener.java │ │ │ │ ├── data │ │ │ │ ├── CandleData.java │ │ │ │ ├── LineData.java │ │ │ │ ├── BarLineScatterCandleBubbleData.java │ │ │ │ ├── BubbleData.java │ │ │ │ ├── ScatterData.java │ │ │ │ ├── RadarEntry.java │ │ │ │ ├── BarLineScatterCandleBubbleDataSet.java │ │ │ │ ├── BaseEntry.java │ │ │ │ ├── RadarData.java │ │ │ │ ├── PieEntry.java │ │ │ │ ├── BubbleEntry.java │ │ │ │ └── BubbleDataSet.java │ │ │ │ ├── renderer │ │ │ │ ├── Renderer.java │ │ │ │ └── scatter │ │ │ │ │ ├── IShapeRenderer.java │ │ │ │ │ ├── CrossShapeRenderer.java │ │ │ │ │ ├── ChevronDownShapeRenderer.java │ │ │ │ │ ├── ChevronUpShapeRenderer.java │ │ │ │ │ ├── XShapeRenderer.java │ │ │ │ │ └── CircleShapeRenderer.java │ │ │ │ ├── utils │ │ │ │ ├── EntryXComparator.java │ │ │ │ ├── HorizontalViewPortHandler.java │ │ │ │ ├── MPPointD.java │ │ │ │ ├── TransformerHorizontalBarChart.java │ │ │ │ └── FSize.java │ │ │ │ ├── formatter │ │ │ │ ├── IAxisValueFormatter.java │ │ │ │ ├── ColorFormatter.java │ │ │ │ ├── IFillFormatter.java │ │ │ │ ├── IValueFormatter.java │ │ │ │ ├── DefaultFillFormatter.java │ │ │ │ ├── PercentFormatter.java │ │ │ │ ├── DefaultAxisValueFormatter.java │ │ │ │ ├── DefaultValueFormatter.java │ │ │ │ └── IndexAxisValueFormatter.java │ │ │ │ ├── charts │ │ │ │ ├── CandleStickChart.java │ │ │ │ ├── BubbleChart.java │ │ │ │ ├── LineChart.java │ │ │ │ └── ScatterChart.java │ │ │ │ ├── jobs │ │ │ │ ├── ViewPortJob.java │ │ │ │ └── MoveViewJob.java │ │ │ │ └── components │ │ │ │ └── IMarker.java │ │ └── AndroidManifest.xml │ └── test │ │ └── java │ │ └── com │ │ └── github │ │ └── mikephil │ │ └── charting │ │ └── test │ │ └── ApproximatorTest.java ├── project.properties ├── proguard-project.txt └── build.gradle ├── MPChartExample ├── .gitignore ├── assets │ ├── stacked_bars.txt │ ├── OpenSans-Bold.ttf │ ├── OpenSans-Light.ttf │ ├── OpenSans-Italic.ttf │ ├── OpenSans-Regular.ttf │ ├── OpenSans-BoldItalic.ttf │ ├── OpenSans-ExtraBold.ttf │ ├── OpenSans-Semibold.ttf │ ├── OpenSans-LightItalic.ttf │ ├── OpenSans-ExtraBoldItalic.ttf │ ├── OpenSans-SemiboldItalic.ttf │ └── n.txt ├── ic_launcher-web.png ├── res │ ├── drawable-nodpi │ │ ├── marker.png │ │ ├── marker2.png │ │ └── radar_marker.png │ ├── drawable-hdpi │ │ └── ic_launcher.png │ ├── drawable-mdpi │ │ └── ic_launcher.png │ ├── drawable-xhdpi │ │ └── ic_launcher.png │ ├── drawable-xxhdpi │ │ └── ic_launcher.png │ ├── values-sw600dp │ │ └── dimens.xml │ ├── menu │ │ ├── realm.xml │ │ ├── realtime.xml │ │ ├── combined.xml │ │ ├── main.xml │ │ ├── dynamical.xml │ │ ├── draw.xml │ │ ├── bubble.xml │ │ ├── scatter.xml │ │ ├── candle.xml │ │ ├── pie.xml │ │ ├── bar.xml │ │ ├── radar.xml │ │ └── line.xml │ ├── values │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ ├── anim │ │ ├── move_left_in_activity.xml │ │ ├── move_left_out_activity.xml │ │ ├── move_right_in_activity.xml │ │ └── move_right_out_activity.xml │ ├── drawable │ │ ├── fade_red.xml │ │ └── new_background.xml │ ├── layout │ │ ├── activity_main.xml │ │ ├── activity_draw_chart.xml │ │ ├── activity_piechart_half.xml │ │ ├── activity_barchart_noseekbar.xml │ │ ├── activity_combined.xml │ │ ├── activity_linechart_noseekbar.xml │ │ ├── activity_piechart_noseekbar.xml │ │ ├── activity_radarchart.xml │ │ ├── activity_bubblechart_noseekbar.xml │ │ ├── activity_realtime_linechart.xml │ │ ├── activity_scatterchart_noseekbar.xml │ │ ├── activity_candlechart_noseekbar.xml │ │ ├── activity_horizontalbarchart_noseekbar.xml │ │ ├── activity_listview_chart.xml │ │ ├── list_item_barchart.xml │ │ ├── list_item_linechart.xml │ │ ├── list_item_piechart.xml │ │ ├── frag_simple_line.xml │ │ ├── frag_simple_pie.xml │ │ ├── frag_simple_scatter.xml │ │ ├── activity_age_distribution.xml │ │ ├── activity_awesomedesign.xml │ │ ├── frag_simple_bar.xml │ │ ├── activity_realm_wiki.xml │ │ ├── activity_radarchart_noseekbar.xml │ │ ├── custom_marker_view.xml │ │ ├── radar_markerview.xml │ │ ├── activity_colored_lines.xml │ │ ├── activity_linechart_time.xml │ │ ├── activity_scrollview.xml │ │ ├── activity_barchart_sinus.xml │ │ ├── activity_performance_linechart.xml │ │ ├── list_item.xml │ │ ├── activity_barchart.xml │ │ ├── activity_piechart.xml │ │ ├── activity_linechart.xml │ │ └── activity_scatterchart.xml │ ├── values-sw720dp-land │ │ └── dimens.xml │ ├── values-v11 │ │ └── styles.xml │ └── values-v14 │ │ └── styles.xml ├── .settings │ └── gradle │ │ └── org.springsource.ide.eclipse.gradle.core.prefs ├── src │ └── com │ │ └── xxmassdeveloper │ │ └── mpchartexample │ │ ├── notimportant │ │ ├── ContentItem.java │ │ ├── DemoBase.java │ │ └── MyAdapter.java │ │ ├── custom │ │ ├── MyEasingFunction.java │ │ ├── RealmFloat.java │ │ ├── MyAxisValueFormatter.java │ │ ├── MyValueFormatter.java │ │ ├── MyFillFormatter.java │ │ ├── YearXAxisFormatter.java │ │ ├── CustomScatterShapeRenderer.java │ │ ├── MyCustomXAxisValueFormatter.java │ │ ├── MyMarkerView.java │ │ ├── RadarMarkerView.java │ │ ├── XYMarkerView.java │ │ └── StackedBarsMarkerView.java │ │ ├── listviewitems │ │ └── ChartItem.java │ │ ├── realm │ │ └── Score.java │ │ └── fragments │ │ ├── ComplexityFragment.java │ │ └── SineCosineFragment.java ├── project.properties ├── proguard-project.txt └── build.gradle ├── gradle.properties ├── design ├── ic_launcher.psd ├── facebook_icon.png ├── header_symbol.png ├── twitter_icon.png ├── feature_graphic.png ├── feature_graphic.psd ├── googleplus_icon.png └── video_thumbnail.png ├── screenshots ├── linechart.png ├── barchart2d.png ├── barchart3d.png ├── bubblechart.png ├── radarchart.png ├── realm_wiki.png ├── screenshot.gif ├── ValueFormatter.jpg ├── build.gradle.png ├── combined_chart.png ├── cubiclinechart.png ├── linechart_wiki.png ├── piechart_wiki.png ├── scatterchart.png ├── smart_legends.png ├── candlestickchart.png ├── groupedbarchart.png ├── linechart_legend.png ├── horizontal_barchart.png ├── line_chart_gradient.png ├── linechart_colored.png ├── linechart_multiline.png ├── piechart_selected.png ├── candlestickchart_old.png ├── grouped_barchart_wiki.png ├── normal_barchart_wiki.png ├── piechart_more_colors.png ├── MPAndroidChart_trending.png ├── barchart2d_multi_dataset.png ├── simpledesign_barchart2.png ├── simpledesign_barchart3.png ├── simpledesign_linechart1.png ├── simpledesign_linechart2.png ├── simpledesign_linechart3.png ├── simpledesign_linechart4.png ├── simpledesign_linechart5.png ├── simpledesign_piechart1.png ├── piechart_holeradius_space.png ├── zero_line_example_barchart.png ├── AndroidWeekly_Issue114_10082014.png ├── barchart2d_multi_dataset_date1.png ├── barchart2d_multi_dataset_date2.png ├── tranding_developers_11_08_2014.png └── linechart_multiline_color_variations.png ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── settings.gradle ├── .settings └── gradle │ └── org.springsource.ide.eclipse.gradle.core.prefs ├── .gitignore └── readme.md /demo/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /MPChartLib/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /MPChartExample/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx2048M -------------------------------------------------------------------------------- /design/ic_launcher.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/design/ic_launcher.psd -------------------------------------------------------------------------------- /design/facebook_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/design/facebook_icon.png -------------------------------------------------------------------------------- /design/header_symbol.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/design/header_symbol.png -------------------------------------------------------------------------------- /design/twitter_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/design/twitter_icon.png -------------------------------------------------------------------------------- /screenshots/linechart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/linechart.png -------------------------------------------------------------------------------- /MPChartExample/assets/stacked_bars.txt: -------------------------------------------------------------------------------- 1 | 4#2#6#0 2 | 0#2#8#1 3 | 3#8#2#2 4 | 0#7#0#3 5 | 5#5#2#4 6 | 9#0#0#5 7 | 3#3#6#6 -------------------------------------------------------------------------------- /demo/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Demo 3 | 4 | -------------------------------------------------------------------------------- /design/feature_graphic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/design/feature_graphic.png -------------------------------------------------------------------------------- /design/feature_graphic.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/design/feature_graphic.psd -------------------------------------------------------------------------------- /design/googleplus_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/design/googleplus_icon.png -------------------------------------------------------------------------------- /design/video_thumbnail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/design/video_thumbnail.png -------------------------------------------------------------------------------- /screenshots/barchart2d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/barchart2d.png -------------------------------------------------------------------------------- /screenshots/barchart3d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/barchart3d.png -------------------------------------------------------------------------------- /screenshots/bubblechart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/bubblechart.png -------------------------------------------------------------------------------- /screenshots/radarchart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/radarchart.png -------------------------------------------------------------------------------- /screenshots/realm_wiki.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/realm_wiki.png -------------------------------------------------------------------------------- /screenshots/screenshot.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/screenshot.gif -------------------------------------------------------------------------------- /MPChartLib/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/MPChartLib/ic_launcher-web.png -------------------------------------------------------------------------------- /screenshots/ValueFormatter.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/ValueFormatter.jpg -------------------------------------------------------------------------------- /screenshots/build.gradle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/build.gradle.png -------------------------------------------------------------------------------- /screenshots/combined_chart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/combined_chart.png -------------------------------------------------------------------------------- /screenshots/cubiclinechart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/cubiclinechart.png -------------------------------------------------------------------------------- /screenshots/linechart_wiki.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/linechart_wiki.png -------------------------------------------------------------------------------- /screenshots/piechart_wiki.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/piechart_wiki.png -------------------------------------------------------------------------------- /screenshots/scatterchart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/scatterchart.png -------------------------------------------------------------------------------- /screenshots/smart_legends.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/smart_legends.png -------------------------------------------------------------------------------- /screenshots/candlestickchart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/candlestickchart.png -------------------------------------------------------------------------------- /screenshots/groupedbarchart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/groupedbarchart.png -------------------------------------------------------------------------------- /screenshots/linechart_legend.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/linechart_legend.png -------------------------------------------------------------------------------- /MPChartExample/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/MPChartExample/ic_launcher-web.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /screenshots/horizontal_barchart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/horizontal_barchart.png -------------------------------------------------------------------------------- /screenshots/line_chart_gradient.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/line_chart_gradient.png -------------------------------------------------------------------------------- /screenshots/linechart_colored.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/linechart_colored.png -------------------------------------------------------------------------------- /screenshots/linechart_multiline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/linechart_multiline.png -------------------------------------------------------------------------------- /screenshots/piechart_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/piechart_selected.png -------------------------------------------------------------------------------- /screenshots/candlestickchart_old.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/candlestickchart_old.png -------------------------------------------------------------------------------- /screenshots/grouped_barchart_wiki.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/grouped_barchart_wiki.png -------------------------------------------------------------------------------- /screenshots/normal_barchart_wiki.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/normal_barchart_wiki.png -------------------------------------------------------------------------------- /screenshots/piechart_more_colors.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/piechart_more_colors.png -------------------------------------------------------------------------------- /MPChartExample/assets/OpenSans-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/MPChartExample/assets/OpenSans-Bold.ttf -------------------------------------------------------------------------------- /MPChartExample/assets/OpenSans-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/MPChartExample/assets/OpenSans-Light.ttf -------------------------------------------------------------------------------- /screenshots/MPAndroidChart_trending.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/MPAndroidChart_trending.png -------------------------------------------------------------------------------- /screenshots/barchart2d_multi_dataset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/barchart2d_multi_dataset.png -------------------------------------------------------------------------------- /screenshots/simpledesign_barchart2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/simpledesign_barchart2.png -------------------------------------------------------------------------------- /screenshots/simpledesign_barchart3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/simpledesign_barchart3.png -------------------------------------------------------------------------------- /screenshots/simpledesign_linechart1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/simpledesign_linechart1.png -------------------------------------------------------------------------------- /screenshots/simpledesign_linechart2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/simpledesign_linechart2.png -------------------------------------------------------------------------------- /screenshots/simpledesign_linechart3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/simpledesign_linechart3.png -------------------------------------------------------------------------------- /screenshots/simpledesign_linechart4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/simpledesign_linechart4.png -------------------------------------------------------------------------------- /screenshots/simpledesign_linechart5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/simpledesign_linechart5.png -------------------------------------------------------------------------------- /screenshots/simpledesign_piechart1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/simpledesign_piechart1.png -------------------------------------------------------------------------------- /MPChartExample/assets/OpenSans-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/MPChartExample/assets/OpenSans-Italic.ttf -------------------------------------------------------------------------------- /MPChartExample/assets/OpenSans-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/MPChartExample/assets/OpenSans-Regular.ttf -------------------------------------------------------------------------------- /screenshots/piechart_holeradius_space.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/piechart_holeradius_space.png -------------------------------------------------------------------------------- /screenshots/zero_line_example_barchart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/zero_line_example_barchart.png -------------------------------------------------------------------------------- /MPChartExample/assets/OpenSans-BoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/MPChartExample/assets/OpenSans-BoldItalic.ttf -------------------------------------------------------------------------------- /MPChartExample/assets/OpenSans-ExtraBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/MPChartExample/assets/OpenSans-ExtraBold.ttf -------------------------------------------------------------------------------- /MPChartExample/assets/OpenSans-Semibold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/MPChartExample/assets/OpenSans-Semibold.ttf -------------------------------------------------------------------------------- /MPChartExample/res/drawable-nodpi/marker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/MPChartExample/res/drawable-nodpi/marker.png -------------------------------------------------------------------------------- /MPChartExample/res/drawable-nodpi/marker2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/MPChartExample/res/drawable-nodpi/marker2.png -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/demo/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/demo/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /MPChartExample/assets/OpenSans-LightItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/MPChartExample/assets/OpenSans-LightItalic.ttf -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/demo/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/demo/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /screenshots/AndroidWeekly_Issue114_10082014.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/AndroidWeekly_Issue114_10082014.png -------------------------------------------------------------------------------- /screenshots/barchart2d_multi_dataset_date1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/barchart2d_multi_dataset_date1.png -------------------------------------------------------------------------------- /screenshots/barchart2d_multi_dataset_date2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/barchart2d_multi_dataset_date2.png -------------------------------------------------------------------------------- /screenshots/tranding_developers_11_08_2014.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/tranding_developers_11_08_2014.png -------------------------------------------------------------------------------- /MPChartExample/assets/OpenSans-ExtraBoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/MPChartExample/assets/OpenSans-ExtraBoldItalic.ttf -------------------------------------------------------------------------------- /MPChartExample/assets/OpenSans-SemiboldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/MPChartExample/assets/OpenSans-SemiboldItalic.ttf -------------------------------------------------------------------------------- /MPChartExample/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/MPChartExample/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /MPChartExample/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/MPChartExample/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /MPChartExample/res/drawable-nodpi/radar_marker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/MPChartExample/res/drawable-nodpi/radar_marker.png -------------------------------------------------------------------------------- /MPChartExample/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/MPChartExample/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /MPChartExample/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/MPChartExample/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/demo/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /screenshots/linechart_multiline_color_variations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-android/MPAndroidChart/HEAD/screenshots/linechart_multiline_color_variations.png -------------------------------------------------------------------------------- /MPChartExample/.settings/gradle/org.springsource.ide.eclipse.gradle.core.prefs: -------------------------------------------------------------------------------- 1 | #org.springsource.ide.eclipse.gradle.core.preferences.GradleProjectPreferences 2 | #Mon Jan 18 23:02:46 CET 2016 3 | org.springsource.ide.eclipse.gradle.rootprojectloc=.. 4 | -------------------------------------------------------------------------------- /demo/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /demo/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /MPChartExample/res/values-sw600dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':demo' 2 | include 'MPChartLib' 3 | //include 'MPAndroidChart-Realm' 4 | include 'MPChartExample' 5 | //include ':MPChartLib-Realm' 6 | //project(':MPChartLib-Realm').projectDir = new File('../MPAndroidChart-Realm/MPChartLib-Realm') 7 | 8 | 9 | -------------------------------------------------------------------------------- /MPChartExample/res/menu/realm.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | -------------------------------------------------------------------------------- /MPChartExample/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16dp 5 | 16dp 6 | 7 | 8 | -------------------------------------------------------------------------------- /MPChartExample/res/anim/move_left_in_activity.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | -------------------------------------------------------------------------------- /MPChartExample/res/anim/move_left_out_activity.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | -------------------------------------------------------------------------------- /MPChartExample/res/anim/move_right_in_activity.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | -------------------------------------------------------------------------------- /MPChartExample/res/anim/move_right_out_activity.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | -------------------------------------------------------------------------------- /MPChartExample/res/drawable/fade_red.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /demo/src/main/res/anim/move_left_in_activity.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | -------------------------------------------------------------------------------- /demo/src/main/res/anim/move_left_out_activity.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | -------------------------------------------------------------------------------- /demo/src/main/res/anim/move_right_in_activity.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | -------------------------------------------------------------------------------- /demo/src/main/res/anim/move_right_out_activity.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Sep 03 21:01:56 CEST 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 7 | -------------------------------------------------------------------------------- /MPChartExample/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /MPChartExample/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | MPAndroidChart Example 5 | Settings 6 | Hello world! 7 | 8 | 9 | -------------------------------------------------------------------------------- /MPChartLib/.settings/gradle/org.springsource.ide.eclipse.gradle.core.prefs: -------------------------------------------------------------------------------- 1 | #org.springsource.ide.eclipse.gradle.core.preferences.GradleProjectPreferences 2 | #Mon Jan 18 23:02:46 CET 2016 3 | org.springsource.ide.eclipse.gradle.linkedresources= 4 | org.springsource.ide.eclipse.gradle.rootprojectloc=.. 5 | -------------------------------------------------------------------------------- /.settings/gradle/org.springsource.ide.eclipse.gradle.core.prefs: -------------------------------------------------------------------------------- 1 | #org.springsource.ide.eclipse.gradle.core.preferences.GradleProjectPreferences 2 | #Mon Jan 18 23:02:46 CET 2016 3 | build.family.org.gradle.tooling.model.eclipse.HierarchicalEclipseProject=;MPChartExample;MPChartLib; 4 | org.springsource.ide.eclipse.gradle.rootprojectloc= 5 | -------------------------------------------------------------------------------- /MPChartExample/res/drawable/new_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /MPChartExample/res/values-sw720dp-land/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 128dp 8 | 9 | 10 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/dataprovider/BubbleDataProvider.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.interfaces.dataprovider; 2 | 3 | import com.github.mikephil.charting.data.BubbleData; 4 | 5 | public interface BubbleDataProvider extends BarLineScatterCandleBubbleDataProvider { 6 | 7 | BubbleData getBubbleData(); 8 | } 9 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/dataprovider/CandleDataProvider.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.interfaces.dataprovider; 2 | 3 | import com.github.mikephil.charting.data.CandleData; 4 | 5 | public interface CandleDataProvider extends BarLineScatterCandleBubbleDataProvider { 6 | 7 | CandleData getCandleData(); 8 | } 9 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/dataprovider/ScatterDataProvider.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.interfaces.dataprovider; 2 | 3 | import com.github.mikephil.charting.data.ScatterData; 4 | 5 | public interface ScatterDataProvider extends BarLineScatterCandleBubbleDataProvider { 6 | 7 | ScatterData getScatterData(); 8 | } 9 | -------------------------------------------------------------------------------- /MPChartExample/res/values-v11/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /demo/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /MPChartExample/src/com/xxmassdeveloper/mpchartexample/notimportant/ContentItem.java: -------------------------------------------------------------------------------- 1 | package com.xxmassdeveloper.mpchartexample.notimportant; 2 | 3 | /** 4 | * Created by Philipp Jahoda on 07/12/15. 5 | */ 6 | public class ContentItem { 7 | 8 | String name; 9 | String desc; 10 | boolean isNew = false; 11 | 12 | public ContentItem(String n, String d) { 13 | name = n; 14 | desc = d; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /demo/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /MPChartExample/res/values-v14/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /MPChartLib/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/dataprovider/LineDataProvider.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.interfaces.dataprovider; 2 | 3 | import com.github.mikephil.charting.components.YAxis; 4 | import com.github.mikephil.charting.data.LineData; 5 | 6 | public interface LineDataProvider extends BarLineScatterCandleBubbleDataProvider { 7 | 8 | LineData getLineData(); 9 | 10 | YAxis getAxis(YAxis.AxisDependency dependency); 11 | } 12 | -------------------------------------------------------------------------------- /MPChartExample/res/layout/activity_draw_chart.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /MPChartExample/res/layout/activity_piechart_half.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | -------------------------------------------------------------------------------- /MPChartExample/res/layout/activity_barchart_noseekbar.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | -------------------------------------------------------------------------------- /MPChartExample/res/layout/activity_combined.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /MPChartExample/res/layout/activity_linechart_noseekbar.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | -------------------------------------------------------------------------------- /MPChartExample/res/layout/activity_piechart_noseekbar.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | -------------------------------------------------------------------------------- /MPChartExample/res/layout/activity_radarchart.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/dataprovider/BarDataProvider.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.interfaces.dataprovider; 2 | 3 | import com.github.mikephil.charting.data.BarData; 4 | 5 | public interface BarDataProvider extends BarLineScatterCandleBubbleDataProvider { 6 | 7 | BarData getBarData(); 8 | boolean isDrawBarShadowEnabled(); 9 | boolean isDrawValueAboveBarEnabled(); 10 | boolean isHighlightFullBarEnabled(); 11 | } 12 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/dataprovider/CombinedDataProvider.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.interfaces.dataprovider; 2 | 3 | import com.github.mikephil.charting.data.CombinedData; 4 | 5 | /** 6 | * Created by philipp on 11/06/16. 7 | */ 8 | public interface CombinedDataProvider extends LineDataProvider, BarDataProvider, BubbleDataProvider, CandleDataProvider, ScatterDataProvider { 9 | 10 | CombinedData getCombinedData(); 11 | } 12 | -------------------------------------------------------------------------------- /MPChartExample/res/layout/activity_bubblechart_noseekbar.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | -------------------------------------------------------------------------------- /MPChartExample/res/layout/activity_realtime_linechart.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /MPChartExample/res/layout/activity_scatterchart_noseekbar.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/highlight/IHighlighter.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.highlight; 2 | 3 | /** 4 | * Created by philipp on 10/06/16. 5 | */ 6 | public interface IHighlighter 7 | { 8 | 9 | /** 10 | * Returns a Highlight object corresponding to the given x- and y- touch positions in pixels. 11 | * 12 | * @param x 13 | * @param y 14 | * @return 15 | */ 16 | Highlight getHighlight(float x, float y); 17 | } 18 | -------------------------------------------------------------------------------- /MPChartExample/res/layout/activity_candlechart_noseekbar.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | -------------------------------------------------------------------------------- /MPChartExample/res/layout/activity_horizontalbarchart_noseekbar.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | -------------------------------------------------------------------------------- /MPChartExample/res/layout/activity_listview_chart.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /MPChartExample/res/layout/list_item_barchart.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /MPChartExample/res/layout/list_item_linechart.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /MPChartExample/res/layout/list_item_piechart.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /MPChartExample/res/layout/frag_simple_line.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /MPChartExample/res/layout/frag_simple_pie.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /MPChartExample/res/menu/realtime.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 11 | 12 | 15 | 16 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/exception/DrawingDataSetNotCreatedException.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.exception; 2 | 3 | public class DrawingDataSetNotCreatedException extends RuntimeException { 4 | 5 | /** 6 | * 7 | */ 8 | private static final long serialVersionUID = 1L; 9 | 10 | public DrawingDataSetNotCreatedException() { 11 | super("Have to create a new drawing set first. Call ChartData's createNewDrawingDataSet() method"); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /MPChartExample/res/layout/frag_simple_scatter.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /demo/src/test/java/com/github/mikephil/demo/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.demo; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /demo/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/animation/EasingFunction.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.animation; 2 | 3 | import android.animation.TimeInterpolator; 4 | import android.annotation.SuppressLint; 5 | 6 | /** 7 | * Interface for creating custom made easing functions. Uses the 8 | * TimeInterpolator interface provided by Android. 9 | */ 10 | @SuppressLint("NewApi") 11 | public interface EasingFunction extends TimeInterpolator { 12 | 13 | @Override 14 | float getInterpolation(float input); 15 | } 16 | -------------------------------------------------------------------------------- /MPChartExample/res/layout/activity_age_distribution.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /MPChartExample/res/menu/combined.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 11 | 12 | 15 | 16 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/listener/OnDrawLineChartTouchListener.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.listener; 2 | 3 | import android.view.GestureDetector.SimpleOnGestureListener; 4 | import android.view.MotionEvent; 5 | import android.view.View; 6 | import android.view.View.OnTouchListener; 7 | 8 | public class OnDrawLineChartTouchListener extends SimpleOnGestureListener implements OnTouchListener { 9 | 10 | @Override 11 | public boolean onTouch(View v, MotionEvent event) { 12 | return false; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/datasets/IBarLineScatterCandleBubbleDataSet.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.interfaces.datasets; 2 | 3 | import com.github.mikephil.charting.data.Entry; 4 | 5 | /** 6 | * Created by philipp on 21/10/15. 7 | */ 8 | public interface IBarLineScatterCandleBubbleDataSet extends IDataSet { 9 | 10 | /** 11 | * Returns the color that is used for drawing the highlight indicators. 12 | * 13 | * @return 14 | */ 15 | int getHighLightColor(); 16 | } 17 | -------------------------------------------------------------------------------- /MPChartExample/res/layout/activity_awesomedesign.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /MPChartExample/res/layout/frag_simple_bar.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /MPChartExample/src/com/xxmassdeveloper/mpchartexample/custom/MyEasingFunction.java: -------------------------------------------------------------------------------- 1 | 2 | package com.xxmassdeveloper.mpchartexample.custom; 3 | 4 | import com.github.mikephil.charting.animation.EasingFunction; 5 | 6 | /** 7 | * Example of a custom made animation EasingFunction. 8 | * 9 | * @author Philipp Jahoda 10 | */ 11 | public class MyEasingFunction implements EasingFunction { 12 | 13 | @Override 14 | public float getInterpolation(float input) { 15 | // do awesome stuff here, this is just linear easing 16 | return input; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /MPChartExample/res/menu/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 11 | 12 | 15 | 16 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/data/CandleData.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.data; 2 | 3 | import com.github.mikephil.charting.interfaces.datasets.ICandleDataSet; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | public class CandleData extends BarLineScatterCandleBubbleData { 9 | 10 | public CandleData() { 11 | super(); 12 | } 13 | 14 | public CandleData(List dataSets) { 15 | super(dataSets); 16 | } 17 | 18 | public CandleData(ICandleDataSet... dataSets) { 19 | super(dataSets); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/renderer/Renderer.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.renderer; 3 | 4 | import com.github.mikephil.charting.utils.ViewPortHandler; 5 | 6 | /** 7 | * Abstract baseclass of all Renderers. 8 | * 9 | * @author Philipp Jahoda 10 | */ 11 | public abstract class Renderer { 12 | 13 | /** 14 | * the component that handles the drawing area of the chart and it's offsets 15 | */ 16 | protected ViewPortHandler mViewPortHandler; 17 | 18 | public Renderer(ViewPortHandler viewPortHandler) { 19 | this.mViewPortHandler = viewPortHandler; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /MPChartLib/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-23 15 | android.library=true 16 | -------------------------------------------------------------------------------- /MPChartExample/src/com/xxmassdeveloper/mpchartexample/custom/RealmFloat.java: -------------------------------------------------------------------------------- 1 | package com.xxmassdeveloper.mpchartexample.custom; 2 | 3 | import io.realm.RealmObject; 4 | 5 | /** 6 | * Created by Philipp Jahoda on 09/11/15. 7 | */ 8 | public class RealmFloat extends RealmObject { 9 | 10 | private float floatValue; 11 | 12 | public RealmFloat() { 13 | 14 | } 15 | 16 | public RealmFloat(float floatValue) { 17 | this.floatValue = floatValue; 18 | } 19 | 20 | public float getFloatValue() { 21 | return floatValue; 22 | } 23 | 24 | public void setFloatValue(float value) { 25 | this.floatValue = value; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # files for the dex VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # generated files 12 | bin/ 13 | gen/ 14 | generated/ 15 | docs/ 16 | finalOutput/ 17 | 18 | build.xml 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Eclipse project files 24 | .classpath 25 | .project 26 | 27 | # Proguard folder generated by Eclipse 28 | proguard/ 29 | 30 | # Intellij project files 31 | *.iml 32 | *.ipr 33 | *.iws 34 | .idea/ 35 | 36 | .directory 37 | 38 | # gradle wrapper working directory 39 | .gradle 40 | 41 | build/ 42 | 43 | # maven 44 | target/ 45 | 46 | .DS_Store 47 | -------------------------------------------------------------------------------- /MPChartExample/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-23 15 | android.library.reference.1=../MPChartLib 16 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/utils/EntryXComparator.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.utils; 2 | 3 | import com.github.mikephil.charting.data.Entry; 4 | 5 | import java.util.Comparator; 6 | 7 | /** 8 | * Comparator for comparing Entry-objects by their x-value. 9 | * Created by philipp on 17/06/15. 10 | */ 11 | public class EntryXComparator implements Comparator { 12 | @Override 13 | public int compare(Entry entry1, Entry entry2) { 14 | float diff = entry1.getX() - entry2.getX(); 15 | 16 | if (diff == 0f) return 0; 17 | else { 18 | if (diff > 0f) return 1; 19 | else return -1; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /MPChartExample/src/com/xxmassdeveloper/mpchartexample/custom/MyAxisValueFormatter.java: -------------------------------------------------------------------------------- 1 | package com.xxmassdeveloper.mpchartexample.custom; 2 | 3 | import com.github.mikephil.charting.components.AxisBase; 4 | import com.github.mikephil.charting.formatter.IAxisValueFormatter; 5 | 6 | import java.text.DecimalFormat; 7 | 8 | public class MyAxisValueFormatter implements IAxisValueFormatter 9 | { 10 | 11 | private DecimalFormat mFormat; 12 | 13 | public MyAxisValueFormatter() { 14 | mFormat = new DecimalFormat("###,###,###,##0.0"); 15 | } 16 | 17 | @Override 18 | public String getFormattedValue(float value, AxisBase axis) { 19 | return mFormat.format(value) + " $"; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/dataprovider/BarLineScatterCandleBubbleDataProvider.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.interfaces.dataprovider; 2 | 3 | import com.github.mikephil.charting.components.YAxis.AxisDependency; 4 | import com.github.mikephil.charting.data.BarLineScatterCandleBubbleData; 5 | import com.github.mikephil.charting.utils.Transformer; 6 | 7 | public interface BarLineScatterCandleBubbleDataProvider extends ChartInterface { 8 | 9 | Transformer getTransformer(AxisDependency axis); 10 | boolean isInverted(AxisDependency axis); 11 | 12 | float getLowestVisibleX(); 13 | float getHighestVisibleX(); 14 | 15 | BarLineScatterCandleBubbleData getData(); 16 | } 17 | -------------------------------------------------------------------------------- /demo/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in D:\ProgramFiles\Android\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/data/LineData.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.data; 3 | 4 | import com.github.mikephil.charting.interfaces.datasets.ILineDataSet; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | /** 10 | * Data object that encapsulates all data associated with a LineChart. 11 | * 12 | * @author Philipp Jahoda 13 | */ 14 | public class LineData extends BarLineScatterCandleBubbleData { 15 | 16 | public LineData() { 17 | super(); 18 | } 19 | 20 | public LineData(ILineDataSet... dataSets) { 21 | super(dataSets); 22 | } 23 | 24 | public LineData(List dataSets) { 25 | super(dataSets); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /MPChartExample/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 14 | 15 | 16 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /MPChartExample/src/com/xxmassdeveloper/mpchartexample/custom/MyValueFormatter.java: -------------------------------------------------------------------------------- 1 | package com.xxmassdeveloper.mpchartexample.custom; 2 | 3 | import com.github.mikephil.charting.data.Entry; 4 | import com.github.mikephil.charting.formatter.IValueFormatter; 5 | import com.github.mikephil.charting.utils.ViewPortHandler; 6 | 7 | import java.text.DecimalFormat; 8 | 9 | public class MyValueFormatter implements IValueFormatter 10 | { 11 | 12 | private DecimalFormat mFormat; 13 | 14 | public MyValueFormatter() { 15 | mFormat = new DecimalFormat("###,###,###,##0.0"); 16 | } 17 | 18 | @Override 19 | public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) { 20 | return mFormat.format(value) + " $"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /demo/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /MPChartExample/res/layout/activity_realm_wiki.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 19 | 20 | -------------------------------------------------------------------------------- /MPChartExample/src/com/xxmassdeveloper/mpchartexample/custom/MyFillFormatter.java: -------------------------------------------------------------------------------- 1 | package com.xxmassdeveloper.mpchartexample.custom; 2 | 3 | import com.github.mikephil.charting.formatter.IFillFormatter; 4 | import com.github.mikephil.charting.interfaces.dataprovider.LineDataProvider; 5 | import com.github.mikephil.charting.interfaces.datasets.ILineDataSet; 6 | 7 | /** 8 | * Created by Philipp Jahoda on 12/09/15. 9 | */ 10 | public class MyFillFormatter implements IFillFormatter 11 | { 12 | 13 | private float mFillPos = 0f; 14 | 15 | public MyFillFormatter(float fillpos) { 16 | this.mFillPos = fillpos; 17 | } 18 | 19 | @Override 20 | public float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider) { 21 | // your logic could be here 22 | return mFillPos; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/datasets/IBubbleDataSet.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.interfaces.datasets; 2 | 3 | import com.github.mikephil.charting.data.BubbleEntry; 4 | 5 | /** 6 | * Created by philipp on 21/10/15. 7 | */ 8 | public interface IBubbleDataSet extends IBarLineScatterCandleBubbleDataSet { 9 | 10 | /** 11 | * Sets the width of the circle that surrounds the bubble when highlighted, 12 | * in dp. 13 | * 14 | * @param width 15 | */ 16 | void setHighlightCircleWidth(float width); 17 | 18 | float getMaxSize(); 19 | 20 | boolean isNormalizeSizeEnabled(); 21 | 22 | /** 23 | * Returns the width of the highlight-circle that surrounds the bubble 24 | * @return 25 | */ 26 | float getHighlightCircleWidth(); 27 | } 28 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/data/BarLineScatterCandleBubbleData.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.data; 3 | 4 | import com.github.mikephil.charting.interfaces.datasets.IBarLineScatterCandleBubbleDataSet; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Baseclass for all Line, Bar, Scatter, Candle and Bubble data. 10 | * 11 | * @author Philipp Jahoda 12 | */ 13 | public abstract class BarLineScatterCandleBubbleData> 14 | extends ChartData { 15 | 16 | public BarLineScatterCandleBubbleData() { 17 | super(); 18 | } 19 | 20 | public BarLineScatterCandleBubbleData(T... sets) { 21 | super(sets); 22 | } 23 | 24 | public BarLineScatterCandleBubbleData(List sets) { 25 | super(sets); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/formatter/IAxisValueFormatter.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.formatter; 2 | 3 | import com.github.mikephil.charting.components.AxisBase; 4 | 5 | /** 6 | * Created by Philipp Jahoda on 20/09/15. 7 | * Custom formatter interface that allows formatting of 8 | * axis labels before they are being drawn. 9 | */ 10 | public interface IAxisValueFormatter 11 | { 12 | 13 | /** 14 | * Called when a value from an axis is to be formatted 15 | * before being drawn. For performance reasons, avoid excessive calculations 16 | * and memory allocations inside this method. 17 | * 18 | * @param value the value to be formatted 19 | * @param axis the axis the value belongs to 20 | * @return 21 | */ 22 | String getFormattedValue(float value, AxisBase axis); 23 | } 24 | -------------------------------------------------------------------------------- /demo/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.1" 6 | 7 | defaultConfig { 8 | applicationId "com.github.mikephil.demo" 9 | minSdkVersion 9 10 | targetSdkVersion 25 11 | versionCode 1 12 | versionName "1.0" 13 | 14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 15 | 16 | } 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | } 24 | 25 | dependencies { 26 | compile fileTree(include: ['*.jar'], dir: 'libs') 27 | compile 'com.android.support:appcompat-v7:25.1.0' 28 | compile 'com.github.open-android:MPAndroidChart:v3.0.1' 29 | } 30 | -------------------------------------------------------------------------------- /MPChartLib/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/highlight/PieHighlighter.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.highlight; 2 | 3 | import com.github.mikephil.charting.charts.PieChart; 4 | import com.github.mikephil.charting.data.Entry; 5 | import com.github.mikephil.charting.interfaces.datasets.IPieDataSet; 6 | 7 | /** 8 | * Created by philipp on 12/06/16. 9 | */ 10 | public class PieHighlighter extends PieRadarHighlighter { 11 | 12 | public PieHighlighter(PieChart chart) { 13 | super(chart); 14 | } 15 | 16 | @Override 17 | protected Highlight getClosestHighlight(int index, float x, float y) { 18 | 19 | IPieDataSet set = mChart.getData().getDataSet(); 20 | 21 | final Entry entry = set.getEntryForIndex(index); 22 | 23 | return new Highlight(index, entry.getY(), x, y, 0, set.getAxisDependency()); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /MPChartExample/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /MPChartExample/src/com/xxmassdeveloper/mpchartexample/listviewitems/ChartItem.java: -------------------------------------------------------------------------------- 1 | package com.xxmassdeveloper.mpchartexample.listviewitems; 2 | 3 | import android.content.Context; 4 | import android.view.View; 5 | 6 | import com.github.mikephil.charting.data.ChartData; 7 | 8 | /** 9 | * baseclass of the chart-listview items 10 | * @author philipp 11 | * 12 | */ 13 | public abstract class ChartItem { 14 | 15 | protected static final int TYPE_BARCHART = 0; 16 | protected static final int TYPE_LINECHART = 1; 17 | protected static final int TYPE_PIECHART = 2; 18 | 19 | protected ChartData mChartData; 20 | 21 | public ChartItem(ChartData cd) { 22 | this.mChartData = cd; 23 | } 24 | 25 | public abstract int getItemType(); 26 | 27 | public abstract View getView(int position, View convertView, Context c); 28 | } 29 | -------------------------------------------------------------------------------- /MPChartExample/res/layout/activity_radarchart_noseekbar.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 15 | 16 | 21 | 22 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/utils/HorizontalViewPortHandler.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.utils; 3 | 4 | /** 5 | * ViewPortHandler for HorizontalBarChart. 6 | */ 7 | public class HorizontalViewPortHandler extends ViewPortHandler { 8 | 9 | 10 | // @Override 11 | // public void setMinimumScaleX(float xScale) { 12 | // setMinimumScaleY(xScale); 13 | // } 14 | // 15 | // @Override 16 | // public void setMinimumScaleY(float yScale) { 17 | // setMinimumScaleX(yScale); 18 | // } 19 | // 20 | // @Override 21 | // public void setMinMaxScaleX(float minScaleX, float maxScaleX) { 22 | // setMinMaxScaleY(minScaleX, maxScaleX); 23 | // } 24 | // 25 | // @Override 26 | // public void setMinMaxScaleY(float minScaleY, float maxScaleY) { 27 | // setMinMaxScaleX(minScaleY, maxScaleY); 28 | // } 29 | } 30 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/formatter/ColorFormatter.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.formatter; 2 | 3 | import com.github.mikephil.charting.data.DataSet; 4 | import com.github.mikephil.charting.data.Entry; 5 | import com.github.mikephil.charting.interfaces.datasets.IDataSet; 6 | 7 | /** 8 | * Interface that can be used to return a customized color instead of setting 9 | * colors via the setColor(...) method of the DataSet. 10 | * 11 | * @author Philipp Jahoda 12 | */ 13 | public interface ColorFormatter { 14 | 15 | /** 16 | * Returns the color to be used for the given Entry at the given index (in the entries array) 17 | * 18 | * @param index index in the entries array 19 | * @param e the entry to color 20 | * @param set the DataSet the entry belongs to 21 | * @return 22 | */ 23 | int getColor(int index, Entry e, IDataSet set); 24 | } -------------------------------------------------------------------------------- /MPChartExample/res/layout/custom_marker_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/formatter/IFillFormatter.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.formatter; 2 | 3 | import com.github.mikephil.charting.interfaces.datasets.ILineDataSet; 4 | import com.github.mikephil.charting.interfaces.dataprovider.LineDataProvider; 5 | 6 | /** 7 | * Interface for providing a custom logic to where the filling line of a LineDataSet 8 | * should end. This of course only works if setFillEnabled(...) is set to true. 9 | * 10 | * @author Philipp Jahoda 11 | */ 12 | public interface IFillFormatter 13 | { 14 | 15 | /** 16 | * Returns the vertical (y-axis) position where the filled-line of the 17 | * LineDataSet should end. 18 | * 19 | * @param dataSet the ILineDataSet that is currently drawn 20 | * @param dataProvider 21 | * @return 22 | */ 23 | float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider); 24 | } 25 | -------------------------------------------------------------------------------- /demo/src/androidTest/java/com/github/mikephil/demo/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.demo; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.github.mikephil.demo", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /MPChartExample/res/menu/dynamical.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 12 | 13 | 14 | 17 | 18 | 19 | 22 | 23 | 24 | 27 | 28 | 29 | 32 | 33 | -------------------------------------------------------------------------------- /MPChartExample/src/com/xxmassdeveloper/mpchartexample/custom/YearXAxisFormatter.java: -------------------------------------------------------------------------------- 1 | package com.xxmassdeveloper.mpchartexample.custom; 2 | 3 | import com.github.mikephil.charting.components.AxisBase; 4 | import com.github.mikephil.charting.formatter.IAxisValueFormatter; 5 | 6 | /** 7 | * Created by Philipp Jahoda on 14/09/15. 8 | */ 9 | public class YearXAxisFormatter implements IAxisValueFormatter 10 | { 11 | 12 | protected String[] mMonths = new String[]{ 13 | "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec" 14 | }; 15 | 16 | public YearXAxisFormatter() { 17 | // maybe do something here or provide parameters in constructor 18 | 19 | } 20 | 21 | @Override 22 | public String getFormattedValue(float value, AxisBase axis) { 23 | 24 | float percent = value / axis.mAxisRange; 25 | return mMonths[(int) (mMonths.length * percent)]; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /MPChartExample/res/layout/radar_markerview.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/listener/OnChartValueSelectedListener.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.listener; 2 | 3 | import com.github.mikephil.charting.data.Entry; 4 | import com.github.mikephil.charting.highlight.Highlight; 5 | 6 | /** 7 | * Listener for callbacks when selecting values inside the chart by 8 | * touch-gesture. 9 | * 10 | * @author Philipp Jahoda 11 | */ 12 | public interface OnChartValueSelectedListener { 13 | 14 | /** 15 | * Called when a value has been selected inside the chart. 16 | * 17 | * @param e The selected Entry 18 | * @param h The corresponding highlight object that contains information 19 | * about the highlighted position such as dataSetIndex, ... 20 | */ 21 | void onValueSelected(Entry e, Highlight h); 22 | 23 | /** 24 | * Called when nothing has been selected or an "un-select" has been made. 25 | */ 26 | void onNothingSelected(); 27 | } 28 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/data/BubbleData.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.data; 3 | 4 | import com.github.mikephil.charting.interfaces.datasets.IBubbleDataSet; 5 | 6 | import java.util.List; 7 | 8 | public class BubbleData extends BarLineScatterCandleBubbleData { 9 | 10 | public BubbleData() { 11 | super(); 12 | } 13 | 14 | public BubbleData(IBubbleDataSet... dataSets) { 15 | super(dataSets); 16 | } 17 | 18 | public BubbleData(List dataSets) { 19 | super(dataSets); 20 | } 21 | 22 | 23 | /** 24 | * Sets the width of the circle that surrounds the bubble when highlighted 25 | * for all DataSet objects this data object contains, in dp. 26 | * 27 | * @param width 28 | */ 29 | public void setHighlightCircleWidth(float width) { 30 | for (IBubbleDataSet set : mDataSets) { 31 | set.setHighlightCircleWidth(width); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/highlight/Range.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.highlight; 2 | 3 | /** 4 | * Created by Philipp Jahoda on 24/07/15. Class that represents the range of one value in a stacked bar entry. e.g. 5 | * stack values are -10, 5, 20 -> then ranges are (-10 - 0, 0 - 5, 5 - 25). 6 | */ 7 | public final class Range { 8 | 9 | public float from; 10 | public float to; 11 | 12 | public Range(float from, float to) { 13 | this.from = from; 14 | this.to = to; 15 | } 16 | 17 | /** 18 | * Returns true if this range contains (if the value is in between) the given value, false if not. 19 | * 20 | * @param value 21 | * @return 22 | */ 23 | public boolean contains(float value) { 24 | 25 | if (value > from && value <= to) 26 | return true; 27 | else 28 | return false; 29 | } 30 | 31 | public boolean isLarger(float value) { 32 | return value > to; 33 | } 34 | 35 | public boolean isSmaller(float value) { 36 | return value < from; 37 | } 38 | } -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/datasets/IRadarDataSet.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.interfaces.datasets; 2 | 3 | import com.github.mikephil.charting.data.RadarEntry; 4 | 5 | /** 6 | * Created by Philipp Jahoda on 03/11/15. 7 | */ 8 | public interface IRadarDataSet extends ILineRadarDataSet { 9 | 10 | /// flag indicating whether highlight circle should be drawn or not 11 | boolean isDrawHighlightCircleEnabled(); 12 | 13 | /// Sets whether highlight circle should be drawn or not 14 | void setDrawHighlightCircleEnabled(boolean enabled); 15 | 16 | int getHighlightCircleFillColor(); 17 | 18 | /// The stroke color for highlight circle. 19 | /// If Utils.COLOR_NONE, the color of the dataset is taken. 20 | int getHighlightCircleStrokeColor(); 21 | 22 | int getHighlightCircleStrokeAlpha(); 23 | 24 | float getHighlightCircleInnerRadius(); 25 | 26 | float getHighlightCircleOuterRadius(); 27 | 28 | float getHighlightCircleStrokeWidth(); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/data/ScatterData.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.data; 3 | 4 | import com.github.mikephil.charting.interfaces.datasets.IScatterDataSet; 5 | 6 | import java.util.List; 7 | 8 | public class ScatterData extends BarLineScatterCandleBubbleData { 9 | 10 | public ScatterData() { 11 | super(); 12 | } 13 | 14 | public ScatterData(List dataSets) { 15 | super(dataSets); 16 | } 17 | 18 | public ScatterData(IScatterDataSet... dataSets) { 19 | super(dataSets); 20 | } 21 | 22 | /** 23 | * Returns the maximum shape-size across all DataSets. 24 | * 25 | * @return 26 | */ 27 | public float getGreatestShapeSize() { 28 | 29 | float max = 0f; 30 | 31 | for (IScatterDataSet set : mDataSets) { 32 | float size = set.getScatterShapeSize(); 33 | 34 | if (size > max) 35 | max = size; 36 | } 37 | 38 | return max; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/datasets/IScatterDataSet.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.interfaces.datasets; 2 | 3 | import com.github.mikephil.charting.data.Entry; 4 | import com.github.mikephil.charting.renderer.scatter.IShapeRenderer; 5 | 6 | /** 7 | * Created by philipp on 21/10/15. 8 | */ 9 | public interface IScatterDataSet extends ILineScatterCandleRadarDataSet { 10 | 11 | /** 12 | * Returns the currently set scatter shape size 13 | * 14 | * @return 15 | */ 16 | float getScatterShapeSize(); 17 | 18 | /** 19 | * Returns radius of the hole in the shape 20 | * 21 | * @return 22 | */ 23 | float getScatterShapeHoleRadius(); 24 | 25 | /** 26 | * Returns the color for the hole in the shape 27 | * 28 | * @return 29 | */ 30 | int getScatterShapeHoleColor(); 31 | 32 | /** 33 | * Returns the IShapeRenderer responsible for rendering this DataSet. 34 | * 35 | * @return 36 | */ 37 | IShapeRenderer getShapeRenderer(); 38 | } 39 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/data/RadarEntry.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.data; 2 | 3 | import android.annotation.SuppressLint; 4 | 5 | /** 6 | * Created by philipp on 13/06/16. 7 | */ 8 | @SuppressLint("ParcelCreator") 9 | public class RadarEntry extends Entry { 10 | 11 | public RadarEntry(float value) { 12 | super(0f, value); 13 | } 14 | 15 | public RadarEntry(float value, Object data) { 16 | super(0f, value, data); 17 | } 18 | 19 | /** 20 | * This is the same as getY(). Returns the value of the RadarEntry. 21 | * 22 | * @return 23 | */ 24 | public float getValue() { 25 | return getY(); 26 | } 27 | 28 | public RadarEntry copy() { 29 | RadarEntry e = new RadarEntry(getY(), getData()); 30 | return e; 31 | } 32 | 33 | @Deprecated 34 | @Override 35 | public void setX(float x) { 36 | super.setX(x); 37 | } 38 | 39 | @Deprecated 40 | @Override 41 | public float getX() { 42 | return super.getX(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/listener/OnDrawListener.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.listener; 2 | 3 | import com.github.mikephil.charting.data.DataSet; 4 | import com.github.mikephil.charting.data.Entry; 5 | 6 | /** 7 | * Listener for callbacks when drawing on the chart. 8 | * 9 | * @author Philipp 10 | * 11 | */ 12 | public interface OnDrawListener { 13 | 14 | /** 15 | * Called whenever an entry is added with the finger. Note this is also called for entries that are generated by the 16 | * library, when the touch gesture is too fast and skips points. 17 | * 18 | * @param entry 19 | * the last drawn entry 20 | */ 21 | void onEntryAdded(Entry entry); 22 | 23 | /** 24 | * Called whenever an entry is moved by the user after beeing highlighted 25 | * 26 | * @param entry 27 | */ 28 | void onEntryMoved(Entry entry); 29 | 30 | /** 31 | * Called when drawing finger is lifted and the draw is finished. 32 | * 33 | * @param dataSet 34 | * the last drawn DataSet 35 | */ 36 | void onDrawFinished(DataSet dataSet); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /MPChartExample/src/com/xxmassdeveloper/mpchartexample/custom/CustomScatterShapeRenderer.java: -------------------------------------------------------------------------------- 1 | package com.xxmassdeveloper.mpchartexample.custom; 2 | 3 | import android.graphics.Canvas; 4 | import android.graphics.Paint; 5 | 6 | import com.github.mikephil.charting.interfaces.datasets.IScatterDataSet; 7 | import com.github.mikephil.charting.renderer.scatter.IShapeRenderer; 8 | import com.github.mikephil.charting.utils.ViewPortHandler; 9 | 10 | /** 11 | * Custom shape renderer that draws a single line. 12 | * Created by philipp on 26/06/16. 13 | */ 14 | public class CustomScatterShapeRenderer implements IShapeRenderer 15 | { 16 | 17 | @Override 18 | public void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler, 19 | float posX, float posY, Paint renderPaint) { 20 | 21 | final float shapeHalf = dataSet.getScatterShapeSize() / 2f; 22 | 23 | c.drawLine( 24 | posX - shapeHalf, 25 | posY - shapeHalf, 26 | posX + shapeHalf, 27 | posY + shapeHalf, 28 | renderPaint); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /MPChartExample/res/menu/draw.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 11 | 12 | 15 | 16 | 19 | 20 | 23 | 24 | 27 | 28 | 31 | 32 | 35 | 36 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/datasets/ILineScatterCandleRadarDataSet.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.interfaces.datasets; 2 | 3 | import android.graphics.DashPathEffect; 4 | 5 | import com.github.mikephil.charting.data.Entry; 6 | 7 | /** 8 | * Created by Philipp Jahoda on 21/10/15. 9 | */ 10 | public interface ILineScatterCandleRadarDataSet extends IBarLineScatterCandleBubbleDataSet { 11 | 12 | /** 13 | * Returns true if vertical highlight indicator lines are enabled (drawn) 14 | * @return 15 | */ 16 | boolean isVerticalHighlightIndicatorEnabled(); 17 | 18 | /** 19 | * Returns true if vertical highlight indicator lines are enabled (drawn) 20 | * @return 21 | */ 22 | boolean isHorizontalHighlightIndicatorEnabled(); 23 | 24 | /** 25 | * Returns the line-width in which highlight lines are to be drawn. 26 | * @return 27 | */ 28 | float getHighlightLineWidth(); 29 | 30 | /** 31 | * Returns the DashPathEffect that is used for highlighting. 32 | * @return 33 | */ 34 | DashPathEffect getDashPathEffectHighlight(); 35 | } 36 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/renderer/scatter/IShapeRenderer.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.renderer.scatter; 2 | 3 | import android.graphics.Canvas; 4 | import android.graphics.Paint; 5 | 6 | import com.github.mikephil.charting.interfaces.datasets.IScatterDataSet; 7 | import com.github.mikephil.charting.utils.ViewPortHandler; 8 | 9 | /** 10 | * Created by wajdic on 15/06/2016. 11 | * Created at Time 09:07 12 | */ 13 | public interface IShapeRenderer 14 | { 15 | 16 | /** 17 | * Renders the provided ScatterDataSet with a shape. 18 | * 19 | * @param c Canvas object for drawing the shape 20 | * @param dataSet The DataSet to be drawn 21 | * @param viewPortHandler Contains information about the current state of the view 22 | * @param posX Position to draw the shape at 23 | * @param posY Position to draw the shape at 24 | * @param renderPaint Paint object used for styling and drawing 25 | */ 26 | void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler, 27 | float posX, float posY, Paint renderPaint); 28 | } 29 | -------------------------------------------------------------------------------- /MPChartLib/src/test/java/com/github/mikephil/charting/test/ApproximatorTest.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.test; 2 | 3 | import com.github.mikephil.charting.data.Entry; 4 | import com.github.mikephil.charting.data.filter.Approximator; 5 | 6 | import org.junit.Test; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | import static junit.framework.Assert.assertEquals; 12 | 13 | /** 14 | * Created by philipp on 07/06/16. 15 | */ 16 | public class ApproximatorTest { 17 | 18 | @Test 19 | public void testApproximation() { 20 | 21 | float[] points = new float[]{ 22 | 10, 20, 23 | 20, 30, 24 | 25, 25, 25 | 30, 28, 26 | 31, 31, 27 | 33, 33, 28 | 40, 40, 29 | 44, 40, 30 | 48, 23, 31 | 50, 20, 32 | 55, 20, 33 | 60, 25}; 34 | 35 | assertEquals(24, points.length); 36 | 37 | Approximator a = new Approximator(); 38 | 39 | float[] reduced = a.reduceWithDouglasPeucker(points, 2); 40 | 41 | assertEquals(18, reduced.length); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /MPChartExample/res/layout/activity_colored_lines.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 17 | 22 | 27 | 28 | -------------------------------------------------------------------------------- /MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/Score.java: -------------------------------------------------------------------------------- 1 | package com.xxmassdeveloper.mpchartexample.realm; 2 | 3 | 4 | import io.realm.RealmObject; 5 | 6 | /** 7 | * our data object 8 | */ 9 | public class Score extends RealmObject { 10 | 11 | private float totalScore; 12 | 13 | private float scoreNr; 14 | 15 | private String playerName; 16 | 17 | public Score() { 18 | } 19 | 20 | public Score(float totalScore, float scoreNr, String playerName) { 21 | this.scoreNr = scoreNr; 22 | this.playerName = playerName; 23 | this.totalScore = totalScore; 24 | } 25 | 26 | // all getters and setters... 27 | 28 | public float getTotalScore() { 29 | return totalScore; 30 | } 31 | 32 | public void setTotalScore(float totalScore) { 33 | this.totalScore = totalScore; 34 | } 35 | 36 | public float getScoreNr() { 37 | return scoreNr; 38 | } 39 | 40 | public void setScoreNr(float scoreNr) { 41 | this.scoreNr = scoreNr; 42 | } 43 | 44 | public String getPlayerName() { 45 | return playerName; 46 | } 47 | 48 | public void setPlayerName(String playerName) { 49 | this.playerName = playerName; 50 | } 51 | } -------------------------------------------------------------------------------- /MPChartExample/res/menu/bubble.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 11 | 12 | 15 | 16 | 19 | 20 | 23 | 24 | 27 | 28 | 31 | 32 | 35 | 36 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /MPChartExample/res/menu/scatter.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 11 | 12 | 15 | 16 | 19 | 20 | 23 | 24 | 27 | 28 | 31 | 32 | 35 | 36 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /MPChartExample/res/menu/candle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 11 | 12 | 15 | 16 | 19 | 20 | 23 | 24 | 27 | 28 | 31 | 32 | 35 | 36 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/data/BarLineScatterCandleBubbleDataSet.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.data; 3 | 4 | import android.graphics.Color; 5 | 6 | import com.github.mikephil.charting.interfaces.datasets.IBarLineScatterCandleBubbleDataSet; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Baseclass of all DataSets for Bar-, Line-, Scatter- and CandleStickChart. 12 | * 13 | * @author Philipp Jahoda 14 | */ 15 | public abstract class BarLineScatterCandleBubbleDataSet extends DataSet implements IBarLineScatterCandleBubbleDataSet { 16 | 17 | /** default highlight color */ 18 | protected int mHighLightColor = Color.rgb(255, 187, 115); 19 | 20 | public BarLineScatterCandleBubbleDataSet(List yVals, String label) { 21 | super(yVals, label); 22 | } 23 | 24 | /** 25 | * Sets the color that is used for drawing the highlight indicators. Dont 26 | * forget to resolve the color using getResources().getColor(...) or 27 | * Color.rgb(...). 28 | * 29 | * @param color 30 | */ 31 | public void setHighLightColor(int color) { 32 | mHighLightColor = color; 33 | } 34 | 35 | @Override 36 | public int getHighLightColor() { 37 | return mHighLightColor; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /MPChartExample/res/menu/pie.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 11 | 12 | 15 | 16 | 19 | 20 | 23 | 24 | 27 | 28 | 31 | 32 | 35 | 36 | 39 | 40 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /MPChartExample/res/menu/bar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 11 | 12 | 15 | 16 | 19 | 20 | 23 | 24 | 27 | 28 | 31 | 32 | 35 | 36 | 39 | 40 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/renderer/scatter/CrossShapeRenderer.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.renderer.scatter; 2 | 3 | import android.graphics.Canvas; 4 | import android.graphics.Paint; 5 | 6 | import com.github.mikephil.charting.interfaces.datasets.IScatterDataSet; 7 | import com.github.mikephil.charting.utils.Utils; 8 | import com.github.mikephil.charting.utils.ViewPortHandler; 9 | 10 | /** 11 | * Created by wajdic on 15/06/2016. 12 | * Created at Time 09:08 13 | */ 14 | public class CrossShapeRenderer implements IShapeRenderer 15 | { 16 | 17 | 18 | @Override 19 | public void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler, 20 | float posX, float posY, Paint renderPaint) { 21 | 22 | final float shapeHalf = dataSet.getScatterShapeSize() / 2f; 23 | 24 | renderPaint.setStyle(Paint.Style.STROKE); 25 | renderPaint.setStrokeWidth(Utils.convertDpToPixel(1f)); 26 | 27 | c.drawLine( 28 | posX - shapeHalf, 29 | posY, 30 | posX + shapeHalf, 31 | posY, 32 | renderPaint); 33 | c.drawLine( 34 | posX, 35 | posY - shapeHalf, 36 | posX, 37 | posY + shapeHalf, 38 | renderPaint); 39 | 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/charts/CandleStickChart.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.charts; 3 | 4 | import android.content.Context; 5 | import android.util.AttributeSet; 6 | 7 | import com.github.mikephil.charting.data.CandleData; 8 | import com.github.mikephil.charting.interfaces.dataprovider.CandleDataProvider; 9 | import com.github.mikephil.charting.renderer.CandleStickChartRenderer; 10 | 11 | /** 12 | * Financial chart type that draws candle-sticks (OHCL chart). 13 | * 14 | * @author Philipp Jahoda 15 | */ 16 | public class CandleStickChart extends BarLineChartBase implements CandleDataProvider { 17 | 18 | public CandleStickChart(Context context) { 19 | super(context); 20 | } 21 | 22 | public CandleStickChart(Context context, AttributeSet attrs) { 23 | super(context, attrs); 24 | } 25 | 26 | public CandleStickChart(Context context, AttributeSet attrs, int defStyle) { 27 | super(context, attrs, defStyle); 28 | } 29 | 30 | @Override 31 | protected void init() { 32 | super.init(); 33 | 34 | mRenderer = new CandleStickChartRenderer(this, mAnimator, mViewPortHandler); 35 | 36 | getXAxis().setSpaceMin(0.5f); 37 | getXAxis().setSpaceMax(0.5f); 38 | } 39 | 40 | @Override 41 | public CandleData getCandleData() { 42 | return mData; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/renderer/scatter/ChevronDownShapeRenderer.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.renderer.scatter; 2 | 3 | import android.graphics.Canvas; 4 | import android.graphics.Paint; 5 | 6 | import com.github.mikephil.charting.interfaces.datasets.IScatterDataSet; 7 | import com.github.mikephil.charting.utils.Utils; 8 | import com.github.mikephil.charting.utils.ViewPortHandler; 9 | 10 | /** 11 | * Created by wajdic on 15/06/2016. 12 | * Created at Time 09:08 13 | */ 14 | public class ChevronDownShapeRenderer implements IShapeRenderer 15 | { 16 | 17 | 18 | @Override 19 | public void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler, 20 | float posX, float posY, Paint renderPaint) { 21 | 22 | final float shapeHalf = dataSet.getScatterShapeSize() / 2f; 23 | 24 | renderPaint.setStyle(Paint.Style.STROKE); 25 | renderPaint.setStrokeWidth(Utils.convertDpToPixel(1f)); 26 | 27 | c.drawLine( 28 | posX, 29 | posY + (2 * shapeHalf), 30 | posX + (2 * shapeHalf), 31 | posY, 32 | renderPaint); 33 | 34 | c.drawLine( 35 | posX, 36 | posY + (2 * shapeHalf), 37 | posX - (2 * shapeHalf), 38 | posY, 39 | renderPaint); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/utils/MPPointD.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.utils; 3 | 4 | import java.util.List; 5 | 6 | /** 7 | * Point encapsulating two double values. 8 | * 9 | * @author Philipp Jahoda 10 | */ 11 | public class MPPointD extends ObjectPool.Poolable { 12 | 13 | private static ObjectPool pool; 14 | 15 | static { 16 | pool = ObjectPool.create(64, new MPPointD(0,0)); 17 | pool.setReplenishPercentage(0.5f); 18 | } 19 | 20 | public static MPPointD getInstance(double x, double y){ 21 | MPPointD result = pool.get(); 22 | result.x = x; 23 | result.y = y; 24 | return result; 25 | } 26 | 27 | public static void recycleInstance(MPPointD instance){ 28 | pool.recycle(instance); 29 | } 30 | 31 | public static void recycleInstances(List instances){ 32 | pool.recycle(instances); 33 | } 34 | 35 | public double x; 36 | public double y; 37 | 38 | protected ObjectPool.Poolable instantiate(){ 39 | return new MPPointD(0,0); 40 | } 41 | 42 | private MPPointD(double x, double y) { 43 | this.x = x; 44 | this.y = y; 45 | } 46 | 47 | /** 48 | * returns a string representation of the object 49 | */ 50 | public String toString() { 51 | return "MPPointD, x: " + x + ", y: " + y; 52 | } 53 | } -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/renderer/scatter/ChevronUpShapeRenderer.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.renderer.scatter; 2 | 3 | import android.graphics.Canvas; 4 | import android.graphics.Paint; 5 | 6 | import com.github.mikephil.charting.interfaces.datasets.IScatterDataSet; 7 | import com.github.mikephil.charting.utils.Utils; 8 | import com.github.mikephil.charting.utils.ViewPortHandler; 9 | 10 | /** 11 | * Created by wajdic on 15/06/2016. 12 | * Created at Time 09:08 13 | */ 14 | public class ChevronUpShapeRenderer implements IShapeRenderer 15 | { 16 | 17 | 18 | @Override 19 | public void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler, 20 | float posX, float posY, Paint renderPaint) { 21 | 22 | final float shapeHalf = dataSet.getScatterShapeSize() / 2f; 23 | 24 | renderPaint.setStyle(Paint.Style.STROKE); 25 | renderPaint.setStrokeWidth(Utils.convertDpToPixel(1f)); 26 | 27 | c.drawLine( 28 | posX, 29 | posY - (2 * shapeHalf), 30 | posX + (2 * shapeHalf), 31 | posY, 32 | renderPaint); 33 | 34 | c.drawLine( 35 | posX, 36 | posY - (2 * shapeHalf), 37 | posX - (2 * shapeHalf), 38 | posY, 39 | renderPaint); 40 | 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/renderer/scatter/XShapeRenderer.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.renderer.scatter; 2 | 3 | import android.graphics.Canvas; 4 | import android.graphics.Paint; 5 | 6 | import com.github.mikephil.charting.interfaces.datasets.IScatterDataSet; 7 | import com.github.mikephil.charting.utils.Utils; 8 | import com.github.mikephil.charting.utils.ViewPortHandler; 9 | 10 | /** 11 | * Created by wajdic on 15/06/2016. 12 | * Created at Time 09:08 13 | */ 14 | public class XShapeRenderer implements IShapeRenderer 15 | { 16 | 17 | 18 | @Override 19 | public void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler, 20 | float posX, float posY, Paint renderPaint) { 21 | 22 | final float shapeHalf = dataSet.getScatterShapeSize() / 2f; 23 | 24 | renderPaint.setStyle(Paint.Style.STROKE); 25 | renderPaint.setStrokeWidth(Utils.convertDpToPixel(1f)); 26 | 27 | c.drawLine( 28 | posX - shapeHalf, 29 | posY - shapeHalf, 30 | posX + shapeHalf, 31 | posY + shapeHalf, 32 | renderPaint); 33 | c.drawLine( 34 | posX + shapeHalf, 35 | posY - shapeHalf, 36 | posX - shapeHalf, 37 | posY + shapeHalf, 38 | renderPaint); 39 | 40 | } 41 | 42 | } -------------------------------------------------------------------------------- /MPChartExample/res/layout/activity_linechart_time.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | 22 | 23 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/formatter/IValueFormatter.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.formatter; 2 | 3 | import com.github.mikephil.charting.data.Entry; 4 | import com.github.mikephil.charting.utils.ViewPortHandler; 5 | 6 | /** 7 | * Interface that allows custom formatting of all values inside the chart before they are 8 | * being drawn to the screen. Simply create your own formatting class and let 9 | * it implement IValueFormatter. Then override the getFormattedValue(...) method 10 | * and return whatever you want. 11 | * 12 | * @author Philipp Jahoda 13 | */ 14 | public interface IValueFormatter 15 | { 16 | 17 | /** 18 | * Called when a value (from labels inside the chart) is formatted 19 | * before being drawn. For performance reasons, avoid excessive calculations 20 | * and memory allocations inside this method. 21 | * 22 | * @param value the value to be formatted 23 | * @param entry the entry the value belongs to - in e.g. BarChart, this is of class BarEntry 24 | * @param dataSetIndex the index of the DataSet the entry in focus belongs to 25 | * @param viewPortHandler provides information about the current chart state (scale, translation, ...) 26 | * @return the formatted label ready for being drawn 27 | */ 28 | String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler); 29 | } 30 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/formatter/DefaultFillFormatter.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.formatter; 2 | 3 | 4 | import com.github.mikephil.charting.data.LineData; 5 | import com.github.mikephil.charting.interfaces.dataprovider.LineDataProvider; 6 | import com.github.mikephil.charting.interfaces.datasets.ILineDataSet; 7 | 8 | /** 9 | * Default formatter that calculates the position of the filled line. 10 | * 11 | * @author Philipp Jahoda 12 | */ 13 | public class DefaultFillFormatter implements IFillFormatter 14 | { 15 | 16 | @Override 17 | public float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider) { 18 | 19 | float fillMin = 0f; 20 | float chartMaxY = dataProvider.getYChartMax(); 21 | float chartMinY = dataProvider.getYChartMin(); 22 | 23 | LineData data = dataProvider.getLineData(); 24 | 25 | if (dataSet.getYMax() > 0 && dataSet.getYMin() < 0) { 26 | fillMin = 0f; 27 | } else { 28 | 29 | float max, min; 30 | 31 | if (data.getYMax() > 0) 32 | max = 0f; 33 | else 34 | max = chartMaxY; 35 | if (data.getYMin() < 0) 36 | min = 0f; 37 | else 38 | min = chartMinY; 39 | 40 | fillMin = dataSet.getYMin() >= 0 ? min : max; 41 | } 42 | 43 | return fillMin; 44 | } 45 | } -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/charts/BubbleChart.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.charts; 3 | 4 | import android.content.Context; 5 | import android.util.AttributeSet; 6 | 7 | import com.github.mikephil.charting.data.BubbleData; 8 | import com.github.mikephil.charting.interfaces.dataprovider.BubbleDataProvider; 9 | import com.github.mikephil.charting.renderer.BubbleChartRenderer; 10 | 11 | /** 12 | * The BubbleChart. Draws bubbles. Bubble chart implementation: Copyright 2015 13 | * Pierre-Marc Airoldi Licensed under Apache License 2.0. In the BubbleChart, it 14 | * is the area of the bubble, not the radius or diameter of the bubble that 15 | * conveys the data. 16 | * 17 | * @author Philipp Jahoda 18 | */ 19 | public class BubbleChart extends BarLineChartBase implements BubbleDataProvider { 20 | 21 | public BubbleChart(Context context) { 22 | super(context); 23 | } 24 | 25 | public BubbleChart(Context context, AttributeSet attrs) { 26 | super(context, attrs); 27 | } 28 | 29 | public BubbleChart(Context context, AttributeSet attrs, int defStyle) { 30 | super(context, attrs, defStyle); 31 | } 32 | 33 | @Override 34 | protected void init() { 35 | super.init(); 36 | 37 | mRenderer = new BubbleChartRenderer(this, mAnimator, mViewPortHandler); 38 | } 39 | 40 | public BubbleData getBubbleData() { 41 | return mData; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/data/BaseEntry.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.data; 2 | 3 | /** 4 | * Created by Philipp Jahoda on 02/06/16. 5 | */ 6 | public abstract class BaseEntry { 7 | 8 | /** the y value */ 9 | private float y = 0f; 10 | 11 | /** optional spot for additional data this Entry represents */ 12 | private Object mData = null; 13 | 14 | public BaseEntry() { 15 | 16 | } 17 | 18 | public BaseEntry(float y) { 19 | this.y = y; 20 | } 21 | 22 | public BaseEntry(float y, Object data) { 23 | this(y); 24 | this.mData = data; 25 | } 26 | 27 | /** 28 | * Returns the y value of this Entry. 29 | * 30 | * @return 31 | */ 32 | public float getY() { 33 | return y; 34 | } 35 | 36 | /** 37 | * Sets the y-value for the Entry. 38 | * 39 | * @param y 40 | */ 41 | public void setY(float y) { 42 | this.y = y; 43 | } 44 | 45 | /** 46 | * Returns the data, additional information that this Entry represents, or 47 | * null, if no data has been specified. 48 | * 49 | * @return 50 | */ 51 | public Object getData() { 52 | return mData; 53 | } 54 | 55 | /** 56 | * Sets additional data this Entry should represent. 57 | * 58 | * @param data 59 | */ 60 | public void setData(Object data) { 61 | this.mData = data; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /MPChartExample/res/layout/activity_scrollview.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | 16 | 17 | 18 | 19 | 22 | 23 | 27 | 28 | 29 | 30 | 33 | 34 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/formatter/PercentFormatter.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.formatter; 3 | 4 | import com.github.mikephil.charting.components.AxisBase; 5 | import com.github.mikephil.charting.data.Entry; 6 | import com.github.mikephil.charting.utils.ViewPortHandler; 7 | 8 | import java.text.DecimalFormat; 9 | 10 | /** 11 | * This IValueFormatter is just for convenience and simply puts a "%" sign after 12 | * each value. (Recommeded for PieChart) 13 | * 14 | * @author Philipp Jahoda 15 | */ 16 | public class PercentFormatter implements IValueFormatter, IAxisValueFormatter 17 | { 18 | 19 | protected DecimalFormat mFormat; 20 | 21 | public PercentFormatter() { 22 | mFormat = new DecimalFormat("###,###,##0.0"); 23 | } 24 | 25 | /** 26 | * Allow a custom decimalformat 27 | * 28 | * @param format 29 | */ 30 | public PercentFormatter(DecimalFormat format) { 31 | this.mFormat = format; 32 | } 33 | 34 | // IValueFormatter 35 | @Override 36 | public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) { 37 | return mFormat.format(value) + " %"; 38 | } 39 | 40 | // IAxisValueFormatter 41 | @Override 42 | public String getFormattedValue(float value, AxisBase axis) { 43 | return mFormat.format(value) + " %"; 44 | } 45 | 46 | public int getDecimalDigits() { 47 | return 1; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /MPChartExample/src/com/xxmassdeveloper/mpchartexample/custom/MyCustomXAxisValueFormatter.java: -------------------------------------------------------------------------------- 1 | package com.xxmassdeveloper.mpchartexample.custom; 2 | 3 | import com.github.mikephil.charting.components.AxisBase; 4 | import com.github.mikephil.charting.formatter.IAxisValueFormatter; 5 | import com.github.mikephil.charting.utils.ViewPortHandler; 6 | 7 | import java.text.DecimalFormat; 8 | 9 | /** 10 | * Created by Philipp Jahoda on 14/09/15. 11 | */ 12 | public class MyCustomXAxisValueFormatter implements IAxisValueFormatter 13 | { 14 | 15 | private DecimalFormat mFormat; 16 | private ViewPortHandler mViewPortHandler; 17 | 18 | public MyCustomXAxisValueFormatter(ViewPortHandler viewPortHandler) { 19 | mViewPortHandler = viewPortHandler; 20 | // maybe do something here or provide parameters in constructor 21 | mFormat = new DecimalFormat("###,###,###,##0.0"); 22 | } 23 | 24 | @Override 25 | public String getFormattedValue(float value, AxisBase axis) { 26 | 27 | //Log.i("TRANS", "x: " + viewPortHandler.getTransX() + ", y: " + viewPortHandler.getTransY()); 28 | 29 | // e.g. adjust the x-axis values depending on scale / zoom level 30 | final float xScale = mViewPortHandler.getScaleX(); 31 | if (xScale > 5) 32 | return "4"; 33 | else if (xScale > 3) 34 | return "3"; 35 | else if (xScale > 1) 36 | return "2"; 37 | else 38 | return mFormat.format(value); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/utils/TransformerHorizontalBarChart.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.utils; 3 | 4 | /** 5 | * Transformer class for the HorizontalBarChart. 6 | * 7 | * @author Philipp Jahoda 8 | */ 9 | public class TransformerHorizontalBarChart extends Transformer { 10 | 11 | public TransformerHorizontalBarChart(ViewPortHandler viewPortHandler) { 12 | super(viewPortHandler); 13 | } 14 | 15 | /** 16 | * Prepares the matrix that contains all offsets. 17 | * 18 | * @param inverted 19 | */ 20 | public void prepareMatrixOffset(boolean inverted) { 21 | 22 | mMatrixOffset.reset(); 23 | 24 | // offset.postTranslate(mOffsetLeft, getHeight() - mOffsetBottom); 25 | 26 | if (!inverted) 27 | mMatrixOffset.postTranslate(mViewPortHandler.offsetLeft(), 28 | mViewPortHandler.getChartHeight() - mViewPortHandler.offsetBottom()); 29 | else { 30 | mMatrixOffset 31 | .setTranslate( 32 | -(mViewPortHandler.getChartWidth() - mViewPortHandler.offsetRight()), 33 | mViewPortHandler.getChartHeight() - mViewPortHandler.offsetBottom()); 34 | mMatrixOffset.postScale(-1.0f, 1.0f); 35 | } 36 | 37 | // mMatrixOffset.set(offset); 38 | 39 | // mMatrixOffset.reset(); 40 | // 41 | // mMatrixOffset.postTranslate(mOffsetLeft, getHeight() - 42 | // mOffsetBottom); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /MPChartExample/res/layout/activity_barchart_sinus.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | 24 | 25 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/charts/LineChart.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.charts; 3 | 4 | import android.content.Context; 5 | import android.util.AttributeSet; 6 | 7 | import com.github.mikephil.charting.data.LineData; 8 | import com.github.mikephil.charting.interfaces.dataprovider.LineDataProvider; 9 | import com.github.mikephil.charting.renderer.LineChartRenderer; 10 | 11 | /** 12 | * Chart that draws lines, surfaces, circles, ... 13 | * 14 | * @author Philipp Jahoda 15 | */ 16 | public class LineChart extends BarLineChartBase implements LineDataProvider { 17 | 18 | public LineChart(Context context) { 19 | super(context); 20 | } 21 | 22 | public LineChart(Context context, AttributeSet attrs) { 23 | super(context, attrs); 24 | } 25 | 26 | public LineChart(Context context, AttributeSet attrs, int defStyle) { 27 | super(context, attrs, defStyle); 28 | } 29 | 30 | @Override 31 | protected void init() { 32 | super.init(); 33 | 34 | mRenderer = new LineChartRenderer(this, mAnimator, mViewPortHandler); 35 | } 36 | 37 | @Override 38 | public LineData getLineData() { 39 | return mData; 40 | } 41 | 42 | @Override 43 | protected void onDetachedFromWindow() { 44 | // releases the bitmap in the renderer to avoid oom error 45 | if (mRenderer != null && mRenderer instanceof LineChartRenderer) { 46 | ((LineChartRenderer) mRenderer).releaseBitmap(); 47 | } 48 | super.onDetachedFromWindow(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /MPChartExample/res/menu/radar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 11 | 12 | 15 | 16 | 19 | 20 | 23 | 24 | 27 | 28 | 31 | 32 | 35 | 36 | 39 | 40 | 43 | 44 | 47 | 48 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /MPChartExample/res/layout/activity_performance_linechart.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | 25 | 26 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/jobs/ViewPortJob.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.jobs; 3 | 4 | import android.view.View; 5 | 6 | import com.github.mikephil.charting.utils.ObjectPool; 7 | import com.github.mikephil.charting.utils.Transformer; 8 | import com.github.mikephil.charting.utils.ViewPortHandler; 9 | 10 | /** 11 | * Runnable that is used for viewport modifications since they cannot be 12 | * executed at any time. This can be used to delay the execution of viewport 13 | * modifications until the onSizeChanged(...) method of the chart-view is called. 14 | * This is especially important if viewport modifying methods are called on the chart 15 | * directly after initialization. 16 | * 17 | * @author Philipp Jahoda 18 | */ 19 | public abstract class ViewPortJob extends ObjectPool.Poolable implements Runnable { 20 | 21 | protected float[] pts = new float[2]; 22 | 23 | protected ViewPortHandler mViewPortHandler; 24 | protected float xValue = 0f; 25 | protected float yValue = 0f; 26 | protected Transformer mTrans; 27 | protected View view; 28 | 29 | public ViewPortJob(ViewPortHandler viewPortHandler, float xValue, float yValue, 30 | Transformer trans, View v) { 31 | 32 | this.mViewPortHandler = viewPortHandler; 33 | this.xValue = xValue; 34 | this.yValue = yValue; 35 | this.mTrans = trans; 36 | this.view = v; 37 | 38 | } 39 | 40 | public float getXValue() { 41 | return xValue; 42 | } 43 | 44 | public float getYValue() { 45 | return yValue; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # MPAndroidChart项目使用 2 | 3 | 开源地址:[https://github.com/open-android/MPAndroidChart](https://github.com/open-android/MPAndroidChart "https://github.com/open-android/MPAndroidChart") 4 | 5 | # 运行效果 6 | 7 | 详细效果请参考MPChartExample例子 8 | 9 | ![](screenshots/screenshot.gif) 10 | 11 | * 爱生活,爱学习,更爱做代码的搬运工,分类查找更方便请下载黑马助手app 12 | 13 | 14 | ![黑马助手.png](http://upload-images.jianshu.io/upload_images/4037105-f777f1214328dcc4.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 15 | 16 | ## 使用步骤 17 | 18 | ### 1. 在project的build.gradle添加如下代码(如下图) 19 | 20 | allprojects { 21 | repositories { 22 | maven { url "https://jitpack.io" } 23 | } 24 | } 25 | 26 | ![](screenshots/build.gradle.png) 27 | 28 | ### 2. 在Module的build.gradle添加依赖 29 | 30 | compile 'com.github.open-android:MPAndroidChart:v3.0.1' 31 | 32 | 33 | ### 3.清单文件添加权限 34 | 35 | 36 | 37 | ### 4.布局文件使用 38 | 39 | 43 | 44 | ### 5.Activity中初始化 45 | 46 | mChart = (LineChart) findViewById(R.id.line_chart);//初始化对应的Chart控件 47 | //省略部分代码,具体请参考MPChartExample例子实现想要的效果 48 | setData(1000, 500f);//给图表设置数据 49 | mChart.invalidate();//刷新 50 | 51 | 52 | 53 | * 详细的使用方法在DEMO里面都演示啦,如果你觉得这个库还不错,请赏我一颗star吧~~~ 54 | 55 | * 欢迎关注微信公众号 56 | 57 | ![](http://upload-images.jianshu.io/upload_images/4037105-8f737b5104dd0b5d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 58 | 59 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/formatter/DefaultAxisValueFormatter.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.formatter; 2 | 3 | import com.github.mikephil.charting.components.AxisBase; 4 | 5 | import java.text.DecimalFormat; 6 | 7 | /** 8 | * Created by philipp on 02/06/16. 9 | */ 10 | public class DefaultAxisValueFormatter implements IAxisValueFormatter 11 | { 12 | 13 | /** 14 | * decimalformat for formatting 15 | */ 16 | protected DecimalFormat mFormat; 17 | 18 | /** 19 | * the number of decimal digits this formatter uses 20 | */ 21 | protected int digits = 0; 22 | 23 | /** 24 | * Constructor that specifies to how many digits the value should be 25 | * formatted. 26 | * 27 | * @param digits 28 | */ 29 | public DefaultAxisValueFormatter(int digits) { 30 | this.digits = digits; 31 | 32 | StringBuffer b = new StringBuffer(); 33 | for (int i = 0; i < digits; i++) { 34 | if (i == 0) 35 | b.append("."); 36 | b.append("0"); 37 | } 38 | 39 | mFormat = new DecimalFormat("###,###,###,##0" + b.toString()); 40 | } 41 | 42 | @Override 43 | public String getFormattedValue(float value, AxisBase axis) { 44 | // avoid memory allocations here (for performance) 45 | return mFormat.format(value); 46 | } 47 | 48 | /** 49 | * Returns the number of decimal digits this formatter uses or -1, if unspecified. 50 | * 51 | * @return 52 | */ 53 | public int getDecimalDigits() { 54 | return digits; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/data/RadarData.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.data; 3 | 4 | import com.github.mikephil.charting.highlight.Highlight; 5 | import com.github.mikephil.charting.interfaces.datasets.IRadarDataSet; 6 | 7 | import java.util.ArrayList; 8 | import java.util.Arrays; 9 | import java.util.List; 10 | 11 | /** 12 | * Data container for the RadarChart. 13 | * 14 | * @author Philipp Jahoda 15 | */ 16 | public class RadarData extends ChartData { 17 | 18 | private List mLabels; 19 | 20 | public RadarData() { 21 | super(); 22 | } 23 | 24 | public RadarData(List dataSets) { 25 | super(dataSets); 26 | } 27 | 28 | public RadarData(IRadarDataSet... dataSets) { 29 | super(dataSets); 30 | } 31 | 32 | /** 33 | * Sets the labels that should be drawn around the RadarChart at the end of each web line. 34 | * 35 | * @param labels 36 | */ 37 | public void setLabels(List labels) { 38 | this.mLabels = labels; 39 | } 40 | 41 | /** 42 | * Sets the labels that should be drawn around the RadarChart at the end of each web line. 43 | * 44 | * @param labels 45 | */ 46 | public void setLabels(String... labels) { 47 | this.mLabels = Arrays.asList(labels); 48 | } 49 | 50 | public List getLabels() { 51 | return mLabels; 52 | } 53 | 54 | @Override 55 | public Entry getEntryForHighlight(Highlight highlight) { 56 | return getDataSetByIndex(highlight.getDataSetIndex()).getEntryForIndex((int) highlight.getX()); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /MPChartExample/src/com/xxmassdeveloper/mpchartexample/custom/MyMarkerView.java: -------------------------------------------------------------------------------- 1 | 2 | package com.xxmassdeveloper.mpchartexample.custom; 3 | 4 | import android.content.Context; 5 | import android.widget.TextView; 6 | 7 | import com.github.mikephil.charting.components.MarkerView; 8 | import com.github.mikephil.charting.data.CandleEntry; 9 | import com.github.mikephil.charting.data.Entry; 10 | import com.github.mikephil.charting.highlight.Highlight; 11 | import com.github.mikephil.charting.utils.MPPointF; 12 | import com.github.mikephil.charting.utils.Utils; 13 | import com.xxmassdeveloper.mpchartexample.R; 14 | 15 | /** 16 | * Custom implementation of the MarkerView. 17 | * 18 | * @author Philipp Jahoda 19 | */ 20 | public class MyMarkerView extends MarkerView { 21 | 22 | private TextView tvContent; 23 | 24 | public MyMarkerView(Context context, int layoutResource) { 25 | super(context, layoutResource); 26 | 27 | tvContent = (TextView) findViewById(R.id.tvContent); 28 | } 29 | 30 | // callbacks everytime the MarkerView is redrawn, can be used to update the 31 | // content (user-interface) 32 | @Override 33 | public void refreshContent(Entry e, Highlight highlight) { 34 | 35 | if (e instanceof CandleEntry) { 36 | 37 | CandleEntry ce = (CandleEntry) e; 38 | 39 | tvContent.setText("" + Utils.formatNumber(ce.getHigh(), 0, true)); 40 | } else { 41 | 42 | tvContent.setText("" + Utils.formatNumber(e.getY(), 0, true)); 43 | } 44 | 45 | super.refreshContent(e, highlight); 46 | } 47 | 48 | @Override 49 | public MPPointF getOffset() { 50 | return new MPPointF(-(getWidth() / 2), -getHeight()); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/data/PieEntry.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.data; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.util.Log; 5 | 6 | /** 7 | * Created by Philipp Jahoda on 31/05/16. 8 | */ 9 | @SuppressLint("ParcelCreator") 10 | public class PieEntry extends Entry { 11 | 12 | private String label; 13 | 14 | public PieEntry(float value) { 15 | super(0f, value); 16 | } 17 | 18 | public PieEntry(float value, Object data) { 19 | super(0f, value, data); 20 | } 21 | 22 | public PieEntry(float value, String label) { 23 | super(0f, value); 24 | this.label = label; 25 | } 26 | 27 | public PieEntry(float value, String label, Object data) { 28 | super(0f, value, data); 29 | this.label = label; 30 | } 31 | 32 | /** 33 | * This is the same as getY(). Returns the value of the PieEntry. 34 | * 35 | * @return 36 | */ 37 | public float getValue() { 38 | return getY(); 39 | } 40 | 41 | public String getLabel() { 42 | return label; 43 | } 44 | 45 | public void setLabel(String label) { 46 | this.label = label; 47 | } 48 | 49 | @Deprecated 50 | @Override 51 | public void setX(float x) { 52 | super.setX(x); 53 | Log.i("DEPRECATED", "Pie entries do not have x values"); 54 | } 55 | 56 | @Deprecated 57 | @Override 58 | public float getX() { 59 | Log.i("DEPRECATED", "Pie entries do not have x values"); 60 | return super.getX(); 61 | } 62 | 63 | public PieEntry copy() { 64 | PieEntry e = new PieEntry(getY(), label, getData()); 65 | return e; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /MPChartExample/src/com/xxmassdeveloper/mpchartexample/custom/RadarMarkerView.java: -------------------------------------------------------------------------------- 1 | 2 | package com.xxmassdeveloper.mpchartexample.custom; 3 | 4 | import android.content.Context; 5 | import android.graphics.Typeface; 6 | import android.widget.TextView; 7 | 8 | import com.github.mikephil.charting.components.MarkerView; 9 | import com.github.mikephil.charting.data.CandleEntry; 10 | import com.github.mikephil.charting.data.Entry; 11 | import com.github.mikephil.charting.highlight.Highlight; 12 | import com.github.mikephil.charting.utils.MPPointF; 13 | import com.github.mikephil.charting.utils.Utils; 14 | import com.xxmassdeveloper.mpchartexample.R; 15 | 16 | import java.text.DecimalFormat; 17 | 18 | /** 19 | * Custom implementation of the MarkerView. 20 | * 21 | * @author Philipp Jahoda 22 | */ 23 | public class RadarMarkerView extends MarkerView { 24 | 25 | private TextView tvContent; 26 | private DecimalFormat format = new DecimalFormat("##0"); 27 | 28 | public RadarMarkerView(Context context, int layoutResource) { 29 | super(context, layoutResource); 30 | 31 | tvContent = (TextView) findViewById(R.id.tvContent); 32 | tvContent.setTypeface(Typeface.createFromAsset(context.getAssets(), "OpenSans-Light.ttf")); 33 | } 34 | 35 | // callbacks everytime the MarkerView is redrawn, can be used to update the 36 | // content (user-interface) 37 | @Override 38 | public void refreshContent(Entry e, Highlight highlight) { 39 | tvContent.setText(format.format(e.getY()) + " %"); 40 | 41 | super.refreshContent(e, highlight); 42 | } 43 | 44 | @Override 45 | public MPPointF getOffset() { 46 | return new MPPointF(-(getWidth() / 2), -getHeight() - 10); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/data/BubbleEntry.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.data; 3 | 4 | import android.annotation.SuppressLint; 5 | 6 | /** 7 | * Subclass of Entry that holds a value for one entry in a BubbleChart. Bubble 8 | * chart implementation: Copyright 2015 Pierre-Marc Airoldi Licensed under 9 | * Apache License 2.0 10 | * 11 | * @author Philipp Jahoda 12 | */ 13 | @SuppressLint("ParcelCreator") 14 | public class BubbleEntry extends Entry { 15 | 16 | /** size value */ 17 | private float mSize = 0f; 18 | 19 | /** 20 | * Constructor. 21 | * 22 | * @param x The value on the x-axis. 23 | * @param y The value on the y-axis. 24 | * @param size The size of the bubble. 25 | */ 26 | public BubbleEntry(float x, float y, float size) { 27 | super(x, y); 28 | this.mSize = size; 29 | } 30 | 31 | /** 32 | * Constructor. 33 | * 34 | * @param x The value on the x-axis. 35 | * @param y The value on the y-axis. 36 | * @param size The size of the bubble. 37 | * @param data Spot for additional data this Entry represents. 38 | */ 39 | public BubbleEntry(float x, float y, float size, Object data) { 40 | super(x, y, data); 41 | this.mSize = size; 42 | } 43 | 44 | public BubbleEntry copy() { 45 | 46 | BubbleEntry c = new BubbleEntry(getX(), getY(), mSize, getData()); 47 | return c; 48 | } 49 | 50 | /** 51 | * Returns the size of this entry (the size of the bubble). 52 | * 53 | * @return 54 | */ 55 | public float getSize() { 56 | return mSize; 57 | } 58 | 59 | public void setSize(float size) { 60 | this.mSize = size; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /MPChartExample/assets/n.txt: -------------------------------------------------------------------------------- 1 | 0.0#0 2 | 0.05#1 3 | 0.1#2 4 | 0.15#3 5 | 0.2#4 6 | 0.25#5 7 | 0.3#6 8 | 0.35000002#7 9 | 0.40000004#8 10 | 0.45000005#9 11 | 0.50000006#10 12 | 0.5500001#11 13 | 0.6000001#12 14 | 0.6500001#13 15 | 0.7000001#14 16 | 0.7500001#15 17 | 0.80000013#16 18 | 0.85000014#17 19 | 0.90000015#18 20 | 0.95000017#19 21 | 1.0000001#20 22 | 1.0500001#21 23 | 1.1#22 24 | 1.15#23 25 | 1.1999999#24 26 | 1.2499999#25 27 | 1.2999998#26 28 | 1.3499998#27 29 | 1.3999997#28 30 | 1.4499997#29 31 | 1.4999996#30 32 | 1.5499996#31 33 | 1.5999995#32 34 | 1.6499995#33 35 | 1.6999995#34 36 | 1.7499994#35 37 | 1.7999994#36 38 | 1.8499993#37 39 | 1.8999993#38 40 | 1.9499992#39 41 | 1.9999992#40 42 | 2.0499992#41 43 | 2.0999992#42 44 | 2.1499991#43 45 | 2.199999#44 46 | 2.249999#45 47 | 2.299999#46 48 | 2.349999#47 49 | 2.399999#48 50 | 2.4499989#49 51 | 2.4999988#50 52 | 2.5499988#51 53 | 2.5999987#52 54 | 2.6499987#53 55 | 2.6999986#54 56 | 2.7499986#55 57 | 2.7999985#56 58 | 2.8499985#57 59 | 2.8999984#58 60 | 2.9499984#59 61 | 2.9999983#60 62 | 3.0499983#61 63 | 3.0999982#62 64 | 3.1499982#63 65 | 3.1999981#64 66 | 3.249998#65 67 | 3.299998#66 68 | 3.349998#67 69 | 3.399998#68 70 | 3.449998#69 71 | 3.4999979#70 72 | 3.5499978#71 73 | 3.5999978#72 74 | 3.6499977#73 75 | 3.6999977#74 76 | 3.7499976#75 77 | 3.7999976#76 78 | 3.8499975#77 79 | 3.8999975#78 80 | 3.9499974#79 81 | 3.9999974#80 82 | 4.0499973#81 83 | 4.0999975#82 84 | 4.1499977#83 85 | 4.199998#84 86 | 4.249998#85 87 | 4.2999983#86 88 | 4.3499985#87 89 | 4.3999987#88 90 | 4.449999#89 91 | 4.499999#90 92 | 4.549999#91 93 | 4.5999994#92 94 | 4.6499996#93 95 | 4.7#94 96 | 4.75#95 97 | 4.8#96 98 | 4.8500004#97 99 | 4.9000006#98 100 | 4.950001#99 -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/datasets/ILineRadarDataSet.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.interfaces.datasets; 2 | 3 | import android.graphics.drawable.Drawable; 4 | 5 | import com.github.mikephil.charting.data.Entry; 6 | 7 | /** 8 | * Created by Philipp Jahoda on 21/10/15. 9 | */ 10 | public interface ILineRadarDataSet extends ILineScatterCandleRadarDataSet { 11 | 12 | /** 13 | * Returns the color that is used for filling the line surface area. 14 | * 15 | * @return 16 | */ 17 | int getFillColor(); 18 | 19 | /** 20 | * Returns the drawable used for filling the area below the line. 21 | * 22 | * @return 23 | */ 24 | Drawable getFillDrawable(); 25 | 26 | /** 27 | * Returns the alpha value that is used for filling the line surface, 28 | * default: 85 29 | * 30 | * @return 31 | */ 32 | int getFillAlpha(); 33 | 34 | /** 35 | * Returns the stroke-width of the drawn line 36 | * 37 | * @return 38 | */ 39 | float getLineWidth(); 40 | 41 | /** 42 | * Returns true if filled drawing is enabled, false if not 43 | * 44 | * @return 45 | */ 46 | boolean isDrawFilledEnabled(); 47 | 48 | /** 49 | * Set to true if the DataSet should be drawn filled (surface), and not just 50 | * as a line, disabling this will give great performance boost. Please note that this method 51 | * uses the canvas.clipPath(...) method for drawing the filled area. 52 | * For devices with API level < 18 (Android 4.3), hardware acceleration of the chart should 53 | * be turned off. Default: false 54 | * 55 | * @param enabled 56 | */ 57 | void setDrawFilled(boolean enabled); 58 | } 59 | -------------------------------------------------------------------------------- /MPChartExample/src/com/xxmassdeveloper/mpchartexample/custom/XYMarkerView.java: -------------------------------------------------------------------------------- 1 | 2 | package com.xxmassdeveloper.mpchartexample.custom; 3 | 4 | import android.content.Context; 5 | import android.widget.TextView; 6 | 7 | import com.github.mikephil.charting.components.MarkerView; 8 | import com.github.mikephil.charting.data.Entry; 9 | import com.github.mikephil.charting.formatter.IAxisValueFormatter; 10 | import com.github.mikephil.charting.highlight.Highlight; 11 | import com.github.mikephil.charting.utils.MPPointF; 12 | import com.xxmassdeveloper.mpchartexample.R; 13 | 14 | import java.text.DecimalFormat; 15 | 16 | /** 17 | * Custom implementation of the MarkerView. 18 | * 19 | * @author Philipp Jahoda 20 | */ 21 | public class XYMarkerView extends MarkerView { 22 | 23 | private TextView tvContent; 24 | private IAxisValueFormatter xAxisValueFormatter; 25 | 26 | private DecimalFormat format; 27 | 28 | public XYMarkerView(Context context, IAxisValueFormatter xAxisValueFormatter) { 29 | super(context, R.layout.custom_marker_view); 30 | 31 | this.xAxisValueFormatter = xAxisValueFormatter; 32 | tvContent = (TextView) findViewById(R.id.tvContent); 33 | format = new DecimalFormat("###.0"); 34 | } 35 | 36 | // callbacks everytime the MarkerView is redrawn, can be used to update the 37 | // content (user-interface) 38 | @Override 39 | public void refreshContent(Entry e, Highlight highlight) { 40 | 41 | tvContent.setText("x: " + xAxisValueFormatter.getFormattedValue(e.getX(), null) + ", y: " + format.format(e.getY())); 42 | 43 | super.refreshContent(e, highlight); 44 | } 45 | 46 | @Override 47 | public MPPointF getOffset() { 48 | return new MPPointF(-(getWidth() / 2), -getHeight()); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /MPChartExample/res/layout/list_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 16 | 17 | 29 | 30 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/jobs/MoveViewJob.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.jobs; 3 | 4 | import android.view.View; 5 | 6 | import com.github.mikephil.charting.utils.ObjectPool; 7 | import com.github.mikephil.charting.utils.Transformer; 8 | import com.github.mikephil.charting.utils.ViewPortHandler; 9 | 10 | /** 11 | * Created by Philipp Jahoda on 19/02/16. 12 | */ 13 | public class MoveViewJob extends ViewPortJob { 14 | 15 | private static ObjectPool pool; 16 | 17 | static { 18 | pool = ObjectPool.create(2, new MoveViewJob(null,0,0,null,null)); 19 | pool.setReplenishPercentage(0.5f); 20 | } 21 | 22 | public static MoveViewJob getInstance(ViewPortHandler viewPortHandler, float xValue, float yValue, Transformer trans, View v){ 23 | MoveViewJob result = pool.get(); 24 | result.mViewPortHandler = viewPortHandler; 25 | result.xValue = xValue; 26 | result.yValue = yValue; 27 | result.mTrans = trans; 28 | result.view = v; 29 | return result; 30 | } 31 | 32 | public static void recycleInstance(MoveViewJob instance){ 33 | pool.recycle(instance); 34 | } 35 | 36 | public MoveViewJob(ViewPortHandler viewPortHandler, float xValue, float yValue, Transformer trans, View v) { 37 | super(viewPortHandler, xValue, yValue, trans, v); 38 | } 39 | 40 | @Override 41 | public void run() { 42 | 43 | pts[0] = xValue; 44 | pts[1] = yValue; 45 | 46 | mTrans.pointValuesToPixel(pts); 47 | mViewPortHandler.centerViewPort(pts, view); 48 | 49 | this.recycleInstance(this); 50 | } 51 | 52 | @Override 53 | protected ObjectPool.Poolable instantiate() { 54 | return new MoveViewJob(mViewPortHandler, xValue, yValue, mTrans, view); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/datasets/IBarDataSet.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.interfaces.datasets; 2 | 3 | import com.github.mikephil.charting.data.BarEntry; 4 | 5 | /** 6 | * Created by philipp on 21/10/15. 7 | */ 8 | public interface IBarDataSet extends IBarLineScatterCandleBubbleDataSet { 9 | 10 | /** 11 | * Returns true if this DataSet is stacked (stacksize > 1) or not. 12 | * 13 | * @return 14 | */ 15 | boolean isStacked(); 16 | 17 | /** 18 | * Returns the maximum number of bars that can be stacked upon another in 19 | * this DataSet. This should return 1 for non stacked bars, and > 1 for stacked bars. 20 | * 21 | * @return 22 | */ 23 | int getStackSize(); 24 | 25 | /** 26 | * Returns the color used for drawing the bar-shadows. The bar shadows is a 27 | * surface behind the bar that indicates the maximum value. 28 | * 29 | * @return 30 | */ 31 | int getBarShadowColor(); 32 | 33 | /** 34 | * Returns the width used for drawing borders around the bars. 35 | * If borderWidth == 0, no border will be drawn. 36 | * 37 | * @return 38 | */ 39 | float getBarBorderWidth(); 40 | 41 | /** 42 | * Returns the color drawing borders around the bars. 43 | * 44 | * @return 45 | */ 46 | int getBarBorderColor(); 47 | 48 | /** 49 | * Returns the alpha value (transparency) that is used for drawing the 50 | * highlight indicator. 51 | * 52 | * @return 53 | */ 54 | int getHighLightAlpha(); 55 | 56 | 57 | /** 58 | * Returns the labels used for the different value-stacks in the legend. 59 | * This is only relevant for stacked bar entries. 60 | * 61 | * @return 62 | */ 63 | String[] getStackLabels(); 64 | } 65 | -------------------------------------------------------------------------------- /MPChartExample/src/com/xxmassdeveloper/mpchartexample/fragments/ComplexityFragment.java: -------------------------------------------------------------------------------- 1 | package com.xxmassdeveloper.mpchartexample.fragments; 2 | import android.graphics.Typeface; 3 | import android.os.Bundle; 4 | import android.support.v4.app.Fragment; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | 9 | import com.github.mikephil.charting.charts.LineChart; 10 | import com.github.mikephil.charting.components.Legend; 11 | import com.github.mikephil.charting.components.XAxis; 12 | import com.github.mikephil.charting.components.YAxis; 13 | import com.xxmassdeveloper.mpchartexample.R; 14 | 15 | 16 | public class ComplexityFragment extends SimpleFragment { 17 | 18 | public static Fragment newInstance() { 19 | return new ComplexityFragment(); 20 | } 21 | 22 | private LineChart mChart; 23 | 24 | @Override 25 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 26 | View v = inflater.inflate(R.layout.frag_simple_line, container, false); 27 | 28 | mChart = (LineChart) v.findViewById(R.id.lineChart1); 29 | 30 | mChart.getDescription().setEnabled(false); 31 | 32 | mChart.setDrawGridBackground(false); 33 | 34 | mChart.setData(getComplexity()); 35 | mChart.animateX(3000); 36 | 37 | Typeface tf = Typeface.createFromAsset(getActivity().getAssets(),"OpenSans-Light.ttf"); 38 | 39 | Legend l = mChart.getLegend(); 40 | l.setTypeface(tf); 41 | 42 | YAxis leftAxis = mChart.getAxisLeft(); 43 | leftAxis.setTypeface(tf); 44 | 45 | mChart.getAxisRight().setEnabled(false); 46 | 47 | XAxis xAxis = mChart.getXAxis(); 48 | xAxis.setEnabled(false); 49 | 50 | return v; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/dataprovider/ChartInterface.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.interfaces.dataprovider; 2 | 3 | import android.graphics.RectF; 4 | 5 | import com.github.mikephil.charting.data.ChartData; 6 | import com.github.mikephil.charting.formatter.IValueFormatter; 7 | import com.github.mikephil.charting.utils.MPPointF; 8 | 9 | /** 10 | * Interface that provides everything there is to know about the dimensions, 11 | * bounds, and range of the chart. 12 | * 13 | * @author Philipp Jahoda 14 | */ 15 | public interface ChartInterface { 16 | 17 | /** 18 | * Returns the minimum x value of the chart, regardless of zoom or translation. 19 | * 20 | * @return 21 | */ 22 | float getXChartMin(); 23 | 24 | /** 25 | * Returns the maximum x value of the chart, regardless of zoom or translation. 26 | * 27 | * @return 28 | */ 29 | float getXChartMax(); 30 | 31 | float getXRange(); 32 | 33 | /** 34 | * Returns the minimum y value of the chart, regardless of zoom or translation. 35 | * 36 | * @return 37 | */ 38 | float getYChartMin(); 39 | 40 | /** 41 | * Returns the maximum y value of the chart, regardless of zoom or translation. 42 | * 43 | * @return 44 | */ 45 | float getYChartMax(); 46 | 47 | /** 48 | * Returns the maximum distance in scren dp a touch can be away from an entry to cause it to get highlighted. 49 | * 50 | * @return 51 | */ 52 | float getMaxHighlightDistance(); 53 | 54 | int getWidth(); 55 | 56 | int getHeight(); 57 | 58 | MPPointF getCenterOfView(); 59 | 60 | MPPointF getCenterOffsets(); 61 | 62 | RectF getContentRect(); 63 | 64 | IValueFormatter getDefaultValueFormatter(); 65 | 66 | ChartData getData(); 67 | 68 | int getMaxVisibleCount(); 69 | } 70 | -------------------------------------------------------------------------------- /MPChartExample/res/menu/line.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 11 | 12 | 15 | 16 | 19 | 20 | 23 | 24 | 27 | 28 | 31 | 32 | 35 | 36 | 39 | 40 | 43 | 44 | 47 | 48 | 51 | 52 | 55 | 56 | 59 | 60 | -------------------------------------------------------------------------------- /MPChartExample/src/com/xxmassdeveloper/mpchartexample/notimportant/DemoBase.java: -------------------------------------------------------------------------------- 1 | 2 | package com.xxmassdeveloper.mpchartexample.notimportant; 3 | 4 | import android.graphics.Typeface; 5 | import android.os.Bundle; 6 | import android.renderscript.Type; 7 | import android.support.annotation.Nullable; 8 | import android.support.v4.app.FragmentActivity; 9 | 10 | import com.xxmassdeveloper.mpchartexample.R; 11 | 12 | /** 13 | * Baseclass of all Activities of the Demo Application. 14 | * 15 | * @author Philipp Jahoda 16 | */ 17 | public abstract class DemoBase extends FragmentActivity { 18 | 19 | protected String[] mMonths = new String[] { 20 | "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec" 21 | }; 22 | 23 | protected String[] mParties = new String[] { 24 | "Party A", "Party B", "Party C", "Party D", "Party E", "Party F", "Party G", "Party H", 25 | "Party I", "Party J", "Party K", "Party L", "Party M", "Party N", "Party O", "Party P", 26 | "Party Q", "Party R", "Party S", "Party T", "Party U", "Party V", "Party W", "Party X", 27 | "Party Y", "Party Z" 28 | }; 29 | 30 | protected Typeface mTfRegular; 31 | protected Typeface mTfLight; 32 | 33 | @Override 34 | protected void onCreate(@Nullable Bundle savedInstanceState) { 35 | super.onCreate(savedInstanceState); 36 | 37 | mTfRegular = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf"); 38 | mTfLight = Typeface.createFromAsset(getAssets(), "OpenSans-Light.ttf"); 39 | } 40 | 41 | protected float getRandom(float range, float startsfrom) { 42 | return (float) (Math.random() * range) + startsfrom; 43 | } 44 | 45 | @Override 46 | public void onBackPressed() { 47 | super.onBackPressed(); 48 | overridePendingTransition(R.anim.move_left_in_activity, R.anim.move_right_out_activity); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /MPChartExample/src/com/xxmassdeveloper/mpchartexample/fragments/SineCosineFragment.java: -------------------------------------------------------------------------------- 1 | package com.xxmassdeveloper.mpchartexample.fragments; 2 | import android.graphics.Typeface; 3 | import android.os.Bundle; 4 | import android.support.v4.app.Fragment; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | 9 | import com.github.mikephil.charting.charts.LineChart; 10 | import com.github.mikephil.charting.components.Legend; 11 | import com.github.mikephil.charting.components.XAxis; 12 | import com.github.mikephil.charting.components.YAxis; 13 | import com.xxmassdeveloper.mpchartexample.R; 14 | 15 | 16 | public class SineCosineFragment extends SimpleFragment { 17 | 18 | public static Fragment newInstance() { 19 | return new SineCosineFragment(); 20 | } 21 | 22 | private LineChart mChart; 23 | 24 | @Override 25 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 26 | View v = inflater.inflate(R.layout.frag_simple_line, container, false); 27 | 28 | mChart = (LineChart) v.findViewById(R.id.lineChart1); 29 | 30 | mChart.getDescription().setEnabled(false); 31 | 32 | mChart.setDrawGridBackground(false); 33 | 34 | mChart.setData(generateLineData()); 35 | mChart.animateX(3000); 36 | 37 | Typeface tf = Typeface.createFromAsset(getActivity().getAssets(),"OpenSans-Light.ttf"); 38 | 39 | Legend l = mChart.getLegend(); 40 | l.setTypeface(tf); 41 | 42 | YAxis leftAxis = mChart.getAxisLeft(); 43 | leftAxis.setTypeface(tf); 44 | leftAxis.setAxisMaximum(1.2f); 45 | leftAxis.setAxisMinimum(-1.2f); 46 | 47 | mChart.getAxisRight().setEnabled(false); 48 | 49 | XAxis xAxis = mChart.getXAxis(); 50 | xAxis.setEnabled(false); 51 | 52 | return v; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /MPChartExample/src/com/xxmassdeveloper/mpchartexample/custom/StackedBarsMarkerView.java: -------------------------------------------------------------------------------- 1 | 2 | package com.xxmassdeveloper.mpchartexample.custom; 3 | 4 | import android.content.Context; 5 | import android.widget.TextView; 6 | 7 | import com.github.mikephil.charting.components.MarkerView; 8 | import com.github.mikephil.charting.data.BarEntry; 9 | import com.github.mikephil.charting.data.Entry; 10 | import com.github.mikephil.charting.highlight.Highlight; 11 | import com.github.mikephil.charting.utils.MPPointF; 12 | import com.github.mikephil.charting.utils.Utils; 13 | import com.xxmassdeveloper.mpchartexample.R; 14 | 15 | /** 16 | * Custom implementation of the MarkerView. 17 | * 18 | * @author Philipp Jahoda 19 | */ 20 | public class StackedBarsMarkerView extends MarkerView { 21 | 22 | private TextView tvContent; 23 | 24 | public StackedBarsMarkerView(Context context, int layoutResource) { 25 | super(context, layoutResource); 26 | 27 | tvContent = (TextView) findViewById(R.id.tvContent); 28 | } 29 | 30 | // callbacks everytime the MarkerView is redrawn, can be used to update the 31 | // content (user-interface) 32 | @Override 33 | public void refreshContent(Entry e, Highlight highlight) { 34 | 35 | if (e instanceof BarEntry) { 36 | 37 | BarEntry be = (BarEntry) e; 38 | 39 | if(be.getYVals() != null) { 40 | 41 | // draw the stack value 42 | tvContent.setText("" + Utils.formatNumber(be.getYVals()[highlight.getStackIndex()], 0, true)); 43 | } else { 44 | tvContent.setText("" + Utils.formatNumber(be.getY(), 0, true)); 45 | } 46 | } else { 47 | 48 | tvContent.setText("" + Utils.formatNumber(e.getY(), 0, true)); 49 | } 50 | 51 | super.refreshContent(e, highlight); 52 | } 53 | 54 | @Override 55 | public MPPointF getOffset() { 56 | return new MPPointF(-(getWidth() / 2), -getHeight()); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /demo/src/main/java/com/github/mikephil/demo/MainActivity.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.demo; 3 | 4 | import android.app.Activity; 5 | import android.graphics.Color; 6 | import android.os.Bundle; 7 | 8 | import com.github.mikephil.charting.charts.LineChart; 9 | import com.github.mikephil.charting.components.Legend; 10 | import com.github.mikephil.charting.data.Entry; 11 | import com.github.mikephil.charting.data.LineData; 12 | import com.github.mikephil.charting.data.LineDataSet; 13 | import com.github.mikephil.charting.utils.Utils; 14 | 15 | import java.util.ArrayList; 16 | 17 | public class MainActivity extends Activity { 18 | 19 | private LineChart mChart; 20 | 21 | @Override 22 | protected void onCreate(Bundle savedInstanceState) { 23 | super.onCreate(savedInstanceState); 24 | setContentView(R.layout.activity_main); 25 | 26 | mChart = (LineChart) findViewById(R.id.line_chart);//初始化对应的Chart控件 27 | setData(1000, 500f);//给图表设置数据 28 | mChart.invalidate();//刷新 29 | } 30 | 31 | private void setData(int count, float range) { 32 | 33 | ArrayList yVals = new ArrayList(); 34 | 35 | for (int i = 0; i < count; i++) { 36 | float mult = (range + 1); 37 | float val = (float) (Math.random() * mult) + 3;// + (float) 38 | // ((mult * 39 | // 0.1) / 10); 40 | yVals.add(new Entry(i * 0.001f, val)); 41 | } 42 | 43 | // create a dataset and give it a type 44 | LineDataSet set1 = new LineDataSet(yVals, "DataSet 1"); 45 | 46 | set1.setColor(Color.BLUE); 47 | set1.setLineWidth(0.5f); 48 | set1.setDrawValues(false); 49 | set1.setDrawCircles(false); 50 | 51 | // create a data object with the datasets 52 | LineData data = new LineData(set1); 53 | 54 | // set data 55 | mChart.setData(data); 56 | 57 | // get the legend (only possible after setting data) 58 | Legend l = mChart.getLegend(); 59 | l.setEnabled(false); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/formatter/DefaultValueFormatter.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.formatter; 3 | 4 | import com.github.mikephil.charting.data.Entry; 5 | import com.github.mikephil.charting.utils.ViewPortHandler; 6 | 7 | import java.text.DecimalFormat; 8 | 9 | /** 10 | * Default formatter used for formatting values inside the chart. Uses a DecimalFormat with 11 | * pre-calculated number of digits (depending on max and min value). 12 | * 13 | * @author Philipp Jahoda 14 | */ 15 | public class DefaultValueFormatter implements IValueFormatter 16 | { 17 | 18 | /** 19 | * DecimalFormat for formatting 20 | */ 21 | protected DecimalFormat mFormat; 22 | 23 | protected int mDecimalDigits; 24 | 25 | /** 26 | * Constructor that specifies to how many digits the value should be 27 | * formatted. 28 | * 29 | * @param digits 30 | */ 31 | public DefaultValueFormatter(int digits) { 32 | setup(digits); 33 | } 34 | 35 | /** 36 | * Sets up the formatter with a given number of decimal digits. 37 | * 38 | * @param digits 39 | */ 40 | public void setup(int digits) { 41 | 42 | this.mDecimalDigits = digits; 43 | 44 | StringBuffer b = new StringBuffer(); 45 | for (int i = 0; i < digits; i++) { 46 | if (i == 0) 47 | b.append("."); 48 | b.append("0"); 49 | } 50 | 51 | mFormat = new DecimalFormat("###,###,###,##0" + b.toString()); 52 | } 53 | 54 | @Override 55 | public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) { 56 | 57 | // put more logic here ... 58 | // avoid memory allocations here (for performance reasons) 59 | 60 | return mFormat.format(value); 61 | } 62 | 63 | /** 64 | * Returns the number of decimal digits this formatter uses. 65 | * 66 | * @return 67 | */ 68 | public int getDecimalDigits() { 69 | return mDecimalDigits; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/formatter/IndexAxisValueFormatter.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.formatter; 3 | 4 | import com.github.mikephil.charting.components.AxisBase; 5 | import com.github.mikephil.charting.data.Entry; 6 | import com.github.mikephil.charting.utils.ViewPortHandler; 7 | 8 | import java.text.DecimalFormat; 9 | import java.util.Arrays; 10 | import java.util.Collection; 11 | 12 | /** 13 | * This formatter is used for passing an array of x-axis labels, on whole x steps. 14 | */ 15 | public class IndexAxisValueFormatter implements IAxisValueFormatter 16 | { 17 | private String[] mValues = new String[] {}; 18 | private int mValueCount = 0; 19 | 20 | /** 21 | * An empty constructor. 22 | * Use `setValues` to set the axis labels. 23 | */ 24 | public IndexAxisValueFormatter() { 25 | } 26 | 27 | /** 28 | * Constructor that specifies axis labels. 29 | * 30 | * @param values The values string array 31 | */ 32 | public IndexAxisValueFormatter(String[] values) { 33 | if (values != null) 34 | setValues(values); 35 | } 36 | 37 | /** 38 | * Constructor that specifies axis labels. 39 | * 40 | * @param values The values string array 41 | */ 42 | public IndexAxisValueFormatter(Collection values) { 43 | if (values != null) 44 | setValues(values.toArray(new String[values.size()])); 45 | } 46 | 47 | public String getFormattedValue(float value, AxisBase axis) { 48 | int index = Math.round(value); 49 | 50 | if (index < 0 || index >= mValueCount || index != (int)value) 51 | return ""; 52 | 53 | return mValues[index]; 54 | } 55 | 56 | public String[] getValues() 57 | { 58 | return mValues; 59 | } 60 | 61 | public void setValues(String[] values) 62 | { 63 | if (values == null) 64 | values = new String[] {}; 65 | 66 | this.mValues = values; 67 | this.mValueCount = values.length; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/datasets/ICandleDataSet.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.interfaces.datasets; 2 | 3 | import android.graphics.Paint; 4 | 5 | import com.github.mikephil.charting.data.CandleEntry; 6 | 7 | /** 8 | * Created by philipp on 21/10/15. 9 | */ 10 | public interface ICandleDataSet extends ILineScatterCandleRadarDataSet { 11 | 12 | /** 13 | * Returns the space that is left out on the left and right side of each 14 | * candle. 15 | * 16 | * @return 17 | */ 18 | float getBarSpace(); 19 | 20 | /** 21 | * Returns whether the candle bars should show? 22 | * When false, only "ticks" will show 23 | * 24 | * - default: true 25 | * 26 | * @return 27 | */ 28 | boolean getShowCandleBar(); 29 | 30 | /** 31 | * Returns the width of the candle-shadow-line in pixels. 32 | * 33 | * @return 34 | */ 35 | float getShadowWidth(); 36 | 37 | /** 38 | * Returns shadow color for all entries 39 | * 40 | * @return 41 | */ 42 | int getShadowColor(); 43 | 44 | /** 45 | * Returns the neutral color (for open == close) 46 | * 47 | * @return 48 | */ 49 | int getNeutralColor(); 50 | 51 | /** 52 | * Returns the increasing color (for open < close). 53 | * 54 | * @return 55 | */ 56 | int getIncreasingColor(); 57 | 58 | /** 59 | * Returns the decreasing color (for open > close). 60 | * 61 | * @return 62 | */ 63 | int getDecreasingColor(); 64 | 65 | /** 66 | * Returns paint style when open < close 67 | * 68 | * @return 69 | */ 70 | Paint.Style getIncreasingPaintStyle(); 71 | 72 | /** 73 | * Returns paint style when open > close 74 | * 75 | * @return 76 | */ 77 | Paint.Style getDecreasingPaintStyle(); 78 | 79 | /** 80 | * Is the shadow color same as the candle color? 81 | * 82 | * @return 83 | */ 84 | boolean getShadowColorSameAsCandle(); 85 | } 86 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/data/BubbleDataSet.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.data; 3 | 4 | import com.github.mikephil.charting.interfaces.datasets.IBubbleDataSet; 5 | import com.github.mikephil.charting.utils.Utils; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | public class BubbleDataSet extends BarLineScatterCandleBubbleDataSet implements IBubbleDataSet { 11 | 12 | protected float mMaxSize; 13 | protected boolean mNormalizeSize = true; 14 | 15 | private float mHighlightCircleWidth = 2.5f; 16 | 17 | public BubbleDataSet(List yVals, String label) { 18 | super(yVals, label); 19 | } 20 | 21 | @Override 22 | public void setHighlightCircleWidth(float width) { 23 | mHighlightCircleWidth = Utils.convertDpToPixel(width); 24 | } 25 | 26 | @Override 27 | public float getHighlightCircleWidth() { 28 | return mHighlightCircleWidth; 29 | } 30 | 31 | @Override 32 | protected void calcMinMax(BubbleEntry e) { 33 | super.calcMinMax(e); 34 | 35 | final float size = e.getSize(); 36 | 37 | if (size > mMaxSize) { 38 | mMaxSize = size; 39 | } 40 | } 41 | 42 | @Override 43 | public DataSet copy() { 44 | 45 | List yVals = new ArrayList(); 46 | 47 | for (int i = 0; i < mValues.size(); i++) { 48 | yVals.add(mValues.get(i).copy()); 49 | } 50 | 51 | BubbleDataSet copied = new BubbleDataSet(yVals, getLabel()); 52 | copied.mColors = mColors; 53 | copied.mHighLightColor = mHighLightColor; 54 | 55 | return copied; 56 | } 57 | 58 | @Override 59 | public float getMaxSize() { 60 | return mMaxSize; 61 | } 62 | 63 | @Override 64 | public boolean isNormalizeSizeEnabled() { 65 | return mNormalizeSize; 66 | } 67 | 68 | public void setNormalizeSizeEnabled(boolean normalizeSize) { 69 | mNormalizeSize = normalizeSize; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/highlight/PieRadarHighlighter.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.highlight; 2 | 3 | import com.github.mikephil.charting.charts.PieChart; 4 | import com.github.mikephil.charting.charts.PieRadarChartBase; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | /** 10 | * Created by philipp on 12/06/16. 11 | */ 12 | public abstract class PieRadarHighlighter implements IHighlighter 13 | { 14 | 15 | protected T mChart; 16 | 17 | /** 18 | * buffer for storing previously highlighted values 19 | */ 20 | protected List mHighlightBuffer = new ArrayList(); 21 | 22 | public PieRadarHighlighter(T chart) { 23 | this.mChart = chart; 24 | } 25 | 26 | @Override 27 | public Highlight getHighlight(float x, float y) { 28 | 29 | float touchDistanceToCenter = mChart.distanceToCenter(x, y); 30 | 31 | // check if a slice was touched 32 | if (touchDistanceToCenter > mChart.getRadius()) { 33 | 34 | // if no slice was touched, highlight nothing 35 | return null; 36 | 37 | } else { 38 | 39 | float angle = mChart.getAngleForPoint(x, y); 40 | 41 | if (mChart instanceof PieChart) { 42 | angle /= mChart.getAnimator().getPhaseY(); 43 | } 44 | 45 | int index = mChart.getIndexForAngle(angle); 46 | 47 | // check if the index could be found 48 | if (index < 0 || index >= mChart.getData().getMaxEntryCountSet().getEntryCount()) { 49 | return null; 50 | 51 | } else { 52 | return getClosestHighlight(index, x, y); 53 | } 54 | } 55 | } 56 | 57 | /** 58 | * Returns the closest Highlight object of the given objects based on the touch position inside the chart. 59 | * 60 | * @param index 61 | * @param x 62 | * @param y 63 | * @return 64 | */ 65 | protected abstract Highlight getClosestHighlight(int index, float x, float y); 66 | } 67 | -------------------------------------------------------------------------------- /MPChartLib/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'com.github.dcendents.android-maven' 3 | group='com.github.open-android' 4 | 5 | android { 6 | compileSdkVersion 24 7 | buildToolsVersion '23.0.3' 8 | // resourcePrefix 'mpcht' 9 | defaultConfig { 10 | minSdkVersion 9 11 | targetSdkVersion 24 12 | versionCode 3 13 | versionName '3.0.1' 14 | } 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | lintOptions { 22 | abortOnError false 23 | } 24 | testOptions { 25 | unitTests.returnDefaultValues = true // this prevents "not mocked" error 26 | } 27 | } 28 | 29 | repositories { 30 | maven { 31 | url 'http://oss.jfrog.org/artifactory/oss-snapshot-local' 32 | } 33 | } 34 | 35 | dependencies { 36 | //compile fileTree(dir: 'libs', include: ['*.jar']) 37 | //compile 'com.android.support:support-v4:19.+' 38 | //provided 'io.realm:realm-android:0.87.5' // "optional" dependency to realm-database API 39 | testCompile 'junit:junit:4.12' 40 | testCompile "org.mockito:mockito-core:1.9.5" 41 | } 42 | 43 | android.libraryVariants.all { variant -> 44 | def name = variant.buildType.name 45 | def task = project.tasks.create "jar${name.capitalize()}", Jar 46 | task.dependsOn variant.javaCompile 47 | task.from variant.javaCompile.destinationDir 48 | artifacts.add('archives', task); 49 | } 50 | 51 | task sourcesJar(type: Jar) { 52 | from android.sourceSets.main.java.srcDirs 53 | classifier = 'sources' 54 | } 55 | 56 | task javadoc(type: Javadoc) { 57 | failOnError false 58 | source = android.sourceSets.main.java.sourceFiles 59 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) 60 | } 61 | 62 | task javadocJar(type: Jar, dependsOn: javadoc) { 63 | classifier = 'javadoc' 64 | from javadoc.destinationDir 65 | } 66 | 67 | artifacts { 68 | archives sourcesJar 69 | archives javadocJar 70 | } 71 | -------------------------------------------------------------------------------- /MPChartExample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'realm-android' 3 | 4 | android { 5 | compileSdkVersion 24 6 | buildToolsVersion '23.0.3' 7 | defaultConfig { 8 | minSdkVersion 16 9 | targetSdkVersion 24 10 | versionCode 54 11 | versionName '3.0.1' 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | 14 | sourceSets { 15 | main { 16 | java.srcDirs = ['src'] 17 | res.srcDirs = ['res'] 18 | assets.srcDirs = ['assets'] 19 | manifest.srcFile 'AndroidManifest.xml' 20 | } 21 | } 22 | } 23 | 24 | buildTypes { 25 | 26 | release { 27 | minifyEnabled false 28 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 29 | } 30 | } 31 | 32 | lintOptions { 33 | abortOnError false 34 | } 35 | } 36 | 37 | buildscript { 38 | repositories { 39 | jcenter() 40 | } 41 | dependencies { 42 | classpath 'com.android.tools.build:gradle:2.2.3' 43 | //classpath 'io.realm:realm-gradle-plugin:0.88.2' 44 | // NOTE: Do not place your application dependencies here; they belong 45 | // in the individual module build.gradle files 46 | } 47 | } 48 | 49 | repositories { 50 | maven { url "https://jitpack.io" } 51 | maven { // this is for realm-db 52 | url 'http://oss.jfrog.org/artifactory/oss-snapshot-local' 53 | } 54 | } 55 | 56 | dependencies { 57 | //compile fileTree(dir: 'libs', include: ['*.jar']) 58 | //compile project(':MPChartLib-Realm') // clone "https://github.com/PhilJay/MPAndroidChart-Realm" to get this or uncomment the gradle dependency below: 59 | compile 'com.github.PhilJay:MPAndroidChart-Realm:v2.0.2@aar' 60 | compile 'com.android.support:appcompat-v7:24.2.1' 61 | compile 'com.github.open-android:MPAndroidChart:v3.0.1' 62 | //compile 'io.realm:realm-android:0.87.5' // dependency for realm-database API (http://realm.io) 63 | //compile 'com.github.PhilJay:MPAndroidChart:v2.2.5' 64 | } 65 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/datasets/IPieDataSet.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.interfaces.datasets; 2 | 3 | import com.github.mikephil.charting.data.Entry; 4 | import com.github.mikephil.charting.data.PieDataSet; 5 | import com.github.mikephil.charting.data.PieEntry; 6 | 7 | /** 8 | * Created by Philipp Jahoda on 03/11/15. 9 | */ 10 | public interface IPieDataSet extends IDataSet { 11 | 12 | /** 13 | * Returns the space that is set to be between the piechart-slices of this 14 | * DataSet, in pixels. 15 | * 16 | * @return 17 | */ 18 | float getSliceSpace(); 19 | 20 | /** 21 | * When enabled, slice spacing will be 0.0 when the smallest value is going to be 22 | * smaller than the slice spacing itself. 23 | * 24 | * @return 25 | */ 26 | boolean isAutomaticallyDisableSliceSpacingEnabled(); 27 | 28 | /** 29 | * Returns the distance a highlighted piechart slice is "shifted" away from 30 | * the chart-center in dp. 31 | * 32 | * @return 33 | */ 34 | float getSelectionShift(); 35 | 36 | PieDataSet.ValuePosition getXValuePosition(); 37 | PieDataSet.ValuePosition getYValuePosition(); 38 | 39 | /** 40 | * When valuePosition is OutsideSlice, indicates line color 41 | * */ 42 | int getValueLineColor(); 43 | 44 | /** 45 | * When valuePosition is OutsideSlice, indicates line width 46 | * */ 47 | float getValueLineWidth(); 48 | 49 | /** 50 | * When valuePosition is OutsideSlice, indicates offset as percentage out of the slice size 51 | * */ 52 | float getValueLinePart1OffsetPercentage(); 53 | 54 | /** 55 | * When valuePosition is OutsideSlice, indicates length of first half of the line 56 | * */ 57 | float getValueLinePart1Length(); 58 | 59 | /** 60 | * When valuePosition is OutsideSlice, indicates length of second half of the line 61 | * */ 62 | float getValueLinePart2Length(); 63 | 64 | /** 65 | * When valuePosition is OutsideSlice, this allows variable line length 66 | * */ 67 | boolean isValueLineVariableLength(); 68 | 69 | } 70 | 71 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/utils/FSize.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.utils; 3 | 4 | import java.util.List; 5 | 6 | /** 7 | * Class for describing width and height dimensions in some arbitrary 8 | * unit. Replacement for the android.Util.SizeF which is available only on API >= 21. 9 | */ 10 | public final class FSize extends ObjectPool.Poolable{ 11 | 12 | // TODO : Encapsulate width & height 13 | 14 | public float width; 15 | public float height; 16 | 17 | private static ObjectPool pool; 18 | 19 | static { 20 | pool = ObjectPool.create(256, new FSize(0,0)); 21 | pool.setReplenishPercentage(0.5f); 22 | } 23 | 24 | 25 | protected ObjectPool.Poolable instantiate(){ 26 | return new FSize(0,0); 27 | } 28 | 29 | public static FSize getInstance(final float width, final float height){ 30 | FSize result = pool.get(); 31 | result.width = width; 32 | result.height = height; 33 | return result; 34 | } 35 | 36 | public static void recycleInstance(FSize instance){ 37 | pool.recycle(instance); 38 | } 39 | 40 | public static void recycleInstances(List instances){ 41 | pool.recycle(instances); 42 | } 43 | 44 | public FSize() { 45 | } 46 | 47 | public FSize(final float width, final float height) { 48 | this.width = width; 49 | this.height = height; 50 | } 51 | 52 | @Override 53 | public boolean equals(final Object obj) { 54 | if (obj == null) { 55 | return false; 56 | } 57 | if (this == obj) { 58 | return true; 59 | } 60 | if (obj instanceof FSize) { 61 | final FSize other = (FSize) obj; 62 | return width == other.width && height == other.height; 63 | } 64 | return false; 65 | } 66 | 67 | @Override 68 | public String toString() { 69 | return width + "x" + height; 70 | } 71 | 72 | /** 73 | * {@inheritDoc} 74 | */ 75 | @Override 76 | public int hashCode() { 77 | return Float.floatToIntBits(width) ^ Float.floatToIntBits(height); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/components/IMarker.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.components; 2 | 3 | import android.graphics.Canvas; 4 | 5 | import com.github.mikephil.charting.data.Entry; 6 | import com.github.mikephil.charting.highlight.Highlight; 7 | import com.github.mikephil.charting.utils.MPPointF; 8 | 9 | public interface IMarker { 10 | 11 | /** 12 | * @return The desired (general) offset you wish the IMarker to have on the x- and y-axis. 13 | * By returning x: -(width / 2) you will center the IMarker horizontally. 14 | * By returning y: -(height / 2) you will center the IMarker vertically. 15 | */ 16 | MPPointF getOffset(); 17 | 18 | /** 19 | * @return The offset for drawing at the specific `point`. This allows conditional adjusting of the Marker position. 20 | * If you have no adjustments to make, return getOffset(). 21 | * 22 | * @param posX This is the X position at which the marker wants to be drawn. 23 | * You can adjust the offset conditionally based on this argument. 24 | * @param posY This is the X position at which the marker wants to be drawn. 25 | * You can adjust the offset conditionally based on this argument. 26 | */ 27 | MPPointF getOffsetForDrawingAtPoint(float posX, float posY); 28 | 29 | /** 30 | * This method enables a specified custom IMarker to update it's content every time the IMarker is redrawn. 31 | * 32 | * @param e The Entry the IMarker belongs to. This can also be any subclass of Entry, like BarEntry or 33 | * CandleEntry, simply cast it at runtime. 34 | * @param highlight The highlight object contains information about the highlighted value such as it's dataset-index, the 35 | * selected range or stack-index (only stacked bar entries). 36 | */ 37 | void refreshContent(Entry e, Highlight highlight); 38 | 39 | /** 40 | * Draws the IMarker on the given position on the screen with the given Canvas object. 41 | * 42 | * @param canvas 43 | * @param posX 44 | * @param posY 45 | */ 46 | void draw(Canvas canvas, float posX, float posY); 47 | } 48 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/listener/OnChartGestureListener.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.listener; 2 | 3 | import android.view.MotionEvent; 4 | 5 | /** 6 | * Listener for callbacks when doing gestures on the chart. 7 | * 8 | * @author Philipp Jahoda 9 | */ 10 | public interface OnChartGestureListener { 11 | 12 | /** 13 | * Callbacks when a touch-gesture has started on the chart (ACTION_DOWN) 14 | * 15 | * @param me 16 | * @param lastPerformedGesture 17 | */ 18 | void onChartGestureStart(MotionEvent me, ChartTouchListener.ChartGesture lastPerformedGesture); 19 | 20 | /** 21 | * Callbacks when a touch-gesture has ended on the chart (ACTION_UP, ACTION_CANCEL) 22 | * 23 | * @param me 24 | * @param lastPerformedGesture 25 | */ 26 | void onChartGestureEnd(MotionEvent me, ChartTouchListener.ChartGesture lastPerformedGesture); 27 | 28 | /** 29 | * Callbacks when the chart is longpressed. 30 | * 31 | * @param me 32 | */ 33 | void onChartLongPressed(MotionEvent me); 34 | 35 | /** 36 | * Callbacks when the chart is double-tapped. 37 | * 38 | * @param me 39 | */ 40 | void onChartDoubleTapped(MotionEvent me); 41 | 42 | /** 43 | * Callbacks when the chart is single-tapped. 44 | * 45 | * @param me 46 | */ 47 | void onChartSingleTapped(MotionEvent me); 48 | 49 | /** 50 | * Callbacks then a fling gesture is made on the chart. 51 | * 52 | * @param me1 53 | * @param me2 54 | * @param velocityX 55 | * @param velocityY 56 | */ 57 | void onChartFling(MotionEvent me1, MotionEvent me2, float velocityX, float velocityY); 58 | 59 | /** 60 | * Callbacks when the chart is scaled / zoomed via pinch zoom gesture. 61 | * 62 | * @param me 63 | * @param scaleX scalefactor on the x-axis 64 | * @param scaleY scalefactor on the y-axis 65 | */ 66 | void onChartScale(MotionEvent me, float scaleX, float scaleY); 67 | 68 | /** 69 | * Callbacks when the chart is moved / translated via drag gesture. 70 | * 71 | * @param me 72 | * @param dX translation distance on the x-axis 73 | * @param dY translation distance on the y-axis 74 | */ 75 | void onChartTranslate(MotionEvent me, float dX, float dY); 76 | } 77 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/renderer/scatter/CircleShapeRenderer.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.renderer.scatter; 2 | 3 | import android.graphics.Canvas; 4 | import android.graphics.Paint; 5 | 6 | import com.github.mikephil.charting.interfaces.datasets.IScatterDataSet; 7 | import com.github.mikephil.charting.utils.ColorTemplate; 8 | import com.github.mikephil.charting.utils.Utils; 9 | import com.github.mikephil.charting.utils.ViewPortHandler; 10 | 11 | /** 12 | * Created by wajdic on 15/06/2016. 13 | * Created at Time 09:08 14 | */ 15 | public class CircleShapeRenderer implements IShapeRenderer 16 | { 17 | 18 | @Override 19 | public void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler, 20 | float posX, float posY, Paint renderPaint) { 21 | 22 | final float shapeSize = dataSet.getScatterShapeSize(); 23 | final float shapeHalf = shapeSize / 2f; 24 | final float shapeHoleSizeHalf = Utils.convertDpToPixel(dataSet.getScatterShapeHoleRadius()); 25 | final float shapeHoleSize = shapeHoleSizeHalf * 2.f; 26 | final float shapeStrokeSize = (shapeSize - shapeHoleSize) / 2.f; 27 | final float shapeStrokeSizeHalf = shapeStrokeSize / 2.f; 28 | 29 | final int shapeHoleColor = dataSet.getScatterShapeHoleColor(); 30 | 31 | if (shapeSize > 0.0) { 32 | renderPaint.setStyle(Paint.Style.STROKE); 33 | renderPaint.setStrokeWidth(shapeStrokeSize); 34 | 35 | c.drawCircle( 36 | posX, 37 | posY, 38 | shapeHoleSizeHalf + shapeStrokeSizeHalf, 39 | renderPaint); 40 | 41 | if (shapeHoleColor != ColorTemplate.COLOR_NONE) { 42 | renderPaint.setStyle(Paint.Style.FILL); 43 | 44 | renderPaint.setColor(shapeHoleColor); 45 | c.drawCircle( 46 | posX, 47 | posY, 48 | shapeHoleSizeHalf, 49 | renderPaint); 50 | } 51 | } else { 52 | renderPaint.setStyle(Paint.Style.FILL); 53 | 54 | c.drawCircle( 55 | posX, 56 | posY, 57 | shapeHalf, 58 | renderPaint); 59 | } 60 | 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /MPChartExample/src/com/xxmassdeveloper/mpchartexample/notimportant/MyAdapter.java: -------------------------------------------------------------------------------- 1 | package com.xxmassdeveloper.mpchartexample.notimportant; 2 | 3 | import android.content.Context; 4 | import android.graphics.Typeface; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.widget.ArrayAdapter; 9 | import android.widget.TextView; 10 | 11 | import com.xxmassdeveloper.mpchartexample.R; 12 | 13 | import java.util.List; 14 | 15 | /** 16 | * Created by Philipp Jahoda on 07/12/15. 17 | */ 18 | public class MyAdapter extends ArrayAdapter { 19 | 20 | private Typeface mTypeFaceLight; 21 | private Typeface mTypeFaceRegular; 22 | 23 | public MyAdapter(Context context, List objects) { 24 | super(context, 0, objects); 25 | 26 | mTypeFaceLight = Typeface.createFromAsset(context.getAssets(), "OpenSans-Light.ttf"); 27 | mTypeFaceRegular = Typeface.createFromAsset(context.getAssets(), "OpenSans-Regular.ttf"); 28 | } 29 | 30 | @Override 31 | public View getView(int position, View convertView, ViewGroup parent) { 32 | 33 | ContentItem c = getItem(position); 34 | 35 | ViewHolder holder = null; 36 | 37 | if (convertView == null) { 38 | 39 | holder = new ViewHolder(); 40 | 41 | convertView = LayoutInflater.from(getContext()).inflate(R.layout.list_item, null); 42 | holder.tvName = (TextView) convertView.findViewById(R.id.tvName); 43 | holder.tvDesc = (TextView) convertView.findViewById(R.id.tvDesc); 44 | holder.tvNew = (TextView) convertView.findViewById(R.id.tvNew); 45 | 46 | convertView.setTag(holder); 47 | 48 | } else { 49 | holder = (ViewHolder) convertView.getTag(); 50 | } 51 | 52 | holder.tvNew.setTypeface(mTypeFaceRegular); 53 | holder.tvName.setTypeface(mTypeFaceLight); 54 | holder.tvDesc.setTypeface(mTypeFaceLight); 55 | 56 | holder.tvName.setText(c.name); 57 | holder.tvDesc.setText(c.desc); 58 | 59 | if(c.isNew) 60 | holder.tvNew.setVisibility(View.VISIBLE); 61 | else 62 | holder.tvNew.setVisibility(View.GONE); 63 | 64 | return convertView; 65 | } 66 | 67 | private class ViewHolder { 68 | 69 | TextView tvName, tvDesc; 70 | TextView tvNew; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /MPChartExample/res/layout/activity_barchart.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | 23 | 24 | 35 | 36 | 47 | 48 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /MPChartExample/res/layout/activity_piechart.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | 23 | 24 | 35 | 36 | 47 | 48 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/charts/ScatterChart.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.charts; 3 | 4 | import android.content.Context; 5 | import android.util.AttributeSet; 6 | 7 | import com.github.mikephil.charting.data.ScatterData; 8 | import com.github.mikephil.charting.interfaces.dataprovider.ScatterDataProvider; 9 | import com.github.mikephil.charting.renderer.ScatterChartRenderer; 10 | 11 | /** 12 | * The ScatterChart. Draws dots, triangles, squares and custom shapes into the 13 | * Chart-View. CIRCLE and SCQUARE offer the best performance, TRIANGLE has the 14 | * worst performance. 15 | * 16 | * @author Philipp Jahoda 17 | */ 18 | public class ScatterChart extends BarLineChartBase implements ScatterDataProvider { 19 | 20 | public ScatterChart(Context context) { 21 | super(context); 22 | } 23 | 24 | public ScatterChart(Context context, AttributeSet attrs) { 25 | super(context, attrs); 26 | } 27 | 28 | public ScatterChart(Context context, AttributeSet attrs, int defStyle) { 29 | super(context, attrs, defStyle); 30 | } 31 | 32 | 33 | @Override 34 | protected void init() { 35 | super.init(); 36 | 37 | mRenderer = new ScatterChartRenderer(this, mAnimator, mViewPortHandler); 38 | } 39 | 40 | @Override 41 | public ScatterData getScatterData() { 42 | return mData; 43 | } 44 | 45 | /** 46 | * Predefined ScatterShapes that allow the specification of a shape a ScatterDataSet should be drawn with. 47 | * If a ScatterShape is specified for a ScatterDataSet, the required renderer is set. 48 | */ 49 | public enum ScatterShape { 50 | 51 | SQUARE("SQUARE"), 52 | CIRCLE("CIRCLE"), 53 | TRIANGLE("TRIANGLE"), 54 | CROSS("CROSS"), 55 | X("X"), 56 | CHEVRON_UP("CHEVRON_UP"), 57 | CHEVRON_DOWN("CHEVRON_DOWN"); 58 | 59 | private final String shapeIdentifier; 60 | 61 | ScatterShape(final String shapeIdentifier) { 62 | this.shapeIdentifier = shapeIdentifier; 63 | } 64 | 65 | @Override 66 | public String toString() { 67 | return shapeIdentifier; 68 | } 69 | 70 | public static ScatterShape[] getAllDefaultShapes() { 71 | return new ScatterShape[]{SQUARE, CIRCLE, TRIANGLE, CROSS, X, CHEVRON_UP, CHEVRON_DOWN}; 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /MPChartExample/res/layout/activity_linechart.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | 23 | 24 | 35 | 36 | 47 | 48 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /MPChartExample/res/layout/activity_scatterchart.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | 23 | 24 | 35 | 36 | 47 | 48 | 59 | 60 | 61 | --------------------------------------------------------------------------------