├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE.md ├── ISSUE_TEMPLATE │ ├── Bug_report.md │ ├── Feature_request.md │ └── Support_help.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── .idea └── runConfigurations │ └── MPChartExample.xml ├── CONTRIBUTING.md ├── LICENSE ├── MPChartExample ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── assets │ ├── OpenSans-Bold.ttf │ ├── OpenSans-BoldItalic.ttf │ ├── OpenSans-ExtraBold.ttf │ ├── OpenSans-ExtraBoldItalic.ttf │ ├── OpenSans-Italic.ttf │ ├── OpenSans-Light.ttf │ ├── OpenSans-LightItalic.ttf │ ├── OpenSans-Regular.ttf │ ├── OpenSans-Semibold.ttf │ ├── OpenSans-SemiboldItalic.ttf │ ├── cosine.txt │ ├── hugecosine.txt │ ├── hugesine.txt │ ├── n.txt │ ├── nlogn.txt │ ├── othersine.txt │ ├── sine.txt │ ├── square.txt │ ├── stacked_bars.txt │ └── three.txt │ ├── ic_launcher-web.png │ ├── java │ └── com │ │ └── xxmassdeveloper │ │ └── mpchartexample │ │ ├── AnotherBarActivity.java │ │ ├── BarChartActivity.java │ │ ├── BarChartActivityMultiDataset.java │ │ ├── BarChartActivitySinus.java │ │ ├── BarChartPositiveNegative.java │ │ ├── BubbleChartActivity.java │ │ ├── CandleStickChartActivity.java │ │ ├── CombinedChartActivity.java │ │ ├── CubicLineChartActivity.java │ │ ├── DrawChartActivity.java │ │ ├── DynamicalAddingActivity.java │ │ ├── FilledLineActivity.java │ │ ├── HalfPieChartActivity.java │ │ ├── HorizontalBarChartActivity.java │ │ ├── HorizontalBarNegativeChartActivity.java │ │ ├── InvertedLineChartActivity.java │ │ ├── LineChartActivity1.java │ │ ├── LineChartActivity2.java │ │ ├── LineChartActivityColored.java │ │ ├── LineChartTime.java │ │ ├── ListViewBarChartActivity.java │ │ ├── ListViewMultiChartActivity.java │ │ ├── MultiLineChartActivity.java │ │ ├── PerformanceLineChart.java │ │ ├── PieChartActivity.java │ │ ├── PiePolylineChartActivity.java │ │ ├── RadarChartActivity.java │ │ ├── RealtimeLineChartActivity.java │ │ ├── ScatterChartActivity.java │ │ ├── ScrollViewActivity.java │ │ ├── StackedBarActivity.java │ │ ├── StackedBarActivityNegative.java │ │ ├── custom │ │ ├── CustomScatterShapeRenderer.java │ │ ├── DayAxisValueFormatter.java │ │ ├── MyAxisValueFormatter.java │ │ ├── MyCustomXAxisValueFormatter.java │ │ ├── MyFillFormatter.java │ │ ├── MyMarkerView.java │ │ ├── MyValueFormatter.java │ │ ├── RadarMarkerView.java │ │ ├── StackedBarsMarkerView.java │ │ ├── XYMarkerView.java │ │ └── YearXAxisFormatter.java │ │ ├── fragments │ │ ├── BarChartFrag.java │ │ ├── ComplexityFragment.java │ │ ├── PieChartFrag.java │ │ ├── ScatterChartFrag.java │ │ ├── SimpleChartDemo.java │ │ ├── SimpleFragment.java │ │ └── SineCosineFragment.java │ │ ├── listviewitems │ │ ├── BarChartItem.java │ │ ├── ChartItem.java │ │ ├── LineChartItem.java │ │ └── PieChartItem.java │ │ └── notimportant │ │ ├── ContentItem.java │ │ ├── DemoBase.java │ │ ├── MainActivity.java │ │ └── MyAdapter.java │ └── res │ ├── anim │ ├── move_left_in_activity.xml │ ├── move_left_out_activity.xml │ ├── move_right_in_activity.xml │ └── move_right_out_activity.xml │ ├── drawable-hdpi │ ├── ic_launcher.png │ └── star.png │ ├── drawable-mdpi │ └── ic_launcher.png │ ├── drawable-nodpi │ ├── marker2.png │ └── radar_marker.png │ ├── drawable-xhdpi │ └── ic_launcher.png │ ├── drawable-xxhdpi │ └── ic_launcher.png │ ├── drawable │ └── fade_red.xml │ ├── layout │ ├── activity_age_distribution.xml │ ├── activity_awesomedesign.xml │ ├── activity_barchart.xml │ ├── activity_barchart_noseekbar.xml │ ├── activity_barchart_sinus.xml │ ├── activity_bubblechart.xml │ ├── activity_candlechart.xml │ ├── activity_colored_lines.xml │ ├── activity_combined.xml │ ├── activity_draw_chart.xml │ ├── activity_horizontalbarchart.xml │ ├── activity_linechart.xml │ ├── activity_linechart_noseekbar.xml │ ├── activity_linechart_time.xml │ ├── activity_listview_chart.xml │ ├── activity_main.xml │ ├── activity_performance_linechart.xml │ ├── activity_piechart.xml │ ├── activity_piechart_half.xml │ ├── activity_radarchart.xml │ ├── activity_realtime_linechart.xml │ ├── activity_scatterchart.xml │ ├── activity_scrollview.xml │ ├── custom_marker_view.xml │ ├── frag_simple_bar.xml │ ├── frag_simple_line.xml │ ├── frag_simple_pie.xml │ ├── frag_simple_scatter.xml │ ├── list_item.xml │ ├── list_item_barchart.xml │ ├── list_item_linechart.xml │ ├── list_item_piechart.xml │ ├── list_item_section.xml │ └── radar_markerview.xml │ ├── menu │ ├── bar.xml │ ├── bubble.xml │ ├── candle.xml │ ├── combined.xml │ ├── draw.xml │ ├── dynamical.xml │ ├── line.xml │ ├── main.xml │ ├── only_github.xml │ ├── pie.xml │ ├── radar.xml │ ├── realtime.xml │ └── scatter.xml │ └── values │ ├── strings.xml │ └── styles.xml ├── MPChartLib ├── .gitignore ├── build.gradle ├── ic_launcher-web.png ├── pom.xml └── src │ ├── main │ ├── AndroidManifest.xml │ └── java │ │ └── com │ │ └── github │ │ └── mikephil │ │ └── charting │ │ ├── animation │ │ ├── ChartAnimator.java │ │ └── Easing.java │ │ ├── buffer │ │ ├── AbstractBuffer.java │ │ ├── BarBuffer.java │ │ └── HorizontalBarBuffer.java │ │ ├── charts │ │ ├── BarChart.java │ │ ├── BarLineChartBase.java │ │ ├── BubbleChart.java │ │ ├── CandleStickChart.java │ │ ├── Chart.java │ │ ├── CombinedChart.java │ │ ├── HorizontalBarChart.java │ │ ├── LineChart.java │ │ ├── PieChart.java │ │ ├── PieRadarChartBase.java │ │ ├── RadarChart.java │ │ └── ScatterChart.java │ │ ├── components │ │ ├── AxisBase.java │ │ ├── ComponentBase.java │ │ ├── Description.java │ │ ├── IMarker.java │ │ ├── Legend.java │ │ ├── LegendEntry.java │ │ ├── LimitLine.java │ │ ├── MarkerImage.java │ │ ├── MarkerView.java │ │ ├── XAxis.java │ │ └── YAxis.java │ │ ├── data │ │ ├── BarData.java │ │ ├── BarDataSet.java │ │ ├── BarEntry.java │ │ ├── BarLineScatterCandleBubbleData.java │ │ ├── BarLineScatterCandleBubbleDataSet.java │ │ ├── BaseDataSet.java │ │ ├── BaseEntry.java │ │ ├── BubbleData.java │ │ ├── BubbleDataSet.java │ │ ├── BubbleEntry.java │ │ ├── CandleData.java │ │ ├── CandleDataSet.java │ │ ├── CandleEntry.java │ │ ├── ChartData.java │ │ ├── CombinedData.java │ │ ├── DataSet.java │ │ ├── Entry.java │ │ ├── LineData.java │ │ ├── LineDataSet.java │ │ ├── LineRadarDataSet.java │ │ ├── LineScatterCandleRadarDataSet.java │ │ ├── PieData.java │ │ ├── PieDataSet.java │ │ ├── PieEntry.java │ │ ├── RadarData.java │ │ ├── RadarDataSet.java │ │ ├── RadarEntry.java │ │ ├── ScatterData.java │ │ ├── ScatterDataSet.java │ │ └── filter │ │ │ ├── Approximator.java │ │ │ └── ApproximatorN.java │ │ ├── exception │ │ └── DrawingDataSetNotCreatedException.java │ │ ├── formatter │ │ ├── ColorFormatter.java │ │ ├── DefaultAxisValueFormatter.java │ │ ├── DefaultFillFormatter.java │ │ ├── DefaultValueFormatter.java │ │ ├── IAxisValueFormatter.java │ │ ├── IFillFormatter.java │ │ ├── IValueFormatter.java │ │ ├── IndexAxisValueFormatter.java │ │ ├── LargeValueFormatter.java │ │ ├── PercentFormatter.java │ │ └── StackedValueFormatter.java │ │ ├── highlight │ │ ├── BarHighlighter.java │ │ ├── ChartHighlighter.java │ │ ├── CombinedHighlighter.java │ │ ├── Highlight.java │ │ ├── HorizontalBarHighlighter.java │ │ ├── IHighlighter.java │ │ ├── PieHighlighter.java │ │ ├── PieRadarHighlighter.java │ │ ├── RadarHighlighter.java │ │ └── Range.java │ │ ├── interfaces │ │ ├── dataprovider │ │ │ ├── BarDataProvider.java │ │ │ ├── BarLineScatterCandleBubbleDataProvider.java │ │ │ ├── BubbleDataProvider.java │ │ │ ├── CandleDataProvider.java │ │ │ ├── ChartInterface.java │ │ │ ├── CombinedDataProvider.java │ │ │ ├── LineDataProvider.java │ │ │ └── ScatterDataProvider.java │ │ └── datasets │ │ │ ├── IBarDataSet.java │ │ │ ├── IBarLineScatterCandleBubbleDataSet.java │ │ │ ├── IBubbleDataSet.java │ │ │ ├── ICandleDataSet.java │ │ │ ├── IDataSet.java │ │ │ ├── ILineDataSet.java │ │ │ ├── ILineRadarDataSet.java │ │ │ ├── ILineScatterCandleRadarDataSet.java │ │ │ ├── IPieDataSet.java │ │ │ ├── IRadarDataSet.java │ │ │ └── IScatterDataSet.java │ │ ├── jobs │ │ ├── AnimatedMoveViewJob.java │ │ ├── AnimatedViewPortJob.java │ │ ├── AnimatedZoomJob.java │ │ ├── MoveViewJob.java │ │ ├── ViewPortJob.java │ │ └── ZoomJob.java │ │ ├── listener │ │ ├── BarLineChartTouchListener.java │ │ ├── ChartTouchListener.java │ │ ├── OnChartGestureListener.java │ │ ├── OnChartValueSelectedListener.java │ │ ├── OnDrawLineChartTouchListener.java │ │ ├── OnDrawListener.java │ │ └── PieRadarChartTouchListener.java │ │ ├── matrix │ │ └── Vector3.java │ │ ├── model │ │ └── GradientColor.java │ │ ├── renderer │ │ ├── AxisRenderer.java │ │ ├── BarChartRenderer.java │ │ ├── BarLineScatterCandleBubbleRenderer.java │ │ ├── BubbleChartRenderer.java │ │ ├── CandleStickChartRenderer.java │ │ ├── CombinedChartRenderer.java │ │ ├── DataRenderer.java │ │ ├── HorizontalBarChartRenderer.java │ │ ├── LegendRenderer.java │ │ ├── LineChartRenderer.java │ │ ├── LineRadarRenderer.java │ │ ├── LineScatterCandleRadarRenderer.java │ │ ├── PieChartRenderer.java │ │ ├── RadarChartRenderer.java │ │ ├── Renderer.java │ │ ├── ScatterChartRenderer.java │ │ ├── XAxisRenderer.java │ │ ├── XAxisRendererHorizontalBarChart.java │ │ ├── XAxisRendererRadarChart.java │ │ ├── YAxisRenderer.java │ │ ├── YAxisRendererHorizontalBarChart.java │ │ ├── YAxisRendererRadarChart.java │ │ └── scatter │ │ │ ├── ChevronDownShapeRenderer.java │ │ │ ├── ChevronUpShapeRenderer.java │ │ │ ├── CircleShapeRenderer.java │ │ │ ├── CrossShapeRenderer.java │ │ │ ├── IShapeRenderer.java │ │ │ ├── SquareShapeRenderer.java │ │ │ ├── TriangleShapeRenderer.java │ │ │ └── XShapeRenderer.java │ │ └── utils │ │ ├── ColorTemplate.java │ │ ├── EntryXComparator.java │ │ ├── FSize.java │ │ ├── FileUtils.java │ │ ├── Fill.java │ │ ├── HorizontalViewPortHandler.java │ │ ├── MPPointD.java │ │ ├── MPPointF.java │ │ ├── ObjectPool.java │ │ ├── Transformer.java │ │ ├── TransformerHorizontalBarChart.java │ │ ├── Utils.java │ │ └── ViewPortHandler.java │ └── test │ └── java │ └── com │ └── github │ └── mikephil │ └── charting │ └── test │ ├── ApproximatorTest.java │ ├── AxisRendererTest.java │ ├── BarDataTest.java │ ├── ChartDataTest.java │ ├── DataSetTest.java │ ├── LargeValueFormatterTest.java │ └── ObjectPoolTest.java ├── README.md ├── build.gradle ├── design ├── facebook_icon.png ├── feature_graphic.png ├── feature_graphic.psd ├── feature_graphic_smaller.png ├── googleplus_icon.png ├── header_symbol.png ├── ic_launcher.psd ├── other │ ├── bottom.png │ ├── left.png │ └── right.png ├── twitter_icon.png └── video_thumbnail.png ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── screenshots ├── AndroidWeekly_Issue114_10082014.png ├── MPAndroidChart_trending.png ├── ValueFormatter.jpg ├── barchart2d.png ├── barchart2d_multi_dataset.png ├── barchart2d_multi_dataset_date1.png ├── barchart2d_multi_dataset_date2.png ├── barchart3d.png ├── bubblechart.png ├── candlestickchart.png ├── candlestickchart_old.png ├── combined_chart.png ├── cubiclinechart.png ├── grouped_barchart_wiki.png ├── groupedbarchart.png ├── horizontal_barchart.png ├── line_chart_gradient.png ├── linechart.png ├── linechart_colored.png ├── linechart_legend.png ├── linechart_multiline.png ├── linechart_multiline_color_variations.png ├── linechart_wiki.png ├── normal_barchart_wiki.png ├── piechart_holeradius_space.png ├── piechart_more_colors.png ├── piechart_selected.png ├── piechart_wiki.png ├── radarchart.png ├── realm_wiki.png ├── scatterchart.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 ├── smart_legends.png ├── tranding_developers_11_08_2014.png └── zero_line_example_barchart.png └── settings.gradle /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: mpandroidchart 5 | open_collective: philippjahoda 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 17 | 18 | **Summary** 19 | 20 | 21 | **Expected Behavior** 22 | 23 | 24 | **Possible Solution** 25 | 26 | 27 | 28 | **Device (please complete the following information):** 29 | - Device: [e.g. Google Pixel] 30 | - Android Version [e.g. 7.0] 31 | - Library Version (e.g. 3.1.0-alpha) 32 | 33 | **Additional Context** 34 | 38 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/Bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bugs 3 | about: Create a bug report to help us improve 4 | 5 | --- 6 | 7 | 22 | 23 | **Summary** 24 | 25 | 26 | **Expected Behavior** 27 | 28 | 29 | **Possible Solution** 30 | 31 | 32 | 33 | **Device (please complete the following information):** 34 | - Device: [e.g. Google Pixel] 35 | - Android Version [e.g. 7.0] 36 | - Library Version (e.g. 3.1.0-alpha) 37 | 38 | **Additional Context** 39 | 43 | 44 | ADD A REWARD using [Speed](speedoss.com) to SOLVE this issue QUICKLY and SUPPORT this project. 45 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/Feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: Suggest an idea for this project 4 | 5 | --- 6 | 7 | 22 | 23 | **Is your feature request related to a problem? Please describe.** 24 | 25 | 26 | **Describe the solution you'd like** 27 | 28 | 29 | **Describe alternatives you've considered** 30 | 31 | 32 | **Additional context** 33 | 34 | ADD A REWARD using [Speed](speedoss.com) to SOLVE this issue QUICKLY and SUPPORT this project. 35 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/Support_help.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Support 3 | about: I need help! 4 | 5 | --- 6 | 7 | # *STOP RIGHT THERE!* 8 | 9 | Issues are ***NOT*** for getting help, only for reporting bugs and feature requests. 10 | 11 | Search open and closed issues to see if your question already has an answer. However, **do not create a new issue.** 12 | 13 | Instead, do the following: 14 | 15 | 1. Download the [Example App](https://play.google.com/store/apps/details?id=com.xxmassdeveloper.mpchartexample) and check out the [source code](https://github.com/PhilJay/MPAndroidChart/tree/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample). 90% of the time there is an example that does exactly what you are trying to do. 16 | 17 | 1. Look at the [Wiki](https://github.com/PhilJay/MPAndroidChart/wiki) for the official documentation for MPAndroidChart. You can also browse the [javadoc](https://jitpack.io/com/github/philjay/mpandroidchart/v3.1.0-alpha/javadoc/) for a more detailed tutorial of the API. 18 | 19 | 1. Go to [StackOverflow](https://stackoverflow.com/questions/tagged/mpandroidchart) and ask your questions there. The community will be much more helpful and willing to offer guidance. 20 | 21 | 22 | ### You have been warned! 23 | 24 | From now on, any issues asking for help will get closed with a link to this file. 25 | 26 | ### Additional Context 27 | ADD A REWARD using [Speed](speedoss.com) to SOLVE this issue QUICKLY and SUPPORT this project. 28 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## PR Checklist: 2 | - [ ] I have tested this extensively and it does not break any existing behavior. 3 | - [ ] I have added/updated examples and tests for any new behavior. 4 | - [ ] If this is a significant change, an issue has already been created where the problem / solution was discussed: [N/A, or add link to issue here] 5 | 8 | 9 | 10 | ## PR Description 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.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 | projectFilesBackup/ 18 | 19 | build.xml 20 | 21 | # Local configuration file (sdk path, etc) 22 | local.properties 23 | 24 | # Eclipse project files 25 | .classpath 26 | .project 27 | 28 | # Proguard folder generated by Eclipse 29 | proguard/ 30 | 31 | # Intellij project files 32 | *.iml 33 | *.ipr 34 | *.iws 35 | .idea/ 36 | 37 | .directory 38 | 39 | # gradle wrapper working directory 40 | .gradle 41 | 42 | build/ 43 | 44 | # maven 45 | target/ 46 | 47 | .DS_Store 48 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2020 Philipp Jahoda 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this software except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /MPChartExample/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /release 3 | -------------------------------------------------------------------------------- /MPChartExample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | defaultConfig { 6 | applicationId "com.xxmassdeveloper.mpchartexample" 7 | minSdkVersion 16 8 | targetSdkVersion 28 9 | versionCode 57 10 | versionName '3.1.0' 11 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 12 | } 13 | 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | implementation "androidx.appcompat:appcompat:1.0.2" 24 | implementation 'com.google.android.material:material:1.0.0' 25 | implementation project(':MPChartLib') 26 | } 27 | -------------------------------------------------------------------------------- /MPChartExample/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /MPChartExample/src/main/assets/OpenSans-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/MPChartExample/src/main/assets/OpenSans-Bold.ttf -------------------------------------------------------------------------------- /MPChartExample/src/main/assets/OpenSans-BoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/MPChartExample/src/main/assets/OpenSans-BoldItalic.ttf -------------------------------------------------------------------------------- /MPChartExample/src/main/assets/OpenSans-ExtraBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/MPChartExample/src/main/assets/OpenSans-ExtraBold.ttf -------------------------------------------------------------------------------- /MPChartExample/src/main/assets/OpenSans-ExtraBoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/MPChartExample/src/main/assets/OpenSans-ExtraBoldItalic.ttf -------------------------------------------------------------------------------- /MPChartExample/src/main/assets/OpenSans-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/MPChartExample/src/main/assets/OpenSans-Italic.ttf -------------------------------------------------------------------------------- /MPChartExample/src/main/assets/OpenSans-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/MPChartExample/src/main/assets/OpenSans-Light.ttf -------------------------------------------------------------------------------- /MPChartExample/src/main/assets/OpenSans-LightItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/MPChartExample/src/main/assets/OpenSans-LightItalic.ttf -------------------------------------------------------------------------------- /MPChartExample/src/main/assets/OpenSans-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/MPChartExample/src/main/assets/OpenSans-Regular.ttf -------------------------------------------------------------------------------- /MPChartExample/src/main/assets/OpenSans-Semibold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/MPChartExample/src/main/assets/OpenSans-Semibold.ttf -------------------------------------------------------------------------------- /MPChartExample/src/main/assets/OpenSans-SemiboldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/MPChartExample/src/main/assets/OpenSans-SemiboldItalic.ttf -------------------------------------------------------------------------------- /MPChartExample/src/main/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 -------------------------------------------------------------------------------- /MPChartExample/src/main/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 -------------------------------------------------------------------------------- /MPChartExample/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/MPChartExample/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /MPChartExample/src/main/java/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/src/main/java/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 final 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 | -------------------------------------------------------------------------------- /MPChartExample/src/main/java/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 | * @deprecated The {@link MyAxisValueFormatter} does exactly the same thing and is more functional. 13 | */ 14 | @Deprecated 15 | public class MyCustomXAxisValueFormatter implements IAxisValueFormatter 16 | { 17 | 18 | private final DecimalFormat mFormat; 19 | private final ViewPortHandler mViewPortHandler; 20 | 21 | public MyCustomXAxisValueFormatter(ViewPortHandler viewPortHandler) { 22 | mViewPortHandler = viewPortHandler; 23 | // maybe do something here or provide parameters in constructor 24 | mFormat = new DecimalFormat("###,###,###,##0.0"); 25 | } 26 | 27 | @Override 28 | public String getFormattedValue(float value, AxisBase axis) { 29 | 30 | //Log.i("TRANS", "x: " + viewPortHandler.getTransX() + ", y: " + viewPortHandler.getTransY()); 31 | 32 | // e.g. adjust the x-axis values depending on scale / zoom level 33 | final float xScale = mViewPortHandler.getScaleX(); 34 | if (xScale > 5) 35 | return "4"; 36 | else if (xScale > 3) 37 | return "3"; 38 | else if (xScale > 1) 39 | return "2"; 40 | else 41 | return mFormat.format(value); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /MPChartExample/src/main/java/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 | @SuppressWarnings("unused") 11 | public class MyFillFormatter implements IFillFormatter 12 | { 13 | 14 | private float fillPos; 15 | 16 | public MyFillFormatter(float fillPos) { 17 | this.fillPos = fillPos; 18 | } 19 | 20 | @Override 21 | public float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider) { 22 | // your logic could be here 23 | return fillPos; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/custom/MyMarkerView.java: -------------------------------------------------------------------------------- 1 | 2 | package com.xxmassdeveloper.mpchartexample.custom; 3 | 4 | import android.annotation.SuppressLint; 5 | import android.content.Context; 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 | /** 17 | * Custom implementation of the MarkerView. 18 | * 19 | * @author Philipp Jahoda 20 | */ 21 | @SuppressLint("ViewConstructor") 22 | public class MyMarkerView extends MarkerView { 23 | 24 | private final TextView tvContent; 25 | 26 | public MyMarkerView(Context context, int layoutResource) { 27 | super(context, layoutResource); 28 | 29 | tvContent = findViewById(R.id.tvContent); 30 | } 31 | 32 | // runs every time the MarkerView is redrawn, can be used to update the 33 | // content (user-interface) 34 | @Override 35 | public void refreshContent(Entry e, Highlight highlight) { 36 | 37 | if (e instanceof CandleEntry) { 38 | 39 | CandleEntry ce = (CandleEntry) e; 40 | 41 | tvContent.setText(Utils.formatNumber(ce.getHigh(), 0, true)); 42 | } else { 43 | 44 | tvContent.setText(Utils.formatNumber(e.getY(), 0, true)); 45 | } 46 | 47 | super.refreshContent(e, highlight); 48 | } 49 | 50 | @Override 51 | public MPPointF getOffset() { 52 | return new MPPointF(-(getWidth() / 2), -getHeight()); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /MPChartExample/src/main/java/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 final 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 | -------------------------------------------------------------------------------- /MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/custom/RadarMarkerView.java: -------------------------------------------------------------------------------- 1 | 2 | package com.xxmassdeveloper.mpchartexample.custom; 3 | 4 | import android.annotation.SuppressLint; 5 | import android.content.Context; 6 | import android.graphics.Typeface; 7 | import android.widget.TextView; 8 | 9 | import com.github.mikephil.charting.components.MarkerView; 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.xxmassdeveloper.mpchartexample.R; 14 | 15 | import java.text.DecimalFormat; 16 | 17 | /** 18 | * Custom implementation of the MarkerView. 19 | * 20 | * @author Philipp Jahoda 21 | */ 22 | @SuppressLint("ViewConstructor") 23 | public class RadarMarkerView extends MarkerView { 24 | 25 | private final TextView tvContent; 26 | private final DecimalFormat format = new DecimalFormat("##0"); 27 | 28 | public RadarMarkerView(Context context, int layoutResource) { 29 | super(context, layoutResource); 30 | 31 | tvContent = findViewById(R.id.tvContent); 32 | tvContent.setTypeface(Typeface.createFromAsset(context.getAssets(), "OpenSans-Light.ttf")); 33 | } 34 | 35 | // runs every time 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(String.format("%s %%", 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 | -------------------------------------------------------------------------------- /MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/custom/StackedBarsMarkerView.java: -------------------------------------------------------------------------------- 1 | 2 | package com.xxmassdeveloper.mpchartexample.custom; 3 | 4 | import android.annotation.SuppressLint; 5 | import android.content.Context; 6 | import android.widget.TextView; 7 | 8 | import com.github.mikephil.charting.components.MarkerView; 9 | import com.github.mikephil.charting.data.BarEntry; 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 | /** 17 | * Custom implementation of the MarkerView. 18 | * 19 | * @author Philipp Jahoda 20 | */ 21 | @SuppressWarnings("unused") 22 | @SuppressLint("ViewConstructor") 23 | public class StackedBarsMarkerView extends MarkerView { 24 | 25 | private TextView tvContent; 26 | 27 | public StackedBarsMarkerView(Context context, int layoutResource) { 28 | super(context, layoutResource); 29 | 30 | tvContent = findViewById(R.id.tvContent); 31 | } 32 | 33 | // runs every time the MarkerView is redrawn, can be used to update the 34 | // content (user-interface) 35 | @Override 36 | public void refreshContent(Entry e, Highlight highlight) { 37 | 38 | if (e instanceof BarEntry) { 39 | 40 | BarEntry be = (BarEntry) e; 41 | 42 | if(be.getYVals() != null) { 43 | 44 | // draw the stack value 45 | tvContent.setText(Utils.formatNumber(be.getYVals()[highlight.getStackIndex()], 0, true)); 46 | } else { 47 | tvContent.setText(Utils.formatNumber(be.getY(), 0, true)); 48 | } 49 | } else { 50 | 51 | tvContent.setText(Utils.formatNumber(e.getY(), 0, true)); 52 | } 53 | 54 | super.refreshContent(e, highlight); 55 | } 56 | 57 | @Override 58 | public MPPointF getOffset() { 59 | return new MPPointF(-(getWidth() / 2), -getHeight()); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/custom/XYMarkerView.java: -------------------------------------------------------------------------------- 1 | 2 | package com.xxmassdeveloper.mpchartexample.custom; 3 | 4 | import android.annotation.SuppressLint; 5 | import android.content.Context; 6 | import android.widget.TextView; 7 | 8 | import com.github.mikephil.charting.components.MarkerView; 9 | import com.github.mikephil.charting.data.Entry; 10 | import com.github.mikephil.charting.formatter.IAxisValueFormatter; 11 | import com.github.mikephil.charting.highlight.Highlight; 12 | import com.github.mikephil.charting.utils.MPPointF; 13 | import com.xxmassdeveloper.mpchartexample.R; 14 | 15 | import java.text.DecimalFormat; 16 | 17 | /** 18 | * Custom implementation of the MarkerView. 19 | * 20 | * @author Philipp Jahoda 21 | */ 22 | @SuppressLint("ViewConstructor") 23 | public class XYMarkerView extends MarkerView { 24 | 25 | private final TextView tvContent; 26 | private final IAxisValueFormatter xAxisValueFormatter; 27 | 28 | private final DecimalFormat format; 29 | 30 | public XYMarkerView(Context context, IAxisValueFormatter xAxisValueFormatter) { 31 | super(context, R.layout.custom_marker_view); 32 | 33 | this.xAxisValueFormatter = xAxisValueFormatter; 34 | tvContent = findViewById(R.id.tvContent); 35 | format = new DecimalFormat("###.0"); 36 | } 37 | 38 | // runs every time the MarkerView is redrawn, can be used to update the 39 | // content (user-interface) 40 | @Override 41 | public void refreshContent(Entry e, Highlight highlight) { 42 | 43 | tvContent.setText(String.format("x: %s, y: %s", xAxisValueFormatter.getFormattedValue(e.getX(), null), format.format(e.getY()))); 44 | 45 | super.refreshContent(e, highlight); 46 | } 47 | 48 | @Override 49 | public MPPointF getOffset() { 50 | return new MPPointF(-(getWidth() / 2), -getHeight()); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /MPChartExample/src/main/java/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 | @SuppressWarnings("unused") 10 | public class YearXAxisFormatter implements IAxisValueFormatter 11 | { 12 | 13 | private final String[] mMonths = new String[]{ 14 | "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec" 15 | }; 16 | 17 | public YearXAxisFormatter() { 18 | // take parameters to change behavior of formatter 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/src/main/java/com/xxmassdeveloper/mpchartexample/fragments/ComplexityFragment.java: -------------------------------------------------------------------------------- 1 | package com.xxmassdeveloper.mpchartexample.fragments; 2 | import android.graphics.Typeface; 3 | import android.os.Bundle; 4 | import androidx.annotation.NonNull; 5 | import androidx.fragment.app.Fragment; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | 10 | import com.github.mikephil.charting.charts.LineChart; 11 | import com.github.mikephil.charting.components.Legend; 12 | import com.github.mikephil.charting.components.XAxis; 13 | import com.github.mikephil.charting.components.YAxis; 14 | import com.xxmassdeveloper.mpchartexample.R; 15 | 16 | 17 | public class ComplexityFragment extends SimpleFragment { 18 | 19 | @NonNull 20 | public static Fragment newInstance() { 21 | return new ComplexityFragment(); 22 | } 23 | 24 | @SuppressWarnings("FieldCanBeLocal") 25 | private LineChart chart; 26 | 27 | @Override 28 | public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 29 | View v = inflater.inflate(R.layout.frag_simple_line, container, false); 30 | 31 | chart = v.findViewById(R.id.lineChart1); 32 | 33 | chart.getDescription().setEnabled(false); 34 | 35 | chart.setDrawGridBackground(false); 36 | 37 | chart.setData(getComplexity()); 38 | chart.animateX(3000); 39 | 40 | Typeface tf = Typeface.createFromAsset(context.getAssets(), "OpenSans-Light.ttf"); 41 | 42 | Legend l = chart.getLegend(); 43 | l.setTypeface(tf); 44 | 45 | YAxis leftAxis = chart.getAxisLeft(); 46 | leftAxis.setTypeface(tf); 47 | 48 | chart.getAxisRight().setEnabled(false); 49 | 50 | XAxis xAxis = chart.getXAxis(); 51 | xAxis.setEnabled(false); 52 | 53 | return v; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/fragments/PieChartFrag.java: -------------------------------------------------------------------------------- 1 | package com.xxmassdeveloper.mpchartexample.fragments; 2 | import android.graphics.Color; 3 | import android.graphics.Typeface; 4 | import android.os.Bundle; 5 | import androidx.annotation.NonNull; 6 | import androidx.fragment.app.Fragment; 7 | import android.text.SpannableString; 8 | import android.text.style.ForegroundColorSpan; 9 | import android.text.style.RelativeSizeSpan; 10 | import android.view.LayoutInflater; 11 | import android.view.View; 12 | import android.view.ViewGroup; 13 | 14 | import com.github.mikephil.charting.charts.PieChart; 15 | import com.github.mikephil.charting.components.Legend; 16 | import com.xxmassdeveloper.mpchartexample.R; 17 | 18 | 19 | public class PieChartFrag extends SimpleFragment { 20 | 21 | @NonNull 22 | public static Fragment newInstance() { 23 | return new PieChartFrag(); 24 | } 25 | 26 | @SuppressWarnings("FieldCanBeLocal") 27 | private PieChart chart; 28 | 29 | @Override 30 | public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 31 | View v = inflater.inflate(R.layout.frag_simple_pie, container, false); 32 | 33 | chart = v.findViewById(R.id.pieChart1); 34 | chart.getDescription().setEnabled(false); 35 | 36 | Typeface tf = Typeface.createFromAsset(context.getAssets(), "OpenSans-Light.ttf"); 37 | 38 | chart.setCenterTextTypeface(tf); 39 | chart.setCenterText(generateCenterText()); 40 | chart.setCenterTextSize(10f); 41 | chart.setCenterTextTypeface(tf); 42 | 43 | // radius of the center hole in percent of maximum radius 44 | chart.setHoleRadius(45f); 45 | chart.setTransparentCircleRadius(50f); 46 | 47 | Legend l = chart.getLegend(); 48 | l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP); 49 | l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT); 50 | l.setOrientation(Legend.LegendOrientation.VERTICAL); 51 | l.setDrawInside(false); 52 | 53 | chart.setData(generatePieData()); 54 | 55 | return v; 56 | } 57 | 58 | private SpannableString generateCenterText() { 59 | SpannableString s = new SpannableString("Revenues\nQuarters 2015"); 60 | s.setSpan(new RelativeSizeSpan(2f), 0, 8, 0); 61 | s.setSpan(new ForegroundColorSpan(Color.GRAY), 8, s.length(), 0); 62 | return s; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/fragments/SineCosineFragment.java: -------------------------------------------------------------------------------- 1 | package com.xxmassdeveloper.mpchartexample.fragments; 2 | import android.graphics.Typeface; 3 | import android.os.Bundle; 4 | import androidx.annotation.NonNull; 5 | import androidx.fragment.app.Fragment; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | 10 | import com.github.mikephil.charting.charts.LineChart; 11 | import com.github.mikephil.charting.components.Legend; 12 | import com.github.mikephil.charting.components.XAxis; 13 | import com.github.mikephil.charting.components.YAxis; 14 | import com.xxmassdeveloper.mpchartexample.R; 15 | 16 | 17 | public class SineCosineFragment extends SimpleFragment { 18 | 19 | @NonNull 20 | public static Fragment newInstance() { 21 | return new SineCosineFragment(); 22 | } 23 | 24 | @SuppressWarnings("FieldCanBeLocal") 25 | private LineChart chart; 26 | 27 | @Override 28 | public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 29 | View v = inflater.inflate(R.layout.frag_simple_line, container, false); 30 | 31 | chart = v.findViewById(R.id.lineChart1); 32 | 33 | chart.getDescription().setEnabled(false); 34 | 35 | chart.setDrawGridBackground(false); 36 | 37 | chart.setData(generateLineData()); 38 | chart.animateX(3000); 39 | 40 | Typeface tf = Typeface.createFromAsset(context.getAssets(), "OpenSans-Light.ttf"); 41 | 42 | Legend l = chart.getLegend(); 43 | l.setTypeface(tf); 44 | 45 | YAxis leftAxis = chart.getAxisLeft(); 46 | leftAxis.setTypeface(tf); 47 | leftAxis.setAxisMaximum(1.2f); 48 | leftAxis.setAxisMinimum(-1.2f); 49 | 50 | chart.getAxisRight().setEnabled(false); 51 | 52 | XAxis xAxis = chart.getXAxis(); 53 | xAxis.setEnabled(false); 54 | 55 | return v; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /MPChartExample/src/main/java/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 | * Base class of the Chart ListView items 10 | * @author philipp 11 | * 12 | */ 13 | @SuppressWarnings("unused") 14 | public abstract class ChartItem { 15 | 16 | static final int TYPE_BARCHART = 0; 17 | static final int TYPE_LINECHART = 1; 18 | static final int TYPE_PIECHART = 2; 19 | 20 | ChartData mChartData; 21 | 22 | ChartItem(ChartData cd) { 23 | this.mChartData = cd; 24 | } 25 | 26 | public abstract int getItemType(); 27 | 28 | public abstract View getView(int position, View convertView, Context c); 29 | } 30 | -------------------------------------------------------------------------------- /MPChartExample/src/main/java/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 | class ContentItem { 7 | 8 | final String name; 9 | final String desc; 10 | boolean isSection = false; 11 | 12 | ContentItem(String n) { 13 | name = n; 14 | desc = ""; 15 | isSection = true; 16 | } 17 | 18 | ContentItem(String n, String d) { 19 | name = n; 20 | desc = d; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/notimportant/MyAdapter.java: -------------------------------------------------------------------------------- 1 | package com.xxmassdeveloper.mpchartexample.notimportant; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.content.Context; 5 | import android.graphics.Typeface; 6 | import androidx.annotation.NonNull; 7 | 8 | import android.view.LayoutInflater; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | import android.widget.ArrayAdapter; 12 | import android.widget.TextView; 13 | 14 | import com.xxmassdeveloper.mpchartexample.R; 15 | 16 | import java.util.List; 17 | 18 | /** 19 | * Created by Philipp Jahoda on 07/12/15. 20 | */ 21 | class MyAdapter extends ArrayAdapter { 22 | 23 | private final Typeface mTypeFaceLight; 24 | private final Typeface mTypeFaceRegular; 25 | 26 | MyAdapter(Context context, List objects) { 27 | super(context, 0, objects); 28 | 29 | mTypeFaceLight = Typeface.createFromAsset(context.getAssets(), "OpenSans-Light.ttf"); 30 | mTypeFaceRegular = Typeface.createFromAsset(context.getAssets(), "OpenSans-Regular.ttf"); 31 | } 32 | 33 | @SuppressLint("InflateParams") 34 | @NonNull 35 | @Override 36 | public View getView(int position, View convertView, @NonNull ViewGroup parent) { 37 | 38 | ContentItem c = getItem(position); 39 | 40 | ViewHolder holder; 41 | 42 | holder = new ViewHolder(); 43 | 44 | if (c != null && c.isSection) { 45 | convertView = LayoutInflater.from(getContext()).inflate(R.layout.list_item_section, null); 46 | } else { 47 | convertView = LayoutInflater.from(getContext()).inflate(R.layout.list_item, null); 48 | } 49 | 50 | holder.tvName = convertView.findViewById(R.id.tvName); 51 | holder.tvDesc = convertView.findViewById(R.id.tvDesc); 52 | 53 | convertView.setTag(holder); 54 | 55 | if (c != null && c.isSection) 56 | holder.tvName.setTypeface(mTypeFaceRegular); 57 | else 58 | holder.tvName.setTypeface(mTypeFaceLight); 59 | holder.tvDesc.setTypeface(mTypeFaceLight); 60 | 61 | holder.tvName.setText(c != null ? c.name : null); 62 | holder.tvDesc.setText(c != null ? c.desc : null); 63 | 64 | return convertView; 65 | } 66 | 67 | private class ViewHolder { 68 | 69 | TextView tvName, tvDesc; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/anim/move_left_in_activity.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/anim/move_left_out_activity.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/anim/move_right_in_activity.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/anim/move_right_out_activity.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/MPChartExample/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /MPChartExample/src/main/res/drawable-hdpi/star.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/MPChartExample/src/main/res/drawable-hdpi/star.png -------------------------------------------------------------------------------- /MPChartExample/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/MPChartExample/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /MPChartExample/src/main/res/drawable-nodpi/marker2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/MPChartExample/src/main/res/drawable-nodpi/marker2.png -------------------------------------------------------------------------------- /MPChartExample/src/main/res/drawable-nodpi/radar_marker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/MPChartExample/src/main/res/drawable-nodpi/radar_marker.png -------------------------------------------------------------------------------- /MPChartExample/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/MPChartExample/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /MPChartExample/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/MPChartExample/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /MPChartExample/src/main/res/drawable/fade_red.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/layout/activity_age_distribution.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/layout/activity_awesomedesign.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/layout/activity_barchart.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | 23 | 24 | 35 | 36 | 47 | 48 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/layout/activity_barchart_noseekbar.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/layout/activity_barchart_sinus.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | 24 | 25 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/layout/activity_bubblechart.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 12 | 13 | 24 | 25 | 36 | 37 | 48 | 49 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/layout/activity_candlechart.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | 23 | 24 | 35 | 36 | 47 | 48 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/layout/activity_colored_lines.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 17 | 22 | 27 | 28 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/layout/activity_combined.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/layout/activity_draw_chart.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/layout/activity_horizontalbarchart.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 12 | 13 | 24 | 25 | 36 | 37 | 48 | 49 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/layout/activity_linechart.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | 24 | 25 | 36 | 37 | 48 | 49 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/layout/activity_linechart_noseekbar.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/layout/activity_linechart_time.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | 22 | 23 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/layout/activity_listview_chart.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/layout/activity_performance_linechart.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | 24 | 25 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/layout/activity_piechart.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | 23 | 24 | 35 | 36 | 47 | 48 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/layout/activity_piechart_half.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/layout/activity_radarchart.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/layout/activity_realtime_linechart.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/layout/activity_scatterchart.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | 23 | 24 | 35 | 36 | 47 | 48 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /MPChartExample/src/main/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 | 43 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/layout/custom_marker_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/layout/frag_simple_bar.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/layout/frag_simple_line.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/layout/frag_simple_pie.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/layout/frag_simple_scatter.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/layout/list_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 17 | 18 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/layout/list_item_barchart.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/layout/list_item_linechart.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/layout/list_item_piechart.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/layout/list_item_section.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 15 | 16 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/layout/radar_markerview.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /MPChartExample/src/main/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 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /MPChartExample/src/main/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 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /MPChartExample/src/main/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 | 43 | 44 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/menu/combined.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 11 | 12 | 15 | 16 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/menu/draw.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 11 | 12 | 15 | 16 | 19 | 20 | 23 | 24 | 27 | 28 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/menu/dynamical.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 11 | 12 | 15 | 16 | 19 | 20 | 23 | 24 | 27 | 28 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /MPChartExample/src/main/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 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/menu/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 11 | 12 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/menu/only_github.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /MPChartExample/src/main/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 | 47 | 48 | 51 | 52 | 55 | 56 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /MPChartExample/src/main/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 | 55 | 56 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/menu/realtime.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 11 | 12 | 15 | 16 | 19 | 20 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /MPChartExample/src/main/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 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /MPChartExample/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /MPChartLib/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /MPChartLib/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | group='com.github.philjay' 4 | 5 | android { 6 | compileSdkVersion 28 7 | buildToolsVersion '28.0.3' 8 | defaultConfig { 9 | minSdkVersion 14 10 | targetSdkVersion 28 11 | versionCode 3 12 | versionName '3.1.0' 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | testOptions { 21 | unitTests.returnDefaultValues = true // this prevents "not mocked" error 22 | } 23 | } 24 | 25 | dependencies { 26 | implementation 'androidx.annotation:annotation:1.0.0' 27 | testImplementation 'junit:junit:4.12' 28 | } 29 | 30 | task sourcesJar(type: Jar) { 31 | from android.sourceSets.main.java.srcDirs 32 | classifier = 'sources' 33 | } 34 | 35 | task javadoc(type: Javadoc) { 36 | options.charSet = 'UTF-8' 37 | failOnError false 38 | source = android.sourceSets.main.java.sourceFiles 39 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) 40 | } 41 | 42 | task javadocJar(type: Jar, dependsOn: javadoc) { 43 | classifier = 'javadoc' 44 | from javadoc.destinationDir 45 | } 46 | 47 | artifacts { 48 | archives sourcesJar 49 | archives javadocJar 50 | } 51 | -------------------------------------------------------------------------------- /MPChartLib/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/MPChartLib/ic_launcher-web.png -------------------------------------------------------------------------------- /MPChartLib/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/buffer/AbstractBuffer.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.buffer; 3 | 4 | import java.util.List; 5 | 6 | /** 7 | * Buffer class to boost performance while drawing. Concept: Replace instead of 8 | * recreate. 9 | * 10 | * @author Philipp Jahoda 11 | * @param The data the buffer accepts to be fed with. 12 | */ 13 | public abstract class AbstractBuffer { 14 | 15 | /** index in the buffer */ 16 | protected int index = 0; 17 | 18 | /** float-buffer that holds the data points to draw, order: x,y,x,y,... */ 19 | public final float[] buffer; 20 | 21 | /** animation phase x-axis */ 22 | protected float phaseX = 1f; 23 | 24 | /** animation phase y-axis */ 25 | protected float phaseY = 1f; 26 | 27 | /** indicates from which x-index the visible data begins */ 28 | protected int mFrom = 0; 29 | 30 | /** indicates to which x-index the visible data ranges */ 31 | protected int mTo = 0; 32 | 33 | /** 34 | * Initialization with buffer-size. 35 | * 36 | * @param size 37 | */ 38 | public AbstractBuffer(int size) { 39 | index = 0; 40 | buffer = new float[size]; 41 | } 42 | 43 | /** limits the drawing on the x-axis */ 44 | public void limitFrom(int from) { 45 | if (from < 0) 46 | from = 0; 47 | mFrom = from; 48 | } 49 | 50 | /** limits the drawing on the x-axis */ 51 | public void limitTo(int to) { 52 | if (to < 0) 53 | to = 0; 54 | mTo = to; 55 | } 56 | 57 | /** 58 | * Resets the buffer index to 0 and makes the buffer reusable. 59 | */ 60 | public void reset() { 61 | index = 0; 62 | } 63 | 64 | /** 65 | * Returns the size (length) of the buffer array. 66 | * 67 | * @return 68 | */ 69 | public int size() { 70 | return buffer.length; 71 | } 72 | 73 | /** 74 | * Set the phases used for animations. 75 | * 76 | * @param phaseX 77 | * @param phaseY 78 | */ 79 | public void setPhases(float phaseX, float phaseY) { 80 | this.phaseX = phaseX; 81 | this.phaseY = phaseY; 82 | } 83 | 84 | /** 85 | * Builds up the buffer with the provided data and resets the buffer-index 86 | * after feed-completion. This needs to run FAST. 87 | * 88 | * @param data 89 | */ 90 | public abstract void feed(T data); 91 | } 92 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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 | getXAxis().setSpaceMin(0.5f); 40 | getXAxis().setSpaceMax(0.5f); 41 | } 42 | 43 | @Override 44 | public ScatterData getScatterData() { 45 | return mData; 46 | } 47 | 48 | /** 49 | * Predefined ScatterShapes that allow the specification of a shape a ScatterDataSet should be drawn with. 50 | * If a ScatterShape is specified for a ScatterDataSet, the required renderer is set. 51 | */ 52 | public enum ScatterShape { 53 | 54 | SQUARE("SQUARE"), 55 | CIRCLE("CIRCLE"), 56 | TRIANGLE("TRIANGLE"), 57 | CROSS("CROSS"), 58 | X("X"), 59 | CHEVRON_UP("CHEVRON_UP"), 60 | CHEVRON_DOWN("CHEVRON_DOWN"); 61 | 62 | private final String shapeIdentifier; 63 | 64 | ScatterShape(final String shapeIdentifier) { 65 | this.shapeIdentifier = shapeIdentifier; 66 | } 67 | 68 | @Override 69 | public String toString() { 70 | return shapeIdentifier; 71 | } 72 | 73 | public static ScatterShape[] getAllDefaultShapes() { 74 | return new ScatterShape[]{SQUARE, CIRCLE, TRIANGLE, CROSS, X, CHEVRON_UP, CHEVRON_DOWN}; 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /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/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/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 16 | extends DataSet 17 | implements IBarLineScatterCandleBubbleDataSet { 18 | 19 | /** 20 | * default highlight color 21 | */ 22 | protected int mHighLightColor = Color.rgb(255, 187, 115); 23 | 24 | public BarLineScatterCandleBubbleDataSet(List yVals, String label) { 25 | super(yVals, label); 26 | } 27 | 28 | /** 29 | * Sets the color that is used for drawing the highlight indicators. Dont 30 | * forget to resolve the color using getResources().getColor(...) or 31 | * Color.rgb(...). 32 | * 33 | * @param color 34 | */ 35 | public void setHighLightColor(int color) { 36 | mHighLightColor = color; 37 | } 38 | 39 | @Override 40 | public int getHighLightColor() { 41 | return mHighLightColor; 42 | } 43 | 44 | protected void copy(BarLineScatterCandleBubbleDataSet barLineScatterCandleBubbleDataSet) { 45 | super.copy(barLineScatterCandleBubbleDataSet); 46 | barLineScatterCandleBubbleDataSet.mHighLightColor = mHighLightColor; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/data/BaseEntry.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.data; 2 | 3 | import android.graphics.drawable.Drawable; 4 | 5 | /** 6 | * Created by Philipp Jahoda on 02/06/16. 7 | */ 8 | public abstract class BaseEntry { 9 | 10 | /** the y value */ 11 | private float y = 0f; 12 | 13 | /** optional spot for additional data this Entry represents */ 14 | private Object mData = null; 15 | 16 | /** optional icon image */ 17 | private Drawable mIcon = null; 18 | 19 | public BaseEntry() { 20 | 21 | } 22 | 23 | public BaseEntry(float y) { 24 | this.y = y; 25 | } 26 | 27 | public BaseEntry(float y, Object data) { 28 | this(y); 29 | this.mData = data; 30 | } 31 | 32 | public BaseEntry(float y, Drawable icon) { 33 | this(y); 34 | this.mIcon = icon; 35 | } 36 | 37 | public BaseEntry(float y, Drawable icon, Object data) { 38 | this(y); 39 | this.mIcon = icon; 40 | this.mData = data; 41 | } 42 | 43 | /** 44 | * Returns the y value of this Entry. 45 | * 46 | * @return 47 | */ 48 | public float getY() { 49 | return y; 50 | } 51 | 52 | /** 53 | * Sets the icon drawable 54 | * 55 | * @param icon 56 | */ 57 | public void setIcon(Drawable icon) { 58 | this.mIcon = icon; 59 | } 60 | 61 | /** 62 | * Returns the icon of this Entry. 63 | * 64 | * @return 65 | */ 66 | public Drawable getIcon() { 67 | return mIcon; 68 | } 69 | 70 | /** 71 | * Sets the y-value for the Entry. 72 | * 73 | * @param y 74 | */ 75 | public void setY(float y) { 76 | this.y = y; 77 | } 78 | 79 | /** 80 | * Returns the data, additional information that this Entry represents, or 81 | * null, if no data has been specified. 82 | * 83 | * @return 84 | */ 85 | public Object getData() { 86 | return mData; 87 | } 88 | 89 | /** 90 | * Sets additional data this Entry should represent. 91 | * 92 | * @param data 93 | */ 94 | public void setData(Object data) { 95 | this.mData = data; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /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/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 | List entries = new ArrayList(); 45 | for (int i = 0; i < mEntries.size(); i++) { 46 | entries.add(mEntries.get(i).copy()); 47 | } 48 | BubbleDataSet copied = new BubbleDataSet(entries, getLabel()); 49 | copy(copied); 50 | return copied; 51 | } 52 | 53 | protected void copy(BubbleDataSet bubbleDataSet) { 54 | bubbleDataSet.mHighlightCircleWidth = mHighlightCircleWidth; 55 | bubbleDataSet.mNormalizeSize = mNormalizeSize; 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/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/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 | -------------------------------------------------------------------------------- /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.graphics.drawable.Drawable; 5 | import android.util.Log; 6 | 7 | /** 8 | * @author Philipp Jahoda 9 | */ 10 | @SuppressLint("ParcelCreator") 11 | public class PieEntry extends Entry { 12 | 13 | private String label; 14 | 15 | public PieEntry(float value) { 16 | super(0f, value); 17 | } 18 | 19 | public PieEntry(float value, Object data) { 20 | super(0f, value, data); 21 | } 22 | 23 | public PieEntry(float value, Drawable icon) { 24 | super(0f, value, icon); 25 | } 26 | 27 | public PieEntry(float value, Drawable icon, Object data) { 28 | super(0f, value, icon, data); 29 | } 30 | 31 | public PieEntry(float value, String label) { 32 | super(0f, value); 33 | this.label = label; 34 | } 35 | 36 | public PieEntry(float value, String label, Object data) { 37 | super(0f, value, data); 38 | this.label = label; 39 | } 40 | 41 | public PieEntry(float value, String label, Drawable icon) { 42 | super(0f, value, icon); 43 | this.label = label; 44 | } 45 | 46 | public PieEntry(float value, String label, Drawable icon, Object data) { 47 | super(0f, value, icon, data); 48 | this.label = label; 49 | } 50 | 51 | /** 52 | * This is the same as getY(). Returns the value of the PieEntry. 53 | * 54 | * @return 55 | */ 56 | public float getValue() { 57 | return getY(); 58 | } 59 | 60 | public String getLabel() { 61 | return label; 62 | } 63 | 64 | public void setLabel(String label) { 65 | this.label = label; 66 | } 67 | 68 | @Deprecated 69 | @Override 70 | public void setX(float x) { 71 | super.setX(x); 72 | Log.i("DEPRECATED", "Pie entries do not have x values"); 73 | } 74 | 75 | @Deprecated 76 | @Override 77 | public float getX() { 78 | Log.i("DEPRECATED", "Pie entries do not have x values"); 79 | return super.getX(); 80 | } 81 | 82 | public PieEntry copy() { 83 | PieEntry e = new PieEntry(getY(), label, getData()); 84 | return e; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /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/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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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/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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | import com.github.mikephil.charting.utils.Fill; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Created by philipp on 21/10/15. 10 | */ 11 | public interface IBarDataSet extends IBarLineScatterCandleBubbleDataSet { 12 | 13 | List getFills(); 14 | 15 | Fill getFill(int index); 16 | 17 | /** 18 | * Returns true if this DataSet is stacked (stacksize > 1) or not. 19 | * 20 | * @return 21 | */ 22 | boolean isStacked(); 23 | 24 | /** 25 | * Returns the maximum number of bars that can be stacked upon another in 26 | * this DataSet. This should return 1 for non stacked bars, and > 1 for stacked bars. 27 | * 28 | * @return 29 | */ 30 | int getStackSize(); 31 | 32 | /** 33 | * Returns the color used for drawing the bar-shadows. The bar shadows is a 34 | * surface behind the bar that indicates the maximum value. 35 | * 36 | * @return 37 | */ 38 | int getBarShadowColor(); 39 | 40 | /** 41 | * Returns the width used for drawing borders around the bars. 42 | * If borderWidth == 0, no border will be drawn. 43 | * 44 | * @return 45 | */ 46 | float getBarBorderWidth(); 47 | 48 | /** 49 | * Returns the color drawing borders around the bars. 50 | * 51 | * @return 52 | */ 53 | int getBarBorderColor(); 54 | 55 | /** 56 | * Returns the alpha value (transparency) that is used for drawing the 57 | * highlight indicator. 58 | * 59 | * @return 60 | */ 61 | int getHighLightAlpha(); 62 | 63 | 64 | /** 65 | * Returns the labels used for the different value-stacks in the legend. 66 | * This is only relevant for stacked bar entries. 67 | * 68 | * @return 69 | */ 70 | String[] getStackLabels(); 71 | } 72 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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/interfaces/datasets/IPieDataSet.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.interfaces.datasets; 2 | 3 | import androidx.annotation.Nullable; 4 | 5 | import com.github.mikephil.charting.data.PieDataSet; 6 | import com.github.mikephil.charting.data.PieEntry; 7 | 8 | /** 9 | * Created by Philipp Jahoda on 03/11/15. 10 | */ 11 | public interface IPieDataSet extends IDataSet { 12 | 13 | /** 14 | * Returns the space that is set to be between the piechart-slices of this 15 | * DataSet, in pixels. 16 | * 17 | * @return 18 | */ 19 | float getSliceSpace(); 20 | 21 | /** 22 | * When enabled, slice spacing will be 0.0 when the smallest value is going to be 23 | * smaller than the slice spacing itself. 24 | * 25 | * @return 26 | */ 27 | boolean isAutomaticallyDisableSliceSpacingEnabled(); 28 | 29 | /** 30 | * Returns the distance a highlighted piechart slice is "shifted" away from 31 | * the chart-center in dp. 32 | * 33 | * @return 34 | */ 35 | float getSelectionShift(); 36 | 37 | PieDataSet.ValuePosition getXValuePosition(); 38 | PieDataSet.ValuePosition getYValuePosition(); 39 | 40 | /** 41 | * When valuePosition is OutsideSlice, indicates line color 42 | * */ 43 | int getValueLineColor(); 44 | 45 | /** 46 | * When valuePosition is OutsideSlice and enabled, line will have the same color as the slice 47 | * */ 48 | boolean isUseValueColorForLineEnabled(); 49 | 50 | /** 51 | * When valuePosition is OutsideSlice, indicates line width 52 | * */ 53 | float getValueLineWidth(); 54 | 55 | /** 56 | * When valuePosition is OutsideSlice, indicates offset as percentage out of the slice size 57 | * */ 58 | float getValueLinePart1OffsetPercentage(); 59 | 60 | /** 61 | * When valuePosition is OutsideSlice, indicates length of first half of the line 62 | * */ 63 | float getValueLinePart1Length(); 64 | 65 | /** 66 | * When valuePosition is OutsideSlice, indicates length of second half of the line 67 | * */ 68 | float getValueLinePart2Length(); 69 | 70 | /** 71 | * When valuePosition is OutsideSlice, this allows variable line length 72 | * */ 73 | boolean isValueLineVariableLength(); 74 | 75 | /** 76 | * Gets the color for the highlighted sector 77 | * */ 78 | @Nullable 79 | Integer getHighlightColor(); 80 | 81 | } 82 | 83 | -------------------------------------------------------------------------------- /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/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/jobs/AnimatedMoveViewJob.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.jobs; 2 | 3 | import android.animation.ValueAnimator; 4 | import android.annotation.SuppressLint; 5 | import android.view.View; 6 | 7 | import com.github.mikephil.charting.utils.ObjectPool; 8 | import com.github.mikephil.charting.utils.Transformer; 9 | import com.github.mikephil.charting.utils.ViewPortHandler; 10 | 11 | /** 12 | * Created by Philipp Jahoda on 19/02/16. 13 | */ 14 | @SuppressLint("NewApi") 15 | public class AnimatedMoveViewJob extends AnimatedViewPortJob { 16 | 17 | private static ObjectPool pool; 18 | 19 | static { 20 | pool = ObjectPool.create(4, new AnimatedMoveViewJob(null,0,0,null,null,0,0,0)); 21 | pool.setReplenishPercentage(0.5f); 22 | } 23 | 24 | public static AnimatedMoveViewJob getInstance(ViewPortHandler viewPortHandler, float xValue, float yValue, Transformer trans, View v, float xOrigin, float yOrigin, long duration){ 25 | AnimatedMoveViewJob result = pool.get(); 26 | result.mViewPortHandler = viewPortHandler; 27 | result.xValue = xValue; 28 | result.yValue = yValue; 29 | result.mTrans = trans; 30 | result.view = v; 31 | result.xOrigin = xOrigin; 32 | result.yOrigin = yOrigin; 33 | //result.resetAnimator(); 34 | result.animator.setDuration(duration); 35 | return result; 36 | } 37 | 38 | public static void recycleInstance(AnimatedMoveViewJob instance){ 39 | pool.recycle(instance); 40 | } 41 | 42 | 43 | public AnimatedMoveViewJob(ViewPortHandler viewPortHandler, float xValue, float yValue, Transformer trans, View v, float xOrigin, float yOrigin, long duration) { 44 | super(viewPortHandler, xValue, yValue, trans, v, xOrigin, yOrigin, duration); 45 | } 46 | 47 | @Override 48 | public void onAnimationUpdate(ValueAnimator animation) { 49 | 50 | pts[0] = xOrigin + (xValue - xOrigin) * phase; 51 | pts[1] = yOrigin + (yValue - yOrigin) * phase; 52 | 53 | mTrans.pointValuesToPixel(pts); 54 | mViewPortHandler.centerViewPort(pts, view); 55 | } 56 | 57 | public void recycleSelf(){ 58 | recycleInstance(this); 59 | } 60 | 61 | @Override 62 | protected ObjectPool.Poolable instantiate() { 63 | return new AnimatedMoveViewJob(null,0,0,null,null,0,0,0); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 / double-tap 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/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/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/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 | -------------------------------------------------------------------------------- /MPChartLib/src/main/java/com/github/mikephil/charting/model/GradientColor.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.model; 2 | 3 | import com.github.mikephil.charting.utils.Fill; 4 | 5 | /** 6 | * Deprecated. Use `Fill` 7 | */ 8 | @Deprecated 9 | public class GradientColor extends Fill 10 | { 11 | /** 12 | * Deprecated. Use `Fill.getGradientColors()` 13 | */ 14 | @Deprecated 15 | public int getStartColor() 16 | { 17 | return getGradientColors()[0]; 18 | } 19 | 20 | /** 21 | * Deprecated. Use `Fill.setGradientColors(...)` 22 | */ 23 | @Deprecated 24 | public void setStartColor(int startColor) 25 | { 26 | if (getGradientColors() == null || getGradientColors().length != 2) 27 | { 28 | setGradientColors(new int[]{ 29 | startColor, 30 | getGradientColors() != null && getGradientColors().length > 1 31 | ? getGradientColors()[1] 32 | : 0 33 | }); 34 | } else 35 | { 36 | getGradientColors()[0] = startColor; 37 | } 38 | } 39 | 40 | /** 41 | * Deprecated. Use `Fill.getGradientColors()` 42 | */ 43 | @Deprecated 44 | public int getEndColor() 45 | { 46 | return getGradientColors()[1]; 47 | } 48 | 49 | /** 50 | * Deprecated. Use `Fill.setGradientColors(...)` 51 | */ 52 | @Deprecated 53 | public void setEndColor(int endColor) 54 | { 55 | if (getGradientColors() == null || getGradientColors().length != 2) 56 | { 57 | setGradientColors(new int[]{ 58 | getGradientColors() != null && getGradientColors().length > 0 59 | ? getGradientColors()[0] 60 | : 0, 61 | endColor 62 | }); 63 | } else 64 | { 65 | getGradientColors()[1] = endColor; 66 | } 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /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/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/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/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 | -------------------------------------------------------------------------------- /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/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/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 | } -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | google() 4 | mavenCentral() 5 | } 6 | dependencies { 7 | classpath 'com.android.tools.build:gradle:7.0.4' 8 | } 9 | } 10 | 11 | allprojects { 12 | repositories { 13 | google() 14 | mavenCentral() 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /design/facebook_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/design/facebook_icon.png -------------------------------------------------------------------------------- /design/feature_graphic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/design/feature_graphic.png -------------------------------------------------------------------------------- /design/feature_graphic.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/design/feature_graphic.psd -------------------------------------------------------------------------------- /design/feature_graphic_smaller.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/design/feature_graphic_smaller.png -------------------------------------------------------------------------------- /design/googleplus_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/design/googleplus_icon.png -------------------------------------------------------------------------------- /design/header_symbol.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/design/header_symbol.png -------------------------------------------------------------------------------- /design/ic_launcher.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/design/ic_launcher.psd -------------------------------------------------------------------------------- /design/other/bottom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/design/other/bottom.png -------------------------------------------------------------------------------- /design/other/left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/design/other/left.png -------------------------------------------------------------------------------- /design/other/right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/design/other/right.png -------------------------------------------------------------------------------- /design/twitter_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/design/twitter_icon.png -------------------------------------------------------------------------------- /design/video_thumbnail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/design/video_thumbnail.png -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | android.enableJetifier=true 2 | android.useAndroidX=true 3 | org.gradle.jvmargs=-Xmx2048M 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /screenshots/AndroidWeekly_Issue114_10082014.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/AndroidWeekly_Issue114_10082014.png -------------------------------------------------------------------------------- /screenshots/MPAndroidChart_trending.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/MPAndroidChart_trending.png -------------------------------------------------------------------------------- /screenshots/ValueFormatter.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/ValueFormatter.jpg -------------------------------------------------------------------------------- /screenshots/barchart2d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/barchart2d.png -------------------------------------------------------------------------------- /screenshots/barchart2d_multi_dataset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/barchart2d_multi_dataset.png -------------------------------------------------------------------------------- /screenshots/barchart2d_multi_dataset_date1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/barchart2d_multi_dataset_date1.png -------------------------------------------------------------------------------- /screenshots/barchart2d_multi_dataset_date2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/barchart2d_multi_dataset_date2.png -------------------------------------------------------------------------------- /screenshots/barchart3d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/barchart3d.png -------------------------------------------------------------------------------- /screenshots/bubblechart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/bubblechart.png -------------------------------------------------------------------------------- /screenshots/candlestickchart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/candlestickchart.png -------------------------------------------------------------------------------- /screenshots/candlestickchart_old.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/candlestickchart_old.png -------------------------------------------------------------------------------- /screenshots/combined_chart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/combined_chart.png -------------------------------------------------------------------------------- /screenshots/cubiclinechart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/cubiclinechart.png -------------------------------------------------------------------------------- /screenshots/grouped_barchart_wiki.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/grouped_barchart_wiki.png -------------------------------------------------------------------------------- /screenshots/groupedbarchart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/groupedbarchart.png -------------------------------------------------------------------------------- /screenshots/horizontal_barchart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/horizontal_barchart.png -------------------------------------------------------------------------------- /screenshots/line_chart_gradient.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/line_chart_gradient.png -------------------------------------------------------------------------------- /screenshots/linechart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/linechart.png -------------------------------------------------------------------------------- /screenshots/linechart_colored.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/linechart_colored.png -------------------------------------------------------------------------------- /screenshots/linechart_legend.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/linechart_legend.png -------------------------------------------------------------------------------- /screenshots/linechart_multiline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/linechart_multiline.png -------------------------------------------------------------------------------- /screenshots/linechart_multiline_color_variations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/linechart_multiline_color_variations.png -------------------------------------------------------------------------------- /screenshots/linechart_wiki.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/linechart_wiki.png -------------------------------------------------------------------------------- /screenshots/normal_barchart_wiki.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/normal_barchart_wiki.png -------------------------------------------------------------------------------- /screenshots/piechart_holeradius_space.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/piechart_holeradius_space.png -------------------------------------------------------------------------------- /screenshots/piechart_more_colors.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/piechart_more_colors.png -------------------------------------------------------------------------------- /screenshots/piechart_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/piechart_selected.png -------------------------------------------------------------------------------- /screenshots/piechart_wiki.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/piechart_wiki.png -------------------------------------------------------------------------------- /screenshots/radarchart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/radarchart.png -------------------------------------------------------------------------------- /screenshots/realm_wiki.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/realm_wiki.png -------------------------------------------------------------------------------- /screenshots/scatterchart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/scatterchart.png -------------------------------------------------------------------------------- /screenshots/simpledesign_barchart2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/simpledesign_barchart2.png -------------------------------------------------------------------------------- /screenshots/simpledesign_barchart3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/simpledesign_barchart3.png -------------------------------------------------------------------------------- /screenshots/simpledesign_linechart1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/simpledesign_linechart1.png -------------------------------------------------------------------------------- /screenshots/simpledesign_linechart2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/simpledesign_linechart2.png -------------------------------------------------------------------------------- /screenshots/simpledesign_linechart3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/simpledesign_linechart3.png -------------------------------------------------------------------------------- /screenshots/simpledesign_linechart4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/simpledesign_linechart4.png -------------------------------------------------------------------------------- /screenshots/simpledesign_linechart5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/simpledesign_linechart5.png -------------------------------------------------------------------------------- /screenshots/simpledesign_piechart1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/simpledesign_piechart1.png -------------------------------------------------------------------------------- /screenshots/smart_legends.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/smart_legends.png -------------------------------------------------------------------------------- /screenshots/tranding_developers_11_08_2014.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/tranding_developers_11_08_2014.png -------------------------------------------------------------------------------- /screenshots/zero_line_example_barchart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PhilJay/MPAndroidChart/9c7275a0596a7ac0e50ca566e680f7f9d73607af/screenshots/zero_line_example_barchart.png -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include 'MPChartLib' 2 | //include 'MPAndroidChart-Realm' 3 | include 'MPChartExample' 4 | //include ':MPChartLib-Realm' 5 | //project(':MPChartLib-Realm').projectDir = new File('../MPAndroidChart-Realm/MPChartLib-Realm') 6 | 7 | 8 | --------------------------------------------------------------------------------