Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/PhilJay/MPAndroidChart in…
Browse files Browse the repository at this point in the history
…to PhilJay-master

Conflicts:
	MPChartLib/src/com/github/mikephil/charting/data/ChartData.java
  • Loading branch information
simplaapliko committed Oct 10, 2015
2 parents 30683bd + d15f253 commit aa50a4b
Show file tree
Hide file tree
Showing 107 changed files with 2,861 additions and 2,146 deletions.
10 changes: 5 additions & 5 deletions MPChartExample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion '21.1.1'
compileSdkVersion 23
buildToolsVersion '23.0.1'
defaultConfig {
minSdkVersion 8
targetSdkVersion 21
targetSdkVersion 23
versionCode 44
versionName '2.1.3'

Expand Down Expand Up @@ -38,7 +38,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
classpath 'com.android.tools.build:gradle:1.3.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -52,6 +52,6 @@ repositories {
dependencies {
//compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':MPChartLib') // remove this if you only imported the example project
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:appcompat-v7:23.0.0'
//compile 'com.github.PhilJay:MPAndroidChart:v2.1.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
import com.github.mikephil.charting.data.filter.Approximator.ApproximatorType;
import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
import com.github.mikephil.charting.highlight.Highlight;
import com.github.mikephil.charting.utils.ValueFormatter;
import com.xxmassdeveloper.mpchartexample.custom.MyValueFormatter;
import com.github.mikephil.charting.formatter.YAxisValueFormatter;
import com.xxmassdeveloper.mpchartexample.custom.MyYAxisValueFormatter;
import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;

import java.util.ArrayList;
Expand Down Expand Up @@ -92,7 +92,7 @@ protected void onCreate(Bundle savedInstanceState) {
xAxis.setDrawGridLines(false);
xAxis.setSpaceBetweenLabels(2);

ValueFormatter custom = new MyValueFormatter();
YAxisValueFormatter custom = new MyYAxisValueFormatter();

YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setTypeface(mTf);
Expand Down Expand Up @@ -267,7 +267,6 @@ private void setData(int count, float range) {
dataSets.add(set1);

BarData data = new BarData(xVals, dataSets);
// data.setValueFormatter(new MyValueFormatter());
data.setValueTextSize(10f);
data.setValueTypeface(mTf);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
import com.github.mikephil.charting.highlight.Highlight;
import com.github.mikephil.charting.utils.LargeValueFormatter;
import com.github.mikephil.charting.formatter.LargeValueFormatter;
import com.xxmassdeveloper.mpchartexample.custom.MyMarkerView;
import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package com.xxmassdeveloper.mpchartexample;

import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
Expand All @@ -27,9 +28,10 @@
import com.github.mikephil.charting.data.LineDataSet;
import com.github.mikephil.charting.data.filter.Approximator;
import com.github.mikephil.charting.data.filter.Approximator.ApproximatorType;
import com.github.mikephil.charting.highlight.Highlight;
import com.github.mikephil.charting.listener.ChartTouchListener;
import com.github.mikephil.charting.listener.OnChartGestureListener;
import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
import com.github.mikephil.charting.highlight.Highlight;
import com.xxmassdeveloper.mpchartexample.custom.MyMarkerView;
import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;

Expand Down Expand Up @@ -94,7 +96,7 @@ protected void onCreate(Bundle savedInstanceState) {

// set the marker to the chart
mChart.setMarkerView(mv);

// x-axis limit line
LimitLine llXAxis = new LimitLine(10f, "Index 10");
llXAxis.setLineWidth(4f);
Expand All @@ -103,19 +105,24 @@ protected void onCreate(Bundle savedInstanceState) {
llXAxis.setTextSize(10f);

XAxis xAxis = mChart.getXAxis();
xAxis.addLimitLine(llXAxis);

//xAxis.setValueFormatter(new MyCustomXAxisValueFormatter());
//xAxis.addLimitLine(llXAxis); // add x-axis limit line

Typeface tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");

LimitLine ll1 = new LimitLine(130f, "Upper Limit");
ll1.setLineWidth(4f);
ll1.enableDashedLine(10f, 10f, 0f);
ll1.setLabelPosition(LimitLabelPosition.RIGHT_TOP);
ll1.setTextSize(10f);
ll1.setTypeface(tf);

LimitLine ll2 = new LimitLine(-30f, "Lower Limit");
ll2.setLineWidth(4f);
ll2.enableDashedLine(10f, 10f, 0f);
ll2.setLabelPosition(LimitLabelPosition.RIGHT_BOTTOM);
ll2.setTextSize(10f);
ll2.setTypeface(tf);

YAxis leftAxis = mChart.getAxisLeft();
leftAxis.removeAllLimitLines(); // reset all limit lines to avoid overlapping lines
Expand All @@ -126,22 +133,25 @@ protected void onCreate(Bundle savedInstanceState) {
leftAxis.setStartAtZero(false);
//leftAxis.setYOffset(20f);
leftAxis.enableGridDashedLine(10f, 10f, 0f);

// limit lines are drawn behind data (and not on top)
leftAxis.setDrawLimitLinesBehindData(true);

mChart.getAxisRight().setEnabled(false);

//mChart.getViewPortHandler().setMaximumScaleY(2f);
//mChart.getViewPortHandler().setMaximumScaleX(2f);

// add data
setData(45, 100);

// mChart.setVisibleXRange(20);
// mChart.setVisibleYRange(20f, AxisDependency.LEFT);
// mChart.centerViewTo(20, 50, AxisDependency.LEFT);

mChart.animateX(2500, Easing.EasingOption.EaseInOutQuart);
// mChart.invalidate();

// get the legend (only possible after setting data)
Legend l = mChart.getLegend();

Expand All @@ -152,7 +162,7 @@ protected void onCreate(Bundle savedInstanceState) {
// // dont forget to refresh the drawing
// mChart.invalidate();
}

@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
Expand All @@ -168,7 +178,7 @@ public boolean onCreateOptionsMenu(Menu menu) {
public boolean onOptionsItemSelected(MenuItem item) {

switch (item.getItemId()) {
case R.id.actionToggleValues: {
case R.id.actionToggleValues: {
for (DataSet<?> set : mChart.getData().getDataSets())
set.setDrawValues(!set.isDrawValuesEnabled());

Expand Down Expand Up @@ -266,19 +276,6 @@ public boolean onOptionsItemSelected(MenuItem item) {
mChart.disableFiltering();
}
mChart.invalidate();

//
// for(int i = 0; i < 10; i++) {
// mChart.addEntry(new Entry((float) (Math.random() * 100),
// i+2), 0);
// mChart.invalidate();
// }
//
// Toast.makeText(getApplicationContext(), "valcount: " +
// mChart.getDataOriginal().getYValCount() + ", valsum: " +
// mChart.getDataOriginal().getYValueSum(),
// Toast.LENGTH_SHORT).show();
//
break;
}
case R.id.actionSave: {
Expand Down Expand Up @@ -333,8 +330,8 @@ private void setData(int count, float range) {

float mult = (range + 1);
float val = (float) (Math.random() * mult) + 3;// + (float)
// ((mult *
// 0.1) / 10);
// ((mult *
// 0.1) / 10);
yVals.add(new Entry(val, i));
}

Expand All @@ -345,6 +342,7 @@ private void setData(int count, float range) {

// set the line to be drawn like this "- - - - - -"
set1.enableDashedLine(10f, 5f, 0f);
set1.enableDashedHighlightLine(10f, 5f, 0f);
set1.setColor(Color.BLACK);
set1.setCircleColor(Color.BLACK);
set1.setLineWidth(1f);
Expand All @@ -366,7 +364,20 @@ private void setData(int count, float range) {
// set data
mChart.setData(data);
}


@Override
public void onChartGestureStart(MotionEvent me, ChartTouchListener.ChartGesture lastPerformedGesture) {
Log.i("Gesture", "START");
}

@Override
public void onChartGestureEnd(MotionEvent me, ChartTouchListener.ChartGesture lastPerformedGesture) {
Log.i("Gesture", "END, lastGesture: " + lastPerformedGesture);

if(lastPerformedGesture != ChartTouchListener.ChartGesture.SINGLE_TAP)
mChart.highlightValues(null);
}

@Override
public void onChartLongPressed(MotionEvent me) {
Log.i("LongPress", "Chart longpressed.");
Expand All @@ -392,12 +403,12 @@ public void onChartScale(MotionEvent me, float scaleX, float scaleY) {
Log.i("Scale / Zoom", "ScaleX: " + scaleX + ", ScaleY: " + scaleY);
}

@Override
public void onChartTranslate(MotionEvent me, float dX, float dY) {
Log.i("Translate / Move", "dX: " + dX + ", dY: " + dY);
}
@Override
public void onChartTranslate(MotionEvent me, float dX, float dY) {
Log.i("Translate / Move", "dX: " + dX + ", dY: " + dY);
}

@Override
@Override
public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
Log.i("Entry selected", e.toString());
Log.i("", "low: " + mChart.getLowestVisibleXIndex() + ", high: " + mChart.getHighestVisibleXIndex());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
import com.github.mikephil.charting.utils.ColorTemplate;
import com.github.mikephil.charting.highlight.Highlight;
import com.xxmassdeveloper.mpchartexample.custom.MyFillFormatter;
import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;

import java.util.ArrayList;
Expand Down Expand Up @@ -292,6 +293,7 @@ private void setData(int count, float range) {
set1.setFillColor(ColorTemplate.getHoloBlue());
set1.setHighLightColor(Color.rgb(244, 117, 117));
set1.setDrawCircleHole(false);
//set1.setFillFormatter(new MyFillFormatter(0f));
// set1.setDrawHorizontalHighlightIndicator(false);
// set1.setVisible(false);
// set1.setCircleHoleColor(Color.WHITE);
Expand All @@ -317,6 +319,7 @@ private void setData(int count, float range) {
set2.setFillColor(Color.RED);
set2.setDrawCircleHole(false);
set2.setHighLightColor(Color.rgb(244, 117, 117));
//set2.setFillFormatter(new MyFillFormatter(900f));

ArrayList<LineDataSet> dataSets = new ArrayList<LineDataSet>();
dataSets.add(set2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,14 @@ protected void onCreate(Bundle savedInstanceState) {

mChart.setDrawGridBackground(false);
mChart.setDescription("");

// mChart.setStartAtZero(true);
mChart.setDrawBorders(false);

mChart.getAxisLeft().setDrawAxisLine(false);
mChart.getAxisLeft().setDrawGridLines(false);
mChart.getAxisRight().setDrawAxisLine(false);
mChart.getAxisRight().setDrawGridLines(false);
mChart.getXAxis().setDrawAxisLine(false);
mChart.getXAxis().setDrawGridLines(false);

// enable value highlighting
mChart.setHighlightEnabled(true);
Expand Down
Loading

0 comments on commit aa50a4b

Please sign in to comment.