├── .gitignore ├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── MPAndroidChartTest.iml ├── README.md ├── app ├── .gitignore ├── app.iml ├── build.gradle ├── lib │ └── mplib │ │ ├── .gitignore │ │ ├── AndroidManifest.xml │ │ ├── build.gradle │ │ ├── ic_launcher-web.png │ │ ├── pom.xml │ │ ├── proguard-project.txt │ │ ├── project.properties │ │ └── src │ │ └── com │ │ └── github │ │ └── mikephil │ │ └── charting │ │ ├── animation │ │ ├── ChartAnimator.java │ │ ├── Easing.java │ │ └── EasingFunction.java │ │ ├── buffer │ │ ├── AbstractBuffer.java │ │ ├── BarBuffer.java │ │ ├── CandleBodyBuffer.java │ │ ├── CandleShadowBuffer.java │ │ ├── CircleBuffer.java │ │ ├── HorizontalBarBuffer.java │ │ ├── LineBuffer.java │ │ └── ScatterBuffer.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 │ │ ├── Legend.java │ │ ├── LimitLine.java │ │ ├── MarkerView.java │ │ ├── XAxis.java │ │ └── YAxis.java │ │ ├── data │ │ ├── BarData.java │ │ ├── BarDataSet.java │ │ ├── BarEntry.java │ │ ├── BarLineScatterCandleBubbleData.java │ │ ├── BarLineScatterCandleBubbleDataSet.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 │ │ ├── RadarData.java │ │ ├── RadarDataSet.java │ │ ├── ScatterData.java │ │ ├── ScatterDataSet.java │ │ └── filter │ │ │ └── Approximator.java │ │ ├── exception │ │ └── DrawingDataSetNotCreatedException.java │ │ ├── formatter │ │ ├── ColorFormatter.java │ │ ├── DefaultFillFormatter.java │ │ ├── DefaultValueFormatter.java │ │ ├── DefaultXAxisValueFormatter.java │ │ ├── DefaultYAxisValueFormatter.java │ │ ├── FillFormatter.java │ │ ├── LargeValueFormatter.java │ │ ├── PercentFormatter.java │ │ ├── ValueFormatter.java │ │ ├── XAxisValueFormatter.java │ │ └── YAxisValueFormatter.java │ │ ├── highlight │ │ ├── BarHighlighter.java │ │ ├── ChartHighlighter.java │ │ ├── CombinedHighlighter.java │ │ ├── Highlight.java │ │ ├── HorizontalBarHighlighter.java │ │ └── Range.java │ │ ├── interfaces │ │ ├── BarDataProvider.java │ │ ├── BarLineScatterCandleBubbleDataProvider.java │ │ ├── BubbleDataProvider.java │ │ ├── CandleDataProvider.java │ │ ├── ChartInterface.java │ │ ├── LineDataProvider.java │ │ └── ScatterDataProvider.java │ │ ├── jobs │ │ └── MoveViewJob.java │ │ ├── listener │ │ ├── BarLineChartTouchListener.java │ │ ├── ChartTouchListener.java │ │ ├── OnChartGestureListener.java │ │ ├── OnChartValueSelectedListener.java │ │ ├── OnDrawLineChartTouchListener.java │ │ ├── OnDrawListener.java │ │ └── PieRadarChartTouchListener.java │ │ ├── matrix │ │ └── Vector3.java │ │ ├── renderer │ │ ├── AxisRenderer.java │ │ ├── BarChartRenderer.java │ │ ├── BubbleChartRenderer.java │ │ ├── CandleStickChartRenderer.java │ │ ├── CombinedChartRenderer.java │ │ ├── DataRenderer.java │ │ ├── HorizontalBarChartRenderer.java │ │ ├── LegendRenderer.java │ │ ├── LineChartRenderer.java │ │ ├── LineScatterCandleRadarRenderer.java │ │ ├── PieChartRenderer.java │ │ ├── RadarChartRenderer.java │ │ ├── Renderer.java │ │ ├── ScatterChartRenderer.java │ │ ├── XAxisRenderer.java │ │ ├── XAxisRendererBarChart.java │ │ ├── XAxisRendererHorizontalBarChart.java │ │ ├── XAxisRendererRadarChart.java │ │ ├── YAxisRenderer.java │ │ ├── YAxisRendererHorizontalBarChart.java │ │ └── YAxisRendererRadarChart.java │ │ └── utils │ │ ├── ColorTemplate.java │ │ ├── EntryXIndexComparator.java │ │ ├── FSize.java │ │ ├── FileUtils.java │ │ ├── PointD.java │ │ ├── SelectionDetail.java │ │ ├── Transformer.java │ │ ├── TransformerHorizontalBarChart.java │ │ ├── Utils.java │ │ └── ViewPortHandler.java ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── example │ │ └── chenyu │ │ └── mpandroidcharttest │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── example │ │ └── chenyu │ │ └── mpandroidcharttest │ │ ├── BarCharFragment.java │ │ ├── LineCharFragment.java │ │ ├── MainActivity.java │ │ ├── PieCharFragment.java │ │ ├── RadarCharFragment.java │ │ └── ScatterChartFragment.java │ └── res │ ├── drawable │ ├── MPAndroidChart3.gif │ └── ic_launcher.png │ ├── layout │ ├── activity_main.xml │ ├── bar_chart.xml │ ├── liner_chart.xml │ ├── pie_chart.xml │ ├── radar_chart.xml │ └── scatter_chart.xml │ ├── menu │ └── menu_main.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── values-w820dp │ ├── colors.xml │ └── dimens.xml │ └── values │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── lib └── lib.iml ├── mplib └── mplib.iml └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea/workspace.xml 4 | /.idea/libraries 5 | .DS_Store 6 | /build 7 | /captures 8 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | MPAndroidChartTest -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /MPAndroidChartTest.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MPAndroidChartTest 2 | 用的MPAndroidChart写成丰富多彩的各种图表,有折线图、柱形图、饼状图、散列图、雷达图
3 | 效果图如下
4 | ![](https://github.com/changechenyu/MPAndroidChartTest/blob/master/app/src/main/res/drawable/MPAndroidChart3.gif) 5 | ![](https://github.com/changechenyu/MPAndroidChartTest/blob/master/app/src/main/res/drawable/MPAndroidChart3.gif)
6 | 当我们项目有大量的数据需要动态显示的时候可以这些图标更直观让用户获取信息。 7 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.0" 6 | 7 | defaultConfig { 8 | applicationId "com.example.chenyu.mpandroidcharttest" 9 | minSdkVersion 15 10 | targetSdkVersion 23 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | compile 'com.android.support:appcompat-v7:23.0.0' 25 | compile project(':mplib') 26 | } 27 | -------------------------------------------------------------------------------- /app/lib/mplib/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/lib/mplib/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | -------------------------------------------------------------------------------- /app/lib/mplib/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'maven' 3 | apply plugin: 'com.github.dcendents.android-maven' 4 | 5 | android { 6 | compileSdkVersion 23 7 | buildToolsVersion "23.0.0" 8 | // resourcePrefix 'mpcht' 9 | defaultConfig { 10 | minSdkVersion 8 11 | targetSdkVersion 23 12 | versionCode 1 13 | versionName '1.0' 14 | 15 | sourceSets { 16 | main { 17 | java.srcDirs = ['src'] 18 | res.srcDirs = ['res'] 19 | assets.srcDirs = ['assets'] 20 | manifest.srcFile 'AndroidManifest.xml' 21 | } 22 | } 23 | } 24 | buildTypes { 25 | release { 26 | minifyEnabled false 27 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 28 | } 29 | } 30 | lintOptions { 31 | abortOnError false 32 | } 33 | } 34 | 35 | dependencies { 36 | //compile fileTree(dir: 'libs', include: ['*.jar']) 37 | //compile 'com.android.support:support-v4:19.+' 38 | //compile 'com.nineoldandroids:library:2.4.+' 39 | } 40 | 41 | android.libraryVariants.all { variant -> 42 | def name = variant.buildType.name 43 | def task = project.tasks.create "jar${name.capitalize()}", Jar 44 | task.dependsOn variant.javaCompile 45 | task.from variant.javaCompile.destinationDir 46 | artifacts.add('archives', task); 47 | } 48 | 49 | task sourcesJar(type: Jar) { 50 | from android.sourceSets.main.java.srcDirs 51 | classifier = 'sources' 52 | } 53 | 54 | task javadoc(type: Javadoc) { 55 | failOnError false 56 | source = android.sourceSets.main.java.sourceFiles 57 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) 58 | } 59 | 60 | task javadocJar(type: Jar, dependsOn: javadoc) { 61 | classifier = 'javadoc' 62 | from javadoc.destinationDir 63 | } 64 | 65 | artifacts { 66 | archives sourcesJar 67 | archives javadocJar 68 | } 69 | -------------------------------------------------------------------------------- /app/lib/mplib/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/changechenyu/MPAndroidChartTest/555d9ad0a1968987792be9411eb9db66f7065f84/app/lib/mplib/ic_launcher-web.png -------------------------------------------------------------------------------- /app/lib/mplib/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 4.0.0 20 | 1.4.2-SNAPSHOT 21 | com.github.mikephil 22 | MPAndroidChart 23 | MPAndroidChart 24 | A simple Android chart view/graph view library, supporting line- bar- and piecharts as well as scaling, dragging and animations 25 | https://github.com/PhilJay/MPAndroidChart 26 | apklib 27 | 28 | 29 | 30 | UTF-8 31 | 32 | 33 | 34 | src 35 | 36 | 37 | com.jayway.maven.plugins.android.generation2 38 | android-maven-plugin 39 | 3.9.0-rc.2 40 | true 41 | 42 | 43 | 44 | 45 | 46 | true 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | com.google.android 55 | android 56 | provided 57 | 4.1.1.4 58 | 59 | 60 | 61 | 62 | 63 | https://github.com/PhilJay/MPAndroidChart/issues 64 | GitHub Issues 65 | 66 | 67 | 68 | 69 | Apache License Version 2.0 70 | http://www.apache.org/licenses/LICENSE-2.0.html 71 | repo 72 | 73 | 74 | 75 | 76 | https://github.com/PhilJay/MPAndroidChart 77 | scm:git:git://github.com/PhilJay/MPAndroidChart.git 78 | scm:git:git@github.com:PhilJay/MPAndroidChart.git 79 | 80 | 81 | 82 | 83 | Philipp Jahoda 84 | philjay.librarysup@gmail.com 85 | http://stackoverflow.com/users/1590502/philipp-jahoda 86 | PhilJay 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /app/lib/mplib/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /app/lib/mplib/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-22 15 | android.library=true 16 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/animation/EasingFunction.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.animation; 2 | 3 | import android.animation.TimeInterpolator; 4 | import android.annotation.SuppressLint; 5 | 6 | /** 7 | * Interface for creating custom made easing functions. Uses the 8 | * TimeInterpolator interface provided by Android. 9 | */ 10 | @SuppressLint("NewApi") 11 | public interface EasingFunction extends TimeInterpolator { 12 | 13 | @Override 14 | float getInterpolation(float input); 15 | } 16 | -------------------------------------------------------------------------------- /app/lib/mplib/src/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 entries 89 | */ 90 | public abstract void feed(List entries); 91 | } 92 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/buffer/BarBuffer.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.buffer; 3 | 4 | import com.github.mikephil.charting.data.BarEntry; 5 | 6 | import java.util.List; 7 | 8 | public class BarBuffer extends AbstractBuffer { 9 | 10 | protected float mBarSpace = 0f; 11 | protected float mGroupSpace = 0f; 12 | protected int mDataSetIndex = 0; 13 | protected int mDataSetCount = 1; 14 | protected boolean mContainsStacks = false; 15 | protected boolean mInverted = false; 16 | 17 | public BarBuffer(int size, float groupspace, int dataSetCount, boolean containsStacks) { 18 | super(size); 19 | this.mGroupSpace = groupspace; 20 | this.mDataSetCount = dataSetCount; 21 | this.mContainsStacks = containsStacks; 22 | } 23 | 24 | public void setBarSpace(float barspace) { 25 | this.mBarSpace = barspace; 26 | } 27 | 28 | public void setDataSet(int index) { 29 | this.mDataSetIndex = index; 30 | } 31 | 32 | public void setInverted(boolean inverted) { 33 | this.mInverted = inverted; 34 | } 35 | 36 | protected void addBar(float left, float top, float right, float bottom) { 37 | 38 | buffer[index++] = left; 39 | buffer[index++] = top; 40 | buffer[index++] = right; 41 | buffer[index++] = bottom; 42 | } 43 | 44 | @Override 45 | public void feed(List entries) { 46 | 47 | float size = entries.size() * phaseX; 48 | 49 | int dataSetOffset = (mDataSetCount - 1); 50 | float barSpaceHalf = mBarSpace / 2f; 51 | float groupSpaceHalf = mGroupSpace / 2f; 52 | float barWidth = 0.5f; 53 | 54 | for (int i = 0; i < size; i++) { 55 | 56 | BarEntry e = entries.get(i); 57 | 58 | // calculate the x-position, depending on datasetcount 59 | float x = e.getXIndex() + e.getXIndex() * dataSetOffset + mDataSetIndex 60 | + mGroupSpace * e.getXIndex() + groupSpaceHalf; 61 | float y = e.getVal(); 62 | float [] vals = e.getVals(); 63 | 64 | if (!mContainsStacks || vals == null) { 65 | 66 | float left = x - barWidth + barSpaceHalf; 67 | float right = x + barWidth - barSpaceHalf; 68 | float bottom, top; 69 | if (mInverted) { 70 | bottom = y >= 0 ? y : 0; 71 | top = y <= 0 ? y : 0; 72 | } else { 73 | top = y >= 0 ? y : 0; 74 | bottom = y <= 0 ? y : 0; 75 | } 76 | 77 | // multiply the height of the rect with the phase 78 | if (top > 0) 79 | top *= phaseY; 80 | else 81 | bottom *= phaseY; 82 | 83 | addBar(left, top, right, bottom); 84 | 85 | } else { 86 | 87 | float posY = 0f; 88 | float negY = -e.getNegativeSum(); 89 | float yStart = 0f; 90 | 91 | // fill the stack 92 | for (int k = 0; k < vals.length; k++) { 93 | 94 | float value = vals[k]; 95 | 96 | if(value >= 0f) { 97 | y = posY; 98 | yStart = posY + value; 99 | posY = yStart; 100 | } else { 101 | y = negY; 102 | yStart = negY + Math.abs(value); 103 | negY += Math.abs(value); 104 | } 105 | 106 | float left = x - barWidth + barSpaceHalf; 107 | float right = x + barWidth - barSpaceHalf; 108 | float bottom, top; 109 | if (mInverted) { 110 | bottom = y >= yStart ? y : yStart; 111 | top = y <= yStart ? y : yStart; 112 | } else { 113 | top = y >= yStart ? y : yStart; 114 | bottom = y <= yStart ? y : yStart; 115 | } 116 | 117 | // multiply the height of the rect with the phase 118 | top *= phaseY; 119 | bottom *= phaseY; 120 | 121 | addBar(left, top, right, bottom); 122 | } 123 | } 124 | } 125 | 126 | reset(); 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/buffer/CandleBodyBuffer.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.buffer; 3 | 4 | import com.github.mikephil.charting.data.CandleEntry; 5 | 6 | import java.util.List; 7 | 8 | public class CandleBodyBuffer extends AbstractBuffer { 9 | 10 | private float mBodySpace = 0f; 11 | 12 | public CandleBodyBuffer(int size) { 13 | super(size); 14 | } 15 | 16 | public void setBodySpace(float bodySpace) { 17 | this.mBodySpace = bodySpace; 18 | } 19 | 20 | private void addBody(float left, float top, float right, float bottom) { 21 | 22 | buffer[index++] = left; 23 | buffer[index++] = top; 24 | buffer[index++] = right; 25 | buffer[index++] = bottom; 26 | } 27 | 28 | @Override 29 | public void feed(List entries) { 30 | 31 | int size = (int)Math.ceil((mTo - mFrom) * phaseX + mFrom); 32 | 33 | for (int i = mFrom; i < size; i++) { 34 | 35 | CandleEntry e = entries.get(i); 36 | addBody(e.getXIndex() - 0.5f + mBodySpace, e.getClose() * phaseY, e.getXIndex() + 0.5f - mBodySpace, e.getOpen() * phaseY); 37 | } 38 | 39 | reset(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/buffer/CandleShadowBuffer.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.buffer; 3 | 4 | import com.github.mikephil.charting.data.CandleEntry; 5 | 6 | import java.util.List; 7 | 8 | public class CandleShadowBuffer extends AbstractBuffer { 9 | 10 | public CandleShadowBuffer(int size) { 11 | super(size); 12 | } 13 | 14 | private void addShadow(float x1, float y1, float x2, float y2) { 15 | 16 | buffer[index++] = x1; 17 | buffer[index++] = y1; 18 | buffer[index++] = x2; 19 | buffer[index++] = y2; 20 | } 21 | 22 | @Override 23 | public void feed(List entries) { 24 | 25 | int size = (int)Math.ceil((mTo - mFrom) * phaseX + mFrom); 26 | 27 | for (int i = mFrom; i < size; i++) { 28 | 29 | CandleEntry e = entries.get(i); 30 | addShadow(e.getXIndex(), e.getHigh() * phaseY, e.getXIndex(), e.getLow() * phaseY); 31 | } 32 | 33 | reset(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/buffer/CircleBuffer.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.buffer; 3 | 4 | import com.github.mikephil.charting.data.Entry; 5 | 6 | import java.util.List; 7 | 8 | public class CircleBuffer extends AbstractBuffer { 9 | 10 | public CircleBuffer(int size) { 11 | super(size); 12 | } 13 | 14 | protected void addCircle(float x, float y) { 15 | buffer[index++] = x; 16 | buffer[index++] = y; 17 | } 18 | 19 | @Override 20 | public void feed(List entries) { 21 | 22 | int size = (int)Math.ceil((mTo - mFrom) * phaseX + mFrom); 23 | 24 | for (int i = mFrom; i < size; i++) { 25 | 26 | Entry e = entries.get(i); 27 | addCircle(e.getXIndex(), e.getVal() * phaseY); 28 | } 29 | 30 | reset(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/buffer/HorizontalBarBuffer.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.buffer; 3 | 4 | import com.github.mikephil.charting.data.BarEntry; 5 | 6 | import java.util.List; 7 | 8 | public class HorizontalBarBuffer extends BarBuffer { 9 | 10 | public HorizontalBarBuffer(int size, float groupspace, int dataSetCount, boolean containsStacks) { 11 | super(size, groupspace, dataSetCount, containsStacks); 12 | } 13 | 14 | @Override 15 | public void feed(List entries) { 16 | 17 | float size = entries.size() * phaseX; 18 | 19 | int dataSetOffset = (mDataSetCount - 1); 20 | float barSpaceHalf = mBarSpace / 2f; 21 | float groupSpaceHalf = mGroupSpace / 2f; 22 | float barWidth = 0.5f; 23 | 24 | for (int i = 0; i < size; i++) { 25 | 26 | BarEntry e = entries.get(i); 27 | 28 | // calculate the x-position, depending on datasetcount 29 | float x = e.getXIndex() + e.getXIndex() * dataSetOffset + mDataSetIndex 30 | + mGroupSpace * e.getXIndex() + groupSpaceHalf; 31 | float y = e.getVal(); 32 | float[] vals = e.getVals(); 33 | 34 | if (!mContainsStacks || vals == null) { 35 | 36 | float bottom = x - barWidth + barSpaceHalf; 37 | float top = x + barWidth - barSpaceHalf; 38 | float left, right; 39 | if (mInverted) { 40 | left = y >= 0 ? y : 0; 41 | right = y <= 0 ? y : 0; 42 | } else { 43 | right = y >= 0 ? y : 0; 44 | left = y <= 0 ? y : 0; 45 | } 46 | 47 | // multiply the height of the rect with the phase 48 | if (right > 0) 49 | right *= phaseY; 50 | else 51 | left *= phaseY; 52 | 53 | addBar(left, top, right, bottom); 54 | 55 | } else { 56 | 57 | float posY = 0f; 58 | float negY = -e.getNegativeSum(); 59 | float yStart = 0f; 60 | 61 | // fill the stack 62 | for (int k = 0; k < vals.length; k++) { 63 | 64 | float value = vals[k]; 65 | 66 | if(value >= 0f) { 67 | y = posY; 68 | yStart = posY + value; 69 | posY = yStart; 70 | } else { 71 | y = negY; 72 | yStart = negY + Math.abs(value); 73 | negY += Math.abs(value); 74 | } 75 | 76 | float bottom = x - barWidth + barSpaceHalf; 77 | float top = x + barWidth - barSpaceHalf; 78 | float left, right; 79 | if (mInverted) { 80 | left = y >= yStart ? y : yStart; 81 | right = y <= yStart ? y : yStart; 82 | } else { 83 | right = y >= yStart ? y : yStart; 84 | left = y <= yStart ? y : yStart; 85 | } 86 | 87 | // multiply the height of the rect with the phase 88 | right *= phaseY; 89 | left *= phaseY; 90 | 91 | addBar(left, top, right, bottom); 92 | } 93 | } 94 | } 95 | 96 | reset(); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/buffer/LineBuffer.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.buffer; 3 | 4 | import com.github.mikephil.charting.data.Entry; 5 | 6 | import java.util.List; 7 | 8 | public class LineBuffer extends AbstractBuffer { 9 | 10 | public LineBuffer(int size) { 11 | super((size < 4) ? 4 : size); 12 | } 13 | 14 | public void moveTo(float x, float y) { 15 | 16 | if (index != 0) 17 | return; 18 | 19 | buffer[index++] = x; 20 | buffer[index++] = y; 21 | 22 | // in case just one entry, this is overwritten when lineTo is called 23 | buffer[index] = x; 24 | buffer[index + 1] = y; 25 | } 26 | 27 | public void lineTo(float x, float y) { 28 | 29 | if (index == 2) { 30 | buffer[index++] = x; 31 | buffer[index++] = y; 32 | } else { 33 | 34 | float prevX = buffer[index - 2]; 35 | float prevY = buffer[index - 1]; 36 | buffer[index++] = prevX; 37 | buffer[index++] = prevY; 38 | buffer[index++] = x; 39 | buffer[index++] = y; 40 | } 41 | } 42 | 43 | @Override 44 | public void feed(List entries) { 45 | moveTo(entries.get(mFrom).getXIndex(), entries.get(mFrom).getVal() * phaseY); 46 | 47 | int size = (int) Math.ceil((mTo - mFrom) * phaseX + mFrom); 48 | int from = mFrom + 1; 49 | 50 | for (int i = from; i < size; i++) { 51 | 52 | Entry e = entries.get(i); 53 | lineTo(e.getXIndex(), e.getVal() * phaseY); 54 | } 55 | 56 | reset(); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/buffer/ScatterBuffer.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.buffer; 3 | 4 | import com.github.mikephil.charting.data.Entry; 5 | 6 | import java.util.List; 7 | 8 | public class ScatterBuffer extends AbstractBuffer { 9 | 10 | public ScatterBuffer(int size) { 11 | super(size); 12 | } 13 | 14 | protected void addForm(float x, float y) { 15 | buffer[index++] = x; 16 | buffer[index++] = y; 17 | } 18 | 19 | @Override 20 | public void feed(List entries) { 21 | 22 | float size = entries.size() * phaseX; 23 | 24 | for (int i = 0; i < size; i++) { 25 | 26 | Entry e = entries.get(i); 27 | addForm(e.getXIndex(), e.getVal() * phaseY); 28 | } 29 | 30 | reset(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/lib/mplib/src/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.data.BubbleDataSet; 9 | import com.github.mikephil.charting.interfaces.BubbleDataProvider; 10 | import com.github.mikephil.charting.renderer.BubbleChartRenderer; 11 | 12 | /** 13 | * The BubbleChart. Draws bubbles. Bubble chart implementation: Copyright 2015 14 | * Pierre-Marc Airoldi Licensed under Apache License 2.0. In the BubbleChart, it 15 | * is the area of the bubble, not the radius or diameter of the bubble that 16 | * conveys the data. 17 | * 18 | * @author Philipp Jahoda 19 | */ 20 | public class BubbleChart extends BarLineChartBase implements BubbleDataProvider { 21 | 22 | public BubbleChart(Context context) { 23 | super(context); 24 | } 25 | 26 | public BubbleChart(Context context, AttributeSet attrs) { 27 | super(context, attrs); 28 | } 29 | 30 | public BubbleChart(Context context, AttributeSet attrs, int defStyle) { 31 | super(context, attrs, defStyle); 32 | } 33 | 34 | @Override 35 | protected void init() { 36 | super.init(); 37 | 38 | mRenderer = new BubbleChartRenderer(this, mAnimator, mViewPortHandler); 39 | } 40 | 41 | @Override 42 | protected void calcMinMax() { 43 | super.calcMinMax(); 44 | 45 | if (mDeltaX == 0 && mData.getYValCount() > 0) 46 | mDeltaX = 1; 47 | 48 | mXChartMin = -0.5f; 49 | mXChartMax = (float) mData.getXValCount() - 0.5f; 50 | 51 | if (mRenderer != null) { 52 | for (BubbleDataSet set : mData.getDataSets()) { 53 | 54 | final float xmin = set.getXMin(); 55 | final float xmax = set.getXMax(); 56 | 57 | if (xmin < mXChartMin) 58 | mXChartMin = xmin; 59 | 60 | if (xmax > mXChartMax) 61 | mXChartMax = xmax; 62 | } 63 | } 64 | 65 | mDeltaX = Math.abs(mXChartMax - mXChartMin); 66 | } 67 | 68 | public BubbleData getBubbleData() { 69 | return mData; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /app/lib/mplib/src/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.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 | mXChartMin = -0.5f; 36 | } 37 | 38 | @Override 39 | protected void calcMinMax() { 40 | super.calcMinMax(); 41 | 42 | mXChartMax += 0.5f; 43 | mDeltaX = Math.abs(mXChartMax - mXChartMin); 44 | } 45 | 46 | @Override 47 | public CandleData getCandleData() { 48 | return mData; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/lib/mplib/src/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.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 | protected void calcMinMax() { 39 | super.calcMinMax(); 40 | 41 | if (mDeltaX == 0 && mData.getYValCount() > 0) 42 | mDeltaX = 1; 43 | } 44 | 45 | @Override 46 | public LineData getLineData() { 47 | return mData; 48 | } 49 | 50 | @Override 51 | protected void onDetachedFromWindow() { 52 | // releases the bitmap in the renderer to avoid oom error 53 | if(mRenderer != null && mRenderer instanceof LineChartRenderer) { 54 | ((LineChartRenderer) mRenderer).releaseBitmap(); 55 | } 56 | super.onDetachedFromWindow(); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /app/lib/mplib/src/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.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 | /** 21 | * enum that defines the shape that is drawn where the values are, CIRCLE 22 | * and SCQUARE offer the best performance, TRIANGLE has the worst 23 | * performance. 24 | */ 25 | public enum ScatterShape { 26 | CROSS, TRIANGLE, CIRCLE, SQUARE 27 | } 28 | 29 | public ScatterChart(Context context) { 30 | super(context); 31 | } 32 | 33 | public ScatterChart(Context context, AttributeSet attrs) { 34 | super(context, attrs); 35 | } 36 | 37 | public ScatterChart(Context context, AttributeSet attrs, int defStyle) { 38 | super(context, attrs, defStyle); 39 | } 40 | 41 | @Override 42 | protected void init() { 43 | super.init(); 44 | 45 | mRenderer = new ScatterChartRenderer(this, mAnimator, mViewPortHandler); 46 | mXChartMin = -0.5f; 47 | } 48 | 49 | @Override 50 | protected void calcMinMax() { 51 | super.calcMinMax(); 52 | 53 | if (mDeltaX == 0 && mData.getYValCount() > 0) 54 | mDeltaX = 1; 55 | 56 | mXChartMax += 0.5f; 57 | mDeltaX = Math.abs(mXChartMax - mXChartMin); 58 | } 59 | 60 | /** 61 | * Returns all possible predefined ScatterShapes. 62 | * 63 | * @return 64 | */ 65 | public static ScatterShape[] getAllPossibleShapes() { 66 | return new ScatterShape[] { 67 | ScatterShape.SQUARE, ScatterShape.CIRCLE, ScatterShape.TRIANGLE, ScatterShape.CROSS 68 | }; 69 | } 70 | 71 | public ScatterData getScatterData() { 72 | return mData; 73 | }; 74 | } 75 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/components/ComponentBase.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.components; 3 | 4 | import android.graphics.Color; 5 | import android.graphics.Typeface; 6 | 7 | import com.github.mikephil.charting.utils.Utils; 8 | 9 | /** 10 | * This class encapsulates everything both Axis, Legend and LimitLines have in common. 11 | * 12 | * @author Philipp Jahoda 13 | */ 14 | public abstract class ComponentBase { 15 | 16 | /** 17 | * flag that indicates if this axis / legend is enabled or not 18 | */ 19 | protected boolean mEnabled = true; 20 | 21 | /** 22 | * the offset in pixels this axis labels have on the x-axis 23 | */ 24 | protected float mXOffset = 5f; 25 | 26 | /** 27 | * the offset in pixels this axis labels have on the Y-axis 28 | */ 29 | protected float mYOffset = 5f; 30 | 31 | /** 32 | * the typeface used for the labels 33 | */ 34 | protected Typeface mTypeface = null; 35 | 36 | /** 37 | * the text size of the labels 38 | */ 39 | protected float mTextSize = 10f; 40 | 41 | /** 42 | * the text color to use for the labels 43 | */ 44 | protected int mTextColor = Color.BLACK; 45 | 46 | public ComponentBase() { 47 | 48 | } 49 | 50 | /** 51 | * Returns the used offset on the x-axis for drawing the axis or legend 52 | * labels. This offset is applied before and after the label. 53 | * 54 | * @return 55 | */ 56 | public float getXOffset() { 57 | return mXOffset; 58 | } 59 | 60 | /** 61 | * Sets the used x-axis offset for the labels on this axis. 62 | * 63 | * @param xOffset 64 | */ 65 | public void setXOffset(float xOffset) { 66 | mXOffset = Utils.convertDpToPixel(xOffset); 67 | } 68 | 69 | /** 70 | * Returns the used offset on the x-axis for drawing the axis labels. This 71 | * offset is applied before and after the label. 72 | * 73 | * @return 74 | */ 75 | public float getYOffset() { 76 | return mYOffset; 77 | } 78 | 79 | /** 80 | * Sets the used y-axis offset for the labels on this axis. For the legend, 81 | * higher offset means the legend as a whole will be placed further away 82 | * from the top. 83 | * 84 | * @param yOffset 85 | */ 86 | public void setYOffset(float yOffset) { 87 | mYOffset = Utils.convertDpToPixel(yOffset); 88 | } 89 | 90 | /** 91 | * returns the Typeface used for the labels, returns null if none is set 92 | * 93 | * @return 94 | */ 95 | public Typeface getTypeface() { 96 | return mTypeface; 97 | } 98 | 99 | /** 100 | * sets a specific Typeface for the labels 101 | * 102 | * @param tf 103 | */ 104 | public void setTypeface(Typeface tf) { 105 | mTypeface = tf; 106 | } 107 | 108 | /** 109 | * sets the size of the label text in pixels min = 6f, max = 24f, default 110 | * 10f 111 | * 112 | * @param size 113 | */ 114 | public void setTextSize(float size) { 115 | 116 | if (size > 24f) 117 | size = 24f; 118 | if (size < 6f) 119 | size = 6f; 120 | 121 | mTextSize = Utils.convertDpToPixel(size); 122 | } 123 | 124 | /** 125 | * returns the text size that is currently set for the labels 126 | * 127 | * @return 128 | */ 129 | public float getTextSize() { 130 | return mTextSize; 131 | } 132 | 133 | /** 134 | * Sets the text color to use for the labels. Make sure to use 135 | * getResources().getColor(...) when using a color from the resources. 136 | * 137 | * @param color 138 | */ 139 | public void setTextColor(int color) { 140 | mTextColor = color; 141 | } 142 | 143 | /** 144 | * Returns the text color that is set for the labels. 145 | * 146 | * @return 147 | */ 148 | public int getTextColor() { 149 | return mTextColor; 150 | } 151 | 152 | /** 153 | * Set this to true if this component should be enabled (should be drawn), 154 | * false if not. If disabled, nothing of this component will be drawn. 155 | * Default: true 156 | * 157 | * @param enabled 158 | */ 159 | public void setEnabled(boolean enabled) { 160 | mEnabled = enabled; 161 | } 162 | 163 | /** 164 | * Returns true if this comonent is enabled (should be drawn), false if not. 165 | * 166 | * @return 167 | */ 168 | public boolean isEnabled() { 169 | return mEnabled; 170 | } 171 | } 172 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/components/MarkerView.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.components; 2 | 3 | import android.content.Context; 4 | import android.graphics.Canvas; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.widget.RelativeLayout; 8 | 9 | import com.github.mikephil.charting.data.Entry; 10 | import com.github.mikephil.charting.highlight.Highlight; 11 | 12 | /** 13 | * View that can be displayed when selecting values in the chart. Extend this class to provide custom layouts for your 14 | * markers. 15 | * 16 | * @author Philipp Jahoda 17 | */ 18 | public abstract class MarkerView extends RelativeLayout { 19 | 20 | /** 21 | * Constructor. Sets up the MarkerView with a custom layout resource. 22 | * 23 | * @param context 24 | * @param layoutResource the layout resource to use for the MarkerView 25 | */ 26 | public MarkerView(Context context, int layoutResource) { 27 | super(context); 28 | setupLayoutResource(layoutResource); 29 | } 30 | 31 | /** 32 | * Sets the layout resource for a custom MarkerView. 33 | * 34 | * @param layoutResource 35 | */ 36 | private void setupLayoutResource(int layoutResource) { 37 | 38 | View inflated = LayoutInflater.from(getContext()).inflate(layoutResource, this); 39 | 40 | inflated.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); 41 | inflated.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); 42 | 43 | // measure(getWidth(), getHeight()); 44 | inflated.layout(0, 0, inflated.getMeasuredWidth(), inflated.getMeasuredHeight()); 45 | } 46 | 47 | /** 48 | * Draws the MarkerView on the given position on the screen with the given Canvas object. 49 | * 50 | * @param canvas 51 | * @param posx 52 | * @param posy 53 | */ 54 | public void draw(Canvas canvas, float posx, float posy) { 55 | 56 | // take offsets into consideration 57 | posx += getXOffset(posx); 58 | posy += getYOffset(posy); 59 | 60 | // translate to the correct position and draw 61 | canvas.translate(posx, posy); 62 | draw(canvas); 63 | canvas.translate(-posx, -posy); 64 | } 65 | 66 | /** 67 | * This method enables a specified custom MarkerView to update it's content everytime the MarkerView is redrawn. 68 | * 69 | * @param e The Entry the MarkerView belongs to. This can also be any subclass of Entry, like BarEntry or 70 | * CandleEntry, simply cast it at runtime. 71 | * @param highlight the highlight object contains information about the highlighted value such as it's dataset-index, the 72 | * selected range or stack-index (only stacked bar entries). 73 | */ 74 | public abstract void refreshContent(Entry e, Highlight highlight); 75 | 76 | /** 77 | * Use this to return the desired offset you wish the MarkerView to have on the x-axis. By returning -(getWidth() / 78 | * 2) you will center the MarkerView horizontally. 79 | * 80 | * @param xpos the position on the x-axis in pixels where the marker is drawn 81 | * @return 82 | */ 83 | public abstract int getXOffset(float xpos); 84 | 85 | /** 86 | * Use this to return the desired position offset you wish the MarkerView to have on the y-axis. By returning 87 | * -getHeight() you will cause the MarkerView to be above the selected value. 88 | * 89 | * @param ypos the position on the y-axis in pixels where the marker is drawn 90 | * @return 91 | */ 92 | public abstract int getYOffset(float ypos); 93 | } 94 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/data/BarData.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.data; 3 | 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | /** 8 | * Data object that represents all data for the BarChart. 9 | * 10 | * @author Philipp Jahoda 11 | */ 12 | public class BarData extends BarLineScatterCandleBubbleData { 13 | 14 | /** the space that is left between groups of bars */ 15 | private float mGroupSpace = 0.8f; 16 | 17 | // /** 18 | // * The maximum space (in pixels on the screen) a single bar can consume. 19 | // */ 20 | // private float mMaximumBarWidth = 100f; 21 | 22 | public BarData() { 23 | super(); 24 | } 25 | 26 | public BarData(List xVals) { 27 | super(xVals); 28 | } 29 | 30 | public BarData(String[] xVals) { 31 | super(xVals); 32 | } 33 | 34 | public BarData(List xVals, List dataSets) { 35 | super(xVals, dataSets); 36 | } 37 | 38 | public BarData(String[] xVals, List dataSets) { 39 | super(xVals, dataSets); 40 | } 41 | 42 | public BarData(List xVals, BarDataSet dataSet) { 43 | super(xVals, toList(dataSet)); 44 | } 45 | 46 | public BarData(String[] xVals, BarDataSet dataSet) { 47 | super(xVals, toList(dataSet)); 48 | } 49 | 50 | private static List toList(BarDataSet dataSet) { 51 | List sets = new ArrayList(); 52 | sets.add(dataSet); 53 | return sets; 54 | } 55 | 56 | /** 57 | * Returns the space that is left out between groups of bars. Always returns 58 | * 0 if the BarData object only contains one DataSet (because for one 59 | * DataSet, there is no group-space needed). 60 | * 61 | * @return 62 | */ 63 | public float getGroupSpace() { 64 | 65 | if (mDataSets.size() <= 1) 66 | return 0f; 67 | else 68 | return mGroupSpace; 69 | } 70 | 71 | /** 72 | * Sets the space between groups of bars of different datasets in percent of 73 | * the total width of one bar. 100 = space is exactly one bar width, 74 | * default: 80 75 | * 76 | * @param percent 77 | */ 78 | public void setGroupSpace(float percent) { 79 | mGroupSpace = percent / 100f; 80 | } 81 | 82 | /** 83 | * Returns true if this BarData object contains grouped DataSets (more than 84 | * 1 DataSet). 85 | * 86 | * @return 87 | */ 88 | public boolean isGrouped() { 89 | return mDataSets.size() > 1 ? true : false; 90 | } 91 | 92 | // 93 | // /** 94 | // * Sets the maximum width (in density pixels) a single bar in the barchart 95 | // * should consume. 96 | // * 97 | // * @param max 98 | // */ 99 | // public void setBarWidthMaximum(float max) { 100 | // mMaximumBarWidth = Utils.convertDpToPixel(max); 101 | // } 102 | // 103 | // /** 104 | // * Returns the maximum width (in density pixels) a single bar in the 105 | // * barchart should consume. 106 | // * 107 | // * @return 108 | // */ 109 | // public float getBarWidthMaximum() { 110 | // return mMaximumBarWidth; 111 | // } 112 | } 113 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/data/BarEntry.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.data; 2 | 3 | /** 4 | * Entry class for the BarChart. (especially stacked bars) 5 | * 6 | * @author Philipp Jahoda 7 | */ 8 | public class BarEntry extends Entry { 9 | 10 | /** the values the stacked barchart holds */ 11 | private float[] mVals; 12 | 13 | /** the sum of all negative values this entry (if stacked) contains */ 14 | private float mNegativeSum; 15 | 16 | /** the sum of all positive values this entry (if stacked) contains */ 17 | private float mPositiveSum; 18 | 19 | /** 20 | * Constructor for stacked bar entries. 21 | * 22 | * @param vals 23 | * - the stack values, use at lest 2 24 | * @param xIndex 25 | */ 26 | public BarEntry(float[] vals, int xIndex) { 27 | super(calcSum(vals), xIndex); 28 | 29 | this.mVals = vals; 30 | calcPosNegSum(); 31 | } 32 | 33 | /** 34 | * Constructor for normal bars (not stacked). 35 | * 36 | * @param val 37 | * @param xIndex 38 | */ 39 | public BarEntry(float val, int xIndex) { 40 | super(val, xIndex); 41 | } 42 | 43 | /** 44 | * Constructor for stacked bar entries. 45 | * 46 | * @param vals 47 | * - the stack values, use at least 2 48 | * @param xIndex 49 | * @param label 50 | * Additional description label. 51 | */ 52 | public BarEntry(float[] vals, int xIndex, String label) { 53 | super(calcSum(vals), xIndex, label); 54 | 55 | this.mVals = vals; 56 | calcPosNegSum(); 57 | } 58 | 59 | /** 60 | * Constructor for normal bars (not stacked). 61 | * 62 | * @param val 63 | * @param xIndex 64 | * @param data 65 | * Spot for additional data this Entry represents. 66 | */ 67 | public BarEntry(float val, int xIndex, Object data) { 68 | super(val, xIndex, data); 69 | } 70 | 71 | /** 72 | * Returns an exact copy of the BarEntry. 73 | */ 74 | public BarEntry copy() { 75 | 76 | BarEntry copied = new BarEntry(getVal(), getXIndex(), getData()); 77 | copied.setVals(mVals); 78 | return copied; 79 | } 80 | 81 | /** 82 | * Returns the stacked values this BarEntry represents, or null, if only a single value is represented (then, use 83 | * getVal()). 84 | * 85 | * @return 86 | */ 87 | public float[] getVals() { 88 | return mVals; 89 | } 90 | 91 | /** 92 | * Set the array of values this BarEntry should represent. 93 | * 94 | * @param vals 95 | */ 96 | public void setVals(float[] vals) { 97 | setVal(calcSum(vals)); 98 | mVals = vals; 99 | calcPosNegSum(); 100 | } 101 | 102 | /** 103 | * Returns the value of this BarEntry. If the entry is stacked, it returns the positive sum of all values. 104 | * 105 | * @return 106 | */ 107 | @Override 108 | public float getVal() { 109 | return super.getVal(); 110 | } 111 | 112 | /** 113 | * Returns true if this BarEntry is stacked (has a values array), false if not. 114 | * 115 | * @return 116 | */ 117 | public boolean isStacked() { 118 | return mVals != null; 119 | } 120 | 121 | public float getBelowSum(int stackIndex) { 122 | 123 | if (mVals == null) 124 | return 0; 125 | 126 | float remainder = 0f; 127 | int index = mVals.length - 1; 128 | 129 | while (index > stackIndex && index >= 0) { 130 | remainder += mVals[index]; 131 | index--; 132 | } 133 | 134 | return remainder; 135 | } 136 | 137 | /** 138 | * Reuturns the sum of all positive values this entry (if stacked) contains. 139 | * 140 | * @return 141 | */ 142 | public float getPositiveSum() { 143 | return mPositiveSum; 144 | } 145 | 146 | /** 147 | * Returns the sum of all negative values this entry (if stacked) contains. (this is a positive number) 148 | * 149 | * @return 150 | */ 151 | public float getNegativeSum() { 152 | return mNegativeSum; 153 | } 154 | 155 | private void calcPosNegSum() { 156 | 157 | if (mVals == null) { 158 | mNegativeSum = 0; 159 | mPositiveSum = 0; 160 | return; 161 | } 162 | 163 | float sumNeg = 0f; 164 | float sumPos = 0f; 165 | 166 | for (float f : mVals) { 167 | if (f <= 0f) 168 | sumNeg += Math.abs(f); 169 | else 170 | sumPos += f; 171 | } 172 | 173 | mNegativeSum = sumNeg; 174 | mPositiveSum = sumPos; 175 | } 176 | 177 | /** 178 | * Calculates the sum across all values of the given stack. 179 | * 180 | * @param vals 181 | * @return 182 | */ 183 | private static float calcSum(float[] vals) { 184 | 185 | if (vals == null) 186 | return 0f; 187 | 188 | float sum = 0f; 189 | 190 | for (float f : vals) 191 | sum += f; 192 | 193 | return sum; 194 | } 195 | } 196 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/data/BarLineScatterCandleBubbleData.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.data; 3 | 4 | import java.util.List; 5 | 6 | /** 7 | * Baseclass for all Line, Bar, Scatter, Candle and Bubble data. 8 | * 9 | * @author Philipp Jahoda 10 | */ 11 | public abstract class BarLineScatterCandleBubbleData> 12 | extends ChartData { 13 | 14 | public BarLineScatterCandleBubbleData() { 15 | super(); 16 | } 17 | 18 | public BarLineScatterCandleBubbleData(List xVals) { 19 | super(xVals); 20 | } 21 | 22 | public BarLineScatterCandleBubbleData(String[] xVals) { 23 | super(xVals); 24 | } 25 | 26 | public BarLineScatterCandleBubbleData(List xVals, List sets) { 27 | super(xVals, sets); 28 | } 29 | 30 | public BarLineScatterCandleBubbleData(String[] xVals, List sets) { 31 | super(xVals, sets); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/data/BarLineScatterCandleBubbleDataSet.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.data; 3 | 4 | import android.graphics.Color; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Baseclass of all DataSets for Bar-, Line-, Scatter- and CandleStickChart. 10 | * 11 | * @author Philipp Jahoda 12 | */ 13 | public abstract class BarLineScatterCandleBubbleDataSet extends DataSet { 14 | 15 | /** default highlight color */ 16 | protected int mHighLightColor = Color.rgb(255, 187, 115); 17 | 18 | public BarLineScatterCandleBubbleDataSet(List yVals, String label) { 19 | super(yVals, label); 20 | } 21 | 22 | /** 23 | * Sets the color that is used for drawing the highlight indicators. Dont 24 | * forget to resolve the color using getResources().getColor(...) or 25 | * Color.rgb(...). 26 | * 27 | * @param color 28 | */ 29 | public void setHighLightColor(int color) { 30 | mHighLightColor = color; 31 | } 32 | 33 | /** 34 | * Returns the color that is used for drawing the highlight indicators. 35 | * 36 | * @return 37 | */ 38 | public int getHighLightColor() { 39 | return mHighLightColor; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/data/BubbleData.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.data; 3 | 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | public class BubbleData extends BarLineScatterCandleBubbleData { 8 | 9 | public BubbleData() { 10 | super(); 11 | } 12 | 13 | public BubbleData(List xVals) { 14 | super(xVals); 15 | } 16 | 17 | public BubbleData(String[] xVals) { 18 | super(xVals); 19 | } 20 | 21 | public BubbleData(List xVals, List dataSets) { 22 | super(xVals, dataSets); 23 | } 24 | 25 | public BubbleData(String[] xVals, List dataSets) { 26 | super(xVals, dataSets); 27 | } 28 | 29 | public BubbleData(List xVals, BubbleDataSet dataSet) { 30 | super(xVals, toList(dataSet)); 31 | } 32 | 33 | public BubbleData(String[] xVals, BubbleDataSet dataSet) { 34 | super(xVals, toList(dataSet)); 35 | } 36 | 37 | private static List toList(BubbleDataSet dataSet) { 38 | List sets = new ArrayList(); 39 | sets.add(dataSet); 40 | return sets; 41 | } 42 | 43 | /** 44 | * Sets the width of the circle that surrounds the bubble when highlighted 45 | * for all DataSet objects this data object contains, in dp. 46 | * 47 | * @param width 48 | */ 49 | public void setHighlightCircleWidth(float width) { 50 | for (BubbleDataSet set : mDataSets) { 51 | set.setHighlightCircleWidth(width); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/data/BubbleDataSet.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.data; 3 | 4 | import android.graphics.Color; 5 | 6 | import com.github.mikephil.charting.utils.Utils; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | public class BubbleDataSet extends BarLineScatterCandleBubbleDataSet { 12 | 13 | // NOTE: Do not initialize these, as the calcMinMax is called by the super, 14 | // and the initializers are called after that and can reset the values 15 | protected float mXMax; 16 | protected float mXMin; 17 | protected float mMaxSize; 18 | 19 | private float mHighlightCircleWidth = 2.5f; 20 | 21 | public BubbleDataSet(List yVals, String label) { 22 | super(yVals, label); 23 | } 24 | 25 | /** 26 | * Sets the width of the circle that surrounds the bubble when highlighted, 27 | * in dp. 28 | * 29 | * @param width 30 | */ 31 | public void setHighlightCircleWidth(float width) { 32 | mHighlightCircleWidth = Utils.convertDpToPixel(width); 33 | } 34 | 35 | public float getHighlightCircleWidth() { 36 | return mHighlightCircleWidth; 37 | } 38 | 39 | /** 40 | * Sets a color with a specific alpha value. 41 | * @param color 42 | * @param alpha from 0-255 43 | */ 44 | public void setColor(int color, int alpha) { 45 | super.setColor(Color.argb(alpha, Color.red(color), Color.green(color), Color.blue(color))); 46 | } 47 | 48 | @Override 49 | protected void calcMinMax(int start, int end) { 50 | if (mYVals.size() == 0) 51 | return; 52 | 53 | final List entries = getYVals(); 54 | 55 | int endValue; 56 | 57 | if (end == 0) 58 | endValue = mYVals.size() - 1; 59 | else 60 | endValue = end; 61 | 62 | mLastStart = start; 63 | mLastEnd = endValue; 64 | 65 | mYMin = yMin(entries.get(start)); 66 | mYMax = yMax(entries.get(start)); 67 | 68 | // need chart width to guess this properly 69 | 70 | for (int i = start; i <= endValue; i++) { 71 | 72 | final BubbleEntry entry = entries.get(i); 73 | 74 | final float ymin = yMin(entry); 75 | final float ymax = yMax(entry); 76 | 77 | if (ymin < mYMin) 78 | { 79 | mYMin = ymin; 80 | } 81 | 82 | if (ymax > mYMax) 83 | { 84 | mYMax = ymax; 85 | } 86 | 87 | final float xmin = xMin(entry); 88 | final float xmax = xMax(entry); 89 | 90 | if (xmin < mXMin) 91 | { 92 | mXMin = xmin; 93 | } 94 | 95 | if (xmax > mXMax) 96 | { 97 | mXMax = xmax; 98 | } 99 | 100 | final float size = largestSize(entry); 101 | 102 | if (size > mMaxSize) 103 | { 104 | mMaxSize = size; 105 | } 106 | } 107 | } 108 | 109 | @Override 110 | public DataSet copy() { 111 | 112 | List yVals = new ArrayList(); 113 | 114 | for (int i = 0; i < mYVals.size(); i++) { 115 | yVals.add(mYVals.get(i).copy()); 116 | } 117 | 118 | BubbleDataSet copied = new BubbleDataSet(yVals, getLabel()); 119 | copied.mColors = mColors; 120 | copied.mHighLightColor = mHighLightColor; 121 | 122 | return copied; 123 | } 124 | 125 | public float getXMax() { 126 | return mXMax; 127 | } 128 | 129 | public float getXMin() { 130 | return mXMin; 131 | } 132 | 133 | public float getMaxSize() { 134 | return mMaxSize; 135 | } 136 | 137 | private float yMin(BubbleEntry entry) { 138 | return entry.getVal(); 139 | } 140 | 141 | private float yMax(BubbleEntry entry) { 142 | return entry.getVal(); 143 | } 144 | 145 | private float xMin(BubbleEntry entry) { 146 | return (float) entry.getXIndex(); 147 | } 148 | 149 | private float xMax(BubbleEntry entry) { 150 | return (float) entry.getXIndex(); 151 | } 152 | 153 | private float largestSize(BubbleEntry entry) { 154 | return entry.getSize(); 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/data/BubbleEntry.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.data; 3 | 4 | /** 5 | * Subclass of Entry that holds a value for one entry in a BubbleChart. Bubble 6 | * chart implementation: Copyright 2015 Pierre-Marc Airoldi Licensed under 7 | * Apache License 2.0 8 | * 9 | * @author Philipp Jahoda 10 | */ 11 | public class BubbleEntry extends Entry { 12 | 13 | /** size value */ 14 | private float mSize = 0f; 15 | 16 | /** 17 | * Constructor. 18 | * 19 | * @param xIndex The index on the x-axis. 20 | * @param val The value on the y-axis. 21 | * @param size The size of the bubble. 22 | */ 23 | public BubbleEntry(int xIndex, float val, float size) { 24 | super(val, xIndex); 25 | 26 | this.mSize = size; 27 | } 28 | 29 | /** 30 | * Constructor. 31 | * 32 | * @param xIndex The index on the x-axis. 33 | * @param val The value on the y-axis. 34 | * @param size The size of the bubble. 35 | * @param data Spot for additional data this Entry represents. 36 | */ 37 | public BubbleEntry(int xIndex, float val, float size, Object data) { 38 | super(val, xIndex, data); 39 | 40 | this.mSize = size; 41 | } 42 | 43 | public BubbleEntry copy() { 44 | 45 | BubbleEntry c = new BubbleEntry(getXIndex(), getVal(), mSize, getData()); 46 | 47 | return c; 48 | } 49 | 50 | /** 51 | * Returns the size of this entry (the size of the bubble). 52 | * 53 | * @return 54 | */ 55 | public float getSize() { 56 | return mSize; 57 | } 58 | 59 | public void setSize(float size) { 60 | this.mSize = size; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/data/CandleData.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.data; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class CandleData extends BarLineScatterCandleBubbleData { 7 | 8 | public CandleData() { 9 | super(); 10 | } 11 | 12 | public CandleData(List xVals) { 13 | super(xVals); 14 | } 15 | 16 | public CandleData(String[] xVals) { 17 | super(xVals); 18 | } 19 | 20 | public CandleData(List xVals, List dataSets) { 21 | super(xVals, dataSets); 22 | } 23 | 24 | public CandleData(String[] xVals, List dataSets) { 25 | super(xVals, dataSets); 26 | } 27 | 28 | public CandleData(List xVals, CandleDataSet dataSet) { 29 | super(xVals, toList(dataSet)); 30 | } 31 | 32 | public CandleData(String[] xVals, CandleDataSet dataSet) { 33 | super(xVals, toList(dataSet)); 34 | } 35 | 36 | private static List toList(CandleDataSet dataSet) { 37 | List sets = new ArrayList(); 38 | sets.add(dataSet); 39 | return sets; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/data/CandleEntry.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.data; 3 | 4 | /** 5 | * Subclass of Entry that holds all values for one entry in a CandleStickChart. 6 | * 7 | * @author Philipp Jahoda 8 | */ 9 | public class CandleEntry extends Entry { 10 | 11 | /** shadow-high value */ 12 | private float mShadowHigh = 0f; 13 | 14 | /** shadow-low value */ 15 | private float mShadowLow = 0f; 16 | 17 | /** close value */ 18 | private float mClose = 0f; 19 | 20 | /** open value */ 21 | private float mOpen = 0f; 22 | 23 | /** 24 | * Constructor. 25 | * 26 | * @param xIndex The index on the x-axis. 27 | * @param shadowH The (shadow) high value. 28 | * @param shadowL The (shadow) low value. 29 | * @param open The open value. 30 | * @param close The close value. 31 | */ 32 | public CandleEntry(int xIndex, float shadowH, float shadowL, float open, float close) { 33 | super((shadowH + shadowL) / 2f, xIndex); 34 | 35 | this.mShadowHigh = shadowH; 36 | this.mShadowLow = shadowL; 37 | this.mOpen = open; 38 | this.mClose = close; 39 | } 40 | 41 | /** 42 | * Constructor. 43 | * 44 | * @param xIndex The index on the x-axis. 45 | * @param shadowH The (shadow) high value. 46 | * @param shadowL The (shadow) low value. 47 | * @param open 48 | * @param close 49 | * @param data Spot for additional data this Entry represents. 50 | */ 51 | public CandleEntry(int xIndex, float shadowH, float shadowL, float open, float close, 52 | Object data) { 53 | super((shadowH + shadowL) / 2f, xIndex, data); 54 | 55 | this.mShadowHigh = shadowH; 56 | this.mShadowLow = shadowL; 57 | this.mOpen = open; 58 | this.mClose = close; 59 | } 60 | 61 | /** 62 | * Returns the overall range (difference) between shadow-high and 63 | * shadow-low. 64 | * 65 | * @return 66 | */ 67 | public float getShadowRange() { 68 | return Math.abs(mShadowHigh - mShadowLow); 69 | } 70 | 71 | /** 72 | * Returns the body size (difference between open and close). 73 | * 74 | * @return 75 | */ 76 | public float getBodyRange() { 77 | return Math.abs(mOpen - mClose); 78 | } 79 | 80 | /** 81 | * Returns the center value of the candle. (Middle value between high and 82 | * low) 83 | */ 84 | @Override 85 | public float getVal() { 86 | return super.getVal(); 87 | } 88 | 89 | public CandleEntry copy() { 90 | 91 | CandleEntry c = new CandleEntry(getXIndex(), mShadowHigh, mShadowLow, mOpen, 92 | mClose, getData()); 93 | 94 | return c; 95 | } 96 | 97 | /** 98 | * Returns the upper shadows highest value. 99 | * 100 | * @return 101 | */ 102 | public float getHigh() { 103 | return mShadowHigh; 104 | } 105 | 106 | public void setHigh(float mShadowHigh) { 107 | this.mShadowHigh = mShadowHigh; 108 | } 109 | 110 | /** 111 | * Returns the lower shadows lowest value. 112 | * 113 | * @return 114 | */ 115 | public float getLow() { 116 | return mShadowLow; 117 | } 118 | 119 | public void setLow(float mShadowLow) { 120 | this.mShadowLow = mShadowLow; 121 | } 122 | 123 | /** 124 | * Returns the bodys close value. 125 | * 126 | * @return 127 | */ 128 | public float getClose() { 129 | return mClose; 130 | } 131 | 132 | public void setClose(float mClose) { 133 | this.mClose = mClose; 134 | } 135 | 136 | /** 137 | * Returns the bodys open value. 138 | * 139 | * @return 140 | */ 141 | public float getOpen() { 142 | return mOpen; 143 | } 144 | 145 | public void setOpen(float mOpen) { 146 | this.mOpen = mOpen; 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/data/CombinedData.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.data; 3 | 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | /** 8 | * Data object that allows the combination of Line-, Bar-, Scatter-, Bubble- and 9 | * CandleData. Used in the CombinedChart class. 10 | * 11 | * @author Philipp Jahoda 12 | */ 13 | public class CombinedData extends BarLineScatterCandleBubbleData> { 14 | 15 | private LineData mLineData; 16 | private BarData mBarData; 17 | private ScatterData mScatterData; 18 | private CandleData mCandleData; 19 | private BubbleData mBubbleData; 20 | 21 | public CombinedData() { 22 | super(); 23 | } 24 | 25 | public CombinedData(List xVals) { 26 | super(xVals); 27 | } 28 | 29 | public CombinedData(String[] xVals) { 30 | super(xVals); 31 | } 32 | 33 | public void setData(LineData data) { 34 | mLineData = data; 35 | mDataSets.addAll(data.getDataSets()); 36 | init(); 37 | } 38 | 39 | public void setData(BarData data) { 40 | mBarData = data; 41 | mDataSets.addAll(data.getDataSets()); 42 | init(); 43 | } 44 | 45 | public void setData(ScatterData data) { 46 | mScatterData = data; 47 | mDataSets.addAll(data.getDataSets()); 48 | init(); 49 | } 50 | 51 | public void setData(CandleData data) { 52 | mCandleData = data; 53 | mDataSets.addAll(data.getDataSets()); 54 | init(); 55 | } 56 | 57 | public void setData(BubbleData data) { 58 | mBubbleData = data; 59 | mDataSets.addAll(data.getDataSets()); 60 | init(); 61 | } 62 | 63 | public BubbleData getBubbleData() { 64 | return mBubbleData; 65 | } 66 | 67 | public LineData getLineData() { 68 | return mLineData; 69 | } 70 | 71 | public BarData getBarData() { 72 | return mBarData; 73 | } 74 | 75 | public ScatterData getScatterData() { 76 | return mScatterData; 77 | } 78 | 79 | public CandleData getCandleData() { 80 | return mCandleData; 81 | } 82 | 83 | /** 84 | * Returns all data objects in row: line-bar-scatter-candle-bubble if not null. 85 | * @return 86 | */ 87 | public List getAllData() { 88 | 89 | List data = new ArrayList(); 90 | if(mLineData != null) 91 | data.add(mLineData); 92 | if(mBarData != null) 93 | data.add(mBarData); 94 | if(mScatterData != null) 95 | data.add(mScatterData); 96 | if(mCandleData != null) 97 | data.add(mCandleData); 98 | if(mBubbleData != null) 99 | data.add(mBubbleData); 100 | 101 | return data; 102 | } 103 | 104 | @Override 105 | public void notifyDataChanged() { 106 | if (mLineData != null) 107 | mLineData.notifyDataChanged(); 108 | if (mBarData != null) 109 | mBarData.notifyDataChanged(); 110 | if (mCandleData != null) 111 | mCandleData.notifyDataChanged(); 112 | if (mScatterData != null) 113 | mScatterData.notifyDataChanged(); 114 | if (mBubbleData != null) 115 | mBubbleData.notifyDataChanged(); 116 | 117 | init(); // recalculate everything 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/data/Entry.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.data; 3 | 4 | import android.os.Parcel; 5 | import android.os.ParcelFormatException; 6 | import android.os.Parcelable; 7 | 8 | /** 9 | * Class representing one entry in the chart. Might contain multiple values. 10 | * Might only contain a single value depending on the used constructor. 11 | * 12 | * @author Philipp Jahoda 13 | */ 14 | public class Entry implements Parcelable { 15 | 16 | /** the actual value */ 17 | private float mVal = 0f; 18 | 19 | /** the index on the x-axis */ 20 | private int mXIndex = 0; 21 | 22 | /** optional spot for additional data this Entry represents */ 23 | private Object mData = null; 24 | 25 | /** 26 | * A Entry represents one single entry in the chart. 27 | * 28 | * @param val the y value (the actual value of the entry) 29 | * @param xIndex the corresponding index in the x value array (index on the 30 | * x-axis of the chart, must NOT be higher than the length of the 31 | * x-values String array) 32 | */ 33 | public Entry(float val, int xIndex) { 34 | mVal = val; 35 | mXIndex = xIndex; 36 | } 37 | 38 | /** 39 | * A Entry represents one single entry in the chart. 40 | * 41 | * @param val the y value (the actual value of the entry) 42 | * @param xIndex the corresponding index in the x value array (index on the 43 | * x-axis of the chart, must NOT be higher than the length of the 44 | * x-values String array) 45 | * @param data Spot for additional data this Entry represents. 46 | */ 47 | public Entry(float val, int xIndex, Object data) { 48 | this(val, xIndex); 49 | 50 | this.mData = data; 51 | } 52 | 53 | /** 54 | * returns the x-index the value of this object is mapped to 55 | * 56 | * @return 57 | */ 58 | public int getXIndex() { 59 | return mXIndex; 60 | } 61 | 62 | /** 63 | * sets the x-index for the entry 64 | * 65 | * @param x 66 | */ 67 | public void setXIndex(int x) { 68 | this.mXIndex = x; 69 | } 70 | 71 | /** 72 | * Returns the total value the entry represents. 73 | * 74 | * @return 75 | */ 76 | public float getVal() { 77 | return mVal; 78 | } 79 | 80 | /** 81 | * Sets the value for the entry. 82 | * 83 | * @param val 84 | */ 85 | public void setVal(float val) { 86 | this.mVal = val; 87 | } 88 | 89 | /** 90 | * Returns the data, additional information that this Entry represents, or 91 | * null, if no data has been specified. 92 | * 93 | * @return 94 | */ 95 | public Object getData() { 96 | return mData; 97 | } 98 | 99 | /** 100 | * Sets additional data this Entry should represent. 101 | * 102 | * @param data 103 | */ 104 | public void setData(Object data) { 105 | this.mData = data; 106 | } 107 | 108 | /** 109 | * returns an exact copy of the entry 110 | * 111 | * @return 112 | */ 113 | public Entry copy() { 114 | Entry e = new Entry(mVal, mXIndex, mData); 115 | return e; 116 | } 117 | 118 | /** 119 | * Compares value, xIndex and data of the entries. Returns true if entries 120 | * are equal in those points, false if not. Does not check by hash-code like 121 | * it's done by the "equals" method. 122 | * 123 | * @param e 124 | * @return 125 | */ 126 | public boolean equalTo(Entry e) { 127 | 128 | if (e == null) 129 | return false; 130 | 131 | if (e.mData != this.mData) 132 | return false; 133 | if (e.mXIndex != this.mXIndex) 134 | return false; 135 | 136 | if (Math.abs(e.mVal - this.mVal) > 0.00001f) 137 | return false; 138 | 139 | return true; 140 | } 141 | 142 | /** 143 | * returns a string representation of the entry containing x-index and value 144 | */ 145 | @Override 146 | public String toString() { 147 | return "Entry, xIndex: " + mXIndex + " val (sum): " + getVal(); 148 | } 149 | 150 | @Override 151 | public int describeContents() { 152 | return 0; 153 | } 154 | 155 | @Override 156 | public void writeToParcel(Parcel dest, int flags) { 157 | dest.writeFloat(this.mVal); 158 | dest.writeInt(this.mXIndex); 159 | if (mData != null) { 160 | if (mData instanceof Parcelable) { 161 | dest.writeInt(1); 162 | dest.writeParcelable((Parcelable) this.mData, flags); 163 | } else { 164 | throw new ParcelFormatException("Cannot parcel an Entry with non-parcelable data"); 165 | } 166 | } else { 167 | dest.writeInt(0); 168 | } 169 | } 170 | 171 | protected Entry(Parcel in) { 172 | this.mVal = in.readFloat(); 173 | this.mXIndex = in.readInt(); 174 | if (in.readInt() == 1) { 175 | this.mData = in.readParcelable(Object.class.getClassLoader()); 176 | } 177 | } 178 | 179 | public static final Creator CREATOR = new Creator() { 180 | public Entry createFromParcel(Parcel source) { 181 | return new Entry(source); 182 | } 183 | 184 | public Entry[] newArray(int size) { 185 | return new Entry[size]; 186 | } 187 | }; 188 | } 189 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/data/LineData.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.data; 3 | 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | /** 8 | * Data object that encapsulates all data associated with a LineChart. 9 | * 10 | * @author Philipp Jahoda 11 | */ 12 | public class LineData extends BarLineScatterCandleBubbleData { 13 | 14 | public LineData() { 15 | super(); 16 | } 17 | 18 | public LineData(List xVals) { 19 | super(xVals); 20 | } 21 | 22 | public LineData(String[] xVals) { 23 | super(xVals); 24 | } 25 | 26 | public LineData(List xVals, List dataSets) { 27 | super(xVals, dataSets); 28 | } 29 | 30 | public LineData(String[] xVals, List dataSets) { 31 | super(xVals, dataSets); 32 | } 33 | 34 | public LineData(List xVals, LineDataSet dataSet) { 35 | super(xVals, toList(dataSet)); 36 | } 37 | 38 | public LineData(String[] xVals, LineDataSet dataSet) { 39 | super(xVals, toList(dataSet)); 40 | } 41 | 42 | private static List toList(LineDataSet dataSet) { 43 | List sets = new ArrayList(); 44 | sets.add(dataSet); 45 | return sets; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/data/LineRadarDataSet.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.data; 3 | 4 | import android.graphics.Color; 5 | 6 | import com.github.mikephil.charting.utils.Utils; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Base dataset for line and radar DataSets. 12 | * 13 | * @author Philipp Jahoda 14 | */ 15 | public abstract class LineRadarDataSet extends LineScatterCandleRadarDataSet { 16 | 17 | /** the color that is used for filling the line surface */ 18 | private int mFillColor = Color.rgb(140, 234, 255); 19 | 20 | /** transparency used for filling line surface */ 21 | private int mFillAlpha = 85; 22 | 23 | /** the width of the drawn data lines */ 24 | private float mLineWidth = 2.5f; 25 | 26 | /** if true, the data will also be drawn filled */ 27 | private boolean mDrawFilled = false; 28 | 29 | 30 | public LineRadarDataSet(List yVals, String label) { 31 | super(yVals, label); 32 | } 33 | 34 | /** 35 | * returns the color that is used for filling the line surface 36 | * 37 | * @return 38 | */ 39 | public int getFillColor() { 40 | return mFillColor; 41 | } 42 | 43 | /** 44 | * sets the color that is used for filling the line surface 45 | * 46 | * @param color 47 | */ 48 | public void setFillColor(int color) { 49 | mFillColor = color; 50 | } 51 | 52 | /** 53 | * returns the alpha value that is used for filling the line surface, 54 | * default: 85 55 | * 56 | * @return 57 | */ 58 | public int getFillAlpha() { 59 | return mFillAlpha; 60 | } 61 | 62 | /** 63 | * sets the alpha value (transparency) that is used for filling the line 64 | * surface (0-255), default: 85 65 | * 66 | * @param alpha 67 | */ 68 | public void setFillAlpha(int alpha) { 69 | mFillAlpha = alpha; 70 | } 71 | 72 | /** 73 | * set the line width of the chart (min = 0.2f, max = 10f); default 1f NOTE: 74 | * thinner line == better performance, thicker line == worse performance 75 | * 76 | * @param width 77 | */ 78 | public void setLineWidth(float width) { 79 | 80 | if (width < 0.2f) 81 | width = 0.2f; 82 | if (width > 10.0f) 83 | width = 10.0f; 84 | mLineWidth = Utils.convertDpToPixel(width); 85 | } 86 | 87 | /** 88 | * returns the width of the drawn chart line 89 | * 90 | * @return 91 | */ 92 | public float getLineWidth() { 93 | return mLineWidth; 94 | } 95 | 96 | /** 97 | * Set to true if the DataSet should be drawn filled (surface), and not just 98 | * as a line, disabling this will give great performance boost! default: 99 | * false 100 | * 101 | * @param filled 102 | */ 103 | public void setDrawFilled(boolean filled) { 104 | mDrawFilled = filled; 105 | } 106 | 107 | /** 108 | * returns true if filled drawing is enabled, false if not 109 | * 110 | * @return 111 | */ 112 | public boolean isDrawFilledEnabled() { 113 | return mDrawFilled; 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/data/LineScatterCandleRadarDataSet.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.data; 2 | 3 | import android.graphics.DashPathEffect; 4 | 5 | import com.github.mikephil.charting.utils.Utils; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Created by Philipp Jahoda on 11/07/15. 11 | */ 12 | public abstract class LineScatterCandleRadarDataSet extends BarLineScatterCandleBubbleDataSet { 13 | 14 | protected boolean mDrawVerticalHighlightIndicator = true; 15 | protected boolean mDrawHorizontalHighlightIndicator = true; 16 | 17 | /** the width of the highlight indicator lines */ 18 | protected float mHighlightLineWidth = 0.5f; 19 | 20 | /** the path effect for dashed highlight-lines */ 21 | protected DashPathEffect mHighlightDashPathEffect = null; 22 | 23 | 24 | public LineScatterCandleRadarDataSet(List yVals, String label) { 25 | super(yVals, label); 26 | mHighlightLineWidth = Utils.convertDpToPixel(0.5f); 27 | } 28 | 29 | /** 30 | * Enables / disables the horizontal highlight-indicator. If disabled, the indicator is not drawn. 31 | * @param enabled 32 | */ 33 | public void setDrawHorizontalHighlightIndicator(boolean enabled) { 34 | this.mDrawHorizontalHighlightIndicator = enabled; 35 | } 36 | 37 | /** 38 | * Enables / disables the vertical highlight-indicator. If disabled, the indicator is not drawn. 39 | * @param enabled 40 | */ 41 | public void setDrawVerticalHighlightIndicator(boolean enabled) { 42 | this.mDrawVerticalHighlightIndicator = enabled; 43 | } 44 | 45 | /** 46 | * Enables / disables both vertical and horizontal highlight-indicators. 47 | * @param enabled 48 | */ 49 | public void setDrawHighlightIndicators(boolean enabled) { 50 | setDrawVerticalHighlightIndicator(enabled); 51 | setDrawHorizontalHighlightIndicator(enabled); 52 | } 53 | 54 | public boolean isVerticalHighlightIndicatorEnabled() { 55 | return mDrawVerticalHighlightIndicator; 56 | } 57 | 58 | public boolean isHorizontalHighlightIndicatorEnabled() { 59 | return mDrawHorizontalHighlightIndicator; 60 | } 61 | 62 | /** 63 | * Sets the width of the highlight line in dp. 64 | * @param width 65 | */ 66 | public void setHighlightLineWidth(float width) { 67 | mHighlightLineWidth = Utils.convertDpToPixel(width); 68 | } 69 | 70 | /** 71 | * Returns the line-width in which highlight lines are to be drawn. 72 | * @return 73 | */ 74 | public float getHighlightLineWidth() { 75 | return mHighlightLineWidth; 76 | } 77 | 78 | /** 79 | * Enables the highlight-line to be drawn in dashed mode, e.g. like this "- - - - - -" 80 | * 81 | * @param lineLength the length of the line pieces 82 | * @param spaceLength the length of space inbetween the line-pieces 83 | * @param phase offset, in degrees (normally, use 0) 84 | */ 85 | public void enableDashedHighlightLine(float lineLength, float spaceLength, float phase) { 86 | mHighlightDashPathEffect = new DashPathEffect(new float[] { 87 | lineLength, spaceLength 88 | }, phase); 89 | } 90 | 91 | /** 92 | * Disables the highlight-line to be drawn in dashed mode. 93 | */ 94 | public void disableDashedHighlightLine() { 95 | mHighlightDashPathEffect = null; 96 | } 97 | 98 | /** 99 | * Returns true if the dashed-line effect is enabled for highlight lines, false if not. 100 | * Default: disabled 101 | * 102 | * @return 103 | */ 104 | public boolean isDashedHighlightLineEnabled() { 105 | return mHighlightDashPathEffect == null ? false : true; 106 | } 107 | 108 | public DashPathEffect getDashPathEffectHighlight() { 109 | return mHighlightDashPathEffect; 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/data/PieData.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.data; 3 | 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | /** 8 | * A PieData object can only represent one DataSet. Unlike all other charts, the 9 | * legend labels of the PieChart are created from the x-values array, and not 10 | * from the DataSet labels. Each PieData object can only represent one 11 | * PieDataSet (multiple PieDataSets inside a single PieChart are not possible). 12 | * 13 | * @author Philipp Jahoda 14 | */ 15 | public class PieData extends ChartData { 16 | 17 | public PieData() { 18 | super(); 19 | } 20 | 21 | public PieData(List xVals) { 22 | super(xVals); 23 | } 24 | 25 | public PieData(String[] xVals) { 26 | super(xVals); 27 | } 28 | 29 | public PieData(List xVals, PieDataSet dataSet) { 30 | super(xVals, toList(dataSet)); 31 | } 32 | 33 | public PieData(String[] xVals, PieDataSet dataSet) { 34 | super(xVals, toList(dataSet)); 35 | } 36 | 37 | private static List toList(PieDataSet dataSet) { 38 | List sets = new ArrayList(); 39 | sets.add(dataSet); 40 | return sets; 41 | } 42 | 43 | /** 44 | * Sets the PieDataSet this data object should represent. 45 | * 46 | * @param dataSet 47 | */ 48 | public void setDataSet(PieDataSet dataSet) { 49 | mDataSets.clear(); 50 | mDataSets.add(dataSet); 51 | init(); 52 | } 53 | 54 | /** 55 | * Returns the DataSet this PieData object represents. A PieData object can 56 | * only contain one DataSet. 57 | * 58 | * @return 59 | */ 60 | public PieDataSet getDataSet() { 61 | return mDataSets.get(0); 62 | } 63 | 64 | @Override 65 | public PieDataSet getDataSetByIndex(int index) { 66 | return index == 0 ? getDataSet() : null; 67 | } 68 | 69 | @Override 70 | public PieDataSet getDataSetByLabel(String label, boolean ignorecase) { 71 | return ignorecase ? label.equalsIgnoreCase(mDataSets.get(0).getLabel()) ? mDataSets.get(0) 72 | : null : label.equals(mDataSets.get(0).getLabel()) ? mDataSets.get(0) : null; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/data/PieDataSet.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.data; 3 | 4 | import com.github.mikephil.charting.utils.Utils; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | public class PieDataSet extends DataSet { 10 | 11 | /** the space in degrees between the chart-slices, default 0f */ 12 | private float mSliceSpace = 0f; 13 | 14 | /** indicates the selection distance of a pie slice */ 15 | private float mShift = 18f; 16 | 17 | public PieDataSet(List yVals, String label) { 18 | super(yVals, label); 19 | // mShift = Utils.convertDpToPixel(12f); 20 | } 21 | 22 | @Override 23 | public DataSet copy() { 24 | 25 | List yVals = new ArrayList(); 26 | 27 | for (int i = 0; i < mYVals.size(); i++) { 28 | yVals.add(mYVals.get(i).copy()); 29 | } 30 | 31 | PieDataSet copied = new PieDataSet(yVals, getLabel()); 32 | copied.mColors = mColors; 33 | copied.mSliceSpace = mSliceSpace; 34 | copied.mShift = mShift; 35 | return copied; 36 | } 37 | 38 | /** 39 | * sets the space that is left out between the piechart-slices, default: 0° 40 | * --> no space, maximum 45, minimum 0 (no space) 41 | * 42 | * @param degrees 43 | */ 44 | public void setSliceSpace(float degrees) { 45 | 46 | if (degrees > 45) 47 | degrees = 45f; 48 | if (degrees < 0) 49 | degrees = 0f; 50 | 51 | mSliceSpace = degrees; 52 | } 53 | 54 | /** 55 | * returns the space that is set to be between the piechart-slices of this 56 | * DataSet, in degrees 57 | * 58 | * @return 59 | */ 60 | public float getSliceSpace() { 61 | return mSliceSpace; 62 | } 63 | 64 | /** 65 | * sets the distance the highlighted piechart-slice of this DataSet is 66 | * "shifted" away from the center of the chart, default 12f 67 | * 68 | * @param shift 69 | */ 70 | public void setSelectionShift(float shift) { 71 | mShift = Utils.convertDpToPixel(shift); 72 | } 73 | 74 | /** 75 | * returns the distance a highlighted piechart slice is "shifted" away from 76 | * the chart-center 77 | * 78 | * @return 79 | */ 80 | public float getSelectionShift() { 81 | return mShift; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/data/RadarData.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.data; 3 | 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | /** 8 | * Data container for the RadarChart. 9 | * 10 | * @author Philipp Jahoda 11 | */ 12 | public class RadarData extends ChartData { 13 | 14 | public RadarData() { 15 | super(); 16 | } 17 | 18 | public RadarData(List xVals) { 19 | super(xVals); 20 | } 21 | 22 | public RadarData(String[] xVals) { 23 | super(xVals); 24 | } 25 | 26 | public RadarData(List xVals, List dataSets) { 27 | super(xVals, dataSets); 28 | } 29 | 30 | public RadarData(String[] xVals, List dataSets) { 31 | super(xVals, dataSets); 32 | } 33 | 34 | public RadarData(List xVals, RadarDataSet dataSet) { 35 | super(xVals, toList(dataSet)); 36 | } 37 | 38 | public RadarData(String[] xVals, RadarDataSet dataSet) { 39 | super(xVals, toList(dataSet)); 40 | } 41 | 42 | private static List toList(RadarDataSet dataSet) { 43 | List sets = new ArrayList(); 44 | sets.add(dataSet); 45 | return sets; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/data/RadarDataSet.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.data; 3 | 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | public class RadarDataSet extends LineRadarDataSet { 8 | 9 | public RadarDataSet(List yVals, String label) { 10 | super(yVals, label); 11 | } 12 | 13 | @Override 14 | public DataSet copy() { 15 | 16 | List yVals = new ArrayList(); 17 | 18 | for (int i = 0; i < mYVals.size(); i++) { 19 | yVals.add(mYVals.get(i).copy()); 20 | } 21 | 22 | RadarDataSet copied = new RadarDataSet(yVals, getLabel()); 23 | copied.mColors = mColors; 24 | copied.mHighLightColor = mHighLightColor; 25 | 26 | return copied; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/data/ScatterData.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.data; 3 | 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | public class ScatterData extends BarLineScatterCandleBubbleData { 8 | 9 | public ScatterData() { 10 | super(); 11 | } 12 | 13 | public ScatterData(List xVals) { 14 | super(xVals); 15 | } 16 | 17 | public ScatterData(String[] xVals) { 18 | super(xVals); 19 | } 20 | 21 | public ScatterData(List xVals, List dataSets) { 22 | super(xVals, dataSets); 23 | } 24 | 25 | public ScatterData(String[] xVals, List dataSets) { 26 | super(xVals, dataSets); 27 | } 28 | 29 | public ScatterData(List xVals, ScatterDataSet dataSet) { 30 | super(xVals, toList(dataSet)); 31 | } 32 | 33 | public ScatterData(String[] xVals, ScatterDataSet dataSet) { 34 | super(xVals, toList(dataSet)); 35 | } 36 | 37 | private static List toList(ScatterDataSet dataSet) { 38 | List sets = new ArrayList(); 39 | sets.add(dataSet); 40 | return sets; 41 | } 42 | 43 | /** 44 | * Returns the maximum shape-size across all DataSets. 45 | * 46 | * @return 47 | */ 48 | public float getGreatestShapeSize() { 49 | 50 | float max = 0f; 51 | 52 | for (ScatterDataSet set : mDataSets) { 53 | float size = set.getScatterShapeSize(); 54 | 55 | if (size > max) 56 | max = size; 57 | } 58 | 59 | return max; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/data/ScatterDataSet.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.data; 3 | 4 | import android.graphics.Path; 5 | 6 | import com.github.mikephil.charting.charts.ScatterChart.ScatterShape; 7 | import com.github.mikephil.charting.utils.Utils; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | public class ScatterDataSet extends LineScatterCandleRadarDataSet { 13 | 14 | /** the size the scattershape will have, in screen pixels */ 15 | private float mShapeSize = 15f; 16 | 17 | /** 18 | * the type of shape that is set to be drawn where the values are at, 19 | * default ScatterShape.SQUARE 20 | */ 21 | private ScatterShape mScatterShape = ScatterShape.SQUARE; 22 | 23 | /** 24 | * Custom path object the user can provide that is drawn where the values 25 | * are at. This is used when ScatterShape.CUSTOM is set for a DataSet. 26 | */ 27 | private Path mCustomScatterPath = null; 28 | 29 | public ScatterDataSet(List yVals, String label) { 30 | super(yVals, label); 31 | 32 | // mShapeSize = Utils.convertDpToPixel(8f); 33 | } 34 | 35 | @Override 36 | public DataSet copy() { 37 | 38 | List yVals = new ArrayList(); 39 | 40 | for (int i = 0; i < mYVals.size(); i++) { 41 | yVals.add(mYVals.get(i).copy()); 42 | } 43 | 44 | ScatterDataSet copied = new ScatterDataSet(yVals, getLabel()); 45 | copied.mColors = mColors; 46 | copied.mShapeSize = mShapeSize; 47 | copied.mScatterShape = mScatterShape; 48 | copied.mCustomScatterPath = mCustomScatterPath; 49 | copied.mHighLightColor = mHighLightColor; 50 | 51 | return copied; 52 | } 53 | 54 | /** 55 | * Sets the size in density pixels the drawn scattershape will have. This 56 | * only applies for non custom shapes. 57 | * 58 | * @param size 59 | */ 60 | public void setScatterShapeSize(float size) { 61 | mShapeSize = Utils.convertDpToPixel(size); 62 | } 63 | 64 | /** 65 | * returns the currently set scatter shape size 66 | * 67 | * @return 68 | */ 69 | public float getScatterShapeSize() { 70 | return mShapeSize; 71 | } 72 | 73 | /** 74 | * Sets the shape that is drawn on the position where the values are at. If 75 | * "CUSTOM" is chosen, you need to call setCustomScatterShape(...) and 76 | * provide a path object that is drawn as the custom scattershape. 77 | * 78 | * @param shape 79 | */ 80 | public void setScatterShape(ScatterShape shape) { 81 | mScatterShape = shape; 82 | } 83 | 84 | /** 85 | * returns all the different scattershapes the chart uses 86 | * 87 | * @return 88 | */ 89 | public ScatterShape getScatterShape() { 90 | return mScatterShape; 91 | } 92 | 93 | /** 94 | * Sets a path object as the shape to be drawn where the values are at. Do 95 | * not forget to call setScatterShape(...) and set the shape to 96 | * ScatterShape.CUSTOM. 97 | * 98 | * @param shape 99 | */ 100 | public void setCustomScatterShape(Path shape) { 101 | mCustomScatterPath = shape; 102 | } 103 | 104 | /** 105 | * returns the custom path / shape that is specified to be drawn where the 106 | * values are at 107 | * 108 | * @return 109 | */ 110 | public Path getCustomScatterShape() { 111 | return mCustomScatterPath; 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /app/lib/mplib/src/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 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/formatter/ColorFormatter.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.formatter; 2 | 3 | import com.github.mikephil.charting.data.Entry; 4 | 5 | /** 6 | * Interface that can be used to return a customized color instead of setting 7 | * colors via the setColor(...) method of the DataSet. 8 | * 9 | * @author Philipp Jahoda 10 | */ 11 | public interface ColorFormatter { 12 | 13 | int getColor(Entry e, int index); 14 | } -------------------------------------------------------------------------------- /app/lib/mplib/src/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.data.LineDataSet; 6 | import com.github.mikephil.charting.interfaces.LineDataProvider; 7 | 8 | /** 9 | * Default formatter that calculates the position of the filled line. 10 | * 11 | * @author Philipp Jahoda 12 | */ 13 | public class DefaultFillFormatter implements FillFormatter { 14 | 15 | @Override 16 | public float getFillLinePosition(LineDataSet dataSet, LineDataProvider dataProvider) { 17 | 18 | float fillMin = 0f; 19 | float chartMaxY = dataProvider.getYChartMax(); 20 | float chartMinY = dataProvider.getYChartMin(); 21 | 22 | LineData data = dataProvider.getLineData(); 23 | 24 | if (dataSet.getYMax() > 0 && dataSet.getYMin() < 0) { 25 | fillMin = 0f; 26 | } else { 27 | 28 | if (!dataProvider.getAxis(dataSet.getAxisDependency()).isStartAtZeroEnabled()) { 29 | 30 | float max, min; 31 | 32 | if (data.getYMax() > 0) 33 | max = 0f; 34 | else 35 | max = chartMaxY; 36 | if (data.getYMin() < 0) 37 | min = 0f; 38 | else 39 | min = chartMinY; 40 | 41 | fillMin = dataSet.getYMin() >= 0 ? min : max; 42 | } else { 43 | fillMin = 0f; 44 | } 45 | } 46 | 47 | return fillMin; 48 | } 49 | } -------------------------------------------------------------------------------- /app/lib/mplib/src/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 ValueFormatter { 16 | 17 | /** decimalformat for formatting */ 18 | private DecimalFormat mFormat; 19 | 20 | /** 21 | * Constructor that specifies to how many digits the value should be 22 | * formatted. 23 | * 24 | * @param digits 25 | */ 26 | public DefaultValueFormatter(int digits) { 27 | 28 | StringBuffer b = new StringBuffer(); 29 | for (int i = 0; i < digits; i++) { 30 | if (i == 0) 31 | b.append("."); 32 | b.append("0"); 33 | } 34 | 35 | mFormat = new DecimalFormat("###,###,###,##0" + b.toString()); 36 | } 37 | 38 | @Override 39 | public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) { 40 | 41 | // put more logic here ... 42 | // avoid memory allocations here (for performance reasons) 43 | 44 | return mFormat.format(value); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/formatter/DefaultXAxisValueFormatter.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.formatter; 2 | 3 | import com.github.mikephil.charting.utils.ViewPortHandler; 4 | 5 | /** 6 | * Created by Philipp Jahoda on 14/09/15. 7 | * Default formatter class for adjusting x-values before drawing them. 8 | * This simply returns the original value unmodified. 9 | */ 10 | public class DefaultXAxisValueFormatter implements XAxisValueFormatter { 11 | 12 | @Override 13 | public String getXValue(String original, int index, ViewPortHandler viewPortHandler) { 14 | return original; // just return original, no adjustments 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/formatter/DefaultYAxisValueFormatter.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.formatter; 2 | 3 | import com.github.mikephil.charting.components.YAxis; 4 | 5 | import java.text.DecimalFormat; 6 | 7 | /** 8 | * Created by Philipp Jahoda on 20/09/15. 9 | * Default formatter used for formatting labels of the YAxis. Uses a DecimalFormat with 10 | * pre-calculated number of digits (depending on max and min value). 11 | */ 12 | public class DefaultYAxisValueFormatter implements YAxisValueFormatter { 13 | 14 | /** decimalformat for formatting */ 15 | private DecimalFormat mFormat; 16 | 17 | /** 18 | * Constructor that specifies to how many digits the value should be 19 | * formatted. 20 | * 21 | * @param digits 22 | */ 23 | public DefaultYAxisValueFormatter(int digits) { 24 | 25 | StringBuffer b = new StringBuffer(); 26 | for (int i = 0; i < digits; i++) { 27 | if (i == 0) 28 | b.append("."); 29 | b.append("0"); 30 | } 31 | 32 | mFormat = new DecimalFormat("###,###,###,##0" + b.toString()); 33 | } 34 | 35 | @Override 36 | public String getFormattedValue(float value, YAxis yAxis) { 37 | // avoid memory allocations here (for performance) 38 | return mFormat.format(value); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/formatter/FillFormatter.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.formatter; 2 | 3 | import com.github.mikephil.charting.data.LineData; 4 | import com.github.mikephil.charting.data.LineDataSet; 5 | import com.github.mikephil.charting.interfaces.LineDataProvider; 6 | 7 | /** 8 | * Interface for providing a custom logic to where the filling line of a LineDataSet 9 | * should end. This of course only works if setFillEnabled(...) is set to true. 10 | * 11 | * @author Philipp Jahoda 12 | */ 13 | public interface FillFormatter { 14 | 15 | /** 16 | * Returns the vertical (y-axis) position where the filled-line of the 17 | * LineDataSet should end. 18 | * 19 | * @param dataSet the LineDataSet that is currently drawn 20 | * @param dataProvider 21 | * @return 22 | */ 23 | float getFillLinePosition(LineDataSet dataSet, LineDataProvider dataProvider); 24 | } 25 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/formatter/LargeValueFormatter.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.formatter; 3 | 4 | import com.github.mikephil.charting.components.YAxis; 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 | * Predefined value-formatter that formats large numbers in a pretty way. 12 | * Outputs: 856 = 856; 1000 = 1k; 5821 = 5.8k; 10500 = 10k; 101800 = 102k; 13 | * 2000000 = 2m; 7800000 = 7.8m; 92150000 = 92m; 123200000 = 123m; 9999999 = 14 | * 10m; 1000000000 = 1b; Special thanks to Roman Gromov 15 | * (https://github.com/romangromov) for this piece of code. 16 | * 17 | * @author Philipp Jahoda 18 | * @author Oleksandr Tyshkovets 19 | */ 20 | public class LargeValueFormatter implements ValueFormatter, YAxisValueFormatter { 21 | 22 | private static String[] SUFFIX = new String[]{ 23 | "", "k", "m", "b", "t" 24 | }; 25 | private static final int MAX_LENGTH = 4; 26 | private DecimalFormat mFormat; 27 | private String mText = ""; 28 | 29 | public LargeValueFormatter() { 30 | mFormat = new DecimalFormat("###E0"); 31 | } 32 | 33 | /** 34 | * Creates a formatter that appends a specified text to the result string 35 | * 36 | * @param appendix a text that will be appended 37 | */ 38 | public LargeValueFormatter(String appendix) { 39 | this(); 40 | mText = appendix; 41 | } 42 | 43 | // ValueFormatter 44 | @Override 45 | public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) { 46 | return makePretty(value) + mText; 47 | } 48 | 49 | // YAxisValueFormatter 50 | @Override 51 | public String getFormattedValue(float value, YAxis yAxis) { 52 | return makePretty(value) + mText; 53 | } 54 | 55 | /** 56 | * Set an appendix text to be added at the end of the formatted value. 57 | * 58 | * @param appendix 59 | */ 60 | public void setAppendix(String appendix) { 61 | this.mText = appendix; 62 | } 63 | 64 | /** 65 | * Set custom suffix to be appended after the values. 66 | * Default suffix: ["", "k", "m", "b", "t"] 67 | * 68 | * @param suff new suffix 69 | */ 70 | public void setSuffix(String[] suff) { 71 | if (suff.length == 5) { 72 | SUFFIX = suff; 73 | } 74 | } 75 | 76 | /** 77 | * Formats each number properly. Special thanks to Roman Gromov 78 | * (https://github.com/romangromov) for this piece of code. 79 | */ 80 | private String makePretty(double number) { 81 | 82 | String r = mFormat.format(number); 83 | 84 | r = r.replaceAll("E[0-9]", SUFFIX[Character.getNumericValue(r.charAt(r.length() - 1)) / 3]); 85 | 86 | while (r.length() > MAX_LENGTH || r.matches("[0-9]+\\.[a-z]")) { 87 | r = r.substring(0, r.length() - 2) + r.substring(r.length() - 1); 88 | } 89 | 90 | return r; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/formatter/PercentFormatter.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.formatter; 3 | 4 | import com.github.mikephil.charting.components.YAxis; 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 ValueFormatter 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 ValueFormatter, YAxisValueFormatter { 17 | 18 | protected DecimalFormat mFormat; 19 | 20 | public PercentFormatter() { 21 | mFormat = new DecimalFormat("###,###,##0.0"); 22 | } 23 | 24 | /** 25 | * Allow a custom decimalformat 26 | * 27 | * @param format 28 | */ 29 | public PercentFormatter(DecimalFormat format) { 30 | this.mFormat = format; 31 | } 32 | 33 | // ValueFormatter 34 | @Override 35 | public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) { 36 | return mFormat.format(value) + " %"; 37 | } 38 | 39 | // YAxisValueFormatter 40 | @Override 41 | public String getFormattedValue(float value, YAxis yAxis) { 42 | return mFormat.format(value) + " %"; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/formatter/ValueFormatter.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 ValueFormatter. Then override the getFormattedValue(...) method 10 | * and return whatever you want. 11 | * 12 | * @author Philipp Jahoda 13 | */ 14 | public interface ValueFormatter { 15 | 16 | /** 17 | * Called when a value (from labels inside the chart) is formatted 18 | * before being drawn. For performance reasons, avoid excessive calculations 19 | * and memory allocations inside this method. 20 | * 21 | * @param value the value to be formatted 22 | * @param entry the entry the value belongs to - in e.g. BarChart, this is of class BarEntry 23 | * @param dataSetIndex the index of the DataSet the entry in focus belongs to 24 | * @param viewPortHandler provides information about the current chart state (scale, translation, ...) 25 | * @return the formatted label ready for being drawn 26 | */ 27 | String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler); 28 | } 29 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/formatter/XAxisValueFormatter.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.formatter; 2 | 3 | import com.github.mikephil.charting.utils.ViewPortHandler; 4 | 5 | /** 6 | * Created by Philipp Jahoda on 14/09/15. 7 | * An interface for providing custom x-axis Strings. 8 | * 9 | * @author Philipp Jahoda 10 | */ 11 | public interface XAxisValueFormatter { 12 | 13 | /** 14 | * Returns the customized label that is drawn on the x-axis. 15 | * For performance reasons, avoid excessive calculations 16 | * and memory allocations inside this method. 17 | * 18 | * @param original the original x-axis label to be drawn 19 | * @param index the x-index that is currently being drawn 20 | * @param viewPortHandler provides information about the current chart state (scale, translation, ...) 21 | * @return 22 | */ 23 | String getXValue(String original, int index, ViewPortHandler viewPortHandler); 24 | } 25 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/formatter/YAxisValueFormatter.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.formatter; 2 | 3 | import com.github.mikephil.charting.components.YAxis; 4 | 5 | /** 6 | * Created by Philipp Jahoda on 20/09/15. 7 | * Custom formatter interface that allows formatting of 8 | * YAxis labels before they are being drawn. 9 | */ 10 | public interface YAxisValueFormatter { 11 | 12 | /** 13 | * Called when a value from the YAxis is formatted 14 | * before being drawn. For performance reasons, avoid excessive calculations 15 | * and memory allocations inside this method. 16 | * 17 | * @param value the YAxis value to be formatted 18 | * @param yAxis the YAxis object the value belongs to 19 | * @return 20 | */ 21 | String getFormattedValue(float value, YAxis yAxis); 22 | } 23 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/highlight/ChartHighlighter.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.highlight; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import com.github.mikephil.charting.components.YAxis; 7 | import com.github.mikephil.charting.data.DataSet; 8 | import com.github.mikephil.charting.interfaces.BarLineScatterCandleBubbleDataProvider; 9 | import com.github.mikephil.charting.utils.SelectionDetail; 10 | import com.github.mikephil.charting.utils.Utils; 11 | 12 | /** 13 | * Created by Philipp Jahoda on 21/07/15. 14 | */ 15 | public class ChartHighlighter { 16 | 17 | /** instance of the data-provider */ 18 | protected T mChart; 19 | 20 | public ChartHighlighter(T chart) { 21 | this.mChart = chart; 22 | } 23 | 24 | /** 25 | * Returns a Highlight object corresponding to the given x- and y- touch positions in pixels. 26 | * 27 | * @param x 28 | * @param y 29 | * @return 30 | */ 31 | public Highlight getHighlight(float x, float y) { 32 | 33 | int xIndex = getXIndex(x); 34 | if (xIndex == -Integer.MAX_VALUE) 35 | return null; 36 | 37 | int dataSetIndex = getDataSetIndex(xIndex, x, y); 38 | if (dataSetIndex == -Integer.MAX_VALUE) 39 | return null; 40 | 41 | return new Highlight(xIndex, dataSetIndex); 42 | } 43 | 44 | /** 45 | * Returns the corresponding x-index for a given touch-position in pixels. 46 | * 47 | * @param x 48 | * @return 49 | */ 50 | protected int getXIndex(float x) { 51 | 52 | // create an array of the touch-point 53 | float[] pts = new float[2]; 54 | pts[0] = x; 55 | 56 | // take any transformer to determine the x-axis value 57 | mChart.getTransformer(YAxis.AxisDependency.LEFT).pixelsToValue(pts); 58 | 59 | return (int) Math.round(pts[0]); 60 | } 61 | 62 | /** 63 | * Returns the corresponding dataset-index for a given xIndex and xy-touch position in pixels. 64 | * 65 | * @param xIndex 66 | * @param x 67 | * @param y 68 | * @return 69 | */ 70 | protected int getDataSetIndex(int xIndex, float x, float y) { 71 | 72 | List valsAtIndex = getSelectionDetailsAtIndex(xIndex); 73 | 74 | float leftdist = Utils.getMinimumDistance(valsAtIndex, y, YAxis.AxisDependency.LEFT); 75 | float rightdist = Utils.getMinimumDistance(valsAtIndex, y, YAxis.AxisDependency.RIGHT); 76 | 77 | YAxis.AxisDependency axis = leftdist < rightdist ? YAxis.AxisDependency.LEFT : YAxis.AxisDependency.RIGHT; 78 | 79 | int dataSetIndex = Utils.getClosestDataSetIndex(valsAtIndex, y, axis); 80 | 81 | return dataSetIndex; 82 | } 83 | 84 | /** 85 | * Returns a list of SelectionDetail object corresponding to the given xIndex. 86 | * 87 | * @param xIndex 88 | * @return 89 | */ 90 | protected List getSelectionDetailsAtIndex(int xIndex) { 91 | 92 | List vals = new ArrayList(); 93 | 94 | float[] pts = new float[2]; 95 | 96 | for (int i = 0; i < mChart.getData().getDataSetCount(); i++) { 97 | 98 | DataSet dataSet = mChart.getData().getDataSetByIndex(i); 99 | 100 | // dont include datasets that cannot be highlighted 101 | if (!dataSet.isHighlightEnabled()) 102 | continue; 103 | 104 | // extract all y-values from all DataSets at the given x-index 105 | final float yVal = dataSet.getYValForXIndex(xIndex); 106 | if (yVal == Float.NaN) 107 | continue; 108 | 109 | pts[1] = yVal; 110 | 111 | mChart.getTransformer(dataSet.getAxisDependency()).pointValuesToPixel(pts); 112 | 113 | if (!Float.isNaN(pts[1])) { 114 | vals.add(new SelectionDetail(pts[1], i, dataSet)); 115 | } 116 | } 117 | 118 | return vals; 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/highlight/CombinedHighlighter.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.highlight; 2 | 3 | import com.github.mikephil.charting.data.ChartData; 4 | import com.github.mikephil.charting.data.CombinedData; 5 | import com.github.mikephil.charting.data.DataSet; 6 | import com.github.mikephil.charting.interfaces.BarLineScatterCandleBubbleDataProvider; 7 | import com.github.mikephil.charting.utils.SelectionDetail; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | * Created by Philipp Jahoda on 12/09/15. 14 | */ 15 | public class CombinedHighlighter extends ChartHighlighter { 16 | 17 | public CombinedHighlighter(BarLineScatterCandleBubbleDataProvider chart) { 18 | super(chart); 19 | } 20 | 21 | /** 22 | * Returns a list of SelectionDetail object corresponding to the given xIndex. 23 | * 24 | * @param xIndex 25 | * @return 26 | */ 27 | @Override 28 | protected List getSelectionDetailsAtIndex(int xIndex) { 29 | 30 | CombinedData data = (CombinedData) mChart.getData(); 31 | 32 | // get all chartdata objects 33 | List dataObjects = data.getAllData(); 34 | 35 | List vals = new ArrayList(); 36 | 37 | float[] pts = new float[2]; 38 | 39 | for (int i = 0; i < dataObjects.size(); i++) { 40 | 41 | for(int j = 0; j < dataObjects.get(i).getDataSetCount(); j++) { 42 | 43 | DataSet dataSet = dataObjects.get(i).getDataSetByIndex(j); 44 | 45 | // dont include datasets that cannot be highlighted 46 | if (!dataSet.isHighlightEnabled()) 47 | continue; 48 | 49 | // extract all y-values from all DataSets at the given x-index 50 | final float yVal = dataSet.getYValForXIndex(xIndex); 51 | if (yVal == Float.NaN) 52 | continue; 53 | 54 | pts[1] = yVal; 55 | 56 | mChart.getTransformer(dataSet.getAxisDependency()).pointValuesToPixel(pts); 57 | 58 | if (!Float.isNaN(pts[1])) { 59 | vals.add(new SelectionDetail(pts[1], j, dataSet)); 60 | } 61 | } 62 | } 63 | 64 | return vals; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/highlight/Highlight.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.highlight; 3 | 4 | /** 5 | * Contains information needed to determine the highlighted value. 6 | * 7 | * @author Philipp Jahoda 8 | */ 9 | public class Highlight { 10 | 11 | /** the x-index of the highlighted value */ 12 | private int mXIndex; 13 | 14 | /** the index of the dataset the highlighted value is in */ 15 | private int mDataSetIndex; 16 | 17 | /** index which value of a stacked bar entry is highlighted, default -1 */ 18 | private int mStackIndex = -1; 19 | 20 | /** the range of the bar that is selected (only for stacked-barchart) */ 21 | private Range mRange; 22 | 23 | /** 24 | * constructor 25 | * 26 | * @param x the index of the highlighted value on the x-axis 27 | * @param dataSet the index of the DataSet the highlighted value belongs to 28 | */ 29 | public Highlight(int x, int dataSet) { 30 | this.mXIndex = x; 31 | this.mDataSetIndex = dataSet; 32 | } 33 | 34 | /** 35 | * Constructor, only used for stacked-barchart. 36 | * 37 | * @param x the index of the highlighted value on the x-axis 38 | * @param dataSet the index of the DataSet the highlighted value belongs to 39 | * @param stackIndex references which value of a stacked-bar entry has been 40 | * selected 41 | */ 42 | public Highlight(int x, int dataSet, int stackIndex) { 43 | this(x, dataSet); 44 | mStackIndex = stackIndex; 45 | } 46 | 47 | /** 48 | * Constructor, only used for stacked-barchart. 49 | * 50 | * @param x the index of the highlighted value on the x-axis 51 | * @param dataSet the index of the DataSet the highlighted value belongs to 52 | * @param stackIndex references which value of a stacked-bar entry has been 53 | * selected 54 | * @param range the range the selected stack-value is in 55 | */ 56 | public Highlight(int x, int dataSet, int stackIndex, Range range) { 57 | this(x, dataSet, stackIndex); 58 | this.mRange = range; 59 | } 60 | 61 | /** 62 | * returns the index of the DataSet the highlighted value is in 63 | * 64 | * @return 65 | */ 66 | public int getDataSetIndex() { 67 | return mDataSetIndex; 68 | } 69 | 70 | /** 71 | * returns the index of the highlighted value on the x-axis 72 | * 73 | * @return 74 | */ 75 | public int getXIndex() { 76 | return mXIndex; 77 | } 78 | 79 | /** 80 | * Only needed if a stacked-barchart entry was highlighted. References the 81 | * selected value within the stacked-entry. 82 | * 83 | * @return 84 | */ 85 | public int getStackIndex() { 86 | return mStackIndex; 87 | } 88 | 89 | /** 90 | * Returns the range of values the selected value of a stacked bar is in. (this is only relevant for stacked-barchart) 91 | * @return 92 | */ 93 | public Range getRange() { 94 | return mRange; 95 | } 96 | 97 | /** 98 | * returns true if this highlight object is equal to the other (compares 99 | * xIndex and dataSetIndex) 100 | * 101 | * @param h 102 | * @return 103 | */ 104 | public boolean equalTo(Highlight h) { 105 | 106 | if (h == null) 107 | return false; 108 | else { 109 | if (this.mDataSetIndex == h.mDataSetIndex && this.mXIndex == h.mXIndex 110 | && this.mStackIndex == h.mStackIndex) 111 | return true; 112 | else 113 | return false; 114 | } 115 | } 116 | 117 | @Override 118 | public String toString() { 119 | return "Highlight, xIndex: " + mXIndex + ", dataSetIndex: " + mDataSetIndex 120 | + ", stackIndex (only stacked barentry): " + mStackIndex; 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/highlight/HorizontalBarHighlighter.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.highlight; 2 | 3 | import com.github.mikephil.charting.components.YAxis; 4 | import com.github.mikephil.charting.data.BarDataSet; 5 | import com.github.mikephil.charting.interfaces.BarDataProvider; 6 | 7 | /** 8 | * Created by Philipp Jahoda on 22/07/15. 9 | */ 10 | public class HorizontalBarHighlighter extends BarHighlighter { 11 | 12 | public HorizontalBarHighlighter(BarDataProvider chart) { 13 | super(chart); 14 | } 15 | 16 | @Override 17 | public Highlight getHighlight(float x, float y) { 18 | 19 | Highlight h = super.getHighlight(x, y); 20 | 21 | if (h == null) 22 | return h; 23 | else { 24 | 25 | BarDataSet set = mChart.getBarData().getDataSetByIndex(h.getDataSetIndex()); 26 | 27 | if (set.isStacked()) { 28 | 29 | // create an array of the touch-point 30 | float[] pts = new float[2]; 31 | pts[0] = y; 32 | 33 | // take any transformer to determine the x-axis value 34 | mChart.getTransformer(set.getAxisDependency()).pixelsToValue(pts); 35 | 36 | return getStackedHighlight(h, set, h.getXIndex(), h.getDataSetIndex(), pts[0]); 37 | } else 38 | return h; 39 | } 40 | } 41 | 42 | @Override 43 | protected int getXIndex(float x) { 44 | 45 | if (!mChart.getBarData().isGrouped()) { 46 | 47 | // create an array of the touch-point 48 | float[] pts = new float[2]; 49 | pts[1] = x; 50 | 51 | // take any transformer to determine the x-axis value 52 | mChart.getTransformer(YAxis.AxisDependency.LEFT).pixelsToValue(pts); 53 | 54 | return (int) Math.round(pts[1]); 55 | } else { 56 | 57 | float baseNoSpace = getBase(x); 58 | 59 | int setCount = mChart.getBarData().getDataSetCount(); 60 | int xIndex = (int) baseNoSpace / setCount; 61 | 62 | int valCount = mChart.getData().getXValCount(); 63 | 64 | if (xIndex < 0) 65 | xIndex = 0; 66 | else if (xIndex >= valCount) 67 | xIndex = valCount - 1; 68 | 69 | return xIndex; 70 | } 71 | } 72 | 73 | /** 74 | * Returns the base y-value to the corresponding x-touch value in pixels. 75 | * 76 | * @param y 77 | * @return 78 | */ 79 | @Override 80 | protected float getBase(float y) { 81 | 82 | // create an array of the touch-point 83 | float[] pts = new float[2]; 84 | pts[1] = y; 85 | 86 | // take any transformer to determine the x-axis value 87 | mChart.getTransformer(YAxis.AxisDependency.LEFT).pixelsToValue(pts); 88 | float yVal = pts[1]; 89 | 90 | int setCount = mChart.getBarData().getDataSetCount(); 91 | 92 | // calculate how often the group-space appears 93 | int steps = (int) ((float) yVal / ((float) setCount + mChart.getBarData().getGroupSpace())); 94 | 95 | float groupSpaceSum = mChart.getBarData().getGroupSpace() * (float) steps; 96 | 97 | float baseNoSpace = (float) yVal - groupSpaceSum; 98 | return baseNoSpace; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /app/lib/mplib/src/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 | } -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/interfaces/BarDataProvider.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.interfaces; 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 isDrawHighlightArrowEnabled(); 11 | } 12 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/interfaces/BarLineScatterCandleBubbleDataProvider.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.interfaces; 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 | int getMaxVisibleCount(); 11 | boolean isInverted(AxisDependency axis); 12 | 13 | int getLowestVisibleXIndex(); 14 | int getHighestVisibleXIndex(); 15 | 16 | BarLineScatterCandleBubbleData getData(); 17 | } 18 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/interfaces/BubbleDataProvider.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.interfaces; 2 | 3 | import com.github.mikephil.charting.data.BubbleData; 4 | 5 | public interface BubbleDataProvider extends BarLineScatterCandleBubbleDataProvider { 6 | 7 | BubbleData getBubbleData(); 8 | } 9 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/interfaces/CandleDataProvider.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.interfaces; 2 | 3 | import com.github.mikephil.charting.data.CandleData; 4 | 5 | public interface CandleDataProvider extends BarLineScatterCandleBubbleDataProvider { 6 | 7 | CandleData getCandleData(); 8 | } 9 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/interfaces/ChartInterface.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.interfaces; 2 | 3 | import android.graphics.PointF; 4 | import android.graphics.RectF; 5 | 6 | import com.github.mikephil.charting.data.ChartData; 7 | import com.github.mikephil.charting.formatter.ValueFormatter; 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 | float getXChartMin(); 18 | 19 | float getXChartMax(); 20 | 21 | float getYChartMin(); 22 | 23 | float getYChartMax(); 24 | 25 | int getXValCount(); 26 | 27 | int getWidth(); 28 | 29 | int getHeight(); 30 | 31 | PointF getCenterOfView(); 32 | 33 | PointF getCenterOffsets(); 34 | 35 | RectF getContentRect(); 36 | 37 | ValueFormatter getDefaultValueFormatter(); 38 | 39 | ChartData getData(); 40 | } 41 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/interfaces/LineDataProvider.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.interfaces; 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 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/interfaces/ScatterDataProvider.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.interfaces; 2 | 3 | import com.github.mikephil.charting.data.ScatterData; 4 | 5 | public interface ScatterDataProvider extends BarLineScatterCandleBubbleDataProvider { 6 | 7 | ScatterData getScatterData(); 8 | } 9 | -------------------------------------------------------------------------------- /app/lib/mplib/src/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.Transformer; 7 | import com.github.mikephil.charting.utils.ViewPortHandler; 8 | 9 | /** 10 | * Runnable that is used for viewport modifications since they cannot be 11 | * executed at any time. This can be used to delay the execution of viewport 12 | * modifications until the onSizeChanged(...) method of the chartview is called. 13 | * 14 | * @author Philipp Jahoda 15 | */ 16 | public class MoveViewJob implements Runnable { 17 | 18 | protected ViewPortHandler mViewPortHandler; 19 | protected float xIndex = 0f; 20 | protected float yValue = 0f; 21 | protected Transformer mTrans; 22 | protected View view; 23 | 24 | public MoveViewJob(ViewPortHandler viewPortHandler, float xIndex, float yValue, 25 | Transformer trans, View v) { 26 | 27 | this.mViewPortHandler = viewPortHandler; 28 | this.xIndex = xIndex; 29 | this.yValue = yValue; 30 | this.mTrans = trans; 31 | this.view = v; 32 | } 33 | 34 | @Override 35 | public void run() { 36 | 37 | float[] pts = new float[] { 38 | xIndex, yValue 39 | }; 40 | 41 | mTrans.pointValuesToPixel(pts); 42 | mViewPortHandler.centerViewPort(pts, view); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/listener/ChartTouchListener.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.listener; 2 | 3 | import android.view.GestureDetector; 4 | import android.view.MotionEvent; 5 | import android.view.View; 6 | 7 | import com.github.mikephil.charting.charts.Chart; 8 | import com.github.mikephil.charting.highlight.Highlight; 9 | 10 | /** 11 | * Created by philipp on 12/06/15. 12 | */ 13 | public abstract class ChartTouchListener> extends GestureDetector.SimpleOnGestureListener implements View.OnTouchListener { 14 | 15 | public enum ChartGesture { 16 | NONE, DRAG, X_ZOOM, Y_ZOOM, PINCH_ZOOM, ROTATE, SINGLE_TAP, DOUBLE_TAP, LONG_PRESS, FLING 17 | } 18 | 19 | /** 20 | * the last touch gesture that has been performed 21 | **/ 22 | protected ChartGesture mLastGesture = ChartGesture.NONE; 23 | 24 | // states 25 | protected static final int NONE = 0; 26 | protected static final int DRAG = 1; 27 | protected static final int X_ZOOM = 2; 28 | protected static final int Y_ZOOM = 3; 29 | protected static final int PINCH_ZOOM = 4; 30 | protected static final int POST_ZOOM = 5; 31 | protected static final int ROTATE = 6; 32 | 33 | /** 34 | * integer field that holds the current touch-state 35 | */ 36 | protected int mTouchMode = NONE; 37 | 38 | /** 39 | * the last highlighted object (via touch) 40 | */ 41 | protected Highlight mLastHighlighted; 42 | 43 | /** 44 | * the gesturedetector used for detecting taps and longpresses, ... 45 | */ 46 | protected GestureDetector mGestureDetector; 47 | 48 | /** 49 | * the chart the listener represents 50 | */ 51 | protected T mChart; 52 | 53 | public ChartTouchListener(T chart) { 54 | this.mChart = chart; 55 | 56 | mGestureDetector = new GestureDetector(chart.getContext(), this); 57 | } 58 | 59 | /** 60 | * Calls the OnChartGestureListener to do the start callback 61 | * 62 | * @param me 63 | */ 64 | public void startAction(MotionEvent me) { 65 | 66 | OnChartGestureListener l = mChart.getOnChartGestureListener(); 67 | 68 | if (l != null) 69 | l.onChartGestureStart(me, mLastGesture); 70 | } 71 | 72 | /** 73 | * Calls the OnChartGestureListener to do the end callback 74 | * 75 | * @param me 76 | */ 77 | public void endAction(MotionEvent me) { 78 | 79 | OnChartGestureListener l = mChart.getOnChartGestureListener(); 80 | 81 | if (l != null) 82 | l.onChartGestureEnd(me, mLastGesture); 83 | } 84 | 85 | /** 86 | * Sets the last value that was highlighted via touch. 87 | * 88 | * @param high 89 | */ 90 | public void setLastHighlighted(Highlight high) { 91 | mLastHighlighted = high; 92 | } 93 | 94 | /** 95 | * returns the touch mode the listener is currently in 96 | * 97 | * @return 98 | */ 99 | public int getTouchMode() { 100 | return mTouchMode; 101 | } 102 | 103 | /** 104 | * Returns the last gesture that has been performed on the chart. 105 | * 106 | * @return 107 | */ 108 | public ChartGesture getLastGesture() { 109 | return mLastGesture; 110 | } 111 | 112 | 113 | /** 114 | * Perform a highlight operation. 115 | * 116 | * @param e 117 | */ 118 | protected void performHighlight(Highlight h, MotionEvent e) { 119 | 120 | if (h == null || h.equalTo(mLastHighlighted)) { 121 | mChart.highlightTouch(null); 122 | mLastHighlighted = null; 123 | } else { 124 | mLastHighlighted = h; 125 | mChart.highlightTouch(h); 126 | } 127 | } 128 | 129 | /** 130 | * returns the distance between two points 131 | * 132 | * @param eventX 133 | * @param startX 134 | * @param eventY 135 | * @param startY 136 | * @return 137 | */ 138 | protected static float distance(float eventX, float startX, float eventY, float startY) { 139 | float dx = eventX - startX; 140 | float dy = eventY - startY; 141 | return (float) Math.sqrt(dx * dx + dy * dy); 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/listener/OnChartGestureListener.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.listener; 2 | 3 | import android.view.MotionEvent; 4 | 5 | /** 6 | * Listener for callbacks when doing gestures on the chart. 7 | * 8 | * @author Philipp Jahoda 9 | */ 10 | public interface OnChartGestureListener { 11 | 12 | /** 13 | * Callbacks when a touch-gesture has started on the chart (ACTION_DOWN) 14 | * 15 | * @param me 16 | * @param lastPerformedGesture 17 | */ 18 | void onChartGestureStart(MotionEvent me, ChartTouchListener.ChartGesture lastPerformedGesture); 19 | 20 | /** 21 | * Callbacks when a touch-gesture has ended on the chart (ACTION_UP, ACTION_CANCEL) 22 | * 23 | * @param me 24 | * @param lastPerformedGesture 25 | */ 26 | void onChartGestureEnd(MotionEvent me, ChartTouchListener.ChartGesture lastPerformedGesture); 27 | 28 | /** 29 | * Callbacks when the chart is longpressed. 30 | * 31 | * @param me 32 | */ 33 | void onChartLongPressed(MotionEvent me); 34 | 35 | /** 36 | * Callbacks when the chart is double-tapped. 37 | * 38 | * @param me 39 | */ 40 | void onChartDoubleTapped(MotionEvent me); 41 | 42 | /** 43 | * Callbacks when the chart is single-tapped. 44 | * 45 | * @param me 46 | */ 47 | void onChartSingleTapped(MotionEvent me); 48 | 49 | /** 50 | * Callbacks then a fling gesture is made on the chart. 51 | * 52 | * @param me1 53 | * @param me2 54 | * @param velocityX 55 | * @param velocityY 56 | */ 57 | void onChartFling(MotionEvent me1, MotionEvent me2, float velocityX, float velocityY); 58 | 59 | /** 60 | * Callbacks when the chart is scaled / zoomed via pinch zoom gesture. 61 | * 62 | * @param me 63 | * @param scaleX scalefactor on the x-axis 64 | * @param scaleY scalefactor on the y-axis 65 | */ 66 | void onChartScale(MotionEvent me, float scaleX, float scaleY); 67 | 68 | /** 69 | * Callbacks when the chart is moved / translated via drag gesture. 70 | * 71 | * @param me 72 | * @param dX translation distance on the x-axis 73 | * @param dY translation distance on the y-axis 74 | */ 75 | void onChartTranslate(MotionEvent me, float dX, float dY); 76 | } 77 | -------------------------------------------------------------------------------- /app/lib/mplib/src/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 dataSetIndex The index in the datasets array of the data object 19 | * the Entrys DataSet is in. 20 | * @param h the corresponding highlight object that contains information 21 | * about the highlighted position 22 | */ 23 | void onValueSelected(Entry e, int dataSetIndex, Highlight h); 24 | 25 | /** 26 | * Called when nothing has been selected or an "un-select" has been made. 27 | */ 28 | void onNothingSelected(); 29 | } 30 | -------------------------------------------------------------------------------- /app/lib/mplib/src/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 | -------------------------------------------------------------------------------- /app/lib/mplib/src/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 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/matrix/Vector3.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.matrix; 3 | 4 | /** 5 | * Simple 3D vector class. Handles basic vector math for 3D vectors. 6 | */ 7 | public final class Vector3 { 8 | public float x; 9 | public float y; 10 | public float z; 11 | 12 | public static final Vector3 ZERO = new Vector3(0, 0, 0); 13 | public static final Vector3 UNIT_X = new Vector3(1, 0, 0); 14 | public static final Vector3 UNIT_Y = new Vector3(0, 1, 0); 15 | public static final Vector3 UNIT_Z = new Vector3(0, 0, 1); 16 | 17 | public Vector3() { 18 | } 19 | 20 | public Vector3(float[] array) 21 | { 22 | set(array[0], array[1], array[2]); 23 | } 24 | 25 | public Vector3(float xValue, float yValue, float zValue) { 26 | set(xValue, yValue, zValue); 27 | } 28 | 29 | public Vector3(Vector3 other) { 30 | set(other); 31 | } 32 | 33 | public final void add(Vector3 other) { 34 | x += other.x; 35 | y += other.y; 36 | z += other.z; 37 | } 38 | 39 | public final void add(float otherX, float otherY, float otherZ) { 40 | x += otherX; 41 | y += otherY; 42 | z += otherZ; 43 | } 44 | 45 | public final void subtract(Vector3 other) { 46 | x -= other.x; 47 | y -= other.y; 48 | z -= other.z; 49 | } 50 | 51 | public final void subtractMultiple(Vector3 other, float multiplicator) 52 | { 53 | x -= other.x * multiplicator; 54 | y -= other.y * multiplicator; 55 | z -= other.z * multiplicator; 56 | } 57 | 58 | public final void multiply(float magnitude) { 59 | x *= magnitude; 60 | y *= magnitude; 61 | z *= magnitude; 62 | } 63 | 64 | public final void multiply(Vector3 other) { 65 | x *= other.x; 66 | y *= other.y; 67 | z *= other.z; 68 | } 69 | 70 | public final void divide(float magnitude) { 71 | if (magnitude != 0.0f) { 72 | x /= magnitude; 73 | y /= magnitude; 74 | z /= magnitude; 75 | } 76 | } 77 | 78 | public final void set(Vector3 other) { 79 | x = other.x; 80 | y = other.y; 81 | z = other.z; 82 | } 83 | 84 | public final void set(float xValue, float yValue, float zValue) { 85 | x = xValue; 86 | y = yValue; 87 | z = zValue; 88 | } 89 | 90 | public final float dot(Vector3 other) { 91 | return (x * other.x) + (y * other.y) + (z * other.z); 92 | } 93 | 94 | public final Vector3 cross(Vector3 other) { 95 | return new Vector3(y * other.z - z * other.y, 96 | z * other.x - x * other.z, 97 | x * other.y - y * other.x); 98 | } 99 | 100 | public final float length() { 101 | return (float) Math.sqrt(length2()); 102 | } 103 | 104 | public final float length2() { 105 | return (x * x) + (y * y) + (z * z); 106 | } 107 | 108 | public final float distance2(Vector3 other) { 109 | float dx = x - other.x; 110 | float dy = y - other.y; 111 | float dz = z - other.z; 112 | return (dx * dx) + (dy * dy) + (dz * dz); 113 | } 114 | 115 | public final float normalize() { 116 | final float magnitude = length(); 117 | 118 | // TODO: I'm choosing safety over speed here. 119 | if (magnitude != 0.0f) { 120 | x /= magnitude; 121 | y /= magnitude; 122 | z /= magnitude; 123 | } 124 | 125 | return magnitude; 126 | } 127 | 128 | public final void zero() { 129 | set(0.0f, 0.0f, 0.0f); 130 | } 131 | 132 | public final boolean pointsInSameDirection(Vector3 other) { 133 | return this.dot(other) > 0; 134 | } 135 | 136 | } 137 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/renderer/AxisRenderer.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.renderer; 3 | 4 | import android.graphics.Canvas; 5 | import android.graphics.Color; 6 | import android.graphics.Paint; 7 | import android.graphics.Paint.Style; 8 | 9 | import com.github.mikephil.charting.utils.Transformer; 10 | import com.github.mikephil.charting.utils.ViewPortHandler; 11 | 12 | /** 13 | * Baseclass of all axis renderers. 14 | * 15 | * @author Philipp Jahoda 16 | */ 17 | public abstract class AxisRenderer extends Renderer { 18 | 19 | protected Transformer mTrans; 20 | 21 | /** paint object for the grid lines */ 22 | protected Paint mGridPaint; 23 | 24 | /** paint for the x-label values */ 25 | protected Paint mAxisLabelPaint; 26 | 27 | /** paint for the line surrounding the chart */ 28 | protected Paint mAxisLinePaint; 29 | 30 | /** paint used for the limit lines */ 31 | protected Paint mLimitLinePaint; 32 | 33 | public AxisRenderer(ViewPortHandler viewPortHandler, Transformer trans) { 34 | super(viewPortHandler); 35 | 36 | this.mTrans = trans; 37 | 38 | mAxisLabelPaint = new Paint(Paint.ANTI_ALIAS_FLAG); 39 | 40 | mGridPaint = new Paint(); 41 | mGridPaint.setColor(Color.GRAY); 42 | mGridPaint.setStrokeWidth(1f); 43 | mGridPaint.setStyle(Style.STROKE); 44 | mGridPaint.setAlpha(90); 45 | 46 | mAxisLinePaint = new Paint(); 47 | mAxisLinePaint.setColor(Color.BLACK); 48 | mAxisLinePaint.setStrokeWidth(1f); 49 | mAxisLinePaint.setStyle(Style.STROKE); 50 | 51 | mLimitLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG); 52 | mLimitLinePaint.setStyle(Style.STROKE); 53 | } 54 | 55 | /** 56 | * Returns the Paint object used for drawing the axis (labels). 57 | * 58 | * @return 59 | */ 60 | public Paint getPaintAxisLabels() { 61 | return mAxisLabelPaint; 62 | } 63 | 64 | /** 65 | * Returns the Paint object that is used for drawing the grid-lines of the 66 | * axis. 67 | * 68 | * @return 69 | */ 70 | public Paint getPaintGrid() { 71 | return mGridPaint; 72 | } 73 | 74 | /** 75 | * Returns the Paint object that is used for drawing the axis-line that goes 76 | * alongside the axis. 77 | * 78 | * @return 79 | */ 80 | public Paint getPaintAxisLine() { 81 | return mAxisLinePaint; 82 | } 83 | 84 | /** 85 | * Returns the Transformer object used for transforming the axis values. 86 | * 87 | * @return 88 | */ 89 | public Transformer getTransformer() { 90 | return mTrans; 91 | } 92 | 93 | /** 94 | * Draws the axis labels to the screen. 95 | * 96 | * @param c 97 | */ 98 | public abstract void renderAxisLabels(Canvas c); 99 | 100 | /** 101 | * Draws the grid lines belonging to the axis. 102 | * 103 | * @param c 104 | */ 105 | public abstract void renderGridLines(Canvas c); 106 | 107 | /** 108 | * Draws the line that goes alongside the axis. 109 | * 110 | * @param c 111 | */ 112 | public abstract void renderAxisLine(Canvas c); 113 | 114 | /** 115 | * Draws the LimitLines associated with this axis to the screen. 116 | * 117 | * @param c 118 | */ 119 | public abstract void renderLimitLines(Canvas c); 120 | } 121 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/renderer/CombinedChartRenderer.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.renderer; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import android.graphics.Canvas; 7 | 8 | import com.github.mikephil.charting.animation.ChartAnimator; 9 | import com.github.mikephil.charting.charts.CombinedChart; 10 | import com.github.mikephil.charting.charts.CombinedChart.DrawOrder; 11 | import com.github.mikephil.charting.highlight.Highlight; 12 | import com.github.mikephil.charting.interfaces.BarLineScatterCandleBubbleDataProvider; 13 | import com.github.mikephil.charting.utils.ViewPortHandler; 14 | 15 | /** 16 | * Renderer class that is responsible for rendering multiple different data-types. 17 | */ 18 | public class CombinedChartRenderer extends DataRenderer { 19 | 20 | /** 21 | * all rederers for the different kinds of data this combined-renderer can draw 22 | */ 23 | protected List mRenderers; 24 | 25 | public CombinedChartRenderer(CombinedChart chart, ChartAnimator animator, ViewPortHandler viewPortHandler) { 26 | super(animator, viewPortHandler); 27 | 28 | createRenderers(chart, animator, viewPortHandler); 29 | } 30 | 31 | /** 32 | * Creates the renderers needed for this combined-renderer in the required order. Also takes the DrawOrder into 33 | * consideration. 34 | * 35 | * @param chart 36 | * @param animator 37 | * @param viewPortHandler 38 | */ 39 | protected void createRenderers(CombinedChart chart, ChartAnimator animator, ViewPortHandler viewPortHandler) { 40 | 41 | mRenderers = new ArrayList(); 42 | 43 | DrawOrder[] orders = chart.getDrawOrder(); 44 | 45 | for (DrawOrder order : orders) { 46 | 47 | switch (order) { 48 | case BAR: 49 | if (chart.getBarData() != null) 50 | mRenderers.add(new BarChartRenderer(chart, animator, viewPortHandler)); 51 | break; 52 | case BUBBLE: 53 | if (chart.getBubbleData() != null) 54 | mRenderers.add(new BubbleChartRenderer(chart, animator, viewPortHandler)); 55 | break; 56 | case LINE: 57 | if (chart.getLineData() != null) 58 | mRenderers.add(new LineChartRenderer(chart, animator, viewPortHandler)); 59 | break; 60 | case CANDLE: 61 | if (chart.getCandleData() != null) 62 | mRenderers.add(new CandleStickChartRenderer(chart, animator, viewPortHandler)); 63 | break; 64 | case SCATTER: 65 | if (chart.getScatterData() != null) 66 | mRenderers.add(new ScatterChartRenderer(chart, animator, viewPortHandler)); 67 | break; 68 | } 69 | } 70 | } 71 | 72 | @Override 73 | public void initBuffers() { 74 | 75 | for (DataRenderer renderer : mRenderers) 76 | renderer.initBuffers(); 77 | } 78 | 79 | @Override 80 | public void drawData(Canvas c) { 81 | 82 | for (DataRenderer renderer : mRenderers) 83 | renderer.drawData(c); 84 | } 85 | 86 | @Override 87 | public void drawValues(Canvas c) { 88 | 89 | for (DataRenderer renderer : mRenderers) 90 | renderer.drawValues(c); 91 | } 92 | 93 | @Override 94 | public void drawExtras(Canvas c) { 95 | 96 | for (DataRenderer renderer : mRenderers) 97 | renderer.drawExtras(c); 98 | } 99 | 100 | @Override 101 | public void drawHighlighted(Canvas c, Highlight[] indices) { 102 | for (DataRenderer renderer : mRenderers) 103 | renderer.drawHighlighted(c, indices); 104 | } 105 | 106 | @Override 107 | public void calcXBounds(BarLineScatterCandleBubbleDataProvider chart, int xAxisModulus) { 108 | for (DataRenderer renderer : mRenderers) 109 | renderer.calcXBounds(chart, xAxisModulus); 110 | } 111 | 112 | /** 113 | * Returns the sub-renderer object at the specified index. 114 | * 115 | * @param index 116 | * @return 117 | */ 118 | public DataRenderer getSubRenderer(int index) { 119 | if (index >= mRenderers.size() || index < 0) 120 | return null; 121 | else 122 | return mRenderers.get(index); 123 | } 124 | 125 | /** 126 | * Returns all sub-renderers. 127 | * 128 | * @return 129 | */ 130 | public List getSubRenderers() { 131 | return mRenderers; 132 | } 133 | 134 | public void setSubRenderers(List renderers) { 135 | this.mRenderers = renderers; 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/renderer/DataRenderer.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.renderer; 3 | 4 | import android.graphics.Canvas; 5 | import android.graphics.Color; 6 | import android.graphics.Paint; 7 | import android.graphics.Paint.Align; 8 | import android.graphics.Paint.Style; 9 | 10 | import com.github.mikephil.charting.animation.ChartAnimator; 11 | import com.github.mikephil.charting.data.DataSet; 12 | import com.github.mikephil.charting.data.Entry; 13 | import com.github.mikephil.charting.highlight.Highlight; 14 | import com.github.mikephil.charting.utils.Utils; 15 | import com.github.mikephil.charting.formatter.ValueFormatter; 16 | import com.github.mikephil.charting.utils.ViewPortHandler; 17 | 18 | /** 19 | * Superclass of all render classes for the different data types (line, bar, ...). 20 | * 21 | * @author Philipp Jahoda 22 | */ 23 | public abstract class DataRenderer extends Renderer { 24 | 25 | /** 26 | * the animator object used to perform animations on the chart data 27 | */ 28 | protected ChartAnimator mAnimator; 29 | 30 | /** 31 | * main paint object used for rendering 32 | */ 33 | protected Paint mRenderPaint; 34 | 35 | /** 36 | * paint used for highlighting values 37 | */ 38 | protected Paint mHighlightPaint; 39 | 40 | protected Paint mDrawPaint; 41 | 42 | /** 43 | * paint object for drawing values (text representing values of chart 44 | * entries) 45 | */ 46 | protected Paint mValuePaint; 47 | 48 | public DataRenderer(ChartAnimator animator, ViewPortHandler viewPortHandler) { 49 | super(viewPortHandler); 50 | this.mAnimator = animator; 51 | 52 | mRenderPaint = new Paint(Paint.ANTI_ALIAS_FLAG); 53 | mRenderPaint.setStyle(Style.FILL); 54 | 55 | mDrawPaint = new Paint(Paint.DITHER_FLAG); 56 | 57 | mValuePaint = new Paint(Paint.ANTI_ALIAS_FLAG); 58 | mValuePaint.setColor(Color.rgb(63, 63, 63)); 59 | mValuePaint.setTextAlign(Align.CENTER); 60 | mValuePaint.setTextSize(Utils.convertDpToPixel(9f)); 61 | 62 | mHighlightPaint = new Paint(Paint.ANTI_ALIAS_FLAG); 63 | mHighlightPaint.setStyle(Style.STROKE); 64 | mHighlightPaint.setStrokeWidth(2f); 65 | mHighlightPaint.setColor(Color.rgb(255, 187, 115)); 66 | } 67 | 68 | /** 69 | * Returns the Paint object this renderer uses for drawing the values 70 | * (value-text). 71 | * 72 | * @return 73 | */ 74 | public Paint getPaintValues() { 75 | return mValuePaint; 76 | } 77 | 78 | /** 79 | * Returns the Paint object this renderer uses for drawing highlight 80 | * indicators. 81 | * 82 | * @return 83 | */ 84 | public Paint getPaintHighlight() { 85 | return mHighlightPaint; 86 | } 87 | 88 | /** 89 | * Returns the Paint object used for rendering. 90 | * 91 | * @return 92 | */ 93 | public Paint getPaintRender() { 94 | return mRenderPaint; 95 | } 96 | 97 | /** 98 | * Applies the required styling (provided by the DataSet) to the value-paint 99 | * object. 100 | * 101 | * @param set 102 | */ 103 | protected void applyValueTextStyle(DataSet set) { 104 | 105 | mValuePaint.setColor(set.getValueTextColor()); 106 | mValuePaint.setTypeface(set.getValueTypeface()); 107 | mValuePaint.setTextSize(set.getValueTextSize()); 108 | } 109 | 110 | /** 111 | * Initializes the buffers used for rendering with a new size. Since this 112 | * method performs memory allocations, it should only be called if 113 | * necessary. 114 | */ 115 | public abstract void initBuffers(); 116 | 117 | /** 118 | * Draws the actual data in form of lines, bars, ... depending on Renderer subclass. 119 | * 120 | * @param c 121 | */ 122 | public abstract void drawData(Canvas c); 123 | 124 | /** 125 | * Loops over all Entrys and draws their values. 126 | * 127 | * @param c 128 | */ 129 | public abstract void drawValues(Canvas c); 130 | 131 | /** 132 | * Draws the value of the given entry by using the provided ValueFormatter. 133 | * 134 | * @param c canvas 135 | * @param formatter formatter for custom value-formatting 136 | * @param value the value to be drawn 137 | * @param entry the entry the value belongs to 138 | * @param dataSetIndex the index of the DataSet the drawn Entry belongs to 139 | * @param x position 140 | * @param y position 141 | */ 142 | public void drawValue(Canvas c, ValueFormatter formatter, float value, Entry entry, int dataSetIndex, float x, float y) { 143 | c.drawText(formatter.getFormattedValue(value, entry, dataSetIndex, mViewPortHandler), x, y, mValuePaint); 144 | } 145 | 146 | /** 147 | * Draws any kind of additional information (e.g. line-circles). 148 | * 149 | * @param c 150 | */ 151 | public abstract void drawExtras(Canvas c); 152 | 153 | /** 154 | * Draws all highlight indicators for the values that are currently highlighted. 155 | * 156 | * @param c 157 | * @param indices the highlighted values 158 | */ 159 | public abstract void drawHighlighted(Canvas c, Highlight[] indices); 160 | } 161 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/renderer/LineScatterCandleRadarRenderer.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.renderer; 2 | 3 | import android.graphics.Canvas; 4 | import android.graphics.Path; 5 | 6 | import com.github.mikephil.charting.animation.ChartAnimator; 7 | import com.github.mikephil.charting.data.LineScatterCandleRadarDataSet; 8 | import com.github.mikephil.charting.utils.ViewPortHandler; 9 | 10 | /** 11 | * Created by Philipp Jahoda on 11/07/15. 12 | */ 13 | public abstract class LineScatterCandleRadarRenderer extends DataRenderer { 14 | 15 | /** 16 | * path that is used for drawing highlight-lines (drawLines(...) cannot be used because of dashes) 17 | */ 18 | private Path mHighlightLinePath = new Path(); 19 | 20 | public LineScatterCandleRadarRenderer(ChartAnimator animator, ViewPortHandler viewPortHandler) { 21 | super(animator, viewPortHandler); 22 | } 23 | 24 | /** 25 | * Draws vertical & horizontal highlight-lines if enabled. 26 | * 27 | * @param c 28 | * @param pts the transformed x- and y-position of the lines 29 | * @param set the currently drawn dataset 30 | */ 31 | protected void drawHighlightLines(Canvas c, float[] pts, LineScatterCandleRadarDataSet set) { 32 | 33 | // set color and stroke-width 34 | mHighlightPaint.setColor(set.getHighLightColor()); 35 | mHighlightPaint.setStrokeWidth(set.getHighlightLineWidth()); 36 | 37 | // draw highlighted lines (if enabled) 38 | mHighlightPaint.setPathEffect(set.getDashPathEffectHighlight()); 39 | 40 | // draw vertical highlight lines 41 | if (set.isVerticalHighlightIndicatorEnabled()) { 42 | 43 | // create vertical path 44 | mHighlightLinePath.reset(); 45 | mHighlightLinePath.moveTo(pts[0], mViewPortHandler.contentTop()); 46 | mHighlightLinePath.lineTo(pts[0], mViewPortHandler.contentBottom()); 47 | 48 | c.drawPath(mHighlightLinePath, mHighlightPaint); 49 | } 50 | 51 | // draw horizontal highlight lines 52 | if (set.isHorizontalHighlightIndicatorEnabled()) { 53 | 54 | // create horizontal path 55 | mHighlightLinePath.reset(); 56 | mHighlightLinePath.moveTo(mViewPortHandler.contentLeft(), pts[1]); 57 | mHighlightLinePath.lineTo(mViewPortHandler.contentRight(), pts[1]); 58 | 59 | c.drawPath(mHighlightLinePath, mHighlightPaint); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/renderer/Renderer.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.renderer; 3 | 4 | import com.github.mikephil.charting.interfaces.BarLineScatterCandleBubbleDataProvider; 5 | import com.github.mikephil.charting.utils.ViewPortHandler; 6 | 7 | /** 8 | * Abstract baseclass of all Renderers. 9 | * 10 | * @author Philipp Jahoda 11 | */ 12 | public abstract class Renderer { 13 | 14 | /** 15 | * the component that handles the drawing area of the chart and it's offsets 16 | */ 17 | protected ViewPortHandler mViewPortHandler; 18 | 19 | /** the minimum value on the x-axis that should be plotted */ 20 | protected int mMinX = 0; 21 | 22 | /** the maximum value on the x-axis that should be plotted */ 23 | protected int mMaxX = 0; 24 | 25 | public Renderer(ViewPortHandler viewPortHandler) { 26 | this.mViewPortHandler = viewPortHandler; 27 | } 28 | 29 | /** 30 | * Returns true if the specified value fits in between the provided min 31 | * and max bounds, false if not. 32 | * 33 | * @param val 34 | * @param min 35 | * @param max 36 | * @return 37 | */ 38 | protected boolean fitsBounds(float val, float min, float max) { 39 | 40 | if (val < min || val > max) 41 | return false; 42 | else 43 | return true; 44 | } 45 | 46 | /** 47 | * Calculates the minimum and maximum x-value the chart can currently 48 | * display (with the given zoom level). -> mMinX, mMaxX 49 | * 50 | * @param dataProvider 51 | * @param xAxisModulus 52 | */ 53 | public void calcXBounds(BarLineScatterCandleBubbleDataProvider dataProvider, int xAxisModulus) { 54 | 55 | int low = dataProvider.getLowestVisibleXIndex(); 56 | int high = dataProvider.getHighestVisibleXIndex(); 57 | 58 | int subLow = (low % xAxisModulus == 0) ? xAxisModulus : 0; 59 | 60 | mMinX = Math.max((low / xAxisModulus) * (xAxisModulus) - subLow, 0); 61 | mMaxX = Math.min((high / xAxisModulus) * (xAxisModulus) + xAxisModulus, (int) dataProvider.getXChartMax()); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/renderer/XAxisRendererBarChart.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.renderer; 3 | 4 | import android.graphics.Canvas; 5 | import android.graphics.PointF; 6 | 7 | import com.github.mikephil.charting.charts.BarChart; 8 | import com.github.mikephil.charting.components.XAxis; 9 | import com.github.mikephil.charting.data.BarData; 10 | import com.github.mikephil.charting.utils.Transformer; 11 | import com.github.mikephil.charting.utils.Utils; 12 | import com.github.mikephil.charting.utils.ViewPortHandler; 13 | 14 | public class XAxisRendererBarChart extends XAxisRenderer { 15 | 16 | protected BarChart mChart; 17 | 18 | public XAxisRendererBarChart(ViewPortHandler viewPortHandler, XAxis xAxis, Transformer trans, 19 | BarChart chart) { 20 | super(viewPortHandler, xAxis, trans); 21 | 22 | this.mChart = chart; 23 | } 24 | 25 | /** 26 | * draws the x-labels on the specified y-position 27 | * 28 | * @param pos 29 | */ 30 | @Override 31 | protected void drawLabels(Canvas c, float pos, PointF anchor) { 32 | 33 | final float labelRotationAngleDegrees = mXAxis.getLabelRotationAngle(); 34 | 35 | // pre allocate to save performance (dont allocate in loop) 36 | float[] position = new float[] { 37 | 0f, 0f 38 | }; 39 | 40 | BarData bd = mChart.getData(); 41 | int step = bd.getDataSetCount(); 42 | 43 | for (int i = mMinX; i <= mMaxX; i += mXAxis.mAxisLabelModulus) { 44 | 45 | position[0] = i * step + i * bd.getGroupSpace() 46 | + bd.getGroupSpace() / 2f; 47 | 48 | // consider groups (center label for each group) 49 | if (step > 1) { 50 | position[0] += ((float) step - 1f) / 2f; 51 | } 52 | 53 | mTrans.pointValuesToPixel(position); 54 | 55 | if (mViewPortHandler.isInBoundsX(position[0]) && i >= 0 56 | && i < mXAxis.getValues().size()) { 57 | 58 | String label = mXAxis.getValues().get(i); 59 | 60 | if (mXAxis.isAvoidFirstLastClippingEnabled()) { 61 | 62 | // avoid clipping of the last 63 | if (i == mXAxis.getValues().size() - 1) { 64 | float width = Utils.calcTextWidth(mAxisLabelPaint, label); 65 | 66 | if (position[0] + width / 2.f > mViewPortHandler.contentRight()) 67 | position[0] = mViewPortHandler.contentRight() - (width / 2.f); 68 | 69 | // avoid clipping of the first 70 | } else if (i == 0) { 71 | 72 | float width = Utils.calcTextWidth(mAxisLabelPaint, label); 73 | 74 | if (position[0] - width / 2.f < mViewPortHandler.contentLeft()) 75 | position[0] = mViewPortHandler.contentLeft() + (width / 2.f); 76 | } 77 | } 78 | 79 | drawLabel(c, label, i, position[0], pos, anchor, labelRotationAngleDegrees); 80 | } 81 | } 82 | } 83 | 84 | @Override 85 | public void renderGridLines(Canvas c) { 86 | 87 | if (!mXAxis.isDrawGridLinesEnabled() || !mXAxis.isEnabled()) 88 | return; 89 | 90 | float[] position = new float[] { 91 | 0f, 0f 92 | }; 93 | 94 | mGridPaint.setColor(mXAxis.getGridColor()); 95 | mGridPaint.setStrokeWidth(mXAxis.getGridLineWidth()); 96 | 97 | BarData bd = mChart.getData(); 98 | int step = bd.getDataSetCount(); 99 | 100 | for (int i = mMinX; i < mMaxX; i += mXAxis.mAxisLabelModulus) { 101 | 102 | position[0] = i * step + i * bd.getGroupSpace() - 0.5f; 103 | 104 | mTrans.pointValuesToPixel(position); 105 | 106 | if (mViewPortHandler.isInBoundsX(position[0])) { 107 | 108 | c.drawLine(position[0], mViewPortHandler.offsetTop(), position[0], 109 | mViewPortHandler.contentBottom(), mGridPaint); 110 | } 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/renderer/XAxisRendererRadarChart.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.renderer; 3 | 4 | import android.graphics.Canvas; 5 | import android.graphics.PointF; 6 | 7 | import com.github.mikephil.charting.charts.RadarChart; 8 | import com.github.mikephil.charting.components.XAxis; 9 | import com.github.mikephil.charting.utils.Utils; 10 | import com.github.mikephil.charting.utils.ViewPortHandler; 11 | 12 | public class XAxisRendererRadarChart extends XAxisRenderer { 13 | 14 | private RadarChart mChart; 15 | 16 | public XAxisRendererRadarChart(ViewPortHandler viewPortHandler, XAxis xAxis, RadarChart chart) { 17 | super(viewPortHandler, xAxis, null); 18 | 19 | mChart = chart; 20 | } 21 | 22 | @Override 23 | public void renderAxisLabels(Canvas c) { 24 | 25 | if (!mXAxis.isEnabled() || !mXAxis.isDrawLabelsEnabled()) 26 | return; 27 | 28 | final float labelRotationAngleDegrees = mXAxis.getLabelRotationAngle(); 29 | final PointF drawLabelAnchor = new PointF(0.5f, 0.0f); 30 | 31 | mAxisLabelPaint.setTypeface(mXAxis.getTypeface()); 32 | mAxisLabelPaint.setTextSize(mXAxis.getTextSize()); 33 | mAxisLabelPaint.setColor(mXAxis.getTextColor()); 34 | 35 | float sliceangle = mChart.getSliceAngle(); 36 | 37 | // calculate the factor that is needed for transforming the value to 38 | // pixels 39 | float factor = mChart.getFactor(); 40 | 41 | PointF center = mChart.getCenterOffsets(); 42 | 43 | int mod = mXAxis.mAxisLabelModulus; 44 | for (int i = 0; i < mXAxis.getValues().size(); i += mod) { 45 | String label = mXAxis.getValues().get(i); 46 | 47 | float angle = (sliceangle * i + mChart.getRotationAngle()) % 360f; 48 | 49 | PointF p = Utils.getPosition(center, mChart.getYRange() * factor 50 | + mXAxis.mLabelRotatedWidth / 2f, angle); 51 | 52 | drawLabel(c, label, i, p.x, p.y - mXAxis.mLabelRotatedHeight / 2.f, 53 | drawLabelAnchor, labelRotationAngleDegrees); 54 | } 55 | } 56 | 57 | /** 58 | * XAxis LimitLines on RadarChart not yet supported. 59 | * 60 | * @param c 61 | */ 62 | @Override 63 | public void renderLimitLines(Canvas c) { 64 | // this space intentionally left blank 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/utils/ColorTemplate.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.utils; 3 | 4 | import android.content.res.Resources; 5 | import android.graphics.Color; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | /** 11 | * Class that holds predefined color integer arrays (e.g. 12 | * ColorTemplate.VORDIPLOM_COLORS) and convenience methods for loading colors 13 | * from resources. 14 | * 15 | * @author Philipp Jahoda 16 | */ 17 | public class ColorTemplate { 18 | 19 | /** 20 | * an "invalid" color that indicates that no color is set 21 | */ 22 | public static final int COLOR_NONE = -1; 23 | 24 | /** 25 | * this "color" is used for the Legend creation and indicates that the next 26 | * form should be skipped 27 | */ 28 | public static final int COLOR_SKIP = -2; 29 | 30 | /** 31 | * THE COLOR THEMES ARE PREDEFINED (predefined color integer arrays), FEEL 32 | * FREE TO CREATE YOUR OWN WITH AS MANY DIFFERENT COLORS AS YOU WANT 33 | */ 34 | public static final int[] LIBERTY_COLORS = { 35 | Color.rgb(207, 248, 246), Color.rgb(148, 212, 212), Color.rgb(136, 180, 187), 36 | Color.rgb(118, 174, 175), Color.rgb(42, 109, 130) 37 | }; 38 | public static final int[] JOYFUL_COLORS = { 39 | Color.rgb(217, 80, 138), Color.rgb(254, 149, 7), Color.rgb(254, 247, 120), 40 | Color.rgb(106, 167, 134), Color.rgb(53, 194, 209) 41 | }; 42 | public static final int[] PASTEL_COLORS = { 43 | Color.rgb(64, 89, 128), Color.rgb(149, 165, 124), Color.rgb(217, 184, 162), 44 | Color.rgb(191, 134, 134), Color.rgb(179, 48, 80) 45 | }; 46 | public static final int[] COLORFUL_COLORS = { 47 | Color.rgb(193, 37, 82), Color.rgb(255, 102, 0), Color.rgb(245, 199, 0), 48 | Color.rgb(106, 150, 31), Color.rgb(179, 100, 53) 49 | }; 50 | public static final int[] VORDIPLOM_COLORS = { 51 | Color.rgb(192, 255, 140), Color.rgb(255, 247, 140), Color.rgb(255, 208, 140), 52 | Color.rgb(140, 234, 255), Color.rgb(255, 140, 157) 53 | }; 54 | 55 | /** 56 | * Returns the Android ICS holo blue light color. 57 | * 58 | * @return 59 | */ 60 | public static int getHoloBlue() { 61 | return Color.rgb(51, 181, 229); 62 | } 63 | 64 | /** 65 | * turn an array of resource-colors (contains resource-id integers) into an 66 | * array list of actual color integers 67 | * 68 | * @param r 69 | * @param colors an integer array of resource id's of colors 70 | * @return 71 | */ 72 | public static List createColors(Resources r, int[] colors) { 73 | 74 | List result = new ArrayList(); 75 | 76 | for (int i : colors) { 77 | result.add(r.getColor(i)); 78 | } 79 | 80 | return result; 81 | } 82 | 83 | /** 84 | * Turns an array of colors (integer color values) into an ArrayList of 85 | * colors. 86 | * 87 | * @param colors 88 | * @return 89 | */ 90 | public static List createColors(int[] colors) { 91 | 92 | List result = new ArrayList(); 93 | 94 | for (int i : colors) { 95 | result.add(i); 96 | } 97 | 98 | return result; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/utils/EntryXIndexComparator.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-index. 9 | * Created by philipp on 17/06/15. 10 | */ 11 | public class EntryXIndexComparator implements Comparator { 12 | @Override 13 | public int compare(Entry entry1, Entry entry2) { 14 | return entry1.getXIndex() - entry2.getXIndex(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/utils/FSize.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.utils; 3 | 4 | /** 5 | * Immutable class for describing width and height dimensions in some arbitrary 6 | * unit. Replacement for the android.Util.SizeF which is available only on API >= 21. 7 | */ 8 | public final class FSize { 9 | 10 | public final float width; 11 | public final float height; 12 | 13 | public FSize(final float width, final float height) { 14 | this.width = width; 15 | this.height = height; 16 | } 17 | 18 | @Override 19 | public boolean equals(final Object obj) { 20 | if (obj == null) { 21 | return false; 22 | } 23 | if (this == obj) { 24 | return true; 25 | } 26 | if (obj instanceof FSize) { 27 | final FSize other = (FSize) obj; 28 | return width == other.width && height == other.height; 29 | } 30 | return false; 31 | } 32 | 33 | @Override 34 | public String toString() { 35 | return width + "x" + height; 36 | } 37 | 38 | /** 39 | * {@inheritDoc} 40 | */ 41 | @Override 42 | public int hashCode() { 43 | return Float.floatToIntBits(width) ^ Float.floatToIntBits(height); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/utils/PointD.java: -------------------------------------------------------------------------------- 1 | 2 | package com.github.mikephil.charting.utils; 3 | 4 | /** 5 | * Point encapsulating two double values. 6 | * 7 | * @author Philipp Jahoda 8 | */ 9 | public class PointD { 10 | 11 | public double x; 12 | public double y; 13 | 14 | public PointD(double x, double y) { 15 | this.x = x; 16 | this.y = y; 17 | } 18 | 19 | /** 20 | * returns a string representation of the object 21 | */ 22 | public String toString() { 23 | return "PointD, x: " + x + ", y: " + y; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/lib/mplib/src/com/github/mikephil/charting/utils/SelectionDetail.java: -------------------------------------------------------------------------------- 1 | package com.github.mikephil.charting.utils; 2 | 3 | import com.github.mikephil.charting.data.DataSet; 4 | 5 | /** 6 | * Class that encapsulates information of a value that has been 7 | * selected/highlighted and its DataSet index. The SelectionDetail objects give 8 | * information about the value at the selected index and the DataSet it belongs 9 | * to. Needed only for highlighting onTouch(). 10 | * 11 | * @author Philipp Jahoda 12 | */ 13 | public class SelectionDetail { 14 | 15 | public float val; 16 | public int dataSetIndex; 17 | public DataSet dataSet; 18 | 19 | public SelectionDetail(float val, int dataSetIndex, DataSet set) { 20 | this.val = val; 21 | this.dataSetIndex = dataSetIndex; 22 | this.dataSet = set; 23 | } 24 | } -------------------------------------------------------------------------------- /app/lib/mplib/src/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 chart 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 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:\Users\Think\AppData\Local\Android\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/example/chenyu/mpandroidcharttest/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.example.chenyu.mpandroidcharttest; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/chenyu/mpandroidcharttest/BarCharFragment.java: -------------------------------------------------------------------------------- 1 | package com.example.chenyu.mpandroidcharttest; 2 | 3 | import android.app.Fragment; 4 | import android.os.Bundle; 5 | import android.support.annotation.Nullable; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | 10 | import com.github.mikephil.charting.charts.BarChart; 11 | import com.github.mikephil.charting.components.LimitLine; 12 | import com.github.mikephil.charting.data.BarData; 13 | import com.github.mikephil.charting.data.BarDataSet; 14 | import com.github.mikephil.charting.data.BarEntry; 15 | import com.github.mikephil.charting.utils.ColorTemplate; 16 | 17 | import java.util.ArrayList; 18 | 19 | /** 20 | * Created by Think on 2015/11/29. 21 | */ 22 | public class BarCharFragment extends Fragment{ 23 | public BarChart barChart; 24 | public ArrayList entries=new ArrayList(); 25 | public BarDataSet dataset; 26 | public ArrayList labels=new ArrayList(); 27 | @Nullable 28 | @Override 29 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 30 | View view = inflater.inflate(R.layout.bar_chart, container, false); 31 | barChart= (BarChart) view.findViewById(R.id.bar_chart); 32 | initEntriesData(); 33 | initLableData(); 34 | show(); 35 | return view; 36 | } 37 | public void initEntriesData(){ 38 | entries.add(new BarEntry(4f, 0)); 39 | entries.add(new BarEntry(8f, 1)); 40 | entries.add(new BarEntry(6f, 2)); 41 | entries.add(new BarEntry(12f, 3)); 42 | entries.add(new BarEntry(18f, 4)); 43 | entries.add(new BarEntry(9f, 5)); 44 | } 45 | public void initLableData(){ 46 | labels.add("一月"); 47 | labels.add("二月"); 48 | labels.add("三月"); 49 | labels.add("四月"); 50 | labels.add("五月"); 51 | labels.add("六月"); 52 | } 53 | public void show(){ 54 | dataset= new BarDataSet(entries,"# of Calls"); 55 | dataset.setColors(ColorTemplate.COLORFUL_COLORS); 56 | BarData data=new BarData(labels,dataset); 57 | LimitLine line=new LimitLine(10f); 58 | barChart.setData(data); 59 | // chart.animateXY(5000,5000); 60 | // chart.animateX(5000); 61 | barChart.animateY(3000); 62 | barChart.setDescription("hello MPandroidChart"); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/chenyu/mpandroidcharttest/LineCharFragment.java: -------------------------------------------------------------------------------- 1 | package com.example.chenyu.mpandroidcharttest; 2 | 3 | import android.app.Fragment; 4 | import android.graphics.Color; 5 | import android.os.Bundle; 6 | import android.support.annotation.Nullable; 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.view.ViewGroup; 10 | 11 | import com.github.mikephil.charting.charts.LineChart; 12 | import com.github.mikephil.charting.components.Legend; 13 | import com.github.mikephil.charting.data.Entry; 14 | import com.github.mikephil.charting.data.LineData; 15 | import com.github.mikephil.charting.data.LineDataSet; 16 | 17 | import java.util.ArrayList; 18 | 19 | /** 20 | * Created by Think on 2015/11/29. 21 | */ 22 | public class LineCharFragment extends Fragment { 23 | public LineChart lineChart; 24 | public ArrayList x=new ArrayList(); 25 | public ArrayList y=new ArrayList(); 26 | public ArrayList lineDataSets=new ArrayList(); 27 | public LineData lineData=null; 28 | @Nullable 29 | @Override 30 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 31 | View view= inflater.inflate(R.layout.liner_chart, container, false); 32 | lineChart= (LineChart) view.findViewById(R.id.spread_line_chart); 33 | LineData resultLineData=getLineData(40, 100); 34 | showChart(lineChart,resultLineData, Color.rgb(110, 190, 224)); 35 | return view; 36 | } 37 | /** 38 | * 初始化数据 39 | * count 表示坐标点个数,range表示等下y值生成的范围 40 | */ 41 | public LineData getLineData(int count,float range){ 42 | for(int i=0;i x=new ArrayList(); 25 | public ArrayList y=new ArrayList(); 26 | public ArrayList lineDataSets=new ArrayList(); 27 | public LineData lineData=null; 28 | @Nullable 29 | @Override 30 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 31 | View view= inflater.inflate(R.layout.liner_chart, container, false); 32 | lineChart= (LineChart) view.findViewById(R.id.spread_line_chart); 33 | LineData resultLineData=getLineData(40, 100); 34 | showChart(); 35 | return view; 36 | } 37 | /**gv 38 | * 初始化数据 39 | * count 表示坐标点个数,range表示等下y值生成的范围 40 | */ 41 | public LineData getLineData(int count,float range){ 42 | for(int i=0;i entries=new ArrayList(); 25 | public BarDataSet dataset; 26 | public ArrayList labels=new ArrayList(); 27 | @Nullable 28 | @Override 29 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 30 | View view = inflater.inflate(R.layout.bar_chart, container, false); 31 | barChart= (BarChart) view.findViewById(R.id.bar_chart); 32 | initEntriesData(); 33 | initLableData(); 34 | show(); 35 | return view; 36 | } 37 | public void initEntriesData(){ 38 | entries.add(new BarEntry(4f, 0)); 39 | entries.add(new BarEntry(8f, 1)); 40 | entries.add(new BarEntry(6f, 2)); 41 | entries.add(new BarEntry(12f, 3)); 42 | entries.add(new BarEntry(18f, 4)); 43 | entries.add(new BarEntry(9f, 5)); 44 | } 45 | public void initLableData(){ 46 | labels.add("一月"); 47 | labels.add("二月"); 48 | labels.add("三月"); 49 | labels.add("四月"); 50 | labels.add("五月"); 51 | labels.add("六月"); 52 | } 53 | public void show(){ 54 | dataset= new BarDataSet(entries,"# of Calls"); 55 | dataset.setColors(ColorTemplate.COLORFUL_COLORS); 56 | BarData data=new BarData(labels,dataset); 57 | LimitLine line=new LimitLine(10f); 58 | barChart.setData(data); 59 | // chart.animateXY(5000,5000); 60 | // chart.animateX(5000); 61 | barChart.animateY(2000); 62 | barChart.setDescription("hello MPandroidChart"); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/MPAndroidChart3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/changechenyu/MPAndroidChartTest/555d9ad0a1968987792be9411eb9db66f7065f84/app/src/main/res/drawable/MPAndroidChart3.gif -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/changechenyu/MPAndroidChartTest/555d9ad0a1968987792be9411eb9db66f7065f84/app/src/main/res/drawable/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 6 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/layout/bar_chart.xml: -------------------------------------------------------------------------------- 1 | 8 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/layout/liner_chart.xml: -------------------------------------------------------------------------------- 1 | 8 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/layout/pie_chart.xml: -------------------------------------------------------------------------------- 1 | 8 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/layout/radar_chart.xml: -------------------------------------------------------------------------------- 1 | 8 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/layout/scatter_chart.xml: -------------------------------------------------------------------------------- 1 | 8 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 6 | 11 | 12 | 16 | 17 | 18 | 21 | 22 | 26 | 30 | 31 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/changechenyu/MPAndroidChartTest/555d9ad0a1968987792be9411eb9db66f7065f84/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/changechenyu/MPAndroidChartTest/555d9ad0a1968987792be9411eb9db66f7065f84/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/changechenyu/MPAndroidChartTest/555d9ad0a1968987792be9411eb9db66f7065f84/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/changechenyu/MPAndroidChartTest/555d9ad0a1968987792be9411eb9db66f7065f84/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | #29b6f6 3 | #000000 4 | #ffffff 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | MPAndroidChartTest 3 | 4 | Hello world! 5 | Settings 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:1.2.3' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/changechenyu/MPAndroidChartTest/555d9ad0a1968987792be9411eb9db66f7065f84/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Nov 25 00:22:09 CST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /lib/lib.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':mplib' 2 | --------------------------------------------------------------------------------