diff --git a/MPChartExample/build.gradle b/MPChartExample/build.gradle index 96c367b..54cdc1f 100644 --- a/MPChartExample/build.gradle +++ b/MPChartExample/build.gradle @@ -57,9 +57,8 @@ dependencies { //compile fileTree(dir: 'libs', include: ['*.jar']) //compile project(':MPChartLib-Realm') // clone "https://github.com/PhilJay/MPAndroidChart-Realm" to get this or uncomment the gradle dependency below: compile 'com.github.PhilJay:MPAndroidChart-Realm:v2.0.2@aar' - - compile project(':MPChartLib') compile 'com.android.support:appcompat-v7:24.2.1' + compile 'com.github.open-android:MPAndroidChart:v3.0.1' //compile 'io.realm:realm-android:0.87.5' // dependency for realm-database API (http://realm.io) //compile 'com.github.PhilJay:MPAndroidChart:v2.2.5' } diff --git a/build.gradle b/build.gradle index 62ed4c9..1f8e45b 100644 --- a/build.gradle +++ b/build.gradle @@ -16,5 +16,6 @@ buildscript { allprojects { repositories { jcenter() + maven { url 'https://jitpack.io' } } } diff --git a/demo/build.gradle b/demo/build.gradle index b74295e..8a0a1be 100644 --- a/demo/build.gradle +++ b/demo/build.gradle @@ -24,10 +24,6 @@ android { dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') - androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { - exclude group: 'com.android.support', module: 'support-annotations' - }) compile 'com.android.support:appcompat-v7:25.1.0' - testCompile 'junit:junit:4.12' - compile project(':MPChartLib') + compile 'com.github.open-android:MPAndroidChart:v3.0.1' } diff --git a/demo/src/main/java/com/github/mikephil/demo/MainActivity.java b/demo/src/main/java/com/github/mikephil/demo/MainActivity.java index 73527ea..7ac7a04 100644 --- a/demo/src/main/java/com/github/mikephil/demo/MainActivity.java +++ b/demo/src/main/java/com/github/mikephil/demo/MainActivity.java @@ -23,20 +23,9 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - //Utils.init(this); - - mChart = (LineChart) findViewById(R.id.chart1); - // no description text - mChart.getDescription().setEnabled(false); - - mChart.getAxisLeft().setDrawGridLines(false); - mChart.getAxisRight().setEnabled(false); - mChart.getXAxis().setDrawGridLines(true); - mChart.getXAxis().setDrawAxisLine(false); - - setData(1000, 500f); - // dont forget to refresh the drawing - mChart.invalidate(); + mChart = (LineChart) findViewById(R.id.line_chart);//初始化对应的Chart控件 + setData(1000, 500f);//给图表设置数据 + mChart.invalidate();//刷新 } private void setData(int count, float range) { @@ -58,8 +47,6 @@ private void setData(int count, float range) { set1.setLineWidth(0.5f); set1.setDrawValues(false); set1.setDrawCircles(false); -// set1.setMode(LineDataSet.Mode.LINEAR); -// set1.setDrawFilled(false); // create a data object with the datasets LineData data = new LineData(set1); diff --git a/demo/src/main/res/layout/activity_main.xml b/demo/src/main/res/layout/activity_main.xml index 3b8283a..a1827b1 100644 --- a/demo/src/main/res/layout/activity_main.xml +++ b/demo/src/main/res/layout/activity_main.xml @@ -5,7 +5,7 @@ android:background="@android:color/white"> diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..c8c52a4 --- /dev/null +++ b/readme.md @@ -0,0 +1,58 @@ +# MPAndroidChart项目使用 + +开源地址:[https://github.com/open-android/MPAndroidChart](https://github.com/open-android/MPAndroidChart "https://github.com/open-android/MPAndroidChart") + +# 运行效果 + +详细效果请参考MPChartExample例子 + +![](screenshots/screenshot.gif) + +* 爱生活,爱学习,更爱做代码的搬运工,分类查找更方便请下载黑马助手app + + +![黑马助手.png](http://upload-images.jianshu.io/upload_images/4037105-f777f1214328dcc4.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) + +## 使用步骤 + +### 1. 在project的build.gradle添加如下代码(如下图) + + allprojects { + repositories { + maven { url "https://jitpack.io" } + } + } + +![](screenshots/build.gradle.png) + +### 2. 在Module的build.gradle添加依赖 + + compile 'com.github.open-android:MPAndroidChart:v3.0.1' + + +### 3.清单文件添加权限 + + + +### 4.布局文件使用 + + + +### 5.Activity中初始化 + + mChart = (LineChart) findViewById(R.id.line_chart);//初始化对应的Chart控件 + //省略部分代码,具体请参考MPChartExample例子实现想要的效果 + setData(1000, 500f);//给图表设置数据 + mChart.invalidate();//刷新 + + + +* 详细的使用方法在DEMO里面都演示啦,如果你觉得这个库还不错,请赏我一颗star吧~~~ + +* 欢迎关注微信公众号 + +![](http://upload-images.jianshu.io/upload_images/4037105-8f737b5104dd0b5d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) + diff --git a/screenshots/build.gradle.png b/screenshots/build.gradle.png new file mode 100644 index 0000000..ea4c59e Binary files /dev/null and b/screenshots/build.gradle.png differ diff --git a/screenshots/screenshot.gif b/screenshots/screenshot.gif new file mode 100644 index 0000000..ceef4da Binary files /dev/null and b/screenshots/screenshot.gif differ