diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 0000000000..0a213d6792
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1,12 @@
+# These are supported funding model platforms
+
+github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
+patreon: mpandroidchart
+open_collective: philippjahoda
+ko_fi: # Replace with a single Ko-fi username
+tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
+community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
+liberapay: # Replace with a single Liberapay username
+issuehunt: # Replace with a single IssueHunt username
+otechie: # Replace with a single Otechie username
+custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md
new file mode 100644
index 0000000000..b75838b907
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE.md
@@ -0,0 +1,37 @@
+
+
+**Summary**
+
+
+**Expected Behavior**
+
+
+**Possible Solution**
+
+
+
+**Device (please complete the following information):**
+ - Device: [e.g. Google Pixel]
+ - Android Version [e.g. 7.0]
+ - Library Version (e.g. 3.1.0-alpha)
+
+**Additional Context**
+
diff --git a/.github/ISSUE_TEMPLATE/Bug_report.md b/.github/ISSUE_TEMPLATE/Bug_report.md
new file mode 100644
index 0000000000..3a5938eee9
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/Bug_report.md
@@ -0,0 +1,44 @@
+---
+name: Bugs
+about: Create a bug report to help us improve
+
+---
+
+
+
+**Summary**
+
+
+**Expected Behavior**
+
+
+**Possible Solution**
+
+
+
+**Device (please complete the following information):**
+ - Device: [e.g. Google Pixel]
+ - Android Version [e.g. 7.0]
+ - Library Version (e.g. 3.1.0-alpha)
+
+**Additional Context**
+
+
+ADD A REWARD using [Speed](speedoss.com) to SOLVE this issue QUICKLY and SUPPORT this project.
diff --git a/.github/ISSUE_TEMPLATE/Feature_request.md b/.github/ISSUE_TEMPLATE/Feature_request.md
new file mode 100644
index 0000000000..54b30c983b
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/Feature_request.md
@@ -0,0 +1,34 @@
+---
+name: Feature Request
+about: Suggest an idea for this project
+
+---
+
+
+
+**Is your feature request related to a problem? Please describe.**
+
+
+**Describe the solution you'd like**
+
+
+**Describe alternatives you've considered**
+
+
+**Additional context**
+
+ADD A REWARD using [Speed](speedoss.com) to SOLVE this issue QUICKLY and SUPPORT this project.
diff --git a/.github/ISSUE_TEMPLATE/Support_help.md b/.github/ISSUE_TEMPLATE/Support_help.md
new file mode 100644
index 0000000000..70a086d3d7
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/Support_help.md
@@ -0,0 +1,27 @@
+---
+name: Support
+about: I need help!
+
+---
+
+# *STOP RIGHT THERE!*
+
+Issues are ***NOT*** for getting help, only for reporting bugs and feature requests.
+
+Search open and closed issues to see if your question already has an answer. However, **do not create a new issue.**
+
+Instead, do the following:
+
+1. Download the [Example App](https://play.google.com/store/apps/details?id=com.xxmassdeveloper.mpchartexample) and check out the [source code](https://github.com/PhilJay/MPAndroidChart/tree/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample). 90% of the time there is an example that does exactly what you are trying to do.
+
+1. Look at the [Wiki](https://github.com/PhilJay/MPAndroidChart/wiki) for the official documentation for MPAndroidChart. You can also browse the [javadoc](https://jitpack.io/com/github/philjay/mpandroidchart/v3.1.0-alpha/javadoc/) for a more detailed tutorial of the API.
+
+1. Go to [StackOverflow](https://stackoverflow.com/questions/tagged/mpandroidchart) and ask your questions there. The community will be much more helpful and willing to offer guidance.
+
+
+### You have been warned!
+
+From now on, any issues asking for help will get closed with a link to this file.
+
+### Additional Context
+ADD A REWARD using [Speed](speedoss.com) to SOLVE this issue QUICKLY and SUPPORT this project.
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 0000000000..f65a30b178
--- /dev/null
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,15 @@
+## PR Checklist:
+- [ ] I have tested this extensively and it does not break any existing behavior.
+- [ ] I have added/updated examples and tests for any new behavior.
+- [ ] If this is a significant change, an issue has already been created where the problem / solution was discussed: [N/A, or add link to issue here]
+
+
+
+## PR Description
+
+
+
+
+
diff --git a/.gitignore b/.gitignore
index 2152318d78..feed37b27d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,6 +11,12 @@
# generated files
bin/
gen/
+generated/
+docs/
+finalOutput/
+projectFilesBackup/
+
+build.xml
# Local configuration file (sdk path, etc)
local.properties
@@ -37,3 +43,5 @@ build/
# maven
target/
+
+.DS_Store
diff --git a/.idea/runConfigurations/MPChartExample.xml b/.idea/runConfigurations/MPChartExample.xml
new file mode 100644
index 0000000000..e6bcf50331
--- /dev/null
+++ b/.idea/runConfigurations/MPChartExample.xml
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.settings/gradle/org.springsource.ide.eclipse.gradle.core.prefs b/.settings/gradle/org.springsource.ide.eclipse.gradle.core.prefs
deleted file mode 100644
index 9383f623c6..0000000000
--- a/.settings/gradle/org.springsource.ide.eclipse.gradle.core.prefs
+++ /dev/null
@@ -1,4 +0,0 @@
-#org.springsource.ide.eclipse.gradle.core.preferences.GradleProjectPreferences
-#Mon Jan 18 23:02:46 CET 2016
-build.family.org.gradle.tooling.model.eclipse.HierarchicalEclipseProject=;MPChartExample;MPChartLib;
-org.springsource.ide.eclipse.gradle.rootprojectloc=
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000000..98cf0ab89b
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,66 @@
+> ### Notice
+> *Before you continue, this is the* **ANDROID** *library. If you have an* **iOS** *device, please go here instead*:
+>
+> – https://github.com/danielgindi/Charts
+>
+> They might tell you to come back here, if they do, listen to them and ignore this notice.
+
+# How to contribute
+
+Bug-fixes and features often come from users of the MPAndroidChart library and improve it greatly. We want to keep it as easy as possible to contribute changes that improve the experience for users all around the world. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things.
+
+## Creating Issues
+
+There are two main issue templates, one for bugs and another for feature requests. Please use them! You're issue will be much easier to understand, and bugs easier to fix, if you follow the templates. If your issue doesn't fit into those, just use the generic template.
+
+Search existing [issues] to see if your bug has already been reported or if a feature request already exists. Don't forget to remove `is:open` so you see all the issues! If you find that one already exists, use reactions to show how much you care!
+
+## Making Pull Requests
+
+Careful! If you fail to follow these guidlines, you're pull request may be closed, *even if it's really awesome*.
+
+ 0. **Search** open [pull requests] AND existing [issues] to make sure what you want to do isn't already being worked on or already has an open pull request.
+ 1. **Fork** the repository
+ 1. **Create** a new branch based on `master`, and name it according to your changes
+ 1. **Add** your commits, they MUST follow the [Commit Style](#commit-style) below
+ 1. **Test** your changes by actually running the example app, or create a new example
+ 1. **Create** a pull request, following the auto-generated template
+ 1. ???
+ 1. Profit :money_with_wings:
+
+You are encouraged to use [GitHub Desktop] to inspect your code changes before committing them. It can reveal small changes that might have gone unnoticed, and would be requested for removal before merging.
+
+Check out [#3975](https://github.com/PhilJay/MPAndroidChart/pull/3975) for an example of a good-made-better pull request.
+
+## Commit Style
+
+ * **Make commits of logical units**
+ Don't load your commits with tons of changes, this makes it hard to follow what is happening. However, if you have done a lot of work, and there are commits and merges all over the place, squash them down into fewer commits.
+
+ * **Conform to the code style**
+ It's easy, just look around!
+
+ * **Write good commit messages**
+ You may prefer [Tim Pope's style], you might like the [commitizen-friendly] way. Regardless of the color you pick, you MUST stay within the lines!
+ ```
+The commit title CANNOT exceed 50 characters
+
+The body of the message comes after an empty new line, and describes the
+changes more thoroughly. If the change is obvious and self-explanatory
+from the title, you can omit the body. You should describe all changes
+if many were made, or maybe some trickery that only code wizards can
+understand.
+
+Be polite and wrap your lines to 72 characters, but if you prefer going
+to 100 characters then I guess we can't stop you.
+```
+
+## Final Notes
+
+Thanks for reading the contributing file! Have some cake! :cake:
+
+[issues]: https://github.com/PhilJay/MPAndroidChart/issues
+[pull requests]: https://github.com/PhilJay/MPAndroidChart/pulls
+[GitHub Desktop]: https://desktop.github.com/
+[Tim Pope's style]: https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
+[commitizen-friendly]: https://github.com/commitizen/cz-cli
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000000..c1551a9dce
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,13 @@
+ Copyright 2020 Philipp Jahoda
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this software except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/MPChartExample/.gitignore b/MPChartExample/.gitignore
index 796b96d1c4..67e07b8fea 100644
--- a/MPChartExample/.gitignore
+++ b/MPChartExample/.gitignore
@@ -1 +1,2 @@
/build
+/release
diff --git a/MPChartExample/.settings/gradle/org.springsource.ide.eclipse.gradle.core.prefs b/MPChartExample/.settings/gradle/org.springsource.ide.eclipse.gradle.core.prefs
deleted file mode 100644
index be975eb2db..0000000000
--- a/MPChartExample/.settings/gradle/org.springsource.ide.eclipse.gradle.core.prefs
+++ /dev/null
@@ -1,3 +0,0 @@
-#org.springsource.ide.eclipse.gradle.core.preferences.GradleProjectPreferences
-#Mon Jan 18 23:02:46 CET 2016
-org.springsource.ide.eclipse.gradle.rootprojectloc=..
diff --git a/MPChartExample/AndroidManifest.xml b/MPChartExample/AndroidManifest.xml
deleted file mode 100644
index 6895b904fd..0000000000
--- a/MPChartExample/AndroidManifest.xml
+++ /dev/null
@@ -1,67 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/MPChartExample/build.gradle b/MPChartExample/build.gradle
index 300386b1f4..2d607e9991 100644
--- a/MPChartExample/build.gradle
+++ b/MPChartExample/build.gradle
@@ -1,59 +1,26 @@
apply plugin: 'com.android.application'
android {
- compileSdkVersion 23
- buildToolsVersion '23.0.2'
+ compileSdkVersion 28
defaultConfig {
- minSdkVersion 8
- targetSdkVersion 23
- versionCode 49
- versionName '2.2.3'
-
- sourceSets {
- main {
- java.srcDirs = ['src']
- res.srcDirs = ['res']
- assets.srcDirs = ['assets']
- manifest.srcFile 'AndroidManifest.xml'
- }
- }
+ applicationId "com.xxmassdeveloper.mpchartexample"
+ minSdkVersion 16
+ targetSdkVersion 28
+ versionCode 57
+ versionName '3.1.0'
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
-
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
-
- lintOptions {
- abortOnError false
- }
-}
-
-buildscript {
- repositories {
- jcenter()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:1.5.0'
- // NOTE: Do not place your application dependencies here; they belong
- // in the individual module build.gradle files
- }
-}
-
-repositories {
- maven { url "https://jitpack.io" }
- maven { // this is for realm-db
- url 'http://oss.jfrog.org/artifactory/oss-snapshot-local'
- }
}
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:23.1.1'
- compile 'io.realm:realm-android:0.87.5' // dependency for realm-database API (http://realm.io)
- //compile 'com.github.PhilJay:MPAndroidChart:v2.2.0'
+ implementation "androidx.appcompat:appcompat:1.0.2"
+ implementation 'com.google.android.material:material:1.0.0'
+ implementation project(':MPChartLib')
}
diff --git a/MPChartExample/libs/android-support-v4.jar b/MPChartExample/libs/android-support-v4.jar
deleted file mode 100644
index c31cede47e..0000000000
Binary files a/MPChartExample/libs/android-support-v4.jar and /dev/null differ
diff --git a/MPChartExample/proguard-project.txt b/MPChartExample/proguard-project.txt
deleted file mode 100644
index f2fe1559a2..0000000000
--- a/MPChartExample/proguard-project.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-# To enable ProGuard in your project, edit project.properties
-# to define the proguard.config property as described in that file.
-#
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in ${sdk.dir}/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the ProGuard
-# include property in project.properties.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
diff --git a/MPChartExample/proguard-rules.pro b/MPChartExample/proguard-rules.pro
new file mode 100644
index 0000000000..f1b424510d
--- /dev/null
+++ b/MPChartExample/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
diff --git a/MPChartExample/project.properties b/MPChartExample/project.properties
deleted file mode 100644
index b32d807be6..0000000000
--- a/MPChartExample/project.properties
+++ /dev/null
@@ -1,15 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system edit
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-#
-# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
-#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
-
-# Project target.
-target=android-23
-android.library.reference.1=../MPChartLib
diff --git a/MPChartExample/res/drawable-nodpi/marker.png b/MPChartExample/res/drawable-nodpi/marker.png
deleted file mode 100644
index 616cdd7b31..0000000000
Binary files a/MPChartExample/res/drawable-nodpi/marker.png and /dev/null differ
diff --git a/MPChartExample/res/drawable/new_background.xml b/MPChartExample/res/drawable/new_background.xml
deleted file mode 100644
index c2d3b9cfc5..0000000000
--- a/MPChartExample/res/drawable/new_background.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/MPChartExample/res/layout/activity_bubblechart_noseekbar.xml b/MPChartExample/res/layout/activity_bubblechart_noseekbar.xml
deleted file mode 100644
index 6d7a7763df..0000000000
--- a/MPChartExample/res/layout/activity_bubblechart_noseekbar.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/MPChartExample/res/layout/activity_candlechart_noseekbar.xml b/MPChartExample/res/layout/activity_candlechart_noseekbar.xml
deleted file mode 100644
index 8e5d4bc26e..0000000000
--- a/MPChartExample/res/layout/activity_candlechart_noseekbar.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/MPChartExample/res/layout/activity_horizontalbarchart_noseekbar.xml b/MPChartExample/res/layout/activity_horizontalbarchart_noseekbar.xml
deleted file mode 100644
index a48307987e..0000000000
--- a/MPChartExample/res/layout/activity_horizontalbarchart_noseekbar.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/MPChartExample/res/layout/activity_radarchart_noseekbar.xml b/MPChartExample/res/layout/activity_radarchart_noseekbar.xml
deleted file mode 100644
index 1de38d5660..0000000000
--- a/MPChartExample/res/layout/activity_radarchart_noseekbar.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/MPChartExample/res/layout/activity_realm_wiki.xml b/MPChartExample/res/layout/activity_realm_wiki.xml
deleted file mode 100644
index d4e27933cf..0000000000
--- a/MPChartExample/res/layout/activity_realm_wiki.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/MPChartExample/res/layout/activity_scatterchart_noseekbar.xml b/MPChartExample/res/layout/activity_scatterchart_noseekbar.xml
deleted file mode 100644
index 548a0c7a66..0000000000
--- a/MPChartExample/res/layout/activity_scatterchart_noseekbar.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/MPChartExample/res/menu/bubble.xml b/MPChartExample/res/menu/bubble.xml
deleted file mode 100644
index a25afd9861..0000000000
--- a/MPChartExample/res/menu/bubble.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
\ No newline at end of file
diff --git a/MPChartExample/res/menu/candle.xml b/MPChartExample/res/menu/candle.xml
deleted file mode 100644
index cdf1c4e4dd..0000000000
--- a/MPChartExample/res/menu/candle.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
\ No newline at end of file
diff --git a/MPChartExample/res/menu/combined.xml b/MPChartExample/res/menu/combined.xml
deleted file mode 100644
index 9b034d7f4f..0000000000
--- a/MPChartExample/res/menu/combined.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
\ No newline at end of file
diff --git a/MPChartExample/res/menu/dynamical.xml b/MPChartExample/res/menu/dynamical.xml
deleted file mode 100644
index c43a3a0ae6..0000000000
--- a/MPChartExample/res/menu/dynamical.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
\ No newline at end of file
diff --git a/MPChartExample/res/menu/line.xml b/MPChartExample/res/menu/line.xml
deleted file mode 100644
index 42ca211c06..0000000000
--- a/MPChartExample/res/menu/line.xml
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
\ No newline at end of file
diff --git a/MPChartExample/res/menu/pie.xml b/MPChartExample/res/menu/pie.xml
deleted file mode 100644
index fd315839a5..0000000000
--- a/MPChartExample/res/menu/pie.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
\ No newline at end of file
diff --git a/MPChartExample/res/menu/radar.xml b/MPChartExample/res/menu/radar.xml
deleted file mode 100644
index 8dbcf05e9c..0000000000
--- a/MPChartExample/res/menu/radar.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-
-
\ No newline at end of file
diff --git a/MPChartExample/res/menu/realtime.xml b/MPChartExample/res/menu/realtime.xml
deleted file mode 100644
index a4b2d22a78..0000000000
--- a/MPChartExample/res/menu/realtime.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
\ No newline at end of file
diff --git a/MPChartExample/res/values-sw600dp/dimens.xml b/MPChartExample/res/values-sw600dp/dimens.xml
deleted file mode 100644
index 44f01db75f..0000000000
--- a/MPChartExample/res/values-sw600dp/dimens.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
diff --git a/MPChartExample/res/values-sw720dp-land/dimens.xml b/MPChartExample/res/values-sw720dp-land/dimens.xml
deleted file mode 100644
index 61e3fa8fbc..0000000000
--- a/MPChartExample/res/values-sw720dp-land/dimens.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
- 128dp
-
-
diff --git a/MPChartExample/res/values-v11/styles.xml b/MPChartExample/res/values-v11/styles.xml
deleted file mode 100644
index 3c02242ad0..0000000000
--- a/MPChartExample/res/values-v11/styles.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
diff --git a/MPChartExample/res/values-v14/styles.xml b/MPChartExample/res/values-v14/styles.xml
deleted file mode 100644
index a91fd0372b..0000000000
--- a/MPChartExample/res/values-v14/styles.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
diff --git a/MPChartExample/res/values/dimens.xml b/MPChartExample/res/values/dimens.xml
deleted file mode 100644
index 55c1e5908c..0000000000
--- a/MPChartExample/res/values/dimens.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
- 16dp
- 16dp
-
-
diff --git a/MPChartExample/res/values/strings.xml b/MPChartExample/res/values/strings.xml
deleted file mode 100644
index 7f59af64bb..0000000000
--- a/MPChartExample/res/values/strings.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
- MPAndroidChart Example
- Settings
- Hello world!
-
-
diff --git a/MPChartExample/res/values/styles.xml b/MPChartExample/res/values/styles.xml
deleted file mode 100644
index 6ce89c7ba4..0000000000
--- a/MPChartExample/res/values/styles.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/AnotherBarActivity.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/AnotherBarActivity.java
deleted file mode 100644
index cabd72e9dd..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/AnotherBarActivity.java
+++ /dev/null
@@ -1,206 +0,0 @@
-
-package com.xxmassdeveloper.mpchartexample;
-
-import android.os.Bundle;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.WindowManager;
-import android.widget.SeekBar;
-import android.widget.SeekBar.OnSeekBarChangeListener;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import com.github.mikephil.charting.charts.BarChart;
-import com.github.mikephil.charting.components.XAxis;
-import com.github.mikephil.charting.components.XAxis.XAxisPosition;
-import com.github.mikephil.charting.data.BarData;
-import com.github.mikephil.charting.data.BarDataSet;
-import com.github.mikephil.charting.data.BarEntry;
-import com.github.mikephil.charting.data.filter.Approximator;
-import com.github.mikephil.charting.data.filter.Approximator.ApproximatorType;
-import com.github.mikephil.charting.interfaces.datasets.IBarDataSet;
-import com.github.mikephil.charting.interfaces.datasets.IDataSet;
-import com.github.mikephil.charting.utils.ColorTemplate;
-import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
-
-import java.util.ArrayList;
-
-public class AnotherBarActivity extends DemoBase implements OnSeekBarChangeListener {
-
- private BarChart mChart;
- private SeekBar mSeekBarX, mSeekBarY;
- private TextView tvX, tvY;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.activity_barchart);
-
- tvX = (TextView) findViewById(R.id.tvXMax);
- tvY = (TextView) findViewById(R.id.tvYMax);
-
- mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
- mSeekBarX.setOnSeekBarChangeListener(this);
-
- mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
- mSeekBarY.setOnSeekBarChangeListener(this);
-
- mChart = (BarChart) findViewById(R.id.chart1);
-
- mChart.setDescription("");
-
- // if more than 60 entries are displayed in the chart, no values will be
- // drawn
- mChart.setMaxVisibleValueCount(60);
-
- // scaling can now only be done on x- and y-axis separately
- mChart.setPinchZoom(false);
-
- mChart.setDrawBarShadow(false);
- mChart.setDrawGridBackground(false);
-
- XAxis xAxis = mChart.getXAxis();
- xAxis.setPosition(XAxisPosition.BOTTOM);
- xAxis.setSpaceBetweenLabels(0);
- xAxis.setDrawGridLines(false);
-
- mChart.getAxisLeft().setDrawGridLines(false);
-
- // setting data
- mSeekBarX.setProgress(10);
- mSeekBarY.setProgress(100);
-
- // add a nice and smooth animation
- mChart.animateY(2500);
-
- mChart.getLegend().setEnabled(false);
-
- // Legend l = mChart.getLegend();
- // l.setPosition(LegendPosition.BELOW_CHART_CENTER);
- // l.setFormSize(8f);
- // l.setFormToTextSpace(4f);
- // l.setXEntrySpace(6f);
-
- // mChart.setDrawLegend(false);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.bar, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
-
- switch (item.getItemId()) {
- case R.id.actionToggleValues: {
-
- for (IDataSet set : mChart.getData().getDataSets())
- set.setDrawValues(!set.isDrawValuesEnabled());
-
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleHighlight: {
-
- if(mChart.getData() != null) {
- mChart.getData().setHighlightEnabled(!mChart.getData().isHighlightEnabled());
- mChart.invalidate();
- }
- break;
- }
- case R.id.actionTogglePinch: {
- if (mChart.isPinchZoomEnabled())
- mChart.setPinchZoom(false);
- else
- mChart.setPinchZoom(true);
-
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleAutoScaleMinMax: {
- mChart.setAutoScaleMinMaxEnabled(!mChart.isAutoScaleMinMaxEnabled());
- mChart.notifyDataSetChanged();
- break;
- }
- case R.id.actionToggleHighlightArrow: {
- if (mChart.isDrawHighlightArrowEnabled())
- mChart.setDrawHighlightArrow(false);
- else
- mChart.setDrawHighlightArrow(true);
- mChart.invalidate();
- break;
- }
- case R.id.animateX: {
- mChart.animateX(3000);
- break;
- }
- case R.id.animateY: {
- mChart.animateY(3000);
- break;
- }
- case R.id.animateXY: {
-
- mChart.animateXY(3000, 3000);
- break;
- }
- case R.id.actionSave: {
- if (mChart.saveToGallery("title" + System.currentTimeMillis(), 50)) {
- Toast.makeText(getApplicationContext(), "Saving SUCCESSFUL!",
- Toast.LENGTH_SHORT).show();
- } else
- Toast.makeText(getApplicationContext(), "Saving FAILED!", Toast.LENGTH_SHORT)
- .show();
- break;
- }
- }
- return true;
- }
-
- @Override
- public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
-
- tvX.setText("" + (mSeekBarX.getProgress() + 1));
- tvY.setText("" + (mSeekBarY.getProgress()));
-
- ArrayList yVals1 = new ArrayList();
-
- for (int i = 0; i < mSeekBarX.getProgress() + 1; i++) {
- float mult = (mSeekBarY.getProgress() + 1);
- float val1 = (float) (Math.random() * mult) + mult / 3;
- yVals1.add(new BarEntry((int) val1, i));
- }
-
- ArrayList xVals = new ArrayList();
- for (int i = 0; i < mSeekBarX.getProgress() + 1; i++) {
- xVals.add((int) yVals1.get(i).getVal() + "");
- }
-
- BarDataSet set1 = new BarDataSet(yVals1, "Data Set");
- set1.setColors(ColorTemplate.VORDIPLOM_COLORS);
- set1.setDrawValues(false);
-
- ArrayList dataSets = new ArrayList();
- dataSets.add(set1);
-
- BarData data = new BarData(xVals, dataSets);
-
- mChart.setData(data);
- mChart.invalidate();
- }
-
- @Override
- public void onStartTrackingTouch(SeekBar seekBar) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void onStopTrackingTouch(SeekBar seekBar) {
- // TODO Auto-generated method stub
-
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/BarChartActivity.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/BarChartActivity.java
deleted file mode 100644
index 99d3d027fd..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/BarChartActivity.java
+++ /dev/null
@@ -1,274 +0,0 @@
-
-package com.xxmassdeveloper.mpchartexample;
-
-import android.annotation.SuppressLint;
-import android.graphics.PointF;
-import android.graphics.RectF;
-import android.graphics.Typeface;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.WindowManager;
-import android.widget.SeekBar;
-import android.widget.SeekBar.OnSeekBarChangeListener;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import com.github.mikephil.charting.charts.BarChart;
-import com.github.mikephil.charting.components.Legend;
-import com.github.mikephil.charting.components.Legend.LegendForm;
-import com.github.mikephil.charting.components.Legend.LegendPosition;
-import com.github.mikephil.charting.components.XAxis;
-import com.github.mikephil.charting.components.XAxis.XAxisPosition;
-import com.github.mikephil.charting.components.YAxis;
-import com.github.mikephil.charting.components.YAxis.AxisDependency;
-import com.github.mikephil.charting.components.YAxis.YAxisLabelPosition;
-import com.github.mikephil.charting.data.BarData;
-import com.github.mikephil.charting.data.BarDataSet;
-import com.github.mikephil.charting.data.BarEntry;
-import com.github.mikephil.charting.data.Entry;
-import com.github.mikephil.charting.data.filter.Approximator;
-import com.github.mikephil.charting.data.filter.Approximator.ApproximatorType;
-import com.github.mikephil.charting.formatter.YAxisValueFormatter;
-import com.github.mikephil.charting.highlight.Highlight;
-import com.github.mikephil.charting.interfaces.datasets.IBarDataSet;
-import com.github.mikephil.charting.interfaces.datasets.IDataSet;
-import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
-import com.xxmassdeveloper.mpchartexample.custom.MyYAxisValueFormatter;
-import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
-
-import java.util.ArrayList;
-
-public class BarChartActivity extends DemoBase implements OnSeekBarChangeListener,
- OnChartValueSelectedListener {
-
- protected BarChart mChart;
- private SeekBar mSeekBarX, mSeekBarY;
- private TextView tvX, tvY;
-
- private Typeface mTf;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.activity_barchart);
-
- tvX = (TextView) findViewById(R.id.tvXMax);
- tvY = (TextView) findViewById(R.id.tvYMax);
-
- mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
- mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
-
- mChart = (BarChart) findViewById(R.id.chart1);
- mChart.setOnChartValueSelectedListener(this);
-
- mChart.setDrawBarShadow(false);
- mChart.setDrawValueAboveBar(true);
-
- mChart.setDescription("");
-
- // if more than 60 entries are displayed in the chart, no values will be
- // drawn
- mChart.setMaxVisibleValueCount(60);
-
- // scaling can now only be done on x- and y-axis separately
- mChart.setPinchZoom(false);
-
- mChart.setDrawGridBackground(false);
- // mChart.setDrawYLabels(false);
-
- mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
-
- XAxis xAxis = mChart.getXAxis();
- xAxis.setPosition(XAxisPosition.BOTTOM);
- xAxis.setTypeface(mTf);
- xAxis.setDrawGridLines(false);
- xAxis.setSpaceBetweenLabels(2);
-
- YAxisValueFormatter custom = new MyYAxisValueFormatter();
-
- YAxis leftAxis = mChart.getAxisLeft();
- leftAxis.setTypeface(mTf);
- leftAxis.setLabelCount(8, false);
- leftAxis.setValueFormatter(custom);
- leftAxis.setPosition(YAxisLabelPosition.OUTSIDE_CHART);
- leftAxis.setSpaceTop(15f);
- leftAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true)
-
- YAxis rightAxis = mChart.getAxisRight();
- rightAxis.setDrawGridLines(false);
- rightAxis.setTypeface(mTf);
- rightAxis.setLabelCount(8, false);
- rightAxis.setValueFormatter(custom);
- rightAxis.setSpaceTop(15f);
- rightAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true)
-
- Legend l = mChart.getLegend();
- l.setPosition(LegendPosition.BELOW_CHART_LEFT);
- l.setForm(LegendForm.SQUARE);
- l.setFormSize(9f);
- l.setTextSize(11f);
- l.setXEntrySpace(4f);
- // l.setExtra(ColorTemplate.VORDIPLOM_COLORS, new String[] { "abc",
- // "def", "ghj", "ikl", "mno" });
- // l.setCustom(ColorTemplate.VORDIPLOM_COLORS, new String[] { "abc",
- // "def", "ghj", "ikl", "mno" });
-
- setData(12, 50);
-
- // setting data
- mSeekBarY.setProgress(50);
- mSeekBarX.setProgress(12);
-
- mSeekBarY.setOnSeekBarChangeListener(this);
- mSeekBarX.setOnSeekBarChangeListener(this);
-
- // mChart.setDrawLegend(false);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.bar, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
-
- switch (item.getItemId()) {
- case R.id.actionToggleValues: {
- for (IDataSet set : mChart.getData().getDataSets())
- set.setDrawValues(!set.isDrawValuesEnabled());
-
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleHighlight: {
- if(mChart.getData() != null) {
- mChart.getData().setHighlightEnabled(!mChart.getData().isHighlightEnabled());
- mChart.invalidate();
- }
- break;
- }
- case R.id.actionTogglePinch: {
- if (mChart.isPinchZoomEnabled())
- mChart.setPinchZoom(false);
- else
- mChart.setPinchZoom(true);
-
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleAutoScaleMinMax: {
- mChart.setAutoScaleMinMaxEnabled(!mChart.isAutoScaleMinMaxEnabled());
- mChart.notifyDataSetChanged();
- break;
- }
- case R.id.actionToggleHighlightArrow: {
- if (mChart.isDrawHighlightArrowEnabled())
- mChart.setDrawHighlightArrow(false);
- else
- mChart.setDrawHighlightArrow(true);
- mChart.invalidate();
- break;
- }
- case R.id.animateX: {
- mChart.animateX(3000);
- break;
- }
- case R.id.animateY: {
- mChart.animateY(3000);
- break;
- }
- case R.id.animateXY: {
-
- mChart.animateXY(3000, 3000);
- break;
- }
- case R.id.actionSave: {
- if (mChart.saveToGallery("title" + System.currentTimeMillis(), 50)) {
- Toast.makeText(getApplicationContext(), "Saving SUCCESSFUL!",
- Toast.LENGTH_SHORT).show();
- } else
- Toast.makeText(getApplicationContext(), "Saving FAILED!", Toast.LENGTH_SHORT)
- .show();
- break;
- }
- }
- return true;
- }
-
- @Override
- public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
-
- tvX.setText("" + (mSeekBarX.getProgress() + 1));
- tvY.setText("" + (mSeekBarY.getProgress()));
-
- setData(mSeekBarX.getProgress() + 1, mSeekBarY.getProgress());
- mChart.invalidate();
- }
-
- @Override
- public void onStartTrackingTouch(SeekBar seekBar) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void onStopTrackingTouch(SeekBar seekBar) {
- // TODO Auto-generated method stub
-
- }
-
- private void setData(int count, float range) {
-
- ArrayList xVals = new ArrayList();
- for (int i = 0; i < count; i++) {
- xVals.add(mMonths[i % 12]);
- }
-
- ArrayList yVals1 = new ArrayList();
-
- for (int i = 0; i < count; i++) {
- float mult = (range + 1);
- float val = (float) (Math.random() * mult);
- yVals1.add(new BarEntry(val, i));
- }
-
- BarDataSet set1 = new BarDataSet(yVals1, "DataSet");
- set1.setBarSpacePercent(35f);
-
- ArrayList dataSets = new ArrayList();
- dataSets.add(set1);
-
- BarData data = new BarData(xVals, dataSets);
- data.setValueTextSize(10f);
- data.setValueTypeface(mTf);
-
- mChart.setData(data);
- }
-
- @SuppressLint("NewApi")
- @Override
- public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
-
- if (e == null)
- return;
-
- RectF bounds = mChart.getBarBounds((BarEntry) e);
- PointF position = mChart.getPosition(e, AxisDependency.LEFT);
-
- Log.i("bounds", bounds.toString());
- Log.i("position", position.toString());
-
- Log.i("x-index",
- "low: " + mChart.getLowestVisibleXIndex() + ", high: "
- + mChart.getHighestVisibleXIndex());
- }
-
- public void onNothingSelected() {
- };
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/BarChartActivityMultiDataset.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/BarChartActivityMultiDataset.java
deleted file mode 100644
index 4f869ecc3a..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/BarChartActivityMultiDataset.java
+++ /dev/null
@@ -1,254 +0,0 @@
-
-package com.xxmassdeveloper.mpchartexample;
-
-import android.graphics.Color;
-import android.graphics.Typeface;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.WindowManager;
-import android.widget.SeekBar;
-import android.widget.SeekBar.OnSeekBarChangeListener;
-import android.widget.TextView;
-
-import com.github.mikephil.charting.charts.BarChart;
-import com.github.mikephil.charting.components.Legend;
-import com.github.mikephil.charting.components.Legend.LegendPosition;
-import com.github.mikephil.charting.components.XAxis;
-import com.github.mikephil.charting.components.YAxis;
-import com.github.mikephil.charting.data.BarData;
-import com.github.mikephil.charting.data.BarDataSet;
-import com.github.mikephil.charting.data.BarEntry;
-import com.github.mikephil.charting.data.Entry;
-import com.github.mikephil.charting.formatter.LargeValueFormatter;
-import com.github.mikephil.charting.highlight.Highlight;
-import com.github.mikephil.charting.interfaces.datasets.IBarDataSet;
-import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
-import com.xxmassdeveloper.mpchartexample.custom.MyMarkerView;
-import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
-
-import java.util.ArrayList;
-
-public class BarChartActivityMultiDataset extends DemoBase implements OnSeekBarChangeListener,
- OnChartValueSelectedListener {
-
- private BarChart mChart;
- private SeekBar mSeekBarX, mSeekBarY;
- private TextView tvX, tvY;
-
- private Typeface tf;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.activity_barchart);
-
- tvX = (TextView) findViewById(R.id.tvXMax);
- tvY = (TextView) findViewById(R.id.tvYMax);
-
- mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
- mSeekBarX.setOnSeekBarChangeListener(this);
-
- mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
- mSeekBarY.setOnSeekBarChangeListener(this);
-
- mChart = (BarChart) findViewById(R.id.chart1);
- mChart.setOnChartValueSelectedListener(this);
- mChart.setDescription("");
-
-// mChart.setDrawBorders(true);
-
- // scaling can now only be done on x- and y-axis separately
- mChart.setPinchZoom(false);
-
- mChart.setDrawBarShadow(false);
-
- mChart.setDrawGridBackground(false);
-
- // create a custom MarkerView (extend MarkerView) and specify the layout
- // to use for it
- MyMarkerView mv = new MyMarkerView(this, R.layout.custom_marker_view);
-
- // define an offset to change the original position of the marker
- // (optional)
- // mv.setOffsets(-mv.getMeasuredWidth() / 2, -mv.getMeasuredHeight());
-
- // set the marker to the chart
- mChart.setMarkerView(mv);
-
- mSeekBarX.setProgress(10);
- mSeekBarY.setProgress(100);
-
- tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
-
- Legend l = mChart.getLegend();
- l.setPosition(LegendPosition.RIGHT_OF_CHART_INSIDE);
- l.setTypeface(tf);
- l.setYOffset(0f);
- l.setYEntrySpace(0f);
- l.setTextSize(8f);
-
- XAxis xl = mChart.getXAxis();
- xl.setTypeface(tf);
-
- YAxis leftAxis = mChart.getAxisLeft();
- leftAxis.setTypeface(tf);
- leftAxis.setValueFormatter(new LargeValueFormatter());
- leftAxis.setDrawGridLines(false);
- leftAxis.setSpaceTop(30f);
- leftAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true)
-
- mChart.getAxisRight().setEnabled(false);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.bar, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
-
- switch (item.getItemId()) {
- case R.id.actionToggleValues: {
- for (IBarDataSet set : mChart.getData().getDataSets())
- set.setDrawValues(!set.isDrawValuesEnabled());
-
- mChart.invalidate();
- break;
- }
- case R.id.actionTogglePinch: {
- if (mChart.isPinchZoomEnabled())
- mChart.setPinchZoom(false);
- else
- mChart.setPinchZoom(true);
-
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleAutoScaleMinMax: {
- mChart.setAutoScaleMinMaxEnabled(!mChart.isAutoScaleMinMaxEnabled());
- mChart.notifyDataSetChanged();
- break;
- }
- case R.id.actionToggleHighlight: {
- if(mChart.getData() != null) {
- mChart.getData().setHighlightEnabled(!mChart.getData().isHighlightEnabled());
- mChart.invalidate();
- }
- break;
- }
- case R.id.actionToggleHighlightArrow: {
- if (mChart.isDrawHighlightArrowEnabled())
- mChart.setDrawHighlightArrow(false);
- else
- mChart.setDrawHighlightArrow(true);
- mChart.invalidate();
- break;
- }
- case R.id.actionSave: {
- // mChart.saveToGallery("title"+System.currentTimeMillis());
- mChart.saveToPath("title" + System.currentTimeMillis(), "");
- break;
- }
- case R.id.animateX: {
- mChart.animateX(3000);
- break;
- }
- case R.id.animateY: {
- mChart.animateY(3000);
- break;
- }
- case R.id.animateXY: {
-
- mChart.animateXY(3000, 3000);
- break;
- }
- }
- return true;
- }
-
- @Override
- public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
-
- tvX.setText("" + (mSeekBarX.getProgress() * 3));
- tvY.setText("" + (mSeekBarY.getProgress()));
-
- ArrayList xVals = new ArrayList();
- for (int i = 0; i < mSeekBarX.getProgress(); i++) {
- xVals.add((i+1990) + "");
- }
-
- ArrayList yVals1 = new ArrayList();
- ArrayList yVals2 = new ArrayList();
- ArrayList yVals3 = new ArrayList();
-
- float mult = mSeekBarY.getProgress() * 1000f;
-
- for (int i = 0; i < mSeekBarX.getProgress(); i++) {
- float val = (float) (Math.random() * mult) + 3;
- yVals1.add(new BarEntry(val, i));
- }
-
- for (int i = 0; i < mSeekBarX.getProgress(); i++) {
- float val = (float) (Math.random() * mult) + 3;
- yVals2.add(new BarEntry(val, i));
- }
-
- for (int i = 0; i < mSeekBarX.getProgress(); i++) {
- float val = (float) (Math.random() * mult) + 3;
- yVals3.add(new BarEntry(val, i));
- }
-
- // create 3 datasets with different types
- BarDataSet set1 = new BarDataSet(yVals1, "Company A");
- // set1.setColors(ColorTemplate.createColors(getApplicationContext(),
- // ColorTemplate.FRESH_COLORS));
- set1.setColor(Color.rgb(104, 241, 175));
- BarDataSet set2 = new BarDataSet(yVals2, "Company B");
- set2.setColor(Color.rgb(164, 228, 251));
- BarDataSet set3 = new BarDataSet(yVals3, "Company C");
- set3.setColor(Color.rgb(242, 247, 158));
-
- ArrayList dataSets = new ArrayList();
- dataSets.add(set1);
- dataSets.add(set2);
- dataSets.add(set3);
-
- BarData data = new BarData(xVals, dataSets);
-// data.setValueFormatter(new LargeValueFormatter());
-
- // add space between the dataset groups in percent of bar-width
- data.setGroupSpace(80f);
- data.setValueTypeface(tf);
-
- mChart.setData(data);
- mChart.invalidate();
- }
-
- @Override
- public void onStartTrackingTouch(SeekBar seekBar) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void onStopTrackingTouch(SeekBar seekBar) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
- Log.i("Activity", "Selected: " + e.toString() + ", dataSet: " + dataSetIndex);
- }
-
- @Override
- public void onNothingSelected() {
- Log.i("Activity", "Nothing selected.");
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/BarChartActivitySinus.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/BarChartActivitySinus.java
deleted file mode 100644
index 62d9b43096..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/BarChartActivitySinus.java
+++ /dev/null
@@ -1,228 +0,0 @@
-
-package com.xxmassdeveloper.mpchartexample;
-
-import android.graphics.Color;
-import android.graphics.Typeface;
-import android.os.Bundle;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.WindowManager;
-import android.widget.SeekBar;
-import android.widget.SeekBar.OnSeekBarChangeListener;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import com.github.mikephil.charting.charts.BarChart;
-import com.github.mikephil.charting.components.Legend;
-import com.github.mikephil.charting.components.Legend.LegendForm;
-import com.github.mikephil.charting.components.Legend.LegendPosition;
-import com.github.mikephil.charting.components.XAxis;
-import com.github.mikephil.charting.components.XAxis.XAxisPosition;
-import com.github.mikephil.charting.components.YAxis;
-import com.github.mikephil.charting.data.BarData;
-import com.github.mikephil.charting.data.BarDataSet;
-import com.github.mikephil.charting.data.BarEntry;
-import com.github.mikephil.charting.data.filter.Approximator;
-import com.github.mikephil.charting.data.filter.Approximator.ApproximatorType;
-import com.github.mikephil.charting.interfaces.datasets.IBarDataSet;
-import com.github.mikephil.charting.utils.FileUtils;
-import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class BarChartActivitySinus extends DemoBase implements OnSeekBarChangeListener {
-
- protected BarChart mChart;
- private SeekBar mSeekBarX;
- private TextView tvX;
-
- private Typeface mTf;
-
- private List mSinusData;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.activity_barchart_sinus);
-
- mSinusData = FileUtils.loadBarEntriesFromAssets(getAssets(),"othersine.txt");
-
- tvX = (TextView) findViewById(R.id.tvValueCount);
-
- mSeekBarX = (SeekBar) findViewById(R.id.seekbarValues);
-
- mChart = (BarChart) findViewById(R.id.chart1);
-
- mChart.setDrawBarShadow(false);
- mChart.setDrawValueAboveBar(true);
-
- mChart.setDescription("");
-
- // if more than 60 entries are displayed in the chart, no values will be
- // drawn
- mChart.setMaxVisibleValueCount(60);
-
- // scaling can now only be done on x- and y-axis separately
- mChart.setPinchZoom(false);
-
- // draw shadows for each bar that show the maximum value
- // mChart.setDrawBarShadow(true);
-
- // mChart.setDrawXLabels(false);
-
- mChart.setDrawGridBackground(false);
- // mChart.setDrawYLabels(false);
-
- mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
-
- XAxis xAxis = mChart.getXAxis();
- xAxis.setPosition(XAxisPosition.BOTTOM);
- xAxis.setTypeface(mTf);
- xAxis.setDrawGridLines(false);
- xAxis.setEnabled(false);
-
- YAxis leftAxis = mChart.getAxisLeft();
- leftAxis.setTypeface(mTf);
- leftAxis.setLabelCount(6, false);
- leftAxis.setAxisMinValue(-2.5f);
- leftAxis.setAxisMaxValue(2.5f);
-
- YAxis rightAxis = mChart.getAxisRight();
- rightAxis.setDrawGridLines(false);
- rightAxis.setTypeface(mTf);
- rightAxis.setLabelCount(6, false);
- rightAxis.setAxisMinValue(-2.5f);
- rightAxis.setAxisMaxValue(2.5f);
-
- mSeekBarX.setOnSeekBarChangeListener(this);
- mSeekBarX.setProgress(150); // set data
-
- Legend l = mChart.getLegend();
- l.setPosition(LegendPosition.BELOW_CHART_LEFT);
- l.setForm(LegendForm.SQUARE);
- l.setFormSize(9f);
- l.setTextSize(11f);
- l.setXEntrySpace(4f);
-
- mChart.animateXY(2000, 2000);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.bar, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
-
- switch (item.getItemId()) {
- case R.id.actionToggleValues: {
- for (IBarDataSet set : mChart.getData().getDataSets())
- set.setDrawValues(!set.isDrawValuesEnabled());
-
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleHighlight: {
- if(mChart.getData() != null) {
- mChart.getData().setHighlightEnabled(!mChart.getData().isHighlightEnabled());
- mChart.invalidate();
- }
- break;
- }
- case R.id.actionTogglePinch: {
- if (mChart.isPinchZoomEnabled())
- mChart.setPinchZoom(false);
- else
- mChart.setPinchZoom(true);
-
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleAutoScaleMinMax: {
- mChart.setAutoScaleMinMaxEnabled(!mChart.isAutoScaleMinMaxEnabled());
- mChart.notifyDataSetChanged();
- break;
- }
- case R.id.actionToggleHighlightArrow: {
- if (mChart.isDrawHighlightArrowEnabled())
- mChart.setDrawHighlightArrow(false);
- else
- mChart.setDrawHighlightArrow(true);
- mChart.invalidate();
- break;
- }
- case R.id.animateX: {
- mChart.animateX(1500);
- break;
- }
- case R.id.animateY: {
- mChart.animateY(1500);
- break;
- }
- case R.id.animateXY: {
-
- mChart.animateXY(2000, 2000);
- break;
- }
- case R.id.actionSave: {
- if (mChart.saveToGallery("title" + System.currentTimeMillis(), 50)) {
- Toast.makeText(getApplicationContext(), "Saving SUCCESSFUL!",
- Toast.LENGTH_SHORT).show();
- } else
- Toast.makeText(getApplicationContext(), "Saving FAILED!", Toast.LENGTH_SHORT)
- .show();
- break;
- }
- }
- return true;
- }
-
- @Override
- public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
-
- tvX.setText("" + (mSeekBarX.getProgress()));
-
- setData(mSeekBarX.getProgress());
- mChart.invalidate();
- }
-
- @Override
- public void onStartTrackingTouch(SeekBar seekBar) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void onStopTrackingTouch(SeekBar seekBar) {
- // TODO Auto-generated method stub
-
- }
-
- private void setData(int count) {
-
- ArrayList xVals = new ArrayList();
-
- ArrayList entries = new ArrayList();
-
- for (int i = 0; i < count; i++) {
- xVals.add(i+"");
- entries.add(mSinusData.get(i));
- }
-
- BarDataSet set = new BarDataSet(entries, "Sinus Function");
- set.setBarSpacePercent(40f);
- set.setColor(Color.rgb(240, 120, 124));
-
- BarData data = new BarData(xVals, set);
- data.setValueTextSize(10f);
- data.setValueTypeface(mTf);
- data.setDrawValues(false);
-
- mChart.setData(data);
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/BarChartPositiveNegative.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/BarChartPositiveNegative.java
deleted file mode 100644
index 26f8e6fceb..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/BarChartPositiveNegative.java
+++ /dev/null
@@ -1,154 +0,0 @@
-
-package com.xxmassdeveloper.mpchartexample;
-
-import android.graphics.Color;
-import android.graphics.Typeface;
-import android.os.Bundle;
-import android.view.WindowManager;
-
-import com.github.mikephil.charting.charts.BarChart;
-import com.github.mikephil.charting.components.XAxis;
-import com.github.mikephil.charting.components.XAxis.XAxisPosition;
-import com.github.mikephil.charting.components.YAxis;
-import com.github.mikephil.charting.data.BarData;
-import com.github.mikephil.charting.data.BarDataSet;
-import com.github.mikephil.charting.data.BarEntry;
-import com.github.mikephil.charting.data.Entry;
-import com.github.mikephil.charting.utils.ViewPortHandler;
-import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
-
-import java.text.DecimalFormat;
-import java.util.ArrayList;
-import java.util.List;
-
-public class BarChartPositiveNegative extends DemoBase {
-
- protected BarChart mChart;
- private Typeface mTf;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.activity_barchart_noseekbar);
-
- mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
- mChart = (BarChart) findViewById(R.id.chart1);
- mChart.setBackgroundColor(Color.WHITE);
- mChart.setExtraTopOffset(-30f);
- mChart.setExtraBottomOffset(10f);
- mChart.setExtraLeftOffset(70f);
- mChart.setExtraRightOffset(70f);
-
- mChart.setDrawBarShadow(false);
- mChart.setDrawValueAboveBar(true);
-
- mChart.setDescription("");
-
- // scaling can now only be done on x- and y-axis separately
- mChart.setPinchZoom(false);
-
- mChart.setDrawGridBackground(false);
-
- XAxis xAxis = mChart.getXAxis();
- xAxis.setPosition(XAxisPosition.BOTTOM);
- xAxis.setTypeface(mTf);
- xAxis.setDrawGridLines(false);
- xAxis.setDrawAxisLine(false);
- xAxis.setSpaceBetweenLabels(2);
- xAxis.setTextColor(Color.LTGRAY);
- xAxis.setTextSize(13f);
-
- YAxis left = mChart.getAxisLeft();
- left.setDrawLabels(false);
- left.setStartAtZero(false);
- left.setSpaceTop(25f);
- left.setSpaceBottom(25f);
- left.setDrawAxisLine(false);
- left.setDrawGridLines(false);
- left.setDrawZeroLine(true); // draw a zero line
- left.setZeroLineColor(Color.GRAY);
- left.setZeroLineWidth(0.7f);
- mChart.getAxisRight().setEnabled(false);
- mChart.getLegend().setEnabled(false);
-
- // THIS IS THE ORIGINAL DATA YOU WANT TO PLOT
- List data = new ArrayList<>();
- data.add(new Data(0, -224.1f, "12-29"));
- data.add(new Data(1, 238.5f, "12-30"));
- data.add(new Data(2, 1280.1f, "12-31"));
- data.add(new Data(3, -442.3f, "01-01"));
- data.add(new Data(4, -2280.1f, "01-02"));
-
- setData(data);
- }
-
- private void setData(List dataList) {
-
- ArrayList values = new ArrayList();
- String[] dates = new String[dataList.size()];
- List colors = new ArrayList();
-
- int green = Color.rgb(110, 190, 102);
- int red = Color.rgb(211, 74, 88);
-
- for (int i = 0; i < dataList.size(); i++) {
-
- Data d = dataList.get(i);
- BarEntry entry = new BarEntry(d.yValue, d.xIndex);
- values.add(entry);
-
- dates[i] = dataList.get(i).xAxisValue;
-
- // specific colors
- if (d.yValue >= 0)
- colors.add(red);
- else
- colors.add(green);
- }
-
- BarDataSet set = new BarDataSet(values, "Values");
- set.setBarSpacePercent(40f);
- set.setColors(colors);
- set.setValueTextColors(colors);
-
- BarData data = new BarData(dates, set);
- data.setValueTextSize(13f);
- data.setValueTypeface(mTf);
- data.setValueFormatter(new ValueFormatter());
-
- mChart.setData(data);
- mChart.invalidate();
- }
-
- /**
- * Demo class representing data.
- */
- private class Data {
-
- public String xAxisValue;
- public float yValue;
- public int xIndex;
-
- public Data(int xIndex, float yValue, String xAxisValue) {
- this.xAxisValue = xAxisValue;
- this.yValue = yValue;
- this.xIndex = xIndex;
- }
- }
-
- private class ValueFormatter implements com.github.mikephil.charting.formatter.ValueFormatter {
-
- private DecimalFormat mFormat;
-
- public ValueFormatter() {
- mFormat = new DecimalFormat("######.0");
- }
-
- @Override
- public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
- return mFormat.format(value);
- }
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/BubbleChartActivity.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/BubbleChartActivity.java
deleted file mode 100644
index 03d97ed812..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/BubbleChartActivity.java
+++ /dev/null
@@ -1,248 +0,0 @@
-
-package com.xxmassdeveloper.mpchartexample;
-
-import android.graphics.Color;
-import android.graphics.Typeface;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.WindowManager;
-import android.widget.SeekBar;
-import android.widget.SeekBar.OnSeekBarChangeListener;
-import android.widget.TextView;
-
-import com.github.mikephil.charting.charts.BubbleChart;
-import com.github.mikephil.charting.components.Legend;
-import com.github.mikephil.charting.components.Legend.LegendPosition;
-import com.github.mikephil.charting.components.XAxis;
-import com.github.mikephil.charting.components.YAxis;
-import com.github.mikephil.charting.data.BubbleData;
-import com.github.mikephil.charting.data.BubbleDataSet;
-import com.github.mikephil.charting.data.BubbleEntry;
-import com.github.mikephil.charting.data.Entry;
-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.interfaces.datasets.IBubbleDataSet;
-import com.github.mikephil.charting.interfaces.datasets.IDataSet;
-import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
-import com.github.mikephil.charting.utils.ColorTemplate;
-import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
-
-import java.util.ArrayList;
-
-public class BubbleChartActivity extends DemoBase implements OnSeekBarChangeListener,
- OnChartValueSelectedListener {
-
- private BubbleChart mChart;
- private SeekBar mSeekBarX, mSeekBarY;
- private TextView tvX, tvY;
-
- private Typeface tf;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.activity_bubblechart);
-
- tvX = (TextView) findViewById(R.id.tvXMax);
- tvY = (TextView) findViewById(R.id.tvYMax);
-
- mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
- mSeekBarX.setOnSeekBarChangeListener(this);
-
- mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
- mSeekBarY.setOnSeekBarChangeListener(this);
-
- mChart = (BubbleChart) findViewById(R.id.chart1);
- mChart.setDescription("");
-
- tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
-
- mChart.setOnChartValueSelectedListener(this);
-
- mChart.setDrawGridBackground(false);
-
- mChart.setTouchEnabled(true);
-
- // enable scaling and dragging
- mChart.setDragEnabled(true);
- mChart.setScaleEnabled(true);
-
- mChart.setMaxVisibleValueCount(200);
- mChart.setPinchZoom(true);
-
- mSeekBarX.setProgress(5);
- mSeekBarY.setProgress(50);
-
- Legend l = mChart.getLegend();
- l.setPosition(LegendPosition.RIGHT_OF_CHART);
- l.setTypeface(tf);
-
- YAxis yl = mChart.getAxisLeft();
- yl.setTypeface(tf);
- yl.setSpaceTop(30f);
- yl.setSpaceBottom(30f);
- yl.setDrawZeroLine(false);
-
- mChart.getAxisRight().setEnabled(false);
-
- XAxis xl = mChart.getXAxis();
- xl.setPosition(XAxis.XAxisPosition.BOTTOM);
- xl.setTypeface(tf);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.bubble, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
-
- switch (item.getItemId()) {
- case R.id.actionToggleValues: {
- for (IDataSet set : mChart.getData().getDataSets())
- set.setDrawValues(!set.isDrawValuesEnabled());
-
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleHighlight: {
- if(mChart.getData() != null) {
- mChart.getData().setHighlightEnabled(!mChart.getData().isHighlightEnabled());
- mChart.invalidate();
- }
- break;
- }
- case R.id.actionTogglePinch: {
- if (mChart.isPinchZoomEnabled())
- mChart.setPinchZoom(false);
- else
- mChart.setPinchZoom(true);
-
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleAutoScaleMinMax: {
- mChart.setAutoScaleMinMaxEnabled(!mChart.isAutoScaleMinMaxEnabled());
- mChart.notifyDataSetChanged();
- break;
- }
- case R.id.actionSave: {
- // mChart.saveToGallery("title"+System.currentTimeMillis());
- mChart.saveToPath("title" + System.currentTimeMillis(), "");
- break;
- }
- case R.id.animateX: {
- mChart.animateX(3000);
- break;
- }
- case R.id.animateY: {
- mChart.animateY(3000);
- break;
- }
- case R.id.animateXY: {
-
- mChart.animateXY(3000, 3000);
- break;
- }
- }
- return true;
- }
-
- @Override
- public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
-
- int count = mSeekBarX.getProgress() + 1;
- int range = mSeekBarY.getProgress();
-
- tvX.setText("" + count);
- tvY.setText("" + range);
-
- ArrayList xVals = new ArrayList();
- for (int i = 0; i < count; i++) {
- xVals.add((i) + "");
- }
-
- ArrayList yVals1 = new ArrayList();
- ArrayList yVals2 = new ArrayList();
- ArrayList yVals3 = new ArrayList();
-
- for (int i = 0; i < count; i++) {
- float val = (float) (Math.random() * range);
- float size = (float) (Math.random() * range);
-
- yVals1.add(new BubbleEntry(i, val, size));
- }
-
- for (int i = 0; i < count; i++) {
- float val = (float) (Math.random() * range);
- float size = (float) (Math.random() * range);
-
- yVals2.add(new BubbleEntry(i, val, size));
- }
-
- for (int i = 0; i < count; i++) {
- float val = (float) (Math.random() * range);
- float size = (float) (Math.random() * range);
-
- yVals3.add(new BubbleEntry(i, val, size));
- }
-
- // create a dataset and give it a type
- BubbleDataSet set1 = new BubbleDataSet(yVals1, "DS 1");
- set1.setColor(ColorTemplate.COLORFUL_COLORS[0], 130);
- set1.setDrawValues(true);
- BubbleDataSet set2 = new BubbleDataSet(yVals2, "DS 2");
- set2.setColor(ColorTemplate.COLORFUL_COLORS[1], 130);
- set2.setDrawValues(true);
- BubbleDataSet set3 = new BubbleDataSet(yVals3, "DS 3");
- set3.setColor(ColorTemplate.COLORFUL_COLORS[2], 130);
- set3.setDrawValues(true);
-
- ArrayList dataSets = new ArrayList();
- dataSets.add(set1); // add the datasets
- dataSets.add(set2);
- dataSets.add(set3);
-
- // create a data object with the datasets
- BubbleData data = new BubbleData(xVals, dataSets);
- data.setValueTypeface(tf);
- data.setValueTextSize(8f);
- data.setValueTextColor(Color.WHITE);
- data.setHighlightCircleWidth(1.5f);
-
- mChart.setData(data);
- mChart.invalidate();
- }
-
- @Override
- public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
- Log.i("VAL SELECTED",
- "Value: " + e.getVal() + ", xIndex: " + e.getXIndex()
- + ", DataSet index: " + dataSetIndex);
- }
-
- @Override
- public void onNothingSelected() {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void onStartTrackingTouch(SeekBar seekBar) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void onStopTrackingTouch(SeekBar seekBar) {
- // TODO Auto-generated method stub
-
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/CandleStickChartActivity.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/CandleStickChartActivity.java
deleted file mode 100644
index 36211e175c..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/CandleStickChartActivity.java
+++ /dev/null
@@ -1,221 +0,0 @@
-
-package com.xxmassdeveloper.mpchartexample;
-
-import android.graphics.Color;
-import android.graphics.Paint;
-import android.os.Bundle;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.WindowManager;
-import android.widget.SeekBar;
-import android.widget.SeekBar.OnSeekBarChangeListener;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import com.github.mikephil.charting.charts.CandleStickChart;
-import com.github.mikephil.charting.components.XAxis;
-import com.github.mikephil.charting.components.XAxis.XAxisPosition;
-import com.github.mikephil.charting.components.YAxis;
-import com.github.mikephil.charting.components.YAxis.AxisDependency;
-import com.github.mikephil.charting.data.CandleData;
-import com.github.mikephil.charting.data.CandleDataSet;
-import com.github.mikephil.charting.data.CandleEntry;
-import com.github.mikephil.charting.interfaces.datasets.ICandleDataSet;
-import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
-
-import java.util.ArrayList;
-
-public class CandleStickChartActivity extends DemoBase implements OnSeekBarChangeListener {
-
- private CandleStickChart mChart;
- private SeekBar mSeekBarX, mSeekBarY;
- private TextView tvX, tvY;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.activity_candlechart);
-
- tvX = (TextView) findViewById(R.id.tvXMax);
- tvY = (TextView) findViewById(R.id.tvYMax);
-
- mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
- mSeekBarX.setOnSeekBarChangeListener(this);
-
- mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
- mSeekBarY.setOnSeekBarChangeListener(this);
-
- mChart = (CandleStickChart) findViewById(R.id.chart1);
- mChart.setBackgroundColor(Color.WHITE);
-
- mChart.setDescription("");
-
- // if more than 60 entries are displayed in the chart, no values will be
- // drawn
- mChart.setMaxVisibleValueCount(60);
-
- // scaling can now only be done on x- and y-axis separately
- mChart.setPinchZoom(false);
-
- mChart.setDrawGridBackground(false);
-
- XAxis xAxis = mChart.getXAxis();
- xAxis.setPosition(XAxisPosition.BOTTOM);
- xAxis.setSpaceBetweenLabels(2);
- xAxis.setDrawGridLines(false);
-
- YAxis leftAxis = mChart.getAxisLeft();
-// leftAxis.setEnabled(false);
- leftAxis.setLabelCount(7, false);
- leftAxis.setDrawGridLines(false);
- leftAxis.setDrawAxisLine(false);
-
- YAxis rightAxis = mChart.getAxisRight();
- rightAxis.setEnabled(false);
-// rightAxis.setStartAtZero(false);
-
- // setting data
- mSeekBarX.setProgress(40);
- mSeekBarY.setProgress(100);
-
- mChart.getLegend().setEnabled(false);
-
- // Legend l = mChart.getLegend();
- // l.setPosition(LegendPosition.BELOW_CHART_CENTER);
- // l.setFormSize(8f);
- // l.setFormToTextSpace(4f);
- // l.setXEntrySpace(6f);
-
- // mChart.setDrawLegend(false);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.candle, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
-
- switch (item.getItemId()) {
- case R.id.actionToggleHighlight: {
- if(mChart.getData() != null) {
- mChart.getData().setHighlightEnabled(!mChart.getData().isHighlightEnabled());
- mChart.invalidate();
- }
- break;
- }
- case R.id.actionTogglePinch: {
- if (mChart.isPinchZoomEnabled())
- mChart.setPinchZoom(false);
- else
- mChart.setPinchZoom(true);
-
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleAutoScaleMinMax: {
- mChart.setAutoScaleMinMaxEnabled(!mChart.isAutoScaleMinMaxEnabled());
- mChart.notifyDataSetChanged();
- break;
- }
- case R.id.actionToggleMakeShadowSameColorAsCandle: {
- for (ICandleDataSet set : mChart.getData().getDataSets()) {
- //TODO: set.setShadowColorSameAsCandle(!set.getShadowColorSameAsCandle());
- }
-
- mChart.invalidate();
- break;
- }
- case R.id.animateX: {
- mChart.animateX(3000);
- break;
- }
- case R.id.animateY: {
- mChart.animateY(3000);
- break;
- }
- case R.id.animateXY: {
-
- mChart.animateXY(3000, 3000);
- break;
- }
- case R.id.actionSave: {
- if (mChart.saveToGallery("title" + System.currentTimeMillis(), 50)) {
- Toast.makeText(getApplicationContext(), "Saving SUCCESSFUL!",
- Toast.LENGTH_SHORT).show();
- } else
- Toast.makeText(getApplicationContext(), "Saving FAILED!", Toast.LENGTH_SHORT)
- .show();
- break;
- }
- }
- return true;
- }
-
- @Override
- public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
-
- int prog = (mSeekBarX.getProgress() + 1);
-
- tvX.setText("" + prog);
- tvY.setText("" + (mSeekBarY.getProgress()));
-
- mChart.resetTracking();
-
- ArrayList yVals1 = new ArrayList();
-
- for (int i = 0; i < prog; i++) {
- float mult = (mSeekBarY.getProgress() + 1);
- float val = (float) (Math.random() * 40) + mult;
-
- float high = (float) (Math.random() * 9) + 8f;
- float low = (float) (Math.random() * 9) + 8f;
-
- float open = (float) (Math.random() * 6) + 1f;
- float close = (float) (Math.random() * 6) + 1f;
-
- boolean even = i % 2 == 0;
-
- yVals1.add(new CandleEntry(i, val + high, val - low, even ? val + open : val - open,
- even ? val - close : val + close));
- }
-
- ArrayList xVals = new ArrayList();
- for (int i = 0; i < prog; i++) {
- xVals.add("" + (1990 + i));
- }
-
- CandleDataSet set1 = new CandleDataSet(yVals1, "Data Set");
- set1.setAxisDependency(AxisDependency.LEFT);
-// set1.setColor(Color.rgb(80, 80, 80));
- set1.setShadowColor(Color.DKGRAY);
- set1.setShadowWidth(0.7f);
- set1.setDecreasingColor(Color.RED);
- set1.setDecreasingPaintStyle(Paint.Style.FILL);
- set1.setIncreasingColor(Color.rgb(122, 242, 84));
- set1.setIncreasingPaintStyle(Paint.Style.STROKE);
- set1.setNeutralColor(Color.BLUE);
- //set1.setHighlightLineWidth(1f);
-
- CandleData data = new CandleData(xVals, set1);
-
- mChart.setData(data);
- mChart.invalidate();
- }
-
- @Override
- public void onStartTrackingTouch(SeekBar seekBar) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void onStopTrackingTouch(SeekBar seekBar) {
- // TODO Auto-generated method stub
-
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/CombinedChartActivity.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/CombinedChartActivity.java
deleted file mode 100644
index 1cc5a5d9ab..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/CombinedChartActivity.java
+++ /dev/null
@@ -1,223 +0,0 @@
-
-package com.xxmassdeveloper.mpchartexample;
-
-import android.graphics.Color;
-import android.os.Bundle;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.WindowManager;
-
-import com.github.mikephil.charting.charts.CombinedChart;
-import com.github.mikephil.charting.charts.CombinedChart.DrawOrder;
-import com.github.mikephil.charting.components.XAxis;
-import com.github.mikephil.charting.components.XAxis.XAxisPosition;
-import com.github.mikephil.charting.components.YAxis;
-import com.github.mikephil.charting.data.BarData;
-import com.github.mikephil.charting.data.BarDataSet;
-import com.github.mikephil.charting.data.BarEntry;
-import com.github.mikephil.charting.data.BubbleData;
-import com.github.mikephil.charting.data.BubbleDataSet;
-import com.github.mikephil.charting.data.BubbleEntry;
-import com.github.mikephil.charting.data.CandleData;
-import com.github.mikephil.charting.data.CandleDataSet;
-import com.github.mikephil.charting.data.CandleEntry;
-import com.github.mikephil.charting.data.CombinedData;
-import com.github.mikephil.charting.data.Entry;
-import com.github.mikephil.charting.data.LineData;
-import com.github.mikephil.charting.data.LineDataSet;
-import com.github.mikephil.charting.data.ScatterData;
-import com.github.mikephil.charting.data.ScatterDataSet;
-import com.github.mikephil.charting.interfaces.datasets.IDataSet;
-import com.github.mikephil.charting.utils.ColorTemplate;
-import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
-
-import java.util.ArrayList;
-
-public class CombinedChartActivity extends DemoBase {
-
- private CombinedChart mChart;
- private final int itemcount = 12;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.activity_combined);
-
- mChart = (CombinedChart) findViewById(R.id.chart1);
- mChart.setDescription("");
- mChart.setBackgroundColor(Color.WHITE);
- mChart.setDrawGridBackground(false);
- mChart.setDrawBarShadow(false);
-
- // draw bars behind lines
- mChart.setDrawOrder(new DrawOrder[] {
- DrawOrder.BAR, DrawOrder.BUBBLE, DrawOrder.CANDLE, DrawOrder.LINE, DrawOrder.SCATTER
- });
-
- YAxis rightAxis = mChart.getAxisRight();
- rightAxis.setDrawGridLines(false);
- rightAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true)
-
- YAxis leftAxis = mChart.getAxisLeft();
- leftAxis.setDrawGridLines(false);
- leftAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true)
-
- XAxis xAxis = mChart.getXAxis();
- xAxis.setPosition(XAxisPosition.BOTH_SIDED);
-
- CombinedData data = new CombinedData(mMonths);
-
- data.setData(generateLineData());
- data.setData(generateBarData());
-// data.setData(generateBubbleData());
-// data.setData(generateScatterData());
-// data.setData(generateCandleData());
-
- mChart.setData(data);
- mChart.invalidate();
- }
-
- private LineData generateLineData() {
-
- LineData d = new LineData();
-
- ArrayList entries = new ArrayList();
-
- for (int index = 0; index < itemcount; index++)
- entries.add(new Entry(getRandom(15, 10), index));
-
- LineDataSet set = new LineDataSet(entries, "Line DataSet");
- set.setColor(Color.rgb(240, 238, 70));
- set.setLineWidth(2.5f);
- set.setCircleColor(Color.rgb(240, 238, 70));
- set.setCircleRadius(5f);
- set.setFillColor(Color.rgb(240, 238, 70));
- set.setDrawCubic(true);
- set.setDrawValues(true);
- set.setValueTextSize(10f);
- set.setValueTextColor(Color.rgb(240, 238, 70));
-
- set.setAxisDependency(YAxis.AxisDependency.LEFT);
-
- d.addDataSet(set);
-
- return d;
- }
-
- private BarData generateBarData() {
-
- BarData d = new BarData();
-
- ArrayList entries = new ArrayList();
-
- for (int index = 0; index < itemcount; index++)
- entries.add(new BarEntry(getRandom(15, 30), index));
-
- BarDataSet set = new BarDataSet(entries, "Bar DataSet");
- set.setColor(Color.rgb(60, 220, 78));
- set.setValueTextColor(Color.rgb(60, 220, 78));
- set.setValueTextSize(10f);
- d.addDataSet(set);
-
- set.setAxisDependency(YAxis.AxisDependency.LEFT);
-
- return d;
- }
-
- protected ScatterData generateScatterData() {
-
- ScatterData d = new ScatterData();
-
- ArrayList entries = new ArrayList();
-
- for (int index = 0; index < itemcount; index++)
- entries.add(new Entry(getRandom(20, 15), index));
-
- ScatterDataSet set = new ScatterDataSet(entries, "Scatter DataSet");
- set.setColor(Color.GREEN);
- set.setScatterShapeSize(7.5f);
- set.setDrawValues(false);
- set.setValueTextSize(10f);
- d.addDataSet(set);
-
- return d;
- }
-
- protected CandleData generateCandleData() {
-
- CandleData d = new CandleData();
-
- ArrayList entries = new ArrayList();
-
- for (int index = 0; index < itemcount; index++)
- entries.add(new CandleEntry(index, 20f, 10f, 13f, 17f));
-
- CandleDataSet set = new CandleDataSet(entries, "Candle DataSet");
- set.setColor(Color.rgb(80, 80, 80));
- set.setBarSpace(0.3f);
- set.setValueTextSize(10f);
- set.setDrawValues(false);
- d.addDataSet(set);
-
- return d;
- }
-
- protected BubbleData generateBubbleData() {
-
- BubbleData bd = new BubbleData();
-
- ArrayList entries = new ArrayList();
-
- for (int index = 0; index < itemcount; index++) {
- float rnd = getRandom(20, 30);
- entries.add(new BubbleEntry(index, rnd, rnd));
- }
-
- BubbleDataSet set = new BubbleDataSet(entries, "Bubble DataSet");
- set.setColors(ColorTemplate.VORDIPLOM_COLORS);
- set.setValueTextSize(10f);
- set.setValueTextColor(Color.WHITE);
- set.setHighlightCircleWidth(1.5f);
- set.setDrawValues(true);
- bd.addDataSet(set);
-
- return bd;
- }
-
- private float getRandom(float range, float startsfrom) {
- return (float) (Math.random() * range) + startsfrom;
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.combined, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case R.id.actionToggleLineValues: {
- for (IDataSet set : mChart.getData().getDataSets()) {
- if (set instanceof LineDataSet)
- set.setDrawValues(!set.isDrawValuesEnabled());
- }
-
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleBarValues: {
- for (IDataSet set : mChart.getData().getDataSets()) {
- if (set instanceof BarDataSet)
- set.setDrawValues(!set.isDrawValuesEnabled());
- }
-
- mChart.invalidate();
- break;
- }
- }
- return true;
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/CubicLineChartActivity.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/CubicLineChartActivity.java
deleted file mode 100644
index 31f951a379..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/CubicLineChartActivity.java
+++ /dev/null
@@ -1,287 +0,0 @@
-
-package com.xxmassdeveloper.mpchartexample;
-
-import android.graphics.Color;
-import android.graphics.Typeface;
-import android.os.Bundle;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.WindowManager;
-import android.widget.SeekBar;
-import android.widget.SeekBar.OnSeekBarChangeListener;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import com.github.mikephil.charting.charts.LineChart;
-import com.github.mikephil.charting.components.XAxis;
-import com.github.mikephil.charting.components.YAxis;
-import com.github.mikephil.charting.data.Entry;
-import com.github.mikephil.charting.data.LineData;
-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.formatter.FillFormatter;
-import com.github.mikephil.charting.interfaces.datasets.IDataSet;
-import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
-import com.github.mikephil.charting.interfaces.dataprovider.LineDataProvider;
-import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class CubicLineChartActivity extends DemoBase implements OnSeekBarChangeListener {
-
- private LineChart mChart;
- private SeekBar mSeekBarX, mSeekBarY;
- private TextView tvX, tvY;
-
- private Typeface tf;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.activity_linechart);
-
- tvX = (TextView) findViewById(R.id.tvXMax);
- tvY = (TextView) findViewById(R.id.tvYMax);
-
- mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
- mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
-
- mSeekBarX.setProgress(45);
- mSeekBarY.setProgress(100);
-
- mSeekBarY.setOnSeekBarChangeListener(this);
- mSeekBarX.setOnSeekBarChangeListener(this);
-
- mChart = (LineChart) findViewById(R.id.chart1);
- mChart.setViewPortOffsets(0, 20, 0, 0);
- mChart.setBackgroundColor(Color.rgb(104, 241, 175));
-
- // no description text
- mChart.setDescription("");
-
- // enable touch gestures
- mChart.setTouchEnabled(true);
-
- // enable scaling and dragging
- mChart.setDragEnabled(true);
- mChart.setScaleEnabled(true);
-
- // if disabled, scaling can be done on x- and y-axis separately
- mChart.setPinchZoom(false);
-
- mChart.setDrawGridBackground(false);
-
- tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
-
- XAxis x = mChart.getXAxis();
- x.setEnabled(false);
-
- YAxis y = mChart.getAxisLeft();
- y.setTypeface(tf);
- y.setLabelCount(6, false);
- y.setTextColor(Color.WHITE);
- y.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
- y.setDrawGridLines(false);
- y.setAxisLineColor(Color.WHITE);
-
- mChart.getAxisRight().setEnabled(false);
-
- // add data
- setData(45, 100);
-
- mChart.getLegend().setEnabled(false);
-
- mChart.animateXY(2000, 2000);
-
- // dont forget to refresh the drawing
- mChart.invalidate();
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.line, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
-
- switch (item.getItemId()) {
- case R.id.actionToggleValues: {
- for (IDataSet set : mChart.getData().getDataSets())
- set.setDrawValues(!set.isDrawValuesEnabled());
-
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleHighlight: {
- if(mChart.getData() != null) {
- mChart.getData().setHighlightEnabled(!mChart.getData().isHighlightEnabled());
- mChart.invalidate();
- }
- break;
- }
- case R.id.actionToggleFilled: {
-
- List sets = mChart.getData()
- .getDataSets();
-
- for (ILineDataSet iSet : sets) {
-
- LineDataSet set = (LineDataSet) iSet;
-
- if (set.isDrawFilledEnabled())
- set.setDrawFilled(false);
- else
- set.setDrawFilled(true);
- }
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleCircles: {
- List sets = mChart.getData()
- .getDataSets();
-
- for (ILineDataSet iSet : sets) {
-
- LineDataSet set = (LineDataSet) iSet;
- if (set.isDrawCirclesEnabled())
- set.setDrawCircles(false);
- else
- set.setDrawCircles(true);
- }
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleCubic: {
- List sets = mChart.getData()
- .getDataSets();
-
- for (ILineDataSet iSet : sets) {
-
- LineDataSet set = (LineDataSet) iSet;
- if (set.isDrawCubicEnabled())
- set.setDrawCubic(false);
- else
- set.setDrawCubic(true);
- }
- mChart.invalidate();
- break;
- }
- case R.id.actionTogglePinch: {
- if (mChart.isPinchZoomEnabled())
- mChart.setPinchZoom(false);
- else
- mChart.setPinchZoom(true);
-
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleAutoScaleMinMax: {
- mChart.setAutoScaleMinMaxEnabled(!mChart.isAutoScaleMinMaxEnabled());
- mChart.notifyDataSetChanged();
- break;
- }
- case R.id.animateX: {
- mChart.animateX(3000);
- break;
- }
- case R.id.animateY: {
- mChart.animateY(3000);
- break;
- }
- case R.id.animateXY: {
- mChart.animateXY(3000, 3000);
- break;
- }
- case R.id.actionSave: {
- if (mChart.saveToPath("title" + System.currentTimeMillis(), "")) {
- Toast.makeText(getApplicationContext(), "Saving SUCCESSFUL!",
- Toast.LENGTH_SHORT).show();
- } else
- Toast.makeText(getApplicationContext(), "Saving FAILED!", Toast.LENGTH_SHORT)
- .show();
-
- // mChart.saveToGallery("title"+System.currentTimeMillis())
- break;
- }
- }
- return true;
- }
-
- @Override
- public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
-
- tvX.setText("" + (mSeekBarX.getProgress() + 1));
- tvY.setText("" + (mSeekBarY.getProgress()));
-
- setData(mSeekBarX.getProgress() + 1, mSeekBarY.getProgress());
-
- // redraw
- mChart.invalidate();
- }
-
- @Override
- public void onStartTrackingTouch(SeekBar seekBar) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void onStopTrackingTouch(SeekBar seekBar) {
- // TODO Auto-generated method stub
-
- }
-
- private void setData(int count, float range) {
-
- ArrayList xVals = new ArrayList();
- for (int i = 0; i < count; i++) {
- xVals.add((1990 +i) + "");
- }
-
- ArrayList vals1 = new ArrayList();
-
- for (int i = 0; i < count; i++) {
- float mult = (range + 1);
- float val = (float) (Math.random() * mult) + 20;// + (float)
- // ((mult *
- // 0.1) / 10);
- vals1.add(new Entry(val, i));
- }
-
- // create a dataset and give it a type
- LineDataSet set1 = new LineDataSet(vals1, "DataSet 1");
- set1.setDrawCubic(true);
- set1.setCubicIntensity(0.2f);
- //set1.setDrawFilled(true);
- set1.setDrawCircles(false);
- set1.setLineWidth(1.8f);
- set1.setCircleRadius(4f);
- set1.setCircleColor(Color.WHITE);
- set1.setHighLightColor(Color.rgb(244, 117, 117));
- set1.setColor(Color.WHITE);
- set1.setFillColor(Color.WHITE);
- set1.setFillAlpha(100);
- set1.setDrawHorizontalHighlightIndicator(false);
- set1.setFillFormatter(new FillFormatter() {
- @Override
- public float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider) {
- return -10;
- }
- });
-
- // create a data object with the datasets
- LineData data = new LineData(xVals, set1);
- data.setValueTypeface(tf);
- data.setValueTextSize(9f);
- data.setDrawValues(false);
-
- // set data
- mChart.setData(data);
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/DynamicalAddingActivity.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/DynamicalAddingActivity.java
deleted file mode 100644
index 0c19b2032d..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/DynamicalAddingActivity.java
+++ /dev/null
@@ -1,221 +0,0 @@
-
-package com.xxmassdeveloper.mpchartexample;
-
-import android.graphics.Color;
-import android.os.Bundle;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.WindowManager;
-import android.widget.Toast;
-
-import com.github.mikephil.charting.charts.LineChart;
-import com.github.mikephil.charting.components.YAxis.AxisDependency;
-import com.github.mikephil.charting.data.Entry;
-import com.github.mikephil.charting.data.LineData;
-import com.github.mikephil.charting.data.LineDataSet;
-import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
-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.notimportant.DemoBase;
-
-import java.util.ArrayList;
-
-public class DynamicalAddingActivity extends DemoBase implements OnChartValueSelectedListener {
-
- private LineChart mChart;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.activity_linechart_noseekbar);
-
- mChart = (LineChart) findViewById(R.id.chart1);
- mChart.setOnChartValueSelectedListener(this);
- mChart.setDrawGridBackground(false);
- mChart.setDescription("");
-
- // add an empty data object
- mChart.setData(new LineData());
-// mChart.getXAxis().setDrawLabels(false);
-// mChart.getXAxis().setDrawGridLines(false);
-
- mChart.invalidate();
- }
-
- int[] mColors = ColorTemplate.VORDIPLOM_COLORS;
-
- private void addEntry() {
-
- LineData data = mChart.getData();
-
- if(data != null) {
-
- ILineDataSet set = data.getDataSetByIndex(0);
- // set.addEntry(...); // can be called as well
-
- if (set == null) {
- set = createSet();
- data.addDataSet(set);
- }
-
- // add a new x-value first
- data.addXValue(set.getEntryCount() + "");
-
- // choose a random dataSet
- int randomDataSetIndex = (int) (Math.random() * data.getDataSetCount());
-
- data.addEntry(new Entry((float) (Math.random() * 10) + 50f, set.getEntryCount()), randomDataSetIndex);
-
- // let the chart know it's data has changed
- mChart.notifyDataSetChanged();
-
- mChart.setVisibleXRangeMaximum(6);
- mChart.setVisibleYRangeMaximum(15, AxisDependency.LEFT);
-//
-// // this automatically refreshes the chart (calls invalidate())
- mChart.moveViewTo(data.getXValCount()-7, 50f, AxisDependency.LEFT);
- }
- }
-
- private void removeLastEntry() {
-
- LineData data = mChart.getData();
-
- if(data != null) {
-
- ILineDataSet set = data.getDataSetByIndex(0);
-
- if (set != null) {
-
- Entry e = set.getEntryForXIndex(set.getEntryCount() - 1);
-
- data.removeEntry(e, 0);
- // or remove by index
- // mData.removeEntry(xIndex, dataSetIndex);
-
- mChart.notifyDataSetChanged();
- mChart.invalidate();
- }
- }
- }
-
- private void addDataSet() {
-
- LineData data = mChart.getData();
-
- if(data != null) {
-
- int count = (data.getDataSetCount() + 1);
-
- // create 10 y-vals
- ArrayList yVals = new ArrayList();
-
- if(data.getXValCount() == 0) {
- // add 10 x-entries
- for (int i = 0; i < 10; i++) {
- data.addXValue("" + (i+1));
- }
- }
-
- for (int i = 0; i < data.getXValCount(); i++) {
- yVals.add(new Entry((float) (Math.random() * 50f) + 50f * count, i));
- }
-
- LineDataSet set = new LineDataSet(yVals, "DataSet " + count);
- set.setLineWidth(2.5f);
- set.setCircleRadius(4.5f);
-
- int color = mColors[count % mColors.length];
-
- set.setColor(color);
- set.setCircleColor(color);
- set.setHighLightColor(color);
- set.setValueTextSize(10f);
- set.setValueTextColor(color);
-
- data.addDataSet(set);
- mChart.notifyDataSetChanged();
- mChart.invalidate();
- }
- }
-
- private void removeDataSet() {
-
- LineData data = mChart.getData();
-
- if(data != null) {
-
- data.removeDataSet(data.getDataSetByIndex(data.getDataSetCount() - 1));
-
- mChart.notifyDataSetChanged();
- mChart.invalidate();
- }
- }
-
- @Override
- public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
- Toast.makeText(this, e.toString(), Toast.LENGTH_SHORT).show();
- }
-
- @Override
- public void onNothingSelected() {
-
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.dynamical, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
-
- switch (item.getItemId()) {
- case R.id.actionAddEntry:
- addEntry();
- Toast.makeText(this, "Entry added!", Toast.LENGTH_SHORT).show();
- break;
- case R.id.actionRemoveEntry:
- removeLastEntry();
- Toast.makeText(this, "Entry removed!", Toast.LENGTH_SHORT).show();
- break;
- case R.id.actionAddDataSet:
- addDataSet();
- Toast.makeText(this, "DataSet added!", Toast.LENGTH_SHORT).show();
- break;
- case R.id.actionRemoveDataSet:
- removeDataSet();
- Toast.makeText(this, "DataSet removed!", Toast.LENGTH_SHORT).show();
- break;
- case R.id.actionAddEmptyLineData:
- mChart.setData(new LineData());
- mChart.invalidate();
- Toast.makeText(this, "Empty data added!", Toast.LENGTH_SHORT).show();
- break;
- case R.id.actionClear:
- mChart.clear();
- Toast.makeText(this, "Chart cleared!", Toast.LENGTH_SHORT).show();
- break;
- }
-
- return true;
- }
-
- private LineDataSet createSet() {
-
- LineDataSet set = new LineDataSet(null, "DataSet 1");
- set.setLineWidth(2.5f);
- set.setCircleRadius(4.5f);
- set.setColor(Color.rgb(240, 99, 99));
- set.setCircleColor(Color.rgb(240, 99, 99));
- set.setHighLightColor(Color.rgb(190, 190, 190));
- set.setAxisDependency(AxisDependency.LEFT);
- set.setValueTextSize(10f);
-
- return set;
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/HorizontalBarChartActivity.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/HorizontalBarChartActivity.java
deleted file mode 100644
index 3027188cf5..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/HorizontalBarChartActivity.java
+++ /dev/null
@@ -1,267 +0,0 @@
-
-package com.xxmassdeveloper.mpchartexample;
-
-import android.annotation.SuppressLint;
-import android.graphics.PointF;
-import android.graphics.RectF;
-import android.graphics.Typeface;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.WindowManager;
-import android.widget.SeekBar;
-import android.widget.SeekBar.OnSeekBarChangeListener;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import com.github.mikephil.charting.charts.HorizontalBarChart;
-import com.github.mikephil.charting.components.Legend;
-import com.github.mikephil.charting.components.Legend.LegendPosition;
-import com.github.mikephil.charting.components.XAxis;
-import com.github.mikephil.charting.components.XAxis.XAxisPosition;
-import com.github.mikephil.charting.components.YAxis;
-import com.github.mikephil.charting.data.BarData;
-import com.github.mikephil.charting.data.BarDataSet;
-import com.github.mikephil.charting.data.BarEntry;
-import com.github.mikephil.charting.data.Entry;
-import com.github.mikephil.charting.data.filter.Approximator;
-import com.github.mikephil.charting.data.filter.Approximator.ApproximatorType;
-import com.github.mikephil.charting.interfaces.datasets.IBarDataSet;
-import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
-import com.github.mikephil.charting.highlight.Highlight;
-import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class HorizontalBarChartActivity extends DemoBase implements OnSeekBarChangeListener,
- OnChartValueSelectedListener {
-
- protected HorizontalBarChart mChart;
- private SeekBar mSeekBarX, mSeekBarY;
- private TextView tvX, tvY;
-
- private Typeface tf;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.activity_horizontalbarchart);
-
- tvX = (TextView) findViewById(R.id.tvXMax);
- tvY = (TextView) findViewById(R.id.tvYMax);
-
- mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
- mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
-
- mChart = (HorizontalBarChart) findViewById(R.id.chart1);
- mChart.setOnChartValueSelectedListener(this);
- // mChart.setHighlightEnabled(false);
-
- mChart.setDrawBarShadow(false);
-
- mChart.setDrawValueAboveBar(true);
-
- mChart.setDescription("");
-
- // if more than 60 entries are displayed in the chart, no values will be
- // drawn
- mChart.setMaxVisibleValueCount(60);
-
- // scaling can now only be done on x- and y-axis separately
- mChart.setPinchZoom(false);
-
- // draw shadows for each bar that show the maximum value
- // mChart.setDrawBarShadow(true);
-
- // mChart.setDrawXLabels(false);
-
- mChart.setDrawGridBackground(false);
-
- // mChart.setDrawYLabels(false);
-
- tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
-
- XAxis xl = mChart.getXAxis();
- xl.setPosition(XAxisPosition.BOTTOM);
- xl.setTypeface(tf);
- xl.setDrawAxisLine(true);
- xl.setDrawGridLines(true);
- xl.setGridLineWidth(0.3f);
-
- YAxis yl = mChart.getAxisLeft();
- yl.setTypeface(tf);
- yl.setDrawAxisLine(true);
- yl.setDrawGridLines(true);
- yl.setGridLineWidth(0.3f);
- yl.setAxisMinValue(0f); // this replaces setStartAtZero(true)
-// yl.setInverted(true);
-
- YAxis yr = mChart.getAxisRight();
- yr.setTypeface(tf);
- yr.setDrawAxisLine(true);
- yr.setDrawGridLines(false);
- yr.setAxisMinValue(0f); // this replaces setStartAtZero(true)
-// yr.setInverted(true);
-
- setData(12, 50);
- mChart.animateY(2500);
-
- // setting data
- mSeekBarY.setProgress(50);
- mSeekBarX.setProgress(12);
-
- mSeekBarY.setOnSeekBarChangeListener(this);
- mSeekBarX.setOnSeekBarChangeListener(this);
-
- Legend l = mChart.getLegend();
- l.setPosition(LegendPosition.BELOW_CHART_LEFT);
- l.setFormSize(8f);
- l.setXEntrySpace(4f);
-
- // mChart.setDrawLegend(false);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.bar, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
-
- switch (item.getItemId()) {
- case R.id.actionToggleValues: {
- List sets = mChart.getData()
- .getDataSets();
-
- for (IBarDataSet iSet : sets) {
-
- IBarDataSet set = (BarDataSet) iSet;
- set.setDrawValues(!set.isDrawValuesEnabled());
- }
-
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleHighlight: {
- if(mChart.getData() != null) {
- mChart.getData().setHighlightEnabled(!mChart.getData().isHighlightEnabled());
- mChart.invalidate();
- }
- break;
- }
- case R.id.actionTogglePinch: {
- if (mChart.isPinchZoomEnabled())
- mChart.setPinchZoom(false);
- else
- mChart.setPinchZoom(true);
-
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleAutoScaleMinMax: {
- mChart.setAutoScaleMinMaxEnabled(!mChart.isAutoScaleMinMaxEnabled());
- mChart.notifyDataSetChanged();
- break;
- }
- case R.id.actionToggleHighlightArrow: {
- if (mChart.isDrawHighlightArrowEnabled())
- mChart.setDrawHighlightArrow(false);
- else
- mChart.setDrawHighlightArrow(true);
- mChart.invalidate();
- break;
- }
- case R.id.animateX: {
- mChart.animateX(3000);
- break;
- }
- case R.id.animateY: {
- mChart.animateY(3000);
- break;
- }
- case R.id.animateXY: {
-
- mChart.animateXY(3000, 3000);
- break;
- }
- case R.id.actionSave: {
- if (mChart.saveToGallery("title" + System.currentTimeMillis(), 50)) {
- Toast.makeText(getApplicationContext(), "Saving SUCCESSFUL!",
- Toast.LENGTH_SHORT).show();
- } else
- Toast.makeText(getApplicationContext(), "Saving FAILED!", Toast.LENGTH_SHORT)
- .show();
- break;
- }
- }
- return true;
- }
-
- @Override
- public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
-
- tvX.setText("" + (mSeekBarX.getProgress() + 1));
- tvY.setText("" + (mSeekBarY.getProgress()));
-
- setData(mSeekBarX.getProgress() + 1, mSeekBarY.getProgress());
- mChart.invalidate();
- }
-
- @Override
- public void onStartTrackingTouch(SeekBar seekBar) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void onStopTrackingTouch(SeekBar seekBar) {
- // TODO Auto-generated method stub
-
- }
-
- private void setData(int count, float range) {
-
- ArrayList yVals1 = new ArrayList();
- ArrayList xVals = new ArrayList();
-
- for (int i = 0; i < count; i++) {
- xVals.add(mMonths[i % 12]);
- yVals1.add(new BarEntry((float) (Math.random() * range), i));
- }
-
- BarDataSet set1 = new BarDataSet(yVals1, "DataSet 1");
-
- ArrayList dataSets = new ArrayList();
- dataSets.add(set1);
-
- BarData data = new BarData(xVals, dataSets);
- data.setValueTextSize(10f);
- data.setValueTypeface(tf);
-
- mChart.setData(data);
- }
-
- @SuppressLint("NewApi")
- @Override
- public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
-
- if (e == null)
- return;
-
- RectF bounds = mChart.getBarBounds((BarEntry) e);
- PointF position = mChart.getPosition(e, mChart.getData().getDataSetByIndex(dataSetIndex)
- .getAxisDependency());
-
- Log.i("bounds", bounds.toString());
- Log.i("position", position.toString());
- }
-
- public void onNothingSelected() {
- };
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/LineChartActivity1.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/LineChartActivity1.java
deleted file mode 100644
index 0c331f1738..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/LineChartActivity1.java
+++ /dev/null
@@ -1,411 +0,0 @@
-
-package com.xxmassdeveloper.mpchartexample;
-
-import android.graphics.Color;
-import android.graphics.Typeface;
-import android.graphics.drawable.Drawable;
-import android.os.Bundle;
-import android.support.v4.content.ContextCompat;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.MotionEvent;
-import android.view.WindowManager;
-import android.widget.SeekBar;
-import android.widget.SeekBar.OnSeekBarChangeListener;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import com.github.mikephil.charting.animation.Easing;
-import com.github.mikephil.charting.charts.LineChart;
-import com.github.mikephil.charting.components.Legend;
-import com.github.mikephil.charting.components.Legend.LegendForm;
-import com.github.mikephil.charting.components.LimitLine;
-import com.github.mikephil.charting.components.LimitLine.LimitLabelPosition;
-import com.github.mikephil.charting.components.XAxis;
-import com.github.mikephil.charting.components.YAxis;
-import com.github.mikephil.charting.data.Entry;
-import com.github.mikephil.charting.data.LineData;
-import com.github.mikephil.charting.data.LineDataSet;
-import com.github.mikephil.charting.highlight.Highlight;
-import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
-import com.github.mikephil.charting.listener.ChartTouchListener;
-import com.github.mikephil.charting.listener.OnChartGestureListener;
-import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
-import com.xxmassdeveloper.mpchartexample.custom.MyMarkerView;
-import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class LineChartActivity1 extends DemoBase implements OnSeekBarChangeListener,
- OnChartGestureListener, OnChartValueSelectedListener {
-
- private LineChart mChart;
- private SeekBar mSeekBarX, mSeekBarY;
- private TextView tvX, tvY;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.activity_linechart);
-
- tvX = (TextView) findViewById(R.id.tvXMax);
- tvY = (TextView) findViewById(R.id.tvYMax);
-
- mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
- mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
-
- mSeekBarX.setProgress(45);
- mSeekBarY.setProgress(100);
-
- mSeekBarY.setOnSeekBarChangeListener(this);
- mSeekBarX.setOnSeekBarChangeListener(this);
-
- mChart = (LineChart) findViewById(R.id.chart1);
- mChart.setOnChartGestureListener(this);
- mChart.setOnChartValueSelectedListener(this);
- mChart.setDrawGridBackground(false);
-
- // no description text
- mChart.setDescription("");
- mChart.setNoDataTextDescription("You need to provide data for the chart.");
-
- // enable touch gestures
- mChart.setTouchEnabled(true);
-
- // enable scaling and dragging
- mChart.setDragEnabled(true);
- mChart.setScaleEnabled(true);
- // mChart.setScaleXEnabled(true);
- // mChart.setScaleYEnabled(true);
-
- // if disabled, scaling can be done on x- and y-axis separately
- mChart.setPinchZoom(true);
-
- // set an alternative background color
- // mChart.setBackgroundColor(Color.GRAY);
-
- // create a custom MarkerView (extend MarkerView) and specify the layout
- // to use for it
- MyMarkerView mv = new MyMarkerView(this, R.layout.custom_marker_view);
-
- // set the marker to the chart
- mChart.setMarkerView(mv);
-
- // x-axis limit line
- LimitLine llXAxis = new LimitLine(10f, "Index 10");
- llXAxis.setLineWidth(4f);
- llXAxis.enableDashedLine(10f, 10f, 0f);
- llXAxis.setLabelPosition(LimitLabelPosition.RIGHT_BOTTOM);
- llXAxis.setTextSize(10f);
-
- XAxis xAxis = mChart.getXAxis();
- //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
- leftAxis.addLimitLine(ll1);
- leftAxis.addLimitLine(ll2);
- leftAxis.setAxisMaxValue(220f);
- leftAxis.setAxisMinValue(-50f);
- //leftAxis.setYOffset(20f);
- leftAxis.enableGridDashedLine(10f, 10f, 0f);
- leftAxis.setDrawZeroLine(false);
-
- // 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();
-
- // modify the legend ...
- // l.setPosition(LegendPosition.LEFT_OF_CHART);
- l.setForm(LegendForm.LINE);
-
- // // dont forget to refresh the drawing
- // mChart.invalidate();
- }
-
- @Override
- public void onWindowFocusChanged(boolean hasFocus) {
- super.onWindowFocusChanged(hasFocus);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.line, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
-
- switch (item.getItemId()) {
- case R.id.actionToggleValues: {
- List sets = mChart.getData()
- .getDataSets();
-
- for (ILineDataSet iSet : sets) {
-
- LineDataSet set = (LineDataSet) iSet;
- set.setDrawValues(!set.isDrawValuesEnabled());
- }
-
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleHighlight: {
- if(mChart.getData() != null) {
- mChart.getData().setHighlightEnabled(!mChart.getData().isHighlightEnabled());
- mChart.invalidate();
- }
- break;
- }
- case R.id.actionToggleFilled: {
-
- List sets = mChart.getData()
- .getDataSets();
-
- for (ILineDataSet iSet : sets) {
-
- LineDataSet set = (LineDataSet) iSet;
- if (set.isDrawFilledEnabled())
- set.setDrawFilled(false);
- else
- set.setDrawFilled(true);
- }
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleCircles: {
- List sets = mChart.getData()
- .getDataSets();
-
- for (ILineDataSet iSet : sets) {
-
- LineDataSet set = (LineDataSet) iSet;
- if (set.isDrawCirclesEnabled())
- set.setDrawCircles(false);
- else
- set.setDrawCircles(true);
- }
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleCubic: {
- List sets = mChart.getData()
- .getDataSets();
-
- for (ILineDataSet iSet : sets) {
-
- LineDataSet set = (LineDataSet) iSet;
- if (set.isDrawCubicEnabled())
- set.setDrawCubic(false);
- else
- set.setDrawCubic(true);
- }
- mChart.invalidate();
- break;
- }
- case R.id.actionTogglePinch: {
- if (mChart.isPinchZoomEnabled())
- mChart.setPinchZoom(false);
- else
- mChart.setPinchZoom(true);
-
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleAutoScaleMinMax: {
- mChart.setAutoScaleMinMaxEnabled(!mChart.isAutoScaleMinMaxEnabled());
- mChart.notifyDataSetChanged();
- break;
- }
- case R.id.animateX: {
- mChart.animateX(3000);
- break;
- }
- case R.id.animateY: {
- mChart.animateY(3000, Easing.EasingOption.EaseInCubic);
- break;
- }
- case R.id.animateXY: {
- mChart.animateXY(3000, 3000);
- break;
- }
- case R.id.actionSave: {
- if (mChart.saveToPath("title" + System.currentTimeMillis(), "")) {
- Toast.makeText(getApplicationContext(), "Saving SUCCESSFUL!",
- Toast.LENGTH_SHORT).show();
- } else
- Toast.makeText(getApplicationContext(), "Saving FAILED!", Toast.LENGTH_SHORT)
- .show();
-
- // mChart.saveToGallery("title"+System.currentTimeMillis())
- break;
- }
- }
- return true;
- }
-
- @Override
- public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
-
- tvX.setText("" + (mSeekBarX.getProgress() + 1));
- tvY.setText("" + (mSeekBarY.getProgress()));
-
- setData(mSeekBarX.getProgress() + 1, mSeekBarY.getProgress());
-
- // redraw
- mChart.invalidate();
- }
-
- @Override
- public void onStartTrackingTouch(SeekBar seekBar) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void onStopTrackingTouch(SeekBar seekBar) {
- // TODO Auto-generated method stub
-
- }
-
- private void setData(int count, float range) {
-
- ArrayList xVals = new ArrayList();
- for (int i = 0; i < count; i++) {
- xVals.add((i) + "");
- }
-
- ArrayList yVals = new ArrayList();
-
- for (int i = 0; i < count; i++) {
-
- float mult = (range + 1);
- float val = (float) (Math.random() * mult) + 3;// + (float)
- // ((mult *
- // 0.1) / 10);
- yVals.add(new Entry(val, i));
- }
-
- // create a dataset and give it a type
- LineDataSet set1 = new LineDataSet(yVals, "DataSet 1");
- // set1.setFillAlpha(110);
- // set1.setFillColor(Color.RED);
-
- // 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);
- set1.setCircleRadius(3f);
- set1.setDrawCircleHole(false);
- set1.setValueTextSize(9f);
- Drawable drawable = ContextCompat.getDrawable(this, R.drawable.fade_red);
- set1.setFillDrawable(drawable);
- set1.setDrawFilled(true);
-
- ArrayList dataSets = new ArrayList();
- dataSets.add(set1); // add the datasets
-
- // create a data object with the datasets
- LineData data = new LineData(xVals, dataSets);
-
- // set data
- mChart.setData(data);
- }
-
- @Override
- public void onChartGestureStart(MotionEvent me, ChartTouchListener.ChartGesture lastPerformedGesture) {
- Log.i("Gesture", "START, x: " + me.getX() + ", y: " + me.getY());
- }
-
- @Override
- public void onChartGestureEnd(MotionEvent me, ChartTouchListener.ChartGesture lastPerformedGesture) {
- Log.i("Gesture", "END, lastGesture: " + lastPerformedGesture);
-
- // un-highlight values after the gesture is finished and no single-tap
- if(lastPerformedGesture != ChartTouchListener.ChartGesture.SINGLE_TAP)
- mChart.highlightValues(null); // or highlightTouch(null) for callback to onNothingSelected(...)
- }
-
- @Override
- public void onChartLongPressed(MotionEvent me) {
- Log.i("LongPress", "Chart longpressed.");
- }
-
- @Override
- public void onChartDoubleTapped(MotionEvent me) {
- Log.i("DoubleTap", "Chart double-tapped.");
- }
-
- @Override
- public void onChartSingleTapped(MotionEvent me) {
- Log.i("SingleTap", "Chart single-tapped.");
- }
-
- @Override
- public void onChartFling(MotionEvent me1, MotionEvent me2, float velocityX, float velocityY) {
- Log.i("Fling", "Chart flinged. VeloX: " + velocityX + ", VeloY: " + velocityY);
- }
-
- @Override
- 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 onValueSelected(Entry e, int dataSetIndex, Highlight h) {
- Log.i("Entry selected", e.toString());
- Log.i("LOWHIGH", "low: " + mChart.getLowestVisibleXIndex() + ", high: " + mChart.getHighestVisibleXIndex());
- Log.i("MIN MAX", "xmin: " + mChart.getXChartMin() + ", xmax: " + mChart.getXChartMax() + ", ymin: " + mChart.getYChartMin() + ", ymax: " + mChart.getYChartMax());
- }
-
- @Override
- public void onNothingSelected() {
- Log.i("Nothing selected", "Nothing selected.");
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/LineChartActivity2.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/LineChartActivity2.java
deleted file mode 100644
index 7c4236f60c..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/LineChartActivity2.java
+++ /dev/null
@@ -1,351 +0,0 @@
-
-package com.xxmassdeveloper.mpchartexample;
-
-import android.graphics.Color;
-import android.graphics.Typeface;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.WindowManager;
-import android.widget.SeekBar;
-import android.widget.SeekBar.OnSeekBarChangeListener;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import com.github.mikephil.charting.charts.LineChart;
-import com.github.mikephil.charting.components.Legend;
-import com.github.mikephil.charting.components.Legend.LegendForm;
-import com.github.mikephil.charting.components.Legend.LegendPosition;
-import com.github.mikephil.charting.components.XAxis;
-import com.github.mikephil.charting.components.YAxis;
-import com.github.mikephil.charting.components.YAxis.AxisDependency;
-import com.github.mikephil.charting.data.Entry;
-import com.github.mikephil.charting.data.LineData;
-import com.github.mikephil.charting.data.LineDataSet;
-import com.github.mikephil.charting.highlight.Highlight;
-import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
-import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
-import com.github.mikephil.charting.utils.ColorTemplate;
-import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class LineChartActivity2 extends DemoBase implements OnSeekBarChangeListener,
- OnChartValueSelectedListener {
-
- private LineChart mChart;
- private SeekBar mSeekBarX, mSeekBarY;
- private TextView tvX, tvY;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.activity_linechart);
-
- tvX = (TextView) findViewById(R.id.tvXMax);
- tvY = (TextView) findViewById(R.id.tvYMax);
- mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
- mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
-
- mSeekBarX.setProgress(45);
- mSeekBarY.setProgress(100);
-
- mSeekBarY.setOnSeekBarChangeListener(this);
- mSeekBarX.setOnSeekBarChangeListener(this);
-
- mChart = (LineChart) findViewById(R.id.chart1);
- mChart.setOnChartValueSelectedListener(this);
-
- // no description text
- mChart.setDescription("");
- mChart.setNoDataTextDescription("You need to provide data for the chart.");
-
- // enable touch gestures
- mChart.setTouchEnabled(true);
-
- mChart.setDragDecelerationFrictionCoef(0.9f);
-
- // enable scaling and dragging
- mChart.setDragEnabled(true);
- mChart.setScaleEnabled(true);
- mChart.setDrawGridBackground(false);
- mChart.setHighlightPerDragEnabled(true);
-
- // if disabled, scaling can be done on x- and y-axis separately
- mChart.setPinchZoom(true);
-
- // set an alternative background color
- mChart.setBackgroundColor(Color.LTGRAY);
-
- // add data
- setData(20, 30);
-
- mChart.animateX(2500);
-
- Typeface tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
-
- // get the legend (only possible after setting data)
- Legend l = mChart.getLegend();
-
- // modify the legend ...
- // l.setPosition(LegendPosition.LEFT_OF_CHART);
- l.setForm(LegendForm.LINE);
- l.setTypeface(tf);
- l.setTextSize(11f);
- l.setTextColor(Color.WHITE);
- l.setPosition(LegendPosition.BELOW_CHART_LEFT);
-// l.setYOffset(11f);
-
- XAxis xAxis = mChart.getXAxis();
- xAxis.setTypeface(tf);
- xAxis.setTextSize(12f);
- xAxis.setTextColor(Color.WHITE);
- xAxis.setDrawGridLines(false);
- xAxis.setDrawAxisLine(false);
- xAxis.setSpaceBetweenLabels(1);
-
- YAxis leftAxis = mChart.getAxisLeft();
- leftAxis.setTypeface(tf);
- leftAxis.setTextColor(ColorTemplate.getHoloBlue());
- leftAxis.setAxisMaxValue(200f);
- leftAxis.setAxisMinValue(0f);
- leftAxis.setDrawGridLines(true);
-
- YAxis rightAxis = mChart.getAxisRight();
- rightAxis.setTypeface(tf);
- rightAxis.setTextColor(Color.RED);
- rightAxis.setAxisMaxValue(900);
- rightAxis.setAxisMinValue(-200);
- rightAxis.setDrawGridLines(false);
- rightAxis.setDrawZeroLine(false);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.line, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
-
- switch (item.getItemId()) {
- case R.id.actionToggleValues: {
- List sets = mChart.getData()
- .getDataSets();
-
- for (ILineDataSet iSet : sets) {
-
- LineDataSet set = (LineDataSet) iSet;
- set.setDrawValues(!set.isDrawValuesEnabled());
- }
-
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleHighlight: {
- if(mChart.getData() != null) {
- mChart.getData().setHighlightEnabled(!mChart.getData().isHighlightEnabled());
- mChart.invalidate();
- }
- break;
- }
- case R.id.actionToggleFilled: {
-
- List sets = mChart.getData()
- .getDataSets();
-
- for (ILineDataSet iSet : sets) {
-
- LineDataSet set = (LineDataSet) iSet;
- if (set.isDrawFilledEnabled())
- set.setDrawFilled(false);
- else
- set.setDrawFilled(true);
- }
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleCircles: {
- List sets = mChart.getData()
- .getDataSets();
-
- for (ILineDataSet iSet : sets) {
-
- LineDataSet set = (LineDataSet) iSet;
- if (set.isDrawCirclesEnabled())
- set.setDrawCircles(false);
- else
- set.setDrawCircles(true);
- }
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleCubic: {
- List sets = mChart.getData()
- .getDataSets();
-
- for (ILineDataSet iSet : sets) {
-
- LineDataSet set = (LineDataSet) iSet;
- if (set.isDrawCubicEnabled())
- set.setDrawCubic(false);
- else
- set.setDrawCubic(true);
- }
- mChart.invalidate();
- break;
- }
- case R.id.actionTogglePinch: {
- if (mChart.isPinchZoomEnabled())
- mChart.setPinchZoom(false);
- else
- mChart.setPinchZoom(true);
-
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleAutoScaleMinMax: {
- mChart.setAutoScaleMinMaxEnabled(!mChart.isAutoScaleMinMaxEnabled());
- mChart.notifyDataSetChanged();
- break;
- }
- case R.id.animateX: {
- mChart.animateX(3000);
- break;
- }
- case R.id.animateY: {
- mChart.animateY(3000);
- break;
- }
- case R.id.animateXY: {
- mChart.animateXY(3000, 3000);
- break;
- }
-
- case R.id.actionSave: {
- if (mChart.saveToPath("title" + System.currentTimeMillis(), "")) {
- Toast.makeText(getApplicationContext(), "Saving SUCCESSFUL!",
- Toast.LENGTH_SHORT).show();
- } else
- Toast.makeText(getApplicationContext(), "Saving FAILED!", Toast.LENGTH_SHORT)
- .show();
-
- // mChart.saveToGallery("title"+System.currentTimeMillis())
- break;
- }
- }
- return true;
- }
-
- @Override
- public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
-
- tvX.setText("" + (mSeekBarX.getProgress() + 1));
- tvY.setText("" + (mSeekBarY.getProgress()));
-
- setData(mSeekBarX.getProgress() + 1, mSeekBarY.getProgress());
-
- // redraw
- mChart.invalidate();
- }
-
- private void setData(int count, float range) {
-
- ArrayList xVals = new ArrayList();
- for (int i = 0; i < count; i++) {
- xVals.add((i) + "");
- }
-
- ArrayList yVals1 = new ArrayList();
-
- for (int i = 0; i < count; i++) {
- float mult = range / 2f;
- float val = (float) (Math.random() * mult) + 50;// + (float)
- // ((mult *
- // 0.1) / 10);
- yVals1.add(new Entry(val, i));
- }
-
- // create a dataset and give it a type
- LineDataSet set1 = new LineDataSet(yVals1, "DataSet 1");
- set1.setAxisDependency(AxisDependency.LEFT);
- set1.setColor(ColorTemplate.getHoloBlue());
- set1.setCircleColor(Color.WHITE);
- set1.setLineWidth(2f);
- set1.setCircleRadius(3f);
- set1.setFillAlpha(65);
- 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);
-
- ArrayList yVals2 = new ArrayList();
-
- for (int i = 0; i < count; i++) {
- float mult = range;
- float val = (float) (Math.random() * mult) + 450;// + (float)
- // ((mult *
- // 0.1) / 10);
- yVals2.add(new Entry(val, i));
- }
-
- // create a dataset and give it a type
- LineDataSet set2 = new LineDataSet(yVals2, "DataSet 2");
- set2.setAxisDependency(AxisDependency.RIGHT);
- set2.setColor(Color.RED);
- set2.setCircleColor(Color.WHITE);
- set2.setLineWidth(2f);
- set2.setCircleRadius(3f);
- set2.setFillAlpha(65);
- set2.setFillColor(Color.RED);
- set2.setDrawCircleHole(false);
- set2.setHighLightColor(Color.rgb(244, 117, 117));
- //set2.setFillFormatter(new MyFillFormatter(900f));
-
- ArrayList dataSets = new ArrayList();
- dataSets.add(set2);
- dataSets.add(set1); // add the datasets
-
- // create a data object with the datasets
- LineData data = new LineData(xVals, dataSets);
- data.setValueTextColor(Color.WHITE);
- data.setValueTextSize(9f);
-
- // set data
- mChart.setData(data);
- }
-
- @Override
- public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
- Log.i("Entry selected", e.toString());
-
- mChart.centerViewToAnimated(e.getXIndex(), e.getVal(), mChart.getData().getDataSetByIndex(dataSetIndex).getAxisDependency(), 500);
- //mChart.zoomAndCenterAnimated(2.5f, 2.5f, e.getXIndex(), e.getVal(), mChart.getData().getDataSetByIndex(dataSetIndex).getAxisDependency(), 1000);
- //mChart.zoomAndCenterAnimated(1.8f, 1.8f, e.getXIndex(), e.getVal(), mChart.getData().getDataSetByIndex(dataSetIndex).getAxisDependency(), 1000);
- }
-
- @Override
- public void onNothingSelected() {
- Log.i("Nothing selected", "Nothing selected.");
- }
-
- @Override
- public void onStartTrackingTouch(SeekBar seekBar) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void onStopTrackingTouch(SeekBar seekBar) {
- // TODO Auto-generated method stub
-
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/MultiLineChartActivity.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/MultiLineChartActivity.java
deleted file mode 100644
index 05e25fae64..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/MultiLineChartActivity.java
+++ /dev/null
@@ -1,250 +0,0 @@
-
-package com.xxmassdeveloper.mpchartexample;
-
-import android.os.Bundle;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.WindowManager;
-import android.widget.SeekBar;
-import android.widget.SeekBar.OnSeekBarChangeListener;
-import android.widget.TextView;
-
-import com.github.mikephil.charting.charts.LineChart;
-import com.github.mikephil.charting.components.Legend;
-import com.github.mikephil.charting.components.Legend.LegendPosition;
-import com.github.mikephil.charting.data.Entry;
-import com.github.mikephil.charting.data.LineData;
-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.interfaces.datasets.ILineDataSet;
-import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
-import com.github.mikephil.charting.utils.ColorTemplate;
-import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class MultiLineChartActivity extends DemoBase implements OnSeekBarChangeListener,
- OnChartValueSelectedListener {
-
- private LineChart mChart;
- private SeekBar mSeekBarX, mSeekBarY;
- private TextView tvX, tvY;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.activity_linechart);
-
- tvX = (TextView) findViewById(R.id.tvXMax);
- tvY = (TextView) findViewById(R.id.tvYMax);
-
- mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
- mSeekBarX.setOnSeekBarChangeListener(this);
-
- mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
- mSeekBarY.setOnSeekBarChangeListener(this);
-
- mChart = (LineChart) findViewById(R.id.chart1);
- mChart.setOnChartValueSelectedListener(this);
-
- mChart.setDrawGridBackground(false);
- mChart.setDescription("");
- 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 touch gestures
- mChart.setTouchEnabled(true);
-
- // enable scaling and dragging
- mChart.setDragEnabled(true);
- mChart.setScaleEnabled(true);
-
- // if disabled, scaling can be done on x- and y-axis separately
- mChart.setPinchZoom(false);
-
- mSeekBarX.setProgress(20);
- mSeekBarY.setProgress(100);
-
- Legend l = mChart.getLegend();
- l.setPosition(LegendPosition.RIGHT_OF_CHART);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.line, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
-
- switch (item.getItemId()) {
- case R.id.actionToggleValues: {
- List sets = mChart.getData()
- .getDataSets();
-
- for (ILineDataSet iSet : sets) {
-
- LineDataSet set = (LineDataSet) iSet;
- set.setDrawValues(!set.isDrawValuesEnabled());
- }
-
- mChart.invalidate();
- break;
- }
- case R.id.actionTogglePinch: {
- if (mChart.isPinchZoomEnabled())
- mChart.setPinchZoom(false);
- else
- mChart.setPinchZoom(true);
-
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleAutoScaleMinMax: {
- mChart.setAutoScaleMinMaxEnabled(!mChart.isAutoScaleMinMaxEnabled());
- mChart.notifyDataSetChanged();
- break;
- }
- case R.id.actionToggleHighlight: {
- if(mChart.getData() != null) {
- mChart.getData().setHighlightEnabled(!mChart.getData().isHighlightEnabled());
- mChart.invalidate();
- }
- break;
- }
- case R.id.actionToggleFilled: {
- List sets = mChart.getData()
- .getDataSets();
-
- for (ILineDataSet iSet : sets) {
-
- LineDataSet set = (LineDataSet) iSet;
- if (set.isDrawFilledEnabled())
- set.setDrawFilled(false);
- else
- set.setDrawFilled(true);
- }
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleCircles: {
- List sets = mChart.getData()
- .getDataSets();
-
- for (ILineDataSet iSet : sets) {
-
- LineDataSet set = (LineDataSet) iSet;
- if (set.isDrawCirclesEnabled())
- set.setDrawCircles(false);
- else
- set.setDrawCircles(true);
- }
- mChart.invalidate();
- break;
- }
- case R.id.actionSave: {
- // mChart.saveToGallery("title"+System.currentTimeMillis());
- mChart.saveToPath("title" + System.currentTimeMillis(), "");
- break;
- }
- case R.id.animateX: {
- mChart.animateX(3000);
- break;
- }
- case R.id.animateY: {
- mChart.animateY(3000);
- break;
- }
- case R.id.animateXY: {
-
- mChart.animateXY(3000, 3000);
- break;
- }
- }
- return true;
- }
-
- private int[] mColors = new int[] {
- ColorTemplate.VORDIPLOM_COLORS[0],
- ColorTemplate.VORDIPLOM_COLORS[1],
- ColorTemplate.VORDIPLOM_COLORS[2]
- };
-
- @Override
- public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
-
- mChart.resetTracking();
-
- tvX.setText("" + (mSeekBarX.getProgress()));
- tvY.setText("" + (mSeekBarY.getProgress()));
-
- ArrayList xVals = new ArrayList();
- for (int i = 0; i < mSeekBarX.getProgress(); i++) {
- xVals.add((i) + "");
- }
-
- ArrayList dataSets = new ArrayList();
-
- for (int z = 0; z < 3; z++) {
-
- ArrayList values = new ArrayList();
-
- for (int i = 0; i < mSeekBarX.getProgress(); i++) {
- double val = (Math.random() * mSeekBarY.getProgress()) + 3;
- values.add(new Entry((float) val, i));
- }
-
- LineDataSet d = new LineDataSet(values, "DataSet " + (z + 1));
- d.setLineWidth(2.5f);
- d.setCircleRadius(4f);
-
- int color = mColors[z % mColors.length];
- d.setColor(color);
- d.setCircleColor(color);
- dataSets.add(d);
- }
-
- // make the first DataSet dashed
- ((LineDataSet) dataSets.get(0)).enableDashedLine(10, 10, 0);
- ((LineDataSet) dataSets.get(0)).setColors(ColorTemplate.VORDIPLOM_COLORS);
- ((LineDataSet) dataSets.get(0)).setCircleColors(ColorTemplate.VORDIPLOM_COLORS);
-
- LineData data = new LineData(xVals, dataSets);
- mChart.setData(data);
- mChart.invalidate();
- }
-
- @Override
- public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
- Log.i("VAL SELECTED",
- "Value: " + e.getVal() + ", xIndex: " + e.getXIndex()
- + ", DataSet index: " + dataSetIndex);
- }
-
- @Override
- public void onNothingSelected() {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void onStartTrackingTouch(SeekBar seekBar) {
- }
-
- @Override
- public void onStopTrackingTouch(SeekBar seekBar) {
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/PerformanceLineChart.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/PerformanceLineChart.java
deleted file mode 100644
index 9a195cb4b4..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/PerformanceLineChart.java
+++ /dev/null
@@ -1,130 +0,0 @@
-
-package com.xxmassdeveloper.mpchartexample;
-
-import android.graphics.Color;
-import android.os.Bundle;
-import android.view.WindowManager;
-import android.widget.SeekBar;
-import android.widget.SeekBar.OnSeekBarChangeListener;
-import android.widget.TextView;
-
-import com.github.mikephil.charting.charts.LineChart;
-import com.github.mikephil.charting.components.Legend;
-import com.github.mikephil.charting.data.Entry;
-import com.github.mikephil.charting.data.LineData;
-import com.github.mikephil.charting.data.LineDataSet;
-import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
-
-import java.util.ArrayList;
-
-public class PerformanceLineChart extends DemoBase implements OnSeekBarChangeListener {
-
- private LineChart mChart;
- private SeekBar mSeekBarValues;
- private TextView mTvCount;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.activity_performance_linechart);
-
- mTvCount = (TextView) findViewById(R.id.tvValueCount);
- mSeekBarValues = (SeekBar) findViewById(R.id.seekbarValues);
- mTvCount.setText("500");
-
- mSeekBarValues.setProgress(500);
-
- mSeekBarValues.setOnSeekBarChangeListener(this);
-
- mChart = (LineChart) findViewById(R.id.chart1);
- mChart.setDrawGridBackground(false);
-
- // no description text
- mChart.setDescription("");
- mChart.setNoDataTextDescription("You need to provide data for the chart.");
-
- // enable touch gestures
- mChart.setTouchEnabled(true);
-
- // enable scaling and dragging
- mChart.setDragEnabled(true);
- mChart.setScaleEnabled(true);
-
- // if disabled, scaling can be done on x- and y-axis separately
- mChart.setPinchZoom(false);
-
- mChart.getAxisLeft().setDrawGridLines(false);
- mChart.getAxisRight().setEnabled(false);
- mChart.getXAxis().setDrawGridLines(true);
- mChart.getXAxis().setDrawAxisLine(false);
-
- // dont forget to refresh the drawing
- mChart.invalidate();
- }
-
- @Override
- public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
-
- int count = mSeekBarValues.getProgress() + 1000;
- mTvCount.setText("" + count);
-
- mChart.resetTracking();
-
- setData(count, 500f);
-
- // redraw
- mChart.invalidate();
- }
-
- @Override
- public void onStartTrackingTouch(SeekBar seekBar) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void onStopTrackingTouch(SeekBar seekBar) {
- // TODO Auto-generated method stub
-
- }
-
- private void setData(int count, float range) {
-
- ArrayList xVals = new ArrayList();
- for (int i = 0; i < count; i++) {
- xVals.add((i) + "");
- }
-
- ArrayList yVals = new ArrayList();
-
- for (int i = 0; i < count; i++) {
- float mult = (range + 1);
- float val = (float) (Math.random() * mult) + 3;// + (float)
- // ((mult *
- // 0.1) / 10);
- yVals.add(new Entry(val, i));
- }
-
- // create a dataset and give it a type
- LineDataSet set1 = new LineDataSet(yVals, "DataSet 1");
-
- set1.setColor(Color.BLACK);
- set1.setLineWidth(0.5f);
- set1.setDrawValues(false);
- set1.setDrawCircles(false);
- set1.setDrawCubic(false);
- set1.setDrawFilled(false);
-
- // create a data object with the datasets
- LineData data = new LineData(xVals, set1);
-
- // set data
- mChart.setData(data);
-
- // get the legend (only possible after setting data)
- Legend l = mChart.getLegend();
- l.setEnabled(false);
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/PieChartActivity.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/PieChartActivity.java
deleted file mode 100644
index bab7dcb525..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/PieChartActivity.java
+++ /dev/null
@@ -1,278 +0,0 @@
-
-package com.xxmassdeveloper.mpchartexample;
-
-import android.graphics.Color;
-import android.graphics.Typeface;
-import android.os.Bundle;
-import android.text.SpannableString;
-import android.text.style.ForegroundColorSpan;
-import android.text.style.RelativeSizeSpan;
-import android.text.style.StyleSpan;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.WindowManager;
-import android.widget.SeekBar;
-import android.widget.SeekBar.OnSeekBarChangeListener;
-import android.widget.TextView;
-
-import com.github.mikephil.charting.animation.Easing;
-import com.github.mikephil.charting.charts.PieChart;
-import com.github.mikephil.charting.components.Legend;
-import com.github.mikephil.charting.components.Legend.LegendPosition;
-import com.github.mikephil.charting.data.Entry;
-import com.github.mikephil.charting.data.PieData;
-import com.github.mikephil.charting.data.PieDataSet;
-import com.github.mikephil.charting.interfaces.datasets.IDataSet;
-import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
-import com.github.mikephil.charting.utils.ColorTemplate;
-import com.github.mikephil.charting.highlight.Highlight;
-import com.github.mikephil.charting.formatter.PercentFormatter;
-import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
-
-import java.util.ArrayList;
-
-public class PieChartActivity extends DemoBase implements OnSeekBarChangeListener,
- OnChartValueSelectedListener {
-
- private PieChart mChart;
- private SeekBar mSeekBarX, mSeekBarY;
- private TextView tvX, tvY;
-
- private Typeface tf;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.activity_piechart);
-
- tvX = (TextView) findViewById(R.id.tvXMax);
- tvY = (TextView) findViewById(R.id.tvYMax);
-
- mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
- mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
-
- mSeekBarY.setProgress(10);
-
- mSeekBarX.setOnSeekBarChangeListener(this);
- mSeekBarY.setOnSeekBarChangeListener(this);
-
- mChart = (PieChart) findViewById(R.id.chart1);
- mChart.setUsePercentValues(true);
- mChart.setDescription("");
- mChart.setExtraOffsets(5, 10, 5, 5);
-
- mChart.setDragDecelerationFrictionCoef(0.95f);
-
- tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
-
- mChart.setCenterTextTypeface(Typeface.createFromAsset(getAssets(), "OpenSans-Light.ttf"));
- mChart.setCenterText(generateCenterSpannableText());
-
- mChart.setDrawHoleEnabled(true);
- mChart.setHoleColor(Color.WHITE);
-
- mChart.setTransparentCircleColor(Color.WHITE);
- mChart.setTransparentCircleAlpha(110);
-
- mChart.setHoleRadius(58f);
- mChart.setTransparentCircleRadius(61f);
-
- mChart.setDrawCenterText(true);
-
- mChart.setRotationAngle(0);
- // enable rotation of the chart by touch
- mChart.setRotationEnabled(true);
- mChart.setHighlightPerTapEnabled(true);
-
- // mChart.setUnit(" €");
- // mChart.setDrawUnitsInChart(true);
-
- // add a selection listener
- mChart.setOnChartValueSelectedListener(this);
-
- setData(3, 100);
-
- mChart.animateY(1400, Easing.EasingOption.EaseInOutQuad);
- // mChart.spin(2000, 0, 360);
-
- Legend l = mChart.getLegend();
- l.setPosition(LegendPosition.RIGHT_OF_CHART);
- l.setXEntrySpace(7f);
- l.setYEntrySpace(0f);
- l.setYOffset(0f);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.pie, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
-
- switch (item.getItemId()) {
- case R.id.actionToggleValues: {
- for (IDataSet> set : mChart.getData().getDataSets())
- set.setDrawValues(!set.isDrawValuesEnabled());
-
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleHole: {
- if (mChart.isDrawHoleEnabled())
- mChart.setDrawHoleEnabled(false);
- else
- mChart.setDrawHoleEnabled(true);
- mChart.invalidate();
- break;
- }
- case R.id.actionDrawCenter: {
- if (mChart.isDrawCenterTextEnabled())
- mChart.setDrawCenterText(false);
- else
- mChart.setDrawCenterText(true);
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleXVals: {
-
- mChart.setDrawSliceText(!mChart.isDrawSliceTextEnabled());
- mChart.invalidate();
- break;
- }
- case R.id.actionSave: {
- // mChart.saveToGallery("title"+System.currentTimeMillis());
- mChart.saveToPath("title" + System.currentTimeMillis(), "");
- break;
- }
- case R.id.actionTogglePercent:
- mChart.setUsePercentValues(!mChart.isUsePercentValuesEnabled());
- mChart.invalidate();
- break;
- case R.id.animateX: {
- mChart.animateX(1400);
- break;
- }
- case R.id.animateY: {
- mChart.animateY(1400);
- break;
- }
- case R.id.animateXY: {
- mChart.animateXY(1400, 1400);
- break;
- }
- }
- return true;
- }
-
- @Override
- public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
-
- tvX.setText("" + (mSeekBarX.getProgress() + 1));
- tvY.setText("" + (mSeekBarY.getProgress()));
-
- setData(mSeekBarX.getProgress(), mSeekBarY.getProgress());
- }
-
- private void setData(int count, float range) {
-
- float mult = range;
-
- ArrayList yVals1 = new ArrayList();
-
- // IMPORTANT: In a PieChart, no values (Entry) should have the same
- // xIndex (even if from different DataSets), since no values can be
- // drawn above each other.
- for (int i = 0; i < count + 1; i++) {
- yVals1.add(new Entry((float) (Math.random() * mult) + mult / 5, i));
- }
-
- ArrayList xVals = new ArrayList();
-
- for (int i = 0; i < count + 1; i++)
- xVals.add(mParties[i % mParties.length]);
-
- PieDataSet dataSet = new PieDataSet(yVals1, "Election Results");
- dataSet.setSliceSpace(3f);
- dataSet.setSelectionShift(5f);
-
- // add a lot of colors
-
- ArrayList colors = new ArrayList();
-
- for (int c : ColorTemplate.VORDIPLOM_COLORS)
- colors.add(c);
-
- for (int c : ColorTemplate.JOYFUL_COLORS)
- colors.add(c);
-
- for (int c : ColorTemplate.COLORFUL_COLORS)
- colors.add(c);
-
- for (int c : ColorTemplate.LIBERTY_COLORS)
- colors.add(c);
-
- for (int c : ColorTemplate.PASTEL_COLORS)
- colors.add(c);
-
- colors.add(ColorTemplate.getHoloBlue());
-
- dataSet.setColors(colors);
- //dataSet.setSelectionShift(0f);
-
- PieData data = new PieData(xVals, dataSet);
- data.setValueFormatter(new PercentFormatter());
- data.setValueTextSize(11f);
- data.setValueTextColor(Color.WHITE);
- data.setValueTypeface(tf);
- mChart.setData(data);
-
- // undo all highlights
- mChart.highlightValues(null);
-
- mChart.invalidate();
- }
-
- private SpannableString generateCenterSpannableText() {
-
- SpannableString s = new SpannableString("MPAndroidChart\ndeveloped by Philipp Jahoda");
- s.setSpan(new RelativeSizeSpan(1.7f), 0, 14, 0);
- s.setSpan(new StyleSpan(Typeface.NORMAL), 14, s.length() - 15, 0);
- s.setSpan(new ForegroundColorSpan(Color.GRAY), 14, s.length() - 15, 0);
- s.setSpan(new RelativeSizeSpan(.8f), 14, s.length() - 15, 0);
- s.setSpan(new StyleSpan(Typeface.ITALIC), s.length() - 14, s.length(), 0);
- s.setSpan(new ForegroundColorSpan(ColorTemplate.getHoloBlue()), s.length() - 14, s.length(), 0);
- return s;
- }
-
- @Override
- public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
-
- if (e == null)
- return;
- Log.i("VAL SELECTED",
- "Value: " + e.getVal() + ", xIndex: " + e.getXIndex()
- + ", DataSet index: " + dataSetIndex);
- }
-
- @Override
- public void onNothingSelected() {
- Log.i("PieChart", "nothing selected");
- }
-
- @Override
- public void onStartTrackingTouch(SeekBar seekBar) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void onStopTrackingTouch(SeekBar seekBar) {
- // TODO Auto-generated method stub
-
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/RadarChartActivitry.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/RadarChartActivitry.java
deleted file mode 100644
index dbbdc695c8..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/RadarChartActivitry.java
+++ /dev/null
@@ -1,222 +0,0 @@
-
-package com.xxmassdeveloper.mpchartexample;
-
-import android.graphics.Typeface;
-import android.os.Bundle;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.WindowManager;
-import android.widget.Toast;
-
-import com.github.mikephil.charting.animation.Easing;
-import com.github.mikephil.charting.charts.RadarChart;
-import com.github.mikephil.charting.components.Legend;
-import com.github.mikephil.charting.components.Legend.LegendPosition;
-import com.github.mikephil.charting.components.XAxis;
-import com.github.mikephil.charting.components.YAxis;
-import com.github.mikephil.charting.data.Entry;
-import com.github.mikephil.charting.data.RadarData;
-import com.github.mikephil.charting.data.RadarDataSet;
-import com.github.mikephil.charting.interfaces.datasets.IDataSet;
-import com.github.mikephil.charting.interfaces.datasets.IRadarDataSet;
-import com.github.mikephil.charting.utils.ColorTemplate;
-import com.xxmassdeveloper.mpchartexample.custom.MyMarkerView;
-import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
-
-import java.util.ArrayList;
-
-public class RadarChartActivitry extends DemoBase {
-
- private RadarChart mChart;
- private Typeface tf;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.activity_radarchart);
-
- mChart = (RadarChart) findViewById(R.id.chart1);
-
- tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
-
- mChart.setDescription("");
-
- mChart.setWebLineWidth(1.5f);
- mChart.setWebLineWidthInner(0.75f);
- mChart.setWebAlpha(100);
-
- // create a custom MarkerView (extend MarkerView) and specify the layout
- // to use for it
- MyMarkerView mv = new MyMarkerView(this, R.layout.custom_marker_view);
-
- // set the marker to the chart
- mChart.setMarkerView(mv);
-
- setData();
-
- mChart.animateXY(
- 1400, 1400,
- Easing.EasingOption.EaseInOutQuad,
- Easing.EasingOption.EaseInOutQuad);
-
- XAxis xAxis = mChart.getXAxis();
- xAxis.setTypeface(tf);
- xAxis.setTextSize(9f);
-
- YAxis yAxis = mChart.getYAxis();
- yAxis.setTypeface(tf);
- yAxis.setLabelCount(5, false);
- yAxis.setTextSize(9f);
- yAxis.setAxisMinValue(0f);
-
- Legend l = mChart.getLegend();
- l.setPosition(LegendPosition.RIGHT_OF_CHART);
- l.setTypeface(tf);
- l.setXEntrySpace(7f);
- l.setYEntrySpace(5f);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.radar, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
-
- switch (item.getItemId()) {
- case R.id.actionToggleValues: {
- for (IDataSet> set : mChart.getData().getDataSets())
- set.setDrawValues(!set.isDrawValuesEnabled());
-
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleHighlight: {
- if (mChart.getData() != null) {
- mChart.getData().setHighlightEnabled(!mChart.getData().isHighlightEnabled());
- mChart.invalidate();
- }
- break;
- }
- case R.id.actionToggleRotate: {
- if (mChart.isRotationEnabled())
- mChart.setRotationEnabled(false);
- else
- mChart.setRotationEnabled(true);
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleFilled: {
-
- ArrayList sets = (ArrayList) mChart.getData()
- .getDataSets();
-
- for (IRadarDataSet set : sets) {
- if (set.isDrawFilledEnabled())
- set.setDrawFilled(false);
- else
- set.setDrawFilled(true);
- }
- mChart.invalidate();
- break;
- }
- case R.id.actionSave: {
- if (mChart.saveToPath("title" + System.currentTimeMillis(), "")) {
- Toast.makeText(getApplicationContext(), "Saving SUCCESSFUL!",
- Toast.LENGTH_SHORT).show();
- } else
- Toast.makeText(getApplicationContext(), "Saving FAILED!", Toast.LENGTH_SHORT)
- .show();
- break;
- }
- case R.id.actionToggleXLabels: {
- mChart.getXAxis().setEnabled(!mChart.getXAxis().isEnabled());
- mChart.notifyDataSetChanged();
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleYLabels: {
-
- mChart.getYAxis().setEnabled(!mChart.getYAxis().isEnabled());
- mChart.invalidate();
- break;
- }
- case R.id.animateX: {
- mChart.animateX(1400);
- break;
- }
- case R.id.animateY: {
- mChart.animateY(1400);
- break;
- }
- case R.id.animateXY: {
- mChart.animateXY(1400, 1400);
- break;
- }
- case R.id.actionToggleSpin: {
- mChart.spin(2000, mChart.getRotationAngle(), mChart.getRotationAngle() + 360, Easing.EasingOption.EaseInCubic);
- break;
- }
- }
- return true;
- }
-
- private String[] mParties = new String[]{
- "Party A", "Party B", "Party C", "Party D", "Party E", "Party F", "Party G", "Party H",
- "Party I"
- };
-
- public void setData() {
-
- float mult = 150;
- int cnt = 9;
-
- ArrayList yVals1 = new ArrayList();
- ArrayList yVals2 = new ArrayList();
-
- // IMPORTANT: In a PieChart, no values (Entry) should have the same
- // xIndex (even if from different DataSets), since no values can be
- // drawn above each other.
- for (int i = 0; i < cnt; i++) {
- yVals1.add(new Entry((float) (Math.random() * mult) + mult / 2, i));
- }
-
- for (int i = 0; i < cnt; i++) {
- yVals2.add(new Entry((float) (Math.random() * mult) + mult / 2, i));
- }
-
- ArrayList xVals = new ArrayList();
-
- for (int i = 0; i < cnt; i++)
- xVals.add(mParties[i % mParties.length]);
-
- RadarDataSet set1 = new RadarDataSet(yVals1, "Set 1");
- set1.setColor(ColorTemplate.VORDIPLOM_COLORS[0]);
- set1.setFillColor(ColorTemplate.VORDIPLOM_COLORS[0]);
- set1.setDrawFilled(true);
- set1.setLineWidth(2f);
-
- RadarDataSet set2 = new RadarDataSet(yVals2, "Set 2");
- set2.setColor(ColorTemplate.VORDIPLOM_COLORS[4]);
- set2.setFillColor(ColorTemplate.VORDIPLOM_COLORS[4]);
- set2.setDrawFilled(true);
- set2.setLineWidth(2f);
-
- ArrayList sets = new ArrayList();
- sets.add(set1);
- sets.add(set2);
-
- RadarData data = new RadarData(xVals, sets);
- data.setValueTypeface(tf);
- data.setValueTextSize(8f);
- data.setDrawValues(false);
-
- mChart.setData(data);
-
- mChart.invalidate();
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/ScatterChartActivity.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/ScatterChartActivity.java
deleted file mode 100644
index e716f7ff47..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/ScatterChartActivity.java
+++ /dev/null
@@ -1,246 +0,0 @@
-
-package com.xxmassdeveloper.mpchartexample;
-
-import android.graphics.Color;
-import android.graphics.Typeface;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.WindowManager;
-import android.widget.SeekBar;
-import android.widget.SeekBar.OnSeekBarChangeListener;
-import android.widget.TextView;
-
-import com.github.mikephil.charting.charts.ScatterChart;
-import com.github.mikephil.charting.charts.ScatterChart.ScatterShape;
-import com.github.mikephil.charting.components.Legend;
-import com.github.mikephil.charting.components.Legend.LegendPosition;
-import com.github.mikephil.charting.components.XAxis;
-import com.github.mikephil.charting.components.YAxis;
-import com.github.mikephil.charting.data.Entry;
-import com.github.mikephil.charting.data.ScatterData;
-import com.github.mikephil.charting.data.ScatterDataSet;
-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.interfaces.datasets.IScatterDataSet;
-import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
-import com.github.mikephil.charting.utils.ColorTemplate;
-import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class ScatterChartActivity extends DemoBase implements OnSeekBarChangeListener,
- OnChartValueSelectedListener {
-
- private ScatterChart mChart;
- private SeekBar mSeekBarX, mSeekBarY;
- private TextView tvX, tvY;
-
- private Typeface tf;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.activity_scatterchart);
-
- tvX = (TextView) findViewById(R.id.tvXMax);
- tvY = (TextView) findViewById(R.id.tvYMax);
-
- mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
- mSeekBarX.setOnSeekBarChangeListener(this);
-
- mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
- mSeekBarY.setOnSeekBarChangeListener(this);
-
- mChart = (ScatterChart) findViewById(R.id.chart1);
- mChart.setDescription("");
-
- tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
-
- mChart.setOnChartValueSelectedListener(this);
-
- mChart.setDrawGridBackground(false);
-
- mChart.setTouchEnabled(true);
-
- // enable scaling and dragging
- mChart.setDragEnabled(true);
- mChart.setScaleEnabled(true);
-
- mChart.setMaxVisibleValueCount(200);
- mChart.setPinchZoom(true);
-
- mSeekBarX.setProgress(45);
- mSeekBarY.setProgress(100);
-
- Legend l = mChart.getLegend();
- l.setPosition(LegendPosition.RIGHT_OF_CHART);
- l.setTypeface(tf);
-
- YAxis yl = mChart.getAxisLeft();
- yl.setTypeface(tf);
- yl.setAxisMinValue(0f); // this replaces setStartAtZero(true)
-
- mChart.getAxisRight().setEnabled(false);
-
- XAxis xl = mChart.getXAxis();
- xl.setTypeface(tf);
- xl.setDrawGridLines(false);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.scatter, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
-
- switch (item.getItemId()) {
- case R.id.actionToggleValues: {
- List sets = mChart.getData()
- .getDataSets();
-
- for (IScatterDataSet iSet : sets) {
-
- ScatterDataSet set = (ScatterDataSet) iSet;
- set.setDrawValues(!set.isDrawValuesEnabled());
- }
-
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleHighlight: {
- if(mChart.getData() != null) {
- mChart.getData().setHighlightEnabled(!mChart.getData().isHighlightEnabled());
- mChart.invalidate();
- }
- break;
- }
- case R.id.actionTogglePinch: {
- if (mChart.isPinchZoomEnabled())
- mChart.setPinchZoom(false);
- else
- mChart.setPinchZoom(true);
-
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleAutoScaleMinMax: {
- mChart.setAutoScaleMinMaxEnabled(!mChart.isAutoScaleMinMaxEnabled());
- mChart.notifyDataSetChanged();
- break;
- }
- case R.id.actionSave: {
- // mChart.saveToGallery("title"+System.currentTimeMillis());
- mChart.saveToPath("title" + System.currentTimeMillis(), "");
- break;
- }
- case R.id.animateX: {
- mChart.animateX(3000);
- break;
- }
- case R.id.animateY: {
- mChart.animateY(3000);
- break;
- }
- case R.id.animateXY: {
-
- mChart.animateXY(3000, 3000);
- break;
- }
- }
- return true;
- }
-
- @Override
- public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
-
- tvX.setText("" + (mSeekBarX.getProgress() + 1));
- tvY.setText("" + (mSeekBarY.getProgress()));
-
- ArrayList xVals = new ArrayList();
- for (int i = 0; i < mSeekBarX.getProgress() + 1; i++) {
- xVals.add((i) + "");
- }
-
- ArrayList yVals1 = new ArrayList();
- ArrayList yVals2 = new ArrayList();
- ArrayList yVals3 = new ArrayList();
-
- for (int i = 0; i < mSeekBarX.getProgress(); i++) {
- float val = (float) (Math.random() * mSeekBarY.getProgress()) + 3;
- yVals1.add(new Entry(val, i));
- }
-
- for (int i = 0; i < mSeekBarX.getProgress(); i++) {
- float val = (float) (Math.random() * mSeekBarY.getProgress()) + 3;
- yVals2.add(new Entry(val, i));
- }
-
- for (int i = 0; i < mSeekBarX.getProgress(); i++) {
- float val = (float) (Math.random() * mSeekBarY.getProgress()) + 3;
- yVals3.add(new Entry(val, i));
- }
-
- // create a dataset and give it a type
- ScatterDataSet set1 = new ScatterDataSet(yVals1, "DS 1");
- set1.setScatterShape(ScatterShape.SQUARE);
- set1.setColor(ColorTemplate.COLORFUL_COLORS[0]);
- ScatterDataSet set2 = new ScatterDataSet(yVals2, "DS 2");
- set2.setScatterShape(ScatterShape.CIRCLE);
- set2.setScatterShapeHoleColor(Color.WHITE);
- set2.setScatterShapeHoleRadius(5f);
- set2.setColor(ColorTemplate.COLORFUL_COLORS[1]);
- ScatterDataSet set3 = new ScatterDataSet(yVals3, "DS 3");
- set3.setScatterShape(ScatterShape.CROSS);
- set3.setColor(ColorTemplate.COLORFUL_COLORS[2]);
-
- set1.setScatterShapeSize(8f);
- set2.setScatterShapeSize(8f);
- set3.setScatterShapeSize(8f);
-
- ArrayList dataSets = new ArrayList();
- dataSets.add(set1); // add the datasets
- dataSets.add(set2);
- dataSets.add(set3);
-
- // create a data object with the datasets
- ScatterData data = new ScatterData(xVals, dataSets);
- data.setValueTypeface(tf);
-
- mChart.setData(data);
- mChart.invalidate();
- }
-
- @Override
- public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
- Log.i("VAL SELECTED",
- "Value: " + e.getVal() + ", xIndex: " + e.getXIndex()
- + ", DataSet index: " + dataSetIndex);
- }
-
- @Override
- public void onNothingSelected() {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void onStartTrackingTouch(SeekBar seekBar) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void onStopTrackingTouch(SeekBar seekBar) {
- // TODO Auto-generated method stub
-
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/ScrollViewActivity.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/ScrollViewActivity.java
deleted file mode 100644
index 61244bad2e..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/ScrollViewActivity.java
+++ /dev/null
@@ -1,72 +0,0 @@
-
-package com.xxmassdeveloper.mpchartexample;
-
-import android.os.Bundle;
-import android.view.WindowManager;
-
-import com.github.mikephil.charting.charts.BarChart;
-import com.github.mikephil.charting.components.XAxis;
-import com.github.mikephil.charting.components.XAxis.XAxisPosition;
-import com.github.mikephil.charting.data.BarData;
-import com.github.mikephil.charting.data.BarDataSet;
-import com.github.mikephil.charting.data.BarEntry;
-import com.github.mikephil.charting.utils.ColorTemplate;
-import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
-
-import java.util.ArrayList;
-
-public class ScrollViewActivity extends DemoBase {
-
- private BarChart mChart;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.activity_scrollview);
-
- mChart = (BarChart) findViewById(R.id.chart1);
-
- mChart.setDescription("");
-
- // scaling can now only be done on x- and y-axis separately
- mChart.setPinchZoom(false);
-
- mChart.setDrawBarShadow(false);
- mChart.setDrawGridBackground(false);
-
- XAxis xAxis = mChart.getXAxis();
- xAxis.setPosition(XAxisPosition.BOTTOM);
- xAxis.setLabelsToSkip(0);
- xAxis.setDrawGridLines(false);
-
- mChart.getAxisLeft().setDrawGridLines(false);
-
- mChart.getLegend().setEnabled(false);
-
- setData(10);
- }
-
- private void setData(int count) {
-
- ArrayList yVals = new ArrayList();
- ArrayList xVals = new ArrayList();
-
- for (int i = 0; i < count; i++) {
- float val = (float) (Math.random() * count) + 15;
- yVals.add(new BarEntry((int) val, i));
- xVals.add((int) val + "");
- }
-
- BarDataSet set = new BarDataSet(yVals, "Data Set");
- set.setColors(ColorTemplate.VORDIPLOM_COLORS);
- set.setDrawValues(false);
-
- BarData data = new BarData(xVals, set);
-
- mChart.setData(data);
- mChart.invalidate();
- mChart.animateY(800);
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/StackedBarActivity.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/StackedBarActivity.java
deleted file mode 100644
index 77c6d1f23f..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/StackedBarActivity.java
+++ /dev/null
@@ -1,253 +0,0 @@
-package com.xxmassdeveloper.mpchartexample;
-
-import android.os.Bundle;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.WindowManager;
-import android.widget.SeekBar;
-import android.widget.SeekBar.OnSeekBarChangeListener;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import com.github.mikephil.charting.charts.BarChart;
-import com.github.mikephil.charting.components.Legend;
-import com.github.mikephil.charting.components.Legend.LegendPosition;
-import com.github.mikephil.charting.components.XAxis;
-import com.github.mikephil.charting.components.XAxis.XAxisPosition;
-import com.github.mikephil.charting.components.YAxis;
-import com.github.mikephil.charting.data.BarData;
-import com.github.mikephil.charting.data.BarDataSet;
-import com.github.mikephil.charting.data.BarEntry;
-import com.github.mikephil.charting.data.Entry;
-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.interfaces.datasets.IBarDataSet;
-import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
-import com.github.mikephil.charting.utils.ColorTemplate;
-import com.xxmassdeveloper.mpchartexample.custom.MyValueFormatter;
-import com.xxmassdeveloper.mpchartexample.custom.MyYAxisValueFormatter;
-import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class StackedBarActivity extends DemoBase implements OnSeekBarChangeListener, OnChartValueSelectedListener {
-
- private BarChart mChart;
- private SeekBar mSeekBarX, mSeekBarY;
- private TextView tvX, tvY;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.activity_barchart);
-
- tvX = (TextView) findViewById(R.id.tvXMax);
- tvY = (TextView) findViewById(R.id.tvYMax);
-
- mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
- mSeekBarX.setOnSeekBarChangeListener(this);
-
- mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
- mSeekBarY.setOnSeekBarChangeListener(this);
-
- mChart = (BarChart) findViewById(R.id.chart1);
- mChart.setOnChartValueSelectedListener(this);
-
- mChart.setDescription("");
-
- // if more than 60 entries are displayed in the chart, no values will be
- // drawn
- mChart.setMaxVisibleValueCount(60);
-
- // scaling can now only be done on x- and y-axis separately
- mChart.setPinchZoom(false);
-
- mChart.setDrawGridBackground(false);
- mChart.setDrawBarShadow(false);
-
- mChart.setDrawValueAboveBar(false);
-
- // change the position of the y-labels
- YAxis leftAxis = mChart.getAxisLeft();
- leftAxis.setValueFormatter(new MyYAxisValueFormatter());
- leftAxis.setAxisMinValue(0f); // this replaces setStartAtZero(true)
- mChart.getAxisRight().setEnabled(false);
-
- XAxis xLabels = mChart.getXAxis();
- xLabels.setPosition(XAxisPosition.TOP);
-
- // mChart.setDrawXLabels(false);
- // mChart.setDrawYLabels(false);
-
- // setting data
- mSeekBarX.setProgress(12);
- mSeekBarY.setProgress(100);
-
- Legend l = mChart.getLegend();
- l.setPosition(LegendPosition.BELOW_CHART_RIGHT);
- l.setFormSize(8f);
- l.setFormToTextSpace(4f);
- l.setXEntrySpace(6f);
-
- // mChart.setDrawLegend(false);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.bar, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
-
- switch (item.getItemId()) {
- case R.id.actionToggleValues: {
- List sets = mChart.getData()
- .getDataSets();
-
- for (IBarDataSet iSet : sets) {
-
- BarDataSet set = (BarDataSet) iSet;
- set.setDrawValues(!set.isDrawValuesEnabled());
- }
-
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleHighlight: {
- if(mChart.getData() != null) {
- mChart.getData().setHighlightEnabled(!mChart.getData().isHighlightEnabled());
- mChart.invalidate();
- }
- break;
- }
- case R.id.actionTogglePinch: {
- if (mChart.isPinchZoomEnabled())
- mChart.setPinchZoom(false);
- else
- mChart.setPinchZoom(true);
-
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleAutoScaleMinMax: {
- mChart.setAutoScaleMinMaxEnabled(!mChart.isAutoScaleMinMaxEnabled());
- mChart.notifyDataSetChanged();
- break;
- }
- case R.id.actionToggleHighlightArrow: {
- if (mChart.isDrawHighlightArrowEnabled())
- mChart.setDrawHighlightArrow(false);
- else
- mChart.setDrawHighlightArrow(true);
- mChart.invalidate();
- break;
- }
- case R.id.animateX: {
- mChart.animateX(3000);
- break;
- }
- case R.id.animateY: {
- mChart.animateY(3000);
- break;
- }
- case R.id.animateXY: {
-
- mChart.animateXY(3000, 3000);
- break;
- }
- case R.id.actionSave: {
- if (mChart.saveToGallery("title" + System.currentTimeMillis(), 50)) {
- Toast.makeText(getApplicationContext(), "Saving SUCCESSFUL!", Toast.LENGTH_SHORT).show();
- } else
- Toast.makeText(getApplicationContext(), "Saving FAILED!", Toast.LENGTH_SHORT).show();
- break;
- }
- }
- return true;
- }
-
- @Override
- public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
-
- tvX.setText("" + (mSeekBarX.getProgress() + 1));
- tvY.setText("" + (mSeekBarY.getProgress()));
-
- ArrayList xVals = new ArrayList();
- for (int i = 0; i < mSeekBarX.getProgress() + 1; i++) {
- xVals.add(mMonths[i % mMonths.length]);
- }
-
- ArrayList yVals1 = new ArrayList();
-
- for (int i = 0; i < mSeekBarX.getProgress() + 1; i++) {
- float mult = (mSeekBarY.getProgress() + 1);
- float val1 = (float) (Math.random() * mult) + mult / 3;
- float val2 = (float) (Math.random() * mult) + mult / 3;
- float val3 = (float) (Math.random() * mult) + mult / 3;
-
- yVals1.add(new BarEntry(new float[] { val1, val2, val3 }, i));
- }
-
- BarDataSet set1 = new BarDataSet(yVals1, "Statistics Vienna 2014");
- set1.setColors(getColors());
- set1.setStackLabels(new String[] { "Births", "Divorces", "Marriages" });
-
- ArrayList dataSets = new ArrayList();
- dataSets.add(set1);
-
- BarData data = new BarData(xVals, dataSets);
- data.setValueFormatter(new MyValueFormatter());
-
- mChart.setData(data);
- mChart.invalidate();
- }
-
- @Override
- public void onStartTrackingTouch(SeekBar seekBar) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void onStopTrackingTouch(SeekBar seekBar) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
-
- BarEntry entry = (BarEntry) e;
-
- if (entry.getVals() != null)
- Log.i("VAL SELECTED", "Value: " + entry.getVals()[h.getStackIndex()]);
- else
- Log.i("VAL SELECTED", "Value: " + entry.getVal());
- }
-
- @Override
- public void onNothingSelected() {
- // TODO Auto-generated method stub
-
- }
-
- private int[] getColors() {
-
- int stacksize = 3;
-
- // have as many colors as stack-values per entry
- int[] colors = new int[stacksize];
-
- for (int i = 0; i < stacksize; i++) {
- colors[i] = ColorTemplate.VORDIPLOM_COLORS[i];
- }
-
- return colors;
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/StackedBarActivityNegative.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/StackedBarActivityNegative.java
deleted file mode 100644
index d25ee39f2b..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/StackedBarActivityNegative.java
+++ /dev/null
@@ -1,225 +0,0 @@
-
-package com.xxmassdeveloper.mpchartexample;
-
-import android.graphics.Color;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.WindowManager;
-import android.widget.Toast;
-
-import com.github.mikephil.charting.charts.HorizontalBarChart;
-import com.github.mikephil.charting.components.Legend;
-import com.github.mikephil.charting.components.Legend.LegendPosition;
-import com.github.mikephil.charting.components.XAxis;
-import com.github.mikephil.charting.components.XAxis.XAxisPosition;
-import com.github.mikephil.charting.components.YAxis;
-import com.github.mikephil.charting.data.BarData;
-import com.github.mikephil.charting.data.BarDataSet;
-import com.github.mikephil.charting.data.BarEntry;
-import com.github.mikephil.charting.data.Entry;
-import com.github.mikephil.charting.data.filter.Approximator;
-import com.github.mikephil.charting.data.filter.Approximator.ApproximatorType;
-import com.github.mikephil.charting.interfaces.datasets.IBarDataSet;
-import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
-import com.github.mikephil.charting.highlight.Highlight;
-import com.github.mikephil.charting.formatter.ValueFormatter;
-import com.github.mikephil.charting.utils.ViewPortHandler;
-import com.github.mikephil.charting.formatter.YAxisValueFormatter;
-import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
-
-import java.text.DecimalFormat;
-import java.util.ArrayList;
-import java.util.List;
-
-public class StackedBarActivityNegative extends DemoBase implements
- OnChartValueSelectedListener {
-
- private HorizontalBarChart mChart;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.activity_age_distribution);
-
- setTitle("Age Distribution Austria");
-
- mChart = (HorizontalBarChart) findViewById(R.id.chart1);
- mChart.setOnChartValueSelectedListener(this);
- mChart.setDrawGridBackground(false);
- mChart.setDescription("");
-
- // scaling can now only be done on x- and y-axis separately
- mChart.setPinchZoom(false);
-
- mChart.setDrawBarShadow(false);
- mChart.setDrawValueAboveBar(true);
-
- mChart.getAxisLeft().setEnabled(false);
- mChart.getAxisRight().setAxisMaxValue(25f);
- mChart.getAxisRight().setAxisMinValue(-25f);
- mChart.getAxisRight().setDrawGridLines(false);
- mChart.getAxisRight().setDrawZeroLine(true);
- mChart.getAxisRight().setLabelCount(7, false);
- mChart.getAxisRight().setValueFormatter(new CustomFormatter());
- mChart.getAxisRight().setTextSize(9f);
-
- XAxis xAxis = mChart.getXAxis();
- xAxis.setPosition(XAxisPosition.BOTH_SIDED);
- xAxis.setDrawGridLines(false);
- xAxis.setDrawAxisLine(false);
- xAxis.setTextSize(9f);
-
- Legend l = mChart.getLegend();
- l.setPosition(LegendPosition.BELOW_CHART_RIGHT);
- l.setFormSize(8f);
- l.setFormToTextSpace(4f);
- l.setXEntrySpace(6f);
-
- // IMPORTANT: When using negative values in stacked bars, always make sure the negative values are in the array first
- ArrayList yValues = new ArrayList();
- yValues.add(new BarEntry(new float[]{ -10, 10 }, 0));
- yValues.add(new BarEntry(new float[]{ -12, 13 }, 1));
- yValues.add(new BarEntry(new float[]{ -15, 15 }, 2));
- yValues.add(new BarEntry(new float[]{ -17, 17 }, 3));
- yValues.add(new BarEntry(new float[]{ -19, 20 }, 4));
- yValues.add(new BarEntry(new float[]{ -19, 19 }, 5));
- yValues.add(new BarEntry(new float[]{ -16, 16 }, 6));
- yValues.add(new BarEntry(new float[]{ -13, 14 }, 7));
- yValues.add(new BarEntry(new float[]{ -10, 11 }, 8));
- yValues.add(new BarEntry(new float[]{ -5, 6 }, 9));
- yValues.add(new BarEntry(new float[]{ -1, 2 }, 10));
-
- BarDataSet set = new BarDataSet(yValues, "Age Distribution");
- set.setValueFormatter(new CustomFormatter());
- set.setValueTextSize(7f);
- set.setAxisDependency(YAxis.AxisDependency.RIGHT);
- set.setBarSpacePercent(40f);
- set.setColors(new int[] {Color.rgb(67,67,72), Color.rgb(124,181,236)});
- set.setStackLabels(new String[]{
- "Men", "Women"
- });
-
- String []xVals = new String[]{"0-10", "10-20", "20-30", "30-40", "40-50", "50-60", "60-70", "70-80", "80-90", "90-100", "100+"};
-
- BarData data = new BarData(xVals, set);
- mChart.setData(data);
- mChart.invalidate();
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.bar, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
-
- switch (item.getItemId()) {
- case R.id.actionToggleValues: {
- List sets = mChart.getData()
- .getDataSets();
-
- for (IBarDataSet iSet : sets) {
-
- BarDataSet set = (BarDataSet) iSet;
- set.setDrawValues(!set.isDrawValuesEnabled());
- }
-
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleHighlight: {
- if(mChart.getData() != null) {
- mChart.getData().setHighlightEnabled(!mChart.getData().isHighlightEnabled());
- mChart.invalidate();
- }
- break;
- }
- case R.id.actionTogglePinch: {
- if (mChart.isPinchZoomEnabled())
- mChart.setPinchZoom(false);
- else
- mChart.setPinchZoom(true);
-
- mChart.invalidate();
- break;
- }
- case R.id.actionToggleAutoScaleMinMax: {
- mChart.setAutoScaleMinMaxEnabled(!mChart.isAutoScaleMinMaxEnabled());
- mChart.notifyDataSetChanged();
- break;
- }
- case R.id.actionToggleHighlightArrow: {
- if (mChart.isDrawHighlightArrowEnabled())
- mChart.setDrawHighlightArrow(false);
- else
- mChart.setDrawHighlightArrow(true);
- mChart.invalidate();
- break;
- }
- case R.id.animateX: {
- mChart.animateX(3000);
- break;
- }
- case R.id.animateY: {
- mChart.animateY(3000);
- break;
- }
- case R.id.animateXY: {
-
- mChart.animateXY(3000, 3000);
- break;
- }
- case R.id.actionSave: {
- if (mChart.saveToGallery("title" + System.currentTimeMillis(), 50)) {
- Toast.makeText(getApplicationContext(), "Saving SUCCESSFUL!",
- Toast.LENGTH_SHORT).show();
- } else
- Toast.makeText(getApplicationContext(), "Saving FAILED!", Toast.LENGTH_SHORT)
- .show();
- break;
- }
- }
- return true;
- }
-
- @Override
- public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
-
- BarEntry entry = (BarEntry) e;
- Log.i("VAL SELECTED",
- "Value: " + Math.abs(entry.getVals()[h.getStackIndex()]));
- }
-
- @Override
- public void onNothingSelected() {
- // TODO Auto-generated method stub
- Log.i("NOTING SELECTED", "");
- }
-
- private class CustomFormatter implements ValueFormatter, YAxisValueFormatter {
-
- private DecimalFormat mFormat;
-
- public CustomFormatter() {
- mFormat = new DecimalFormat("###");
- }
-
- // data
- @Override
- public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
- return mFormat.format(Math.abs(value)) + "m";
- }
-
- // YAxis
- @Override
- public String getFormattedValue(float value, YAxis yAxis) {
- return mFormat.format(Math.abs(value)) + "m";
- }
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/custom/MyCustomXAxisValueFormatter.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/custom/MyCustomXAxisValueFormatter.java
deleted file mode 100644
index bdf918b1b7..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/custom/MyCustomXAxisValueFormatter.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.xxmassdeveloper.mpchartexample.custom;
-
-import com.github.mikephil.charting.utils.ViewPortHandler;
-import com.github.mikephil.charting.formatter.XAxisValueFormatter;
-
-/**
- * Created by Philipp Jahoda on 14/09/15.
- */
-public class MyCustomXAxisValueFormatter implements XAxisValueFormatter {
-
- public MyCustomXAxisValueFormatter() {
- // maybe do something here or provide parameters in constructor
- }
-
- @Override
- public String getXValue(String original, int index, ViewPortHandler viewPortHandler) {
-
- //Log.i("TRANS", "x: " + viewPortHandler.getTransX() + ", y: " + viewPortHandler.getTransY());
-
- // e.g. adjust the x-axis values depending on scale / zoom level
- if (viewPortHandler.getScaleX() > 5)
- return "4";
- else if (viewPortHandler.getScaleX() > 3)
- return "3";
- else if (viewPortHandler.getScaleX() > 1)
- return "2";
- else
- return original;
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/custom/MyEasingFunction.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/custom/MyEasingFunction.java
deleted file mode 100644
index e874a57ab6..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/custom/MyEasingFunction.java
+++ /dev/null
@@ -1,18 +0,0 @@
-
-package com.xxmassdeveloper.mpchartexample.custom;
-
-import com.github.mikephil.charting.animation.EasingFunction;
-
-/**
- * Example of a custom made animation EasingFunction.
- *
- * @author Philipp Jahoda
- */
-public class MyEasingFunction implements EasingFunction {
-
- @Override
- public float getInterpolation(float input) {
- // do awesome stuff here, this is just linear easing
- return input;
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/custom/MyYAxisValueFormatter.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/custom/MyYAxisValueFormatter.java
deleted file mode 100644
index cae82be1d9..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/custom/MyYAxisValueFormatter.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.xxmassdeveloper.mpchartexample.custom;
-
-import com.github.mikephil.charting.components.YAxis;
-import com.github.mikephil.charting.formatter.YAxisValueFormatter;
-
-import java.text.DecimalFormat;
-
-public class MyYAxisValueFormatter implements YAxisValueFormatter {
-
- private DecimalFormat mFormat;
-
- public MyYAxisValueFormatter() {
- mFormat = new DecimalFormat("###,###,###,##0.0");
- }
-
- @Override
- public String getFormattedValue(float value, YAxis yAxis) {
- return mFormat.format(value) + " $";
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/custom/RealmDemoData.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/custom/RealmDemoData.java
deleted file mode 100644
index 58767447fe..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/custom/RealmDemoData.java
+++ /dev/null
@@ -1,169 +0,0 @@
-package com.xxmassdeveloper.mpchartexample.custom;
-
-
-import io.realm.RealmList;
-import io.realm.RealmObject;
-
-/**
- * Demo class that encapsulates data stored in realm.io database.
- * This class represents data suitable for all chart-types.
- */
-public class RealmDemoData extends RealmObject {
-
- private float value;
-
- private float open, close, high, low;
-
- private float bubbleSize;
-
- private RealmList stackValues;
-
- private int xIndex;
-
- private String xValue;
-
- private String someStringField;
-
- // ofc there could me more fields here...
-
- public RealmDemoData() {
-
- }
-
- public RealmDemoData(float value, int xIndex, String xValue) {
- this.value = value;
- this.xIndex = xIndex;
- this.xValue = xValue;
- }
-
- /**
- * Constructor for stacked bars.
- *
- * @param stackValues
- * @param xIndex
- * @param xValue
- */
- public RealmDemoData(float[] stackValues, int xIndex, String xValue) {
- this.xIndex = xIndex;
- this.xValue = xValue;
- this.stackValues = new RealmList();
-
- for (float val : stackValues) {
- this.stackValues.add(new RealmFloat(val));
- }
- }
-
- /**
- * Constructor for candles.
- *
- * @param high
- * @param low
- * @param open
- * @param close
- * @param xIndex
- */
- public RealmDemoData(float high, float low, float open, float close, int xIndex, String xValue) {
- this.value = (high + low) / 2f;
- this.high = high;
- this.low = low;
- this.open = open;
- this.close = close;
- this.xIndex = xIndex;
- this.xValue = xValue;
- }
-
- /**
- * Constructor for bubbles.
- *
- * @param value
- * @param xIndex
- * @param bubbleSize
- * @param xValue
- */
- public RealmDemoData(float value, int xIndex, float bubbleSize, String xValue) {
- this.value = value;
- this.xIndex = xIndex;
- this.bubbleSize = bubbleSize;
- this.xValue = xValue;
- }
-
- public float getValue() {
- return value;
- }
-
- public void setValue(float value) {
- this.value = value;
- }
-
- public RealmList getStackValues() {
- return stackValues;
- }
-
- public void setStackValues(RealmList stackValues) {
- this.stackValues = stackValues;
- }
-
- public int getxIndex() {
- return xIndex;
- }
-
- public void setxIndex(int xIndex) {
- this.xIndex = xIndex;
- }
-
- public String getxValue() {
- return xValue;
- }
-
- public void setxValue(String xValue) {
- this.xValue = xValue;
- }
-
- public float getOpen() {
- return open;
- }
-
- public void setOpen(float open) {
- this.open = open;
- }
-
- public float getClose() {
- return close;
- }
-
- public void setClose(float close) {
- this.close = close;
- }
-
- public float getHigh() {
- return high;
- }
-
- public void setHigh(float high) {
- this.high = high;
- }
-
- public float getLow() {
- return low;
- }
-
- public void setLow(float low) {
- this.low = low;
- }
-
- public float getBubbleSize() {
- return bubbleSize;
- }
-
- public void setBubbleSize(float bubbleSize) {
- this.bubbleSize = bubbleSize;
- }
-
- public String getSomeStringField() {
- return someStringField;
- }
-
- public void setSomeStringField(String someStringField) {
- this.someStringField = someStringField;
- }
-}
\ No newline at end of file
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/custom/RealmFloat.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/custom/RealmFloat.java
deleted file mode 100644
index 15b027b3ff..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/custom/RealmFloat.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.xxmassdeveloper.mpchartexample.custom;
-
-import io.realm.RealmObject;
-
-/**
- * Created by Philipp Jahoda on 09/11/15.
- */
-public class RealmFloat extends RealmObject {
-
- private float floatValue;
-
- public RealmFloat() {
-
- }
-
- public RealmFloat(float floatValue) {
- this.floatValue = floatValue;
- }
-
- public float getFloatValue() {
- return floatValue;
- }
-
- public void setFloatValue(float value) {
- this.floatValue = value;
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/fragments/SineCosineFragment.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/fragments/SineCosineFragment.java
deleted file mode 100644
index 418a856f5f..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/fragments/SineCosineFragment.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package com.xxmassdeveloper.mpchartexample.fragments;
-import android.graphics.Typeface;
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import com.github.mikephil.charting.charts.LineChart;
-import com.github.mikephil.charting.components.Legend;
-import com.github.mikephil.charting.components.XAxis;
-import com.github.mikephil.charting.components.YAxis;
-import com.xxmassdeveloper.mpchartexample.R;
-
-
-public class SineCosineFragment extends SimpleFragment {
-
- public static Fragment newInstance() {
- return new SineCosineFragment();
- }
-
- private LineChart mChart;
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- View v = inflater.inflate(R.layout.frag_simple_line, container, false);
-
- mChart = (LineChart) v.findViewById(R.id.lineChart1);
-
- mChart.setDescription("");
-
- mChart.setDrawGridBackground(false);
-
- mChart.setData(generateLineData());
- mChart.animateX(3000);
-
- Typeface tf = Typeface.createFromAsset(getActivity().getAssets(),"OpenSans-Light.ttf");
-
- Legend l = mChart.getLegend();
- l.setTypeface(tf);
-
- YAxis leftAxis = mChart.getAxisLeft();
- leftAxis.setTypeface(tf);
- leftAxis.setAxisMaxValue(1.2f);
- leftAxis.setAxisMinValue(-1.2f);
-
- mChart.getAxisRight().setEnabled(false);
-
- XAxis xAxis = mChart.getXAxis();
- xAxis.setEnabled(false);
-
- return v;
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/notimportant/ContentItem.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/notimportant/ContentItem.java
deleted file mode 100644
index 97bb230ec9..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/notimportant/ContentItem.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.xxmassdeveloper.mpchartexample.notimportant;
-
-/**
- * Created by Philipp Jahoda on 07/12/15.
- */
-public class ContentItem {
-
- String name;
- String desc;
- boolean isNew = false;
-
- public ContentItem(String n, String d) {
- name = n;
- desc = d;
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/notimportant/DemoBase.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/notimportant/DemoBase.java
deleted file mode 100644
index 774aff1f75..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/notimportant/DemoBase.java
+++ /dev/null
@@ -1,31 +0,0 @@
-
-package com.xxmassdeveloper.mpchartexample.notimportant;
-
-import android.support.v4.app.FragmentActivity;
-
-import com.xxmassdeveloper.mpchartexample.R;
-
-/**
- * Baseclass of all Activities of the Demo Application.
- *
- * @author Philipp Jahoda
- */
-public abstract class DemoBase extends FragmentActivity {
-
- protected String[] mMonths = new String[] {
- "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec"
- };
-
- protected String[] mParties = new String[] {
- "Party A", "Party B", "Party C", "Party D", "Party E", "Party F", "Party G", "Party H",
- "Party I", "Party J", "Party K", "Party L", "Party M", "Party N", "Party O", "Party P",
- "Party Q", "Party R", "Party S", "Party T", "Party U", "Party V", "Party W", "Party X",
- "Party Y", "Party Z"
- };
-
- @Override
- public void onBackPressed() {
- super.onBackPressed();
- overridePendingTransition(R.anim.move_left_in_activity, R.anim.move_right_out_activity);
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/notimportant/MyAdapter.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/notimportant/MyAdapter.java
deleted file mode 100644
index 8395ce2720..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/notimportant/MyAdapter.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package com.xxmassdeveloper.mpchartexample.notimportant;
-
-import android.content.Context;
-import android.graphics.Typeface;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ArrayAdapter;
-import android.widget.TextView;
-
-import com.xxmassdeveloper.mpchartexample.R;
-
-import java.util.List;
-
-/**
- * Created by Philipp Jahoda on 07/12/15.
- */
-public class MyAdapter extends ArrayAdapter {
-
- private Typeface mTypeFaceLight;
- private Typeface mTypeFaceRegular;
-
- public MyAdapter(Context context, List objects) {
- super(context, 0, objects);
-
- mTypeFaceLight = Typeface.createFromAsset(context.getAssets(), "OpenSans-Light.ttf");
- mTypeFaceRegular = Typeface.createFromAsset(context.getAssets(), "OpenSans-Regular.ttf");
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
-
- ContentItem c = getItem(position);
-
- ViewHolder holder = null;
-
- if (convertView == null) {
-
- holder = new ViewHolder();
-
- convertView = LayoutInflater.from(getContext()).inflate(R.layout.list_item, null);
- holder.tvName = (TextView) convertView.findViewById(R.id.tvName);
- holder.tvDesc = (TextView) convertView.findViewById(R.id.tvDesc);
- holder.tvNew = (TextView) convertView.findViewById(R.id.tvNew);
-
- convertView.setTag(holder);
-
- } else {
- holder = (ViewHolder) convertView.getTag();
- }
-
- holder.tvNew.setTypeface(mTypeFaceRegular);
- holder.tvName.setTypeface(mTypeFaceLight);
- holder.tvDesc.setTypeface(mTypeFaceLight);
-
- holder.tvName.setText(c.name);
- holder.tvDesc.setText(c.desc);
-
- if(c.isNew)
- holder.tvNew.setVisibility(View.VISIBLE);
- else
- holder.tvNew.setVisibility(View.GONE);
-
- return convertView;
- }
-
- private class ViewHolder {
-
- TextView tvName, tvDesc;
- TextView tvNew;
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmBaseActivity.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmBaseActivity.java
deleted file mode 100644
index 09bcc59e1e..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmBaseActivity.java
+++ /dev/null
@@ -1,210 +0,0 @@
-package com.xxmassdeveloper.mpchartexample.realm;
-
-import android.graphics.Color;
-import android.graphics.Typeface;
-import android.os.Bundle;
-
-import com.github.mikephil.charting.charts.BarLineChartBase;
-import com.github.mikephil.charting.charts.Chart;
-import com.github.mikephil.charting.components.XAxis;
-import com.github.mikephil.charting.components.YAxis;
-import com.github.mikephil.charting.data.ChartData;
-import com.github.mikephil.charting.formatter.DefaultYAxisValueFormatter;
-import com.github.mikephil.charting.formatter.PercentFormatter;
-import com.xxmassdeveloper.mpchartexample.custom.MyValueFormatter;
-import com.xxmassdeveloper.mpchartexample.custom.MyYAxisValueFormatter;
-import com.xxmassdeveloper.mpchartexample.custom.RealmDemoData;
-import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
-
-import io.realm.Realm;
-import io.realm.RealmConfiguration;
-
-/**
- * Created by Philipp Jahoda on 05/11/15.
- */
-public abstract class RealmBaseActivity extends DemoBase {
-
- protected Realm mRealm;
-
- protected Typeface mTf;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setTitle("Realm.io Examples");
- }
-
- protected void setup(Chart> chart) {
-
- mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
-
- // no description text
- chart.setDescription("");
- chart.setNoDataTextDescription("You need to provide data for the chart.");
-
- // enable touch gestures
- chart.setTouchEnabled(true);
-
- if (chart instanceof BarLineChartBase) {
-
- BarLineChartBase mChart = (BarLineChartBase) chart;
-
- mChart.setDrawGridBackground(false);
-
- // enable scaling and dragging
- mChart.setDragEnabled(true);
- mChart.setScaleEnabled(true);
-
- // if disabled, scaling can be done on x- and y-axis separately
- mChart.setPinchZoom(false);
-
- YAxis leftAxis = mChart.getAxisLeft();
- leftAxis.removeAllLimitLines(); // reset all limit lines to avoid overlapping lines
- leftAxis.setTypeface(mTf);
- leftAxis.setTextSize(8f);
- leftAxis.setTextColor(Color.DKGRAY);
- leftAxis.setValueFormatter(new PercentFormatter());
-
- XAxis xAxis = mChart.getXAxis();
- xAxis.setTypeface(mTf);
- xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
- xAxis.setTextSize(8f);
- xAxis.setTextColor(Color.DKGRAY);
-
- mChart.getAxisRight().setEnabled(false);
- }
- }
-
- protected void styleData(ChartData data) {
- data.setValueTypeface(mTf);
- data.setValueTextSize(8f);
- data.setValueTextColor(Color.DKGRAY);
- data.setValueFormatter(new PercentFormatter());
- }
-
- @Override
- protected void onResume() {
- super.onResume();
-
- RealmConfiguration config = new RealmConfiguration.Builder(this)
- .name("myrealm.realm")
- .build();
-
- Realm.deleteRealm(config);
-
- Realm.setDefaultConfiguration(config);
-
- mRealm = Realm.getInstance(config);
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- mRealm.close();
- }
-
- protected void writeToDB(int objectCount) {
-
- mRealm.beginTransaction();
-
- mRealm.clear(RealmDemoData.class);
-
- for (int i = 0; i < objectCount; i++) {
-
- float value = 40f + (float) (Math.random() * 60f);
-
- RealmDemoData d = new RealmDemoData(value, i, "" + i);
- mRealm.copyToRealm(d);
- }
-
- mRealm.commitTransaction();
- }
-
- protected void writeToDBStack(int objectCount) {
-
- mRealm.beginTransaction();
-
- mRealm.clear(RealmDemoData.class);
-
- for (int i = 0; i < objectCount; i++) {
-
- float val1 = 34f + (float) (Math.random() * 12.0f);
- float val2 = 34f + (float) (Math.random() * 12.0f);
- float[] stack = new float[]{val1, val2, 100 - val1 - val2};
-
- RealmDemoData d = new RealmDemoData(stack, i, "" + i);
- mRealm.copyToRealm(d);
- }
-
- mRealm.commitTransaction();
- }
-
- protected void writeToDBCandle(int objectCount) {
-
- mRealm.beginTransaction();
-
- mRealm.clear(RealmDemoData.class);
-
- for (int i = 0; i < objectCount; i++) {
-
- float mult = 50;
- float val = (float) (Math.random() * 40) + mult;
-
- float high = (float) (Math.random() * 9) + 8f;
- float low = (float) (Math.random() * 9) + 8f;
-
- float open = (float) (Math.random() * 6) + 1f;
- float close = (float) (Math.random() * 6) + 1f;
-
- boolean even = i % 2 == 0;
-
- RealmDemoData d = new RealmDemoData(val + high, val - low, even ? val + open : val - open,
- even ? val - close : val + close, i, i + "");
-
- mRealm.copyToRealm(d);
- }
-
- mRealm.commitTransaction();
- }
-
- protected void writeToDBBubble(int objectCount) {
-
- mRealm.beginTransaction();
-
- mRealm.clear(RealmDemoData.class);
-
- for (int i = 0; i < objectCount; i++) {
-
- float value = 30f + (float) (Math.random() * 100.0);
- float size = 15f + (float) (Math.random() * 20.0);
-
- RealmDemoData d = new RealmDemoData(value, i, size, "" + i);
- mRealm.copyToRealm(d);
- }
-
- mRealm.commitTransaction();
- }
-
- protected void writeToDBPie() {
-
- mRealm.beginTransaction();
-
- mRealm.clear(RealmDemoData.class);
-
- float value1 = 15f + (float) (Math.random() * 8f);
- float value2 = 15f + (float) (Math.random() * 8f);
- float value3 = 15f + (float) (Math.random() * 8f);
- float value4 = 15f + (float) (Math.random() * 8f);
- float value5 = 100f - value1 - value2 - value3 - value4;
-
- float[] values = new float[] { value1, value2, value3, value4, value5 };
- String[] xValues = new String[]{ "iOS", "Android", "WP 10", "BlackBerry", "Other"};
-
- for (int i = 0; i < values.length; i++) {
- RealmDemoData d = new RealmDemoData(values[i], i, xValues[i]);
- mRealm.copyToRealm(d);
- }
-
- mRealm.commitTransaction();
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmDatabaseActivityBar.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmDatabaseActivityBar.java
deleted file mode 100644
index 4387035191..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmDatabaseActivityBar.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package com.xxmassdeveloper.mpchartexample.realm;
-
-import android.os.Bundle;
-import android.view.WindowManager;
-
-import com.github.mikephil.charting.animation.Easing;
-import com.github.mikephil.charting.charts.BarChart;
-import com.github.mikephil.charting.data.realm.implementation.RealmBarData;
-import com.github.mikephil.charting.data.realm.implementation.RealmBarDataSet;
-import com.github.mikephil.charting.interfaces.datasets.IBarDataSet;
-import com.github.mikephil.charting.utils.ColorTemplate;
-import com.xxmassdeveloper.mpchartexample.R;
-import com.xxmassdeveloper.mpchartexample.custom.RealmDemoData;
-
-import java.util.ArrayList;
-
-import io.realm.RealmResults;
-
-/**
- * Created by Philipp Jahoda on 21/10/15.
- */
-public class RealmDatabaseActivityBar extends RealmBaseActivity {
-
- private BarChart mChart;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.activity_barchart_noseekbar);
-
- mChart = (BarChart) findViewById(R.id.chart1);
- setup(mChart);
- }
-
- @Override
- protected void onResume() {
- super.onResume(); // setup realm
-
- // write some demo-data into the realm.io database
- writeToDB(20);
-
- // add data to the chart
- setData();
- }
-
- private void setData() {
-
- RealmResults result = mRealm.allObjects(RealmDemoData.class);
-
- //RealmBarDataSet set = new RealmBarDataSet(result, "stackValues", "xIndex"); // normal entries
- RealmBarDataSet set = new RealmBarDataSet(result, "value", "xIndex"); // stacked entries
- set.setColors(new int[] {ColorTemplate.rgb("#FF5722"), ColorTemplate.rgb("#03A9F4")});
- set.setLabel("Realm BarDataSet");
-
- ArrayList dataSets = new ArrayList();
- dataSets.add(set); // add the dataset
-
- // create a data object with the dataset list
- RealmBarData data = new RealmBarData(result, "xValue", dataSets);
- styleData(data);
-
- // set data
- mChart.setData(data);
- mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmDatabaseActivityBubble.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmDatabaseActivityBubble.java
deleted file mode 100644
index b98ca0b746..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmDatabaseActivityBubble.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package com.xxmassdeveloper.mpchartexample.realm;
-
-import android.os.Bundle;
-import android.view.WindowManager;
-
-import com.github.mikephil.charting.animation.Easing;
-import com.github.mikephil.charting.charts.BubbleChart;
-import com.github.mikephil.charting.data.realm.implementation.RealmBubbleData;
-import com.github.mikephil.charting.data.realm.implementation.RealmBubbleDataSet;
-import com.github.mikephil.charting.interfaces.datasets.IBubbleDataSet;
-import com.github.mikephil.charting.utils.ColorTemplate;
-import com.xxmassdeveloper.mpchartexample.R;
-import com.xxmassdeveloper.mpchartexample.custom.RealmDemoData;
-
-import java.util.ArrayList;
-
-import io.realm.RealmResults;
-
-/**
- * Created by Philipp Jahoda on 21/10/15.
- */
-public class RealmDatabaseActivityBubble extends RealmBaseActivity {
-
- private BubbleChart mChart;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.activity_bubblechart_noseekbar);
-
- mChart = (BubbleChart) findViewById(R.id.chart1);
- setup(mChart);
-
- mChart.getXAxis().setDrawGridLines(false);
- mChart.getAxisLeft().setDrawGridLines(false);
- mChart.setPinchZoom(true);
- }
-
- @Override
- protected void onResume() {
- super.onResume(); // setup realm
-
- // write some demo-data into the realm.io database
- writeToDBBubble(10);
-
- // add data to the chart
- setData();
- }
-
- private void setData() {
-
- RealmResults result = mRealm.allObjects(RealmDemoData.class);
-
- RealmBubbleDataSet set = new RealmBubbleDataSet(result, "value", "xIndex", "bubbleSize");
- set.setLabel("Realm BubbleDataSet");
- set.setColors(ColorTemplate.COLORFUL_COLORS, 110);
-
- ArrayList dataSets = new ArrayList();
- dataSets.add(set); // add the dataset
-
- // create a data object with the dataset list
- RealmBubbleData data = new RealmBubbleData(result, "xValue", dataSets);
- styleData(data);
-
- // set data
- mChart.setData(data);
- mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmDatabaseActivityCandle.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmDatabaseActivityCandle.java
deleted file mode 100644
index 70e324d4dd..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmDatabaseActivityCandle.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package com.xxmassdeveloper.mpchartexample.realm;
-
-import android.graphics.Color;
-import android.graphics.Paint;
-import android.os.Bundle;
-import android.view.WindowManager;
-
-import com.github.mikephil.charting.animation.Easing;
-import com.github.mikephil.charting.charts.CandleStickChart;
-import com.github.mikephil.charting.data.realm.implementation.RealmCandleData;
-import com.github.mikephil.charting.data.realm.implementation.RealmCandleDataSet;
-import com.github.mikephil.charting.interfaces.datasets.ICandleDataSet;
-import com.xxmassdeveloper.mpchartexample.R;
-import com.xxmassdeveloper.mpchartexample.custom.RealmDemoData;
-
-import java.util.ArrayList;
-
-import io.realm.RealmResults;
-
-/**
- * Created by Philipp Jahoda on 21/10/15.
- */
-public class RealmDatabaseActivityCandle extends RealmBaseActivity {
-
- private CandleStickChart mChart;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.activity_candlechart_noseekbar);
-
- mChart = (CandleStickChart) findViewById(R.id.chart1);
- setup(mChart);
-
- mChart.getAxisLeft().setDrawGridLines(false);
- mChart.getXAxis().setDrawGridLines(false);
- }
-
- @Override
- protected void onResume() {
- super.onResume(); // setup realm
-
- // write some demo-data into the realm.io database
- writeToDBCandle(50);
-
- // add data to the chart
- setData();
- }
-
- private void setData() {
-
- RealmResults result = mRealm.allObjects(RealmDemoData.class);
-
- RealmCandleDataSet set = new RealmCandleDataSet(result, "high", "low", "open", "close", "xIndex");
- set.setLabel("Realm Realm CandleDataSet");
- set.setShadowColor(Color.DKGRAY);
- set.setShadowWidth(0.7f);
- set.setDecreasingColor(Color.RED);
- set.setDecreasingPaintStyle(Paint.Style.FILL);
- set.setIncreasingColor(Color.rgb(122, 242, 84));
- set.setIncreasingPaintStyle(Paint.Style.STROKE);
- set.setNeutralColor(Color.BLUE);
-
- ArrayList dataSets = new ArrayList();
- dataSets.add(set); // add the dataset
-
- // create a data object with the dataset list
- RealmCandleData data = new RealmCandleData(result, "xValue", dataSets);
- styleData(data);
-
- // set data
- mChart.setData(data);
- mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmDatabaseActivityHorizontalBar.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmDatabaseActivityHorizontalBar.java
deleted file mode 100644
index 7a2ef39c18..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmDatabaseActivityHorizontalBar.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package com.xxmassdeveloper.mpchartexample.realm;
-
-import android.graphics.Color;
-import android.os.Bundle;
-import android.view.WindowManager;
-
-import com.github.mikephil.charting.animation.Easing;
-import com.github.mikephil.charting.charts.HorizontalBarChart;
-import com.github.mikephil.charting.data.realm.implementation.RealmBarData;
-import com.github.mikephil.charting.data.realm.implementation.RealmBarDataSet;
-import com.github.mikephil.charting.interfaces.datasets.IBarDataSet;
-import com.github.mikephil.charting.utils.ColorTemplate;
-import com.xxmassdeveloper.mpchartexample.R;
-import com.xxmassdeveloper.mpchartexample.custom.RealmDemoData;
-
-import java.util.ArrayList;
-
-import io.realm.RealmResults;
-
-/**
- * Created by Philipp Jahoda on 21/10/15.
- */
-public class RealmDatabaseActivityHorizontalBar extends RealmBaseActivity {
-
- private HorizontalBarChart mChart;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.activity_horizontalbarchart_noseekbar);
-
- mChart = (HorizontalBarChart) findViewById(R.id.chart1);
- setup(mChart);
-
- mChart.getAxisLeft().setAxisMinValue(0f);
- mChart.setDrawValueAboveBar(false);
- }
-
- @Override
- protected void onResume() {
- super.onResume(); // setup realm
-
- // write some demo-data into the realm.io database
- writeToDBStack(50);
-
- // add data to the chart
- setData();
- }
-
- private void setData() {
-
- RealmResults result = mRealm.allObjects(RealmDemoData.class);
-
- //RealmBarDataSet set = new RealmBarDataSet(result, "stackValues", "xIndex"); // normal entries
- RealmBarDataSet set = new RealmBarDataSet(result, "stackValues", "xIndex", "floatValue"); // stacked entries
- set.setColors(new int[]{ColorTemplate.rgb("#8BC34A"), ColorTemplate.rgb("#FFC107"), ColorTemplate.rgb("#9E9E9E")});
- set.setLabel("Mobile OS distribution");
- set.setStackLabels(new String[]{"iOS", "Android", "Other"});
-
- ArrayList dataSets = new ArrayList();
- dataSets.add(set); // add the dataset
-
- // create a data object with the dataset list
- RealmBarData data = new RealmBarData(result, "xValue", dataSets);
- styleData(data);
- data.setValueTextColor(Color.WHITE);
-
- // set data
- mChart.setData(data);
- mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmDatabaseActivityLine.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmDatabaseActivityLine.java
deleted file mode 100644
index 057662d057..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmDatabaseActivityLine.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package com.xxmassdeveloper.mpchartexample.realm;
-
-import android.os.Bundle;
-import android.view.WindowManager;
-
-import com.github.mikephil.charting.animation.Easing;
-import com.github.mikephil.charting.charts.LineChart;
-import com.github.mikephil.charting.data.realm.implementation.RealmLineData;
-import com.github.mikephil.charting.data.realm.implementation.RealmLineDataSet;
-import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
-import com.github.mikephil.charting.utils.ColorTemplate;
-import com.xxmassdeveloper.mpchartexample.R;
-import com.xxmassdeveloper.mpchartexample.custom.RealmDemoData;
-
-import java.util.ArrayList;
-
-import io.realm.RealmResults;
-
-/**
- * Created by Philipp Jahoda on 21/10/15.
- */
-public class RealmDatabaseActivityLine extends RealmBaseActivity {
-
- private LineChart mChart;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.activity_linechart_noseekbar);
-
- mChart = (LineChart) findViewById(R.id.chart1);
- setup(mChart);
-
- mChart.getAxisLeft().setAxisMaxValue(150f);
- mChart.getAxisLeft().setAxisMinValue(0f);
- mChart.getAxisLeft().setDrawGridLines(false);
- mChart.getXAxis().setDrawGridLines(false);
- }
-
- @Override
- protected void onResume() {
- super.onResume(); // setup realm
-
- // write some demo-data into the realm.io database
- writeToDB(40);
-
- // add data to the chart
- setData();
- }
-
- private void setData() {
-
- RealmResults result = mRealm.allObjects(RealmDemoData.class);
-
- RealmLineDataSet set = new RealmLineDataSet(result, "value", "xIndex");
- set.setDrawCubic(false);
- set.setLabel("Realm LineDataSet");
- set.setDrawCircleHole(false);
- set.setColor(ColorTemplate.rgb("#FF5722"));
- set.setCircleColor(ColorTemplate.rgb("#FF5722"));
- set.setLineWidth(1.8f);
- set.setCircleSize(3.6f);
-
- ArrayList dataSets = new ArrayList();
- dataSets.add(set); // add the dataset
-
- // create a data object with the dataset list
- RealmLineData data = new RealmLineData(result, "xValue", dataSets);
- styleData(data);
-
- // set data
- mChart.setData(data);
- mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmDatabaseActivityPie.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmDatabaseActivityPie.java
deleted file mode 100644
index de6767d145..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmDatabaseActivityPie.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package com.xxmassdeveloper.mpchartexample.realm;
-
-import android.graphics.Color;
-import android.graphics.Typeface;
-import android.os.Bundle;
-import android.text.SpannableString;
-import android.text.style.ForegroundColorSpan;
-import android.text.style.RelativeSizeSpan;
-import android.text.style.StyleSpan;
-import android.view.WindowManager;
-
-import com.github.mikephil.charting.charts.PieChart;
-import com.github.mikephil.charting.data.realm.implementation.RealmPieData;
-import com.github.mikephil.charting.data.realm.implementation.RealmPieDataSet;
-import com.github.mikephil.charting.utils.ColorTemplate;
-import com.xxmassdeveloper.mpchartexample.R;
-import com.xxmassdeveloper.mpchartexample.custom.RealmDemoData;
-
-import io.realm.RealmResults;
-
-/**
- * Created by Philipp Jahoda on 21/10/15.
- */
-public class RealmDatabaseActivityPie extends RealmBaseActivity {
-
- private PieChart mChart;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.activity_piechart_noseekbar);
-
- mChart = (PieChart) findViewById(R.id.chart1);
- setup(mChart);
-
- mChart.setCenterText(generateCenterSpannableText());
- }
-
- @Override
- protected void onResume() {
- super.onResume(); // setup realm
-
- // write some demo-data into the realm.io database
- writeToDBPie();
-
- // add data to the chart
- setData();
- }
-
- private void setData() {
-
- RealmResults result = mRealm.allObjects(RealmDemoData.class);
-
- //RealmBarDataSet set = new RealmBarDataSet(result, "stackValues", "xIndex"); // normal entries
- RealmPieDataSet set = new RealmPieDataSet(result, "value", "xIndex"); // stacked entries
- set.setColors(ColorTemplate.VORDIPLOM_COLORS);
- set.setLabel("Example market share");
- set.setSliceSpace(2);
-
- // create a data object with the dataset list
- RealmPieData data = new RealmPieData(result, "xValue", set);
- styleData(data);
- data.setValueTextColor(Color.WHITE);
- data.setValueTextSize(12f);
-
- // set data
- mChart.setData(data);
- mChart.animateY(1400);
- }
-
- private SpannableString generateCenterSpannableText() {
-
- SpannableString s = new SpannableString("Realm.io\nmobile database");
- s.setSpan(new ForegroundColorSpan(Color.rgb(240, 115, 126)), 0, 8, 0);
- s.setSpan(new RelativeSizeSpan(2.2f), 0, 8, 0);
- s.setSpan(new StyleSpan(Typeface.ITALIC), 9, s.length(), 0);
- s.setSpan(new ForegroundColorSpan(ColorTemplate.getHoloBlue()), 9, s.length(), 0);
- s.setSpan(new RelativeSizeSpan(0.85f), 9, s.length(), 0);
- return s;
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmDatabaseActivityRadar.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmDatabaseActivityRadar.java
deleted file mode 100644
index 7aae4ae377..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmDatabaseActivityRadar.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package com.xxmassdeveloper.mpchartexample.realm;
-
-import android.graphics.Color;
-import android.os.Bundle;
-import android.view.WindowManager;
-
-import com.github.mikephil.charting.charts.RadarChart;
-import com.github.mikephil.charting.data.RadarData;
-import com.github.mikephil.charting.data.realm.implementation.RealmRadarDataSet;
-import com.github.mikephil.charting.interfaces.datasets.IRadarDataSet;
-import com.github.mikephil.charting.utils.ColorTemplate;
-import com.xxmassdeveloper.mpchartexample.R;
-import com.xxmassdeveloper.mpchartexample.custom.RealmDemoData;
-
-import java.util.ArrayList;
-
-import io.realm.RealmResults;
-
-/**
- * Created by Philipp Jahoda on 21/10/15.
- */
-public class RealmDatabaseActivityRadar extends RealmBaseActivity {
-
- private RadarChart mChart;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.activity_radarchart_noseekbar);
-
- mChart = (RadarChart) findViewById(R.id.chart1);
- setup(mChart);
-
- mChart.getYAxis().setEnabled(false);
- mChart.setWebAlpha(180);
- mChart.setWebColorInner(Color.DKGRAY);
- mChart.setWebColor(Color.GRAY);
- }
-
- @Override
- protected void onResume() {
- super.onResume(); // setup realm
-
- // write some demo-data into the realm.io database
- writeToDB(7);
-
- // add data to the chart
- setData();
- }
-
- private void setData() {
-
- RealmResults result = mRealm.allObjects(RealmDemoData.class);
-
- //RealmBarDataSet set = new RealmBarDataSet(result, "stackValues", "xIndex"); // normal entries
- RealmRadarDataSet set = new RealmRadarDataSet(result, "value", "xIndex"); // stacked entries
- set.setLabel("Realm RadarDataSet");
- set.setDrawFilled(true);
- set.setColor(ColorTemplate.rgb("#009688"));
- set.setFillColor(ColorTemplate.rgb("#009688"));
- set.setFillAlpha(130);
- set.setLineWidth(2f);
-
- ArrayList dataSets = new ArrayList();
- dataSets.add(set); // add the dataset
-
- // create a data object with the dataset list
- RadarData data = new RadarData(new String[] {"2013", "2014", "2015", "2016", "2017", "2018", "2019"}, dataSets);
- styleData(data);
-
- // set data
- mChart.setData(data);
- mChart.animateY(1400);
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmDatabaseActivityScatter.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmDatabaseActivityScatter.java
deleted file mode 100644
index b28bf137a8..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmDatabaseActivityScatter.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package com.xxmassdeveloper.mpchartexample.realm;
-
-import android.os.Bundle;
-import android.view.WindowManager;
-
-import com.github.mikephil.charting.animation.Easing;
-import com.github.mikephil.charting.charts.ScatterChart;
-import com.github.mikephil.charting.data.realm.implementation.RealmScatterData;
-import com.github.mikephil.charting.data.realm.implementation.RealmScatterDataSet;
-import com.github.mikephil.charting.interfaces.datasets.IScatterDataSet;
-import com.github.mikephil.charting.utils.ColorTemplate;
-import com.xxmassdeveloper.mpchartexample.R;
-import com.xxmassdeveloper.mpchartexample.custom.RealmDemoData;
-
-import java.util.ArrayList;
-
-import io.realm.RealmResults;
-
-/**
- * Created by Philipp Jahoda on 21/10/15.
- */
-public class RealmDatabaseActivityScatter extends RealmBaseActivity {
-
- private ScatterChart mChart;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.activity_scatterchart_noseekbar);
-
- mChart = (ScatterChart) findViewById(R.id.chart1);
- setup(mChart);
-
- mChart.getAxisLeft().setDrawGridLines(false);
- mChart.getXAxis().setDrawGridLines(false);
- mChart.setPinchZoom(true);
- }
-
- @Override
- protected void onResume() {
- super.onResume(); // setup realm
-
- // write some demo-data into the realm.io database
- writeToDB(45);
-
- // add data to the chart
- setData();
- }
-
- private void setData() {
-
- RealmResults result = mRealm.allObjects(RealmDemoData.class);
-
- RealmScatterDataSet set = new RealmScatterDataSet(result, "value", "xIndex");
- set.setLabel("Realm ScatterDataSet");
- set.setScatterShapeSize(9f);
- set.setColor(ColorTemplate.rgb("#CDDC39"));
- set.setScatterShape(ScatterChart.ScatterShape.CIRCLE);
-
- ArrayList dataSets = new ArrayList();
- dataSets.add(set); // add the dataset
-
- // create a data object with the dataset list
- RealmScatterData data = new RealmScatterData(result, "xValue", dataSets);
- styleData(data);
-
- // set data
- mChart.setData(data);
- mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmMainActivity.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmMainActivity.java
deleted file mode 100644
index fc1ca357e2..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmMainActivity.java
+++ /dev/null
@@ -1,119 +0,0 @@
-package com.xxmassdeveloper.mpchartexample.realm;
-
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Bundle;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.WindowManager;
-import android.widget.AdapterView;
-import android.widget.ListView;
-
-import com.xxmassdeveloper.mpchartexample.R;
-import com.xxmassdeveloper.mpchartexample.notimportant.ContentItem;
-import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
-import com.xxmassdeveloper.mpchartexample.notimportant.MyAdapter;
-
-import java.util.ArrayList;
-
-/**
- * Created by Philipp Jahoda on 07/12/15.
- */
-public class RealmMainActivity extends DemoBase implements AdapterView.OnItemClickListener {
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.activity_main);
-
- setTitle("Realm.io Examples");
-
- ArrayList objects = new ArrayList();
-
- objects.add(new ContentItem("Line Chart", "Creating a LineChart with Realm.io database"));
- objects.add(new ContentItem("Bar Chart",
- "Creating a BarChart with Realm.io database"));
- objects.add(new ContentItem("Horizontal Bar Chart",
- "Creating a HorizontalBarChart with Realm.io database"));
- objects.add(new ContentItem("Scatter Chart",
- "Creating a ScatterChart with Realm.io database"));
- objects.add(new ContentItem("Candle Stick Chart", "Creating a CandleStickChart with Realm.io database"));
- objects.add(new ContentItem("Bubble Chart", "Creating a BubbleChart with Realm.io database"));
- objects.add(new ContentItem("Pie Chart", "Creating a PieChart with Realm.io database"));
- objects.add(new ContentItem("Radar Chart", "Creating a RadarChart with Realm.io database"));
- objects.add(new ContentItem("Realm Wiki", "This is the code related to the wiki entry about realm.io on the MPAndroidChart github page."));
-
- MyAdapter adapter = new MyAdapter(this, objects);
-
- ListView lv = (ListView) findViewById(R.id.listView1);
- lv.setAdapter(adapter);
-
- lv.setOnItemClickListener(this);
- }
-
- @Override
- public void onItemClick(AdapterView> av, View v, int pos, long arg3) {
-
- Intent i;
-
- switch (pos) {
- case 0:
- i = new Intent(this, RealmDatabaseActivityLine.class);
- startActivity(i);
- break;
- case 1:
- i = new Intent(this, RealmDatabaseActivityBar.class);
- startActivity(i);
- break;
- case 2:
- i = new Intent(this, RealmDatabaseActivityHorizontalBar.class);
- startActivity(i);
- break;
- case 3:
- i = new Intent(this, RealmDatabaseActivityScatter.class);
- startActivity(i);
- break;
- case 4:
- i = new Intent(this, RealmDatabaseActivityCandle.class);
- startActivity(i);
- break;
- case 5:
- i = new Intent(this, RealmDatabaseActivityBubble.class);
- startActivity(i);
- break;
- case 6:
- i = new Intent(this, RealmDatabaseActivityPie.class);
- startActivity(i);
- break;
- case 7:
- i = new Intent(this, RealmDatabaseActivityRadar.class);
- startActivity(i);
- break;
- case 8:
- i = new Intent(this, RealmWikiExample.class);
- startActivity(i);
- break;
- }
-
- overridePendingTransition(R.anim.move_right_in_activity, R.anim.move_left_out_activity);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.realm, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
-
- Intent i = new Intent(Intent.ACTION_VIEW);
- i.setData(Uri.parse("https://realm.io"));
- startActivity(i);
-
- return super.onOptionsItemSelected(item);
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmWikiExample.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmWikiExample.java
deleted file mode 100644
index 7066d8167b..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmWikiExample.java
+++ /dev/null
@@ -1,114 +0,0 @@
-package com.xxmassdeveloper.mpchartexample.realm;
-
-import android.os.Bundle;
-import android.view.WindowManager;
-
-import com.github.mikephil.charting.animation.Easing;
-import com.github.mikephil.charting.charts.BarChart;
-import com.github.mikephil.charting.charts.LineChart;
-import com.github.mikephil.charting.data.realm.implementation.RealmBarData;
-import com.github.mikephil.charting.data.realm.implementation.RealmBarDataSet;
-import com.github.mikephil.charting.data.realm.implementation.RealmLineData;
-import com.github.mikephil.charting.data.realm.implementation.RealmLineDataSet;
-import com.github.mikephil.charting.interfaces.datasets.IBarDataSet;
-import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
-import com.github.mikephil.charting.utils.ColorTemplate;
-import com.xxmassdeveloper.mpchartexample.R;
-
-import java.util.ArrayList;
-
-import io.realm.RealmResults;
-
-/**
- * Created by Philipp Jahoda on 18/12/15.
- */
-public class RealmWikiExample extends RealmBaseActivity {
-
- private LineChart lineChart;
- private BarChart barChart;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.activity_realm_wiki);
-
- lineChart = (LineChart) findViewById(R.id.lineChart);
- barChart = (BarChart) findViewById(R.id.barChart);
- setup(lineChart);
- setup(barChart);
-
- lineChart.setExtraBottomOffset(5f);
- barChart.setExtraBottomOffset(5f);
-
- lineChart.getAxisLeft().setDrawGridLines(false);
- lineChart.getXAxis().setDrawGridLines(false);
- barChart.getAxisLeft().setDrawGridLines(false);
- barChart.getXAxis().setDrawGridLines(false);
- }
-
- @Override
- protected void onResume() {
- super.onResume(); // setup realm
-
- mRealm.beginTransaction();
-
- // write some demo-data into the realm.io database
- Score score1 = new Score(100f, 0, "Peter");
- mRealm.copyToRealm(score1);
- Score score2 = new Score(110f, 1, "Lisa");
- mRealm.copyToRealm(score2);
- Score score3 = new Score(130f, 2, "Dennis");
- mRealm.copyToRealm(score3);
- Score score4 = new Score(70f, 3, "Luke");
- mRealm.copyToRealm(score4);
- Score score5 = new Score(80f, 4, "Sarah");
- mRealm.copyToRealm(score5);
-
- mRealm.commitTransaction();
-
- // add data to the chart
- setData();
- }
-
- private void setData() {
-
- // LINE-CHART
- RealmResults results = mRealm.allObjects(Score.class);
-
- RealmLineDataSet lineDataSet = new RealmLineDataSet(results, "totalScore", "scoreNr");
- lineDataSet.setDrawCubic(false);
- lineDataSet.setLabel("Realm LineDataSet");
- lineDataSet.setDrawCircleHole(false);
- lineDataSet.setColor(ColorTemplate.rgb("#FF5722"));
- lineDataSet.setCircleColor(ColorTemplate.rgb("#FF5722"));
- lineDataSet.setLineWidth(1.8f);
- lineDataSet.setCircleSize(3.6f);
-
- ArrayList dataSets = new ArrayList();
- dataSets.add(lineDataSet);
-
- RealmLineData lineData = new RealmLineData(results, "playerName", dataSets);
- styleData(lineData);
-
- // set data
- lineChart.setData(lineData);
- lineChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
-
-
- // BAR-CHART
- RealmBarDataSet barDataSet = new RealmBarDataSet(results, "totalScore", "scoreNr");
- barDataSet.setColors(new int[]{ColorTemplate.rgb("#FF5722"), ColorTemplate.rgb("#03A9F4")});
- barDataSet.setLabel("Realm BarDataSet");
-
- ArrayList barDataSets = new ArrayList();
- barDataSets.add(barDataSet);
-
- RealmBarData barData = new RealmBarData(results, "playerName", barDataSets);
- styleData(barData);
-
- barChart.setData(barData);
- barChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
- }
-}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/Score.java b/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/Score.java
deleted file mode 100644
index cf3afcf46d..0000000000
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/Score.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package com.xxmassdeveloper.mpchartexample.realm;
-
-
-import io.realm.RealmObject;
-
-/**
- * our data object
- */
-public class Score extends RealmObject {
-
- private float totalScore;
-
- private int scoreNr;
-
- private String playerName;
-
- public Score() {
- }
-
- public Score(float totalScore, int scoreNr, String playerName) {
- this.scoreNr = scoreNr;
- this.playerName = playerName;
- this.totalScore = totalScore;
- }
-
- // all getters and setters...
-
- public float getTotalScore() {
- return totalScore;
- }
-
- public void setTotalScore(float totalScore) {
- this.totalScore = totalScore;
- }
-
- public int getScoreNr() {
- return scoreNr;
- }
-
- public void setScoreNr(int scoreNr) {
- this.scoreNr = scoreNr;
- }
-
- public String getPlayerName() {
- return playerName;
- }
-
- public void setPlayerName(String playerName) {
- this.playerName = playerName;
- }
-}
\ No newline at end of file
diff --git a/MPChartExample/src/main/AndroidManifest.xml b/MPChartExample/src/main/AndroidManifest.xml
new file mode 100644
index 0000000000..99334e601a
--- /dev/null
+++ b/MPChartExample/src/main/AndroidManifest.xml
@@ -0,0 +1,57 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/MPChartExample/assets/OpenSans-Bold.ttf b/MPChartExample/src/main/assets/OpenSans-Bold.ttf
similarity index 100%
rename from MPChartExample/assets/OpenSans-Bold.ttf
rename to MPChartExample/src/main/assets/OpenSans-Bold.ttf
diff --git a/MPChartExample/assets/OpenSans-BoldItalic.ttf b/MPChartExample/src/main/assets/OpenSans-BoldItalic.ttf
similarity index 100%
rename from MPChartExample/assets/OpenSans-BoldItalic.ttf
rename to MPChartExample/src/main/assets/OpenSans-BoldItalic.ttf
diff --git a/MPChartExample/assets/OpenSans-ExtraBold.ttf b/MPChartExample/src/main/assets/OpenSans-ExtraBold.ttf
similarity index 100%
rename from MPChartExample/assets/OpenSans-ExtraBold.ttf
rename to MPChartExample/src/main/assets/OpenSans-ExtraBold.ttf
diff --git a/MPChartExample/assets/OpenSans-ExtraBoldItalic.ttf b/MPChartExample/src/main/assets/OpenSans-ExtraBoldItalic.ttf
similarity index 100%
rename from MPChartExample/assets/OpenSans-ExtraBoldItalic.ttf
rename to MPChartExample/src/main/assets/OpenSans-ExtraBoldItalic.ttf
diff --git a/MPChartExample/assets/OpenSans-Italic.ttf b/MPChartExample/src/main/assets/OpenSans-Italic.ttf
similarity index 100%
rename from MPChartExample/assets/OpenSans-Italic.ttf
rename to MPChartExample/src/main/assets/OpenSans-Italic.ttf
diff --git a/MPChartExample/assets/OpenSans-Light.ttf b/MPChartExample/src/main/assets/OpenSans-Light.ttf
similarity index 100%
rename from MPChartExample/assets/OpenSans-Light.ttf
rename to MPChartExample/src/main/assets/OpenSans-Light.ttf
diff --git a/MPChartExample/assets/OpenSans-LightItalic.ttf b/MPChartExample/src/main/assets/OpenSans-LightItalic.ttf
similarity index 100%
rename from MPChartExample/assets/OpenSans-LightItalic.ttf
rename to MPChartExample/src/main/assets/OpenSans-LightItalic.ttf
diff --git a/MPChartExample/assets/OpenSans-Regular.ttf b/MPChartExample/src/main/assets/OpenSans-Regular.ttf
similarity index 100%
rename from MPChartExample/assets/OpenSans-Regular.ttf
rename to MPChartExample/src/main/assets/OpenSans-Regular.ttf
diff --git a/MPChartExample/assets/OpenSans-Semibold.ttf b/MPChartExample/src/main/assets/OpenSans-Semibold.ttf
similarity index 100%
rename from MPChartExample/assets/OpenSans-Semibold.ttf
rename to MPChartExample/src/main/assets/OpenSans-Semibold.ttf
diff --git a/MPChartExample/assets/OpenSans-SemiboldItalic.ttf b/MPChartExample/src/main/assets/OpenSans-SemiboldItalic.ttf
similarity index 100%
rename from MPChartExample/assets/OpenSans-SemiboldItalic.ttf
rename to MPChartExample/src/main/assets/OpenSans-SemiboldItalic.ttf
diff --git a/MPChartExample/assets/cosine.txt b/MPChartExample/src/main/assets/cosine.txt
similarity index 100%
rename from MPChartExample/assets/cosine.txt
rename to MPChartExample/src/main/assets/cosine.txt
diff --git a/MPChartExample/assets/hugecosine.txt b/MPChartExample/src/main/assets/hugecosine.txt
similarity index 100%
rename from MPChartExample/assets/hugecosine.txt
rename to MPChartExample/src/main/assets/hugecosine.txt
diff --git a/MPChartExample/assets/hugesine.txt b/MPChartExample/src/main/assets/hugesine.txt
similarity index 100%
rename from MPChartExample/assets/hugesine.txt
rename to MPChartExample/src/main/assets/hugesine.txt
diff --git a/MPChartExample/assets/n.txt b/MPChartExample/src/main/assets/n.txt
similarity index 100%
rename from MPChartExample/assets/n.txt
rename to MPChartExample/src/main/assets/n.txt
diff --git a/MPChartExample/assets/nlogn.txt b/MPChartExample/src/main/assets/nlogn.txt
similarity index 100%
rename from MPChartExample/assets/nlogn.txt
rename to MPChartExample/src/main/assets/nlogn.txt
diff --git a/MPChartExample/assets/othersine.txt b/MPChartExample/src/main/assets/othersine.txt
similarity index 100%
rename from MPChartExample/assets/othersine.txt
rename to MPChartExample/src/main/assets/othersine.txt
diff --git a/MPChartExample/assets/sine.txt b/MPChartExample/src/main/assets/sine.txt
similarity index 100%
rename from MPChartExample/assets/sine.txt
rename to MPChartExample/src/main/assets/sine.txt
diff --git a/MPChartExample/assets/square.txt b/MPChartExample/src/main/assets/square.txt
similarity index 100%
rename from MPChartExample/assets/square.txt
rename to MPChartExample/src/main/assets/square.txt
diff --git a/MPChartExample/assets/stacked_bars.txt b/MPChartExample/src/main/assets/stacked_bars.txt
similarity index 100%
rename from MPChartExample/assets/stacked_bars.txt
rename to MPChartExample/src/main/assets/stacked_bars.txt
diff --git a/MPChartExample/assets/three.txt b/MPChartExample/src/main/assets/three.txt
similarity index 100%
rename from MPChartExample/assets/three.txt
rename to MPChartExample/src/main/assets/three.txt
diff --git a/MPChartExample/ic_launcher-web.png b/MPChartExample/src/main/ic_launcher-web.png
similarity index 100%
rename from MPChartExample/ic_launcher-web.png
rename to MPChartExample/src/main/ic_launcher-web.png
diff --git a/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/AnotherBarActivity.java b/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/AnotherBarActivity.java
new file mode 100644
index 0000000000..69b5a96c42
--- /dev/null
+++ b/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/AnotherBarActivity.java
@@ -0,0 +1,214 @@
+
+package com.xxmassdeveloper.mpchartexample;
+
+import android.Manifest;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.net.Uri;
+import android.os.Bundle;
+import androidx.core.content.ContextCompat;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.WindowManager;
+import android.widget.SeekBar;
+import android.widget.SeekBar.OnSeekBarChangeListener;
+import android.widget.TextView;
+
+import com.github.mikephil.charting.charts.BarChart;
+import com.github.mikephil.charting.components.XAxis;
+import com.github.mikephil.charting.components.XAxis.XAxisPosition;
+import com.github.mikephil.charting.data.BarData;
+import com.github.mikephil.charting.data.BarDataSet;
+import com.github.mikephil.charting.data.BarEntry;
+import com.github.mikephil.charting.interfaces.datasets.IBarDataSet;
+import com.github.mikephil.charting.interfaces.datasets.IDataSet;
+import com.github.mikephil.charting.utils.ColorTemplate;
+import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
+
+import java.util.ArrayList;
+
+public class AnotherBarActivity extends DemoBase implements OnSeekBarChangeListener {
+
+ private BarChart chart;
+ private SeekBar seekBarX, seekBarY;
+ private TextView tvX, tvY;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
+ WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ setContentView(R.layout.activity_barchart);
+
+ setTitle("AnotherBarActivity");
+
+ tvX = findViewById(R.id.tvXMax);
+ tvY = findViewById(R.id.tvYMax);
+
+ seekBarX = findViewById(R.id.seekBar1);
+ seekBarX.setOnSeekBarChangeListener(this);
+
+ seekBarY = findViewById(R.id.seekBar2);
+ seekBarY.setOnSeekBarChangeListener(this);
+
+ chart = findViewById(R.id.chart1);
+
+ chart.getDescription().setEnabled(false);
+
+ // if more than 60 entries are displayed in the chart, no values will be
+ // drawn
+ chart.setMaxVisibleValueCount(60);
+
+ // scaling can now only be done on x- and y-axis separately
+ chart.setPinchZoom(false);
+
+ chart.setDrawBarShadow(false);
+ chart.setDrawGridBackground(false);
+
+ XAxis xAxis = chart.getXAxis();
+ xAxis.setPosition(XAxisPosition.BOTTOM);
+ xAxis.setDrawGridLines(false);
+
+ chart.getAxisLeft().setDrawGridLines(false);
+
+ // setting data
+ seekBarX.setProgress(10);
+ seekBarY.setProgress(100);
+
+ // add a nice and smooth animation
+ chart.animateY(1500);
+
+ chart.getLegend().setEnabled(false);
+ }
+
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+
+ tvX.setText(String.valueOf(seekBarX.getProgress()));
+ tvY.setText(String.valueOf(seekBarY.getProgress()));
+
+ ArrayList values = new ArrayList<>();
+
+ for (int i = 0; i < seekBarX.getProgress(); i++) {
+ float multi = (seekBarY.getProgress() + 1);
+ float val = (float) (Math.random() * multi) + multi / 3;
+ values.add(new BarEntry(i, val));
+ }
+
+ BarDataSet set1;
+
+ if (chart.getData() != null &&
+ chart.getData().getDataSetCount() > 0) {
+ set1 = (BarDataSet) chart.getData().getDataSetByIndex(0);
+ set1.setValues(values);
+ chart.getData().notifyDataChanged();
+ chart.notifyDataSetChanged();
+ } else {
+ set1 = new BarDataSet(values, "Data Set");
+ set1.setColors(ColorTemplate.VORDIPLOM_COLORS);
+ set1.setDrawValues(false);
+
+ ArrayList dataSets = new ArrayList<>();
+ dataSets.add(set1);
+
+ BarData data = new BarData(dataSets);
+ chart.setData(data);
+ chart.setFitBars(true);
+ }
+
+ chart.invalidate();
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.bar, menu);
+ menu.removeItem(R.id.actionToggleIcons);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+
+ switch (item.getItemId()) {
+ case R.id.viewGithub: {
+ Intent i = new Intent(Intent.ACTION_VIEW);
+ i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/AnotherBarActivity.java"));
+ startActivity(i);
+ break;
+ }
+ case R.id.actionToggleValues: {
+
+ for (IDataSet set : chart.getData().getDataSets())
+ set.setDrawValues(!set.isDrawValuesEnabled());
+
+ chart.invalidate();
+ break;
+ }
+ /*
+ case R.id.actionToggleIcons: { break; }
+ */
+ case R.id.actionToggleHighlight: {
+
+ if(chart.getData() != null) {
+ chart.getData().setHighlightEnabled(!chart.getData().isHighlightEnabled());
+ chart.invalidate();
+ }
+ break;
+ }
+ case R.id.actionTogglePinch: {
+ if (chart.isPinchZoomEnabled())
+ chart.setPinchZoom(false);
+ else
+ chart.setPinchZoom(true);
+
+ chart.invalidate();
+ break;
+ }
+ case R.id.actionToggleAutoScaleMinMax: {
+ chart.setAutoScaleMinMaxEnabled(!chart.isAutoScaleMinMaxEnabled());
+ chart.notifyDataSetChanged();
+ break;
+ }
+ case R.id.actionToggleBarBorders: {
+ for (IBarDataSet set : chart.getData().getDataSets())
+ ((BarDataSet)set).setBarBorderWidth(set.getBarBorderWidth() == 1.f ? 0.f : 1.f);
+
+ chart.invalidate();
+ break;
+ }
+ case R.id.animateX: {
+ chart.animateX(2000);
+ break;
+ }
+ case R.id.animateY: {
+ chart.animateY(2000);
+ break;
+ }
+ case R.id.animateXY: {
+
+ chart.animateXY(2000, 2000);
+ break;
+ }
+ case R.id.actionSave: {
+ if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
+ saveToGallery();
+ } else {
+ requestStoragePermission(chart);
+ }
+ break;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ protected void saveToGallery() {
+ saveToGallery(chart, "AnotherBarActivity");
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {}
+
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {}
+}
diff --git a/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/BarChartActivity.java b/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/BarChartActivity.java
new file mode 100644
index 0000000000..0d83e3444a
--- /dev/null
+++ b/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/BarChartActivity.java
@@ -0,0 +1,327 @@
+
+package com.xxmassdeveloper.mpchartexample;
+
+import android.Manifest;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.graphics.RectF;
+import android.net.Uri;
+import android.os.Bundle;
+import androidx.core.content.ContextCompat;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.WindowManager;
+import android.widget.SeekBar;
+import android.widget.SeekBar.OnSeekBarChangeListener;
+import android.widget.TextView;
+
+import com.github.mikephil.charting.charts.BarChart;
+import com.github.mikephil.charting.components.Legend;
+import com.github.mikephil.charting.components.Legend.LegendForm;
+import com.github.mikephil.charting.components.XAxis;
+import com.github.mikephil.charting.components.XAxis.XAxisPosition;
+import com.github.mikephil.charting.components.YAxis;
+import com.github.mikephil.charting.components.YAxis.AxisDependency;
+import com.github.mikephil.charting.components.YAxis.YAxisLabelPosition;
+import com.github.mikephil.charting.data.BarData;
+import com.github.mikephil.charting.data.BarDataSet;
+import com.github.mikephil.charting.data.BarEntry;
+import com.github.mikephil.charting.data.Entry;
+import com.github.mikephil.charting.formatter.IAxisValueFormatter;
+import com.github.mikephil.charting.highlight.Highlight;
+import com.github.mikephil.charting.interfaces.datasets.IBarDataSet;
+import com.github.mikephil.charting.interfaces.datasets.IDataSet;
+import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
+import com.github.mikephil.charting.utils.Fill;
+import com.github.mikephil.charting.utils.MPPointF;
+import com.xxmassdeveloper.mpchartexample.custom.DayAxisValueFormatter;
+import com.xxmassdeveloper.mpchartexample.custom.MyAxisValueFormatter;
+import com.xxmassdeveloper.mpchartexample.custom.XYMarkerView;
+import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class BarChartActivity extends DemoBase implements OnSeekBarChangeListener,
+ OnChartValueSelectedListener {
+
+ private BarChart chart;
+ private SeekBar seekBarX, seekBarY;
+ private TextView tvX, tvY;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
+ WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ setContentView(R.layout.activity_barchart);
+
+ setTitle("BarChartActivity");
+
+ tvX = findViewById(R.id.tvXMax);
+ tvY = findViewById(R.id.tvYMax);
+
+ seekBarX = findViewById(R.id.seekBar1);
+ seekBarY = findViewById(R.id.seekBar2);
+
+ seekBarY.setOnSeekBarChangeListener(this);
+ seekBarX.setOnSeekBarChangeListener(this);
+
+ chart = findViewById(R.id.chart1);
+ chart.setOnChartValueSelectedListener(this);
+
+ chart.setDrawBarShadow(false);
+ chart.setDrawValueAboveBar(true);
+
+ chart.getDescription().setEnabled(false);
+
+ // if more than 60 entries are displayed in the chart, no values will be
+ // drawn
+ chart.setMaxVisibleValueCount(60);
+
+ // scaling can now only be done on x- and y-axis separately
+ chart.setPinchZoom(false);
+
+ chart.setDrawGridBackground(false);
+ // chart.setDrawYLabels(false);
+
+ IAxisValueFormatter xAxisFormatter = new DayAxisValueFormatter(chart);
+
+ XAxis xAxis = chart.getXAxis();
+ xAxis.setPosition(XAxisPosition.BOTTOM);
+ xAxis.setTypeface(tfLight);
+ xAxis.setDrawGridLines(false);
+ xAxis.setGranularity(1f); // only intervals of 1 day
+ xAxis.setLabelCount(7);
+ xAxis.setValueFormatter(xAxisFormatter);
+
+ IAxisValueFormatter custom = new MyAxisValueFormatter();
+
+ YAxis leftAxis = chart.getAxisLeft();
+ leftAxis.setTypeface(tfLight);
+ leftAxis.setLabelCount(8, false);
+ leftAxis.setValueFormatter(custom);
+ leftAxis.setPosition(YAxisLabelPosition.OUTSIDE_CHART);
+ leftAxis.setSpaceTop(15f);
+ leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
+
+ YAxis rightAxis = chart.getAxisRight();
+ rightAxis.setDrawGridLines(false);
+ rightAxis.setTypeface(tfLight);
+ rightAxis.setLabelCount(8, false);
+ rightAxis.setValueFormatter(custom);
+ rightAxis.setSpaceTop(15f);
+ rightAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
+
+ Legend l = chart.getLegend();
+ l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
+ l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.LEFT);
+ l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
+ l.setDrawInside(false);
+ l.setForm(LegendForm.SQUARE);
+ l.setFormSize(9f);
+ l.setTextSize(11f);
+ l.setXEntrySpace(4f);
+
+ XYMarkerView mv = new XYMarkerView(this, xAxisFormatter);
+ mv.setChartView(chart); // For bounds control
+ chart.setMarker(mv); // Set the marker to the chart
+
+ // setting data
+ seekBarY.setProgress(50);
+ seekBarX.setProgress(12);
+
+ // chart.setDrawLegend(false);
+ }
+
+ private void setData(int count, float range) {
+
+ float start = 1f;
+
+ ArrayList values = new ArrayList<>();
+
+ for (int i = (int) start; i < start + count; i++) {
+ float val = (float) (Math.random() * (range + 1));
+
+ if (Math.random() * 100 < 25) {
+ values.add(new BarEntry(i, val, getResources().getDrawable(R.drawable.star)));
+ } else {
+ values.add(new BarEntry(i, val));
+ }
+ }
+
+ BarDataSet set1;
+
+ if (chart.getData() != null &&
+ chart.getData().getDataSetCount() > 0) {
+ set1 = (BarDataSet) chart.getData().getDataSetByIndex(0);
+ set1.setValues(values);
+ chart.getData().notifyDataChanged();
+ chart.notifyDataSetChanged();
+
+ } else {
+ set1 = new BarDataSet(values, "The year 2017");
+
+ set1.setDrawIcons(false);
+
+ int startColor1 = ContextCompat.getColor(this, android.R.color.holo_orange_light);
+ int startColor2 = ContextCompat.getColor(this, android.R.color.holo_blue_light);
+ int startColor3 = ContextCompat.getColor(this, android.R.color.holo_orange_light);
+ int startColor4 = ContextCompat.getColor(this, android.R.color.holo_green_light);
+ int startColor5 = ContextCompat.getColor(this, android.R.color.holo_red_light);
+ int endColor1 = ContextCompat.getColor(this, android.R.color.holo_blue_dark);
+ int endColor2 = ContextCompat.getColor(this, android.R.color.holo_purple);
+ int endColor3 = ContextCompat.getColor(this, android.R.color.holo_green_dark);
+ int endColor4 = ContextCompat.getColor(this, android.R.color.holo_red_dark);
+ int endColor5 = ContextCompat.getColor(this, android.R.color.holo_orange_dark);
+
+ List gradientFills = new ArrayList<>();
+ gradientFills.add(new Fill(startColor1, endColor1));
+ gradientFills.add(new Fill(startColor2, endColor2));
+ gradientFills.add(new Fill(startColor3, endColor3));
+ gradientFills.add(new Fill(startColor4, endColor4));
+ gradientFills.add(new Fill(startColor5, endColor5));
+
+ set1.setFills(gradientFills);
+
+ ArrayList dataSets = new ArrayList<>();
+ dataSets.add(set1);
+
+ BarData data = new BarData(dataSets);
+ data.setValueTextSize(10f);
+ data.setValueTypeface(tfLight);
+ data.setBarWidth(0.9f);
+
+ chart.setData(data);
+ }
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.bar, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+
+ switch (item.getItemId()) {
+ case R.id.viewGithub: {
+ Intent i = new Intent(Intent.ACTION_VIEW);
+ i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/BarChartActivity.java"));
+ startActivity(i);
+ break;
+ }
+ case R.id.actionToggleValues: {
+ for (IDataSet set : chart.getData().getDataSets())
+ set.setDrawValues(!set.isDrawValuesEnabled());
+
+ chart.invalidate();
+ break;
+ }
+ case R.id.actionToggleIcons: {
+ for (IDataSet set : chart.getData().getDataSets())
+ set.setDrawIcons(!set.isDrawIconsEnabled());
+
+ chart.invalidate();
+ break;
+ }
+ case R.id.actionToggleHighlight: {
+ if (chart.getData() != null) {
+ chart.getData().setHighlightEnabled(!chart.getData().isHighlightEnabled());
+ chart.invalidate();
+ }
+ break;
+ }
+ case R.id.actionTogglePinch: {
+ if (chart.isPinchZoomEnabled())
+ chart.setPinchZoom(false);
+ else
+ chart.setPinchZoom(true);
+
+ chart.invalidate();
+ break;
+ }
+ case R.id.actionToggleAutoScaleMinMax: {
+ chart.setAutoScaleMinMaxEnabled(!chart.isAutoScaleMinMaxEnabled());
+ chart.notifyDataSetChanged();
+ break;
+ }
+ case R.id.actionToggleBarBorders: {
+ for (IBarDataSet set : chart.getData().getDataSets())
+ ((BarDataSet) set).setBarBorderWidth(set.getBarBorderWidth() == 1.f ? 0.f : 1.f);
+
+ chart.invalidate();
+ break;
+ }
+ case R.id.animateX: {
+ chart.animateX(2000);
+ break;
+ }
+ case R.id.animateY: {
+ chart.animateY(2000);
+ break;
+ }
+ case R.id.animateXY: {
+ chart.animateXY(2000, 2000);
+ break;
+ }
+ case R.id.actionSave: {
+ if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
+ saveToGallery();
+ } else {
+ requestStoragePermission(chart);
+ }
+ break;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+
+ tvX.setText(String.valueOf(seekBarX.getProgress()));
+ tvY.setText(String.valueOf(seekBarY.getProgress()));
+
+ setData(seekBarX.getProgress(), seekBarY.getProgress());
+ chart.invalidate();
+ }
+
+ @Override
+ protected void saveToGallery() {
+ saveToGallery(chart, "BarChartActivity");
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {}
+
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {}
+
+ private final RectF onValueSelectedRectF = new RectF();
+
+ @Override
+ public void onValueSelected(Entry e, Highlight h) {
+
+ if (e == null)
+ return;
+
+ RectF bounds = onValueSelectedRectF;
+ chart.getBarBounds((BarEntry) e, bounds);
+ MPPointF position = chart.getPosition(e, AxisDependency.LEFT);
+
+ Log.i("bounds", bounds.toString());
+ Log.i("position", position.toString());
+
+ Log.i("x-index",
+ "low: " + chart.getLowestVisibleX() + ", high: "
+ + chart.getHighestVisibleX());
+
+ MPPointF.recycleInstance(position);
+ }
+
+ @Override
+ public void onNothingSelected() { }
+}
diff --git a/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/BarChartActivityMultiDataset.java b/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/BarChartActivityMultiDataset.java
new file mode 100644
index 0000000000..075af0edbc
--- /dev/null
+++ b/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/BarChartActivityMultiDataset.java
@@ -0,0 +1,289 @@
+
+package com.xxmassdeveloper.mpchartexample;
+
+import android.Manifest;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.graphics.Color;
+import android.net.Uri;
+import android.os.Bundle;
+import androidx.core.content.ContextCompat;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.WindowManager;
+import android.widget.SeekBar;
+import android.widget.SeekBar.OnSeekBarChangeListener;
+import android.widget.TextView;
+
+import com.github.mikephil.charting.charts.BarChart;
+import com.github.mikephil.charting.components.AxisBase;
+import com.github.mikephil.charting.components.Legend;
+import com.github.mikephil.charting.components.XAxis;
+import com.github.mikephil.charting.components.YAxis;
+import com.github.mikephil.charting.data.BarData;
+import com.github.mikephil.charting.data.BarDataSet;
+import com.github.mikephil.charting.data.BarEntry;
+import com.github.mikephil.charting.data.Entry;
+import com.github.mikephil.charting.formatter.IAxisValueFormatter;
+import com.github.mikephil.charting.formatter.LargeValueFormatter;
+import com.github.mikephil.charting.highlight.Highlight;
+import com.github.mikephil.charting.interfaces.datasets.IBarDataSet;
+import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
+import com.xxmassdeveloper.mpchartexample.custom.MyMarkerView;
+import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
+
+import java.util.ArrayList;
+import java.util.Locale;
+
+public class BarChartActivityMultiDataset extends DemoBase implements OnSeekBarChangeListener,
+ OnChartValueSelectedListener {
+
+ private BarChart chart;
+ private SeekBar seekBarX, seekBarY;
+ private TextView tvX, tvY;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
+ WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ setContentView(R.layout.activity_barchart);
+
+ setTitle("BarChartActivityMultiDataset");
+
+ tvX = findViewById(R.id.tvXMax);
+ tvX.setTextSize(10);
+ tvY = findViewById(R.id.tvYMax);
+
+ seekBarX = findViewById(R.id.seekBar1);
+ seekBarX.setMax(50);
+ seekBarX.setOnSeekBarChangeListener(this);
+
+ seekBarY = findViewById(R.id.seekBar2);
+ seekBarY.setOnSeekBarChangeListener(this);
+
+ chart = findViewById(R.id.chart1);
+ chart.setOnChartValueSelectedListener(this);
+ chart.getDescription().setEnabled(false);
+
+// chart.setDrawBorders(true);
+
+ // scaling can now only be done on x- and y-axis separately
+ chart.setPinchZoom(false);
+
+ chart.setDrawBarShadow(false);
+
+ chart.setDrawGridBackground(false);
+
+ // create a custom MarkerView (extend MarkerView) and specify the layout
+ // to use for it
+ MyMarkerView mv = new MyMarkerView(this, R.layout.custom_marker_view);
+ mv.setChartView(chart); // For bounds control
+ chart.setMarker(mv); // Set the marker to the chart
+
+ seekBarX.setProgress(10);
+ seekBarY.setProgress(100);
+
+ Legend l = chart.getLegend();
+ l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
+ l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
+ l.setOrientation(Legend.LegendOrientation.VERTICAL);
+ l.setDrawInside(true);
+ l.setTypeface(tfLight);
+ l.setYOffset(0f);
+ l.setXOffset(10f);
+ l.setYEntrySpace(0f);
+ l.setTextSize(8f);
+
+ XAxis xAxis = chart.getXAxis();
+ xAxis.setTypeface(tfLight);
+ xAxis.setGranularity(1f);
+ xAxis.setCenterAxisLabels(true);
+ xAxis.setValueFormatter(new IAxisValueFormatter() {
+ @Override
+ public String getFormattedValue(float value, AxisBase axis) {
+ return String.valueOf((int) value);
+ }
+ });
+
+ YAxis leftAxis = chart.getAxisLeft();
+ leftAxis.setTypeface(tfLight);
+ leftAxis.setValueFormatter(new LargeValueFormatter());
+ leftAxis.setDrawGridLines(false);
+ leftAxis.setSpaceTop(35f);
+ leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
+
+ chart.getAxisRight().setEnabled(false);
+ }
+
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+
+ float groupSpace = 0.08f;
+ float barSpace = 0.03f; // x4 DataSet
+ float barWidth = 0.2f; // x4 DataSet
+ // (0.2 + 0.03) * 4 + 0.08 = 1.00 -> interval per "group"
+
+ int groupCount = seekBarX.getProgress() + 1;
+ int startYear = 1980;
+ int endYear = startYear + groupCount;
+
+ tvX.setText(String.format(Locale.ENGLISH, "%d-%d", startYear, endYear));
+ tvY.setText(String.valueOf(seekBarY.getProgress()));
+
+ ArrayList values1 = new ArrayList<>();
+ ArrayList values2 = new ArrayList<>();
+ ArrayList values3 = new ArrayList<>();
+ ArrayList values4 = new ArrayList<>();
+
+ float randomMultiplier = seekBarY.getProgress() * 100000f;
+
+ for (int i = startYear; i < endYear; i++) {
+ values1.add(new BarEntry(i, (float) (Math.random() * randomMultiplier)));
+ values2.add(new BarEntry(i, (float) (Math.random() * randomMultiplier)));
+ values3.add(new BarEntry(i, (float) (Math.random() * randomMultiplier)));
+ values4.add(new BarEntry(i, (float) (Math.random() * randomMultiplier)));
+ }
+
+ BarDataSet set1, set2, set3, set4;
+
+ if (chart.getData() != null && chart.getData().getDataSetCount() > 0) {
+
+ set1 = (BarDataSet) chart.getData().getDataSetByIndex(0);
+ set2 = (BarDataSet) chart.getData().getDataSetByIndex(1);
+ set3 = (BarDataSet) chart.getData().getDataSetByIndex(2);
+ set4 = (BarDataSet) chart.getData().getDataSetByIndex(3);
+ set1.setValues(values1);
+ set2.setValues(values2);
+ set3.setValues(values3);
+ set4.setValues(values4);
+ chart.getData().notifyDataChanged();
+ chart.notifyDataSetChanged();
+
+ } else {
+ // create 4 DataSets
+ set1 = new BarDataSet(values1, "Company A");
+ set1.setColor(Color.rgb(104, 241, 175));
+ set2 = new BarDataSet(values2, "Company B");
+ set2.setColor(Color.rgb(164, 228, 251));
+ set3 = new BarDataSet(values3, "Company C");
+ set3.setColor(Color.rgb(242, 247, 158));
+ set4 = new BarDataSet(values4, "Company D");
+ set4.setColor(Color.rgb(255, 102, 0));
+
+ BarData data = new BarData(set1, set2, set3, set4);
+ data.setValueFormatter(new LargeValueFormatter());
+ data.setValueTypeface(tfLight);
+
+ chart.setData(data);
+ }
+
+ // specify the width each bar should have
+ chart.getBarData().setBarWidth(barWidth);
+
+ // restrict the x-axis range
+ chart.getXAxis().setAxisMinimum(startYear);
+
+ // barData.getGroupWith(...) is a helper that calculates the width each group needs based on the provided parameters
+ chart.getXAxis().setAxisMaximum(startYear + chart.getBarData().getGroupWidth(groupSpace, barSpace) * groupCount);
+ chart.groupBars(startYear, groupSpace, barSpace);
+ chart.invalidate();
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.bar, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+
+ switch (item.getItemId()) {
+ case R.id.viewGithub: {
+ Intent i = new Intent(Intent.ACTION_VIEW);
+ i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/BarChartActivityMultiDataset.java"));
+ startActivity(i);
+ break;
+ }
+ case R.id.actionToggleValues: {
+ for (IBarDataSet set : chart.getData().getDataSets())
+ set.setDrawValues(!set.isDrawValuesEnabled());
+
+ chart.invalidate();
+ break;
+ }
+ case R.id.actionTogglePinch: {
+ if (chart.isPinchZoomEnabled())
+ chart.setPinchZoom(false);
+ else
+ chart.setPinchZoom(true);
+
+ chart.invalidate();
+ break;
+ }
+ case R.id.actionToggleAutoScaleMinMax: {
+ chart.setAutoScaleMinMaxEnabled(!chart.isAutoScaleMinMaxEnabled());
+ chart.notifyDataSetChanged();
+ break;
+ }
+ case R.id.actionToggleBarBorders: {
+ for (IBarDataSet set : chart.getData().getDataSets())
+ ((BarDataSet) set).setBarBorderWidth(set.getBarBorderWidth() == 1.f ? 0.f : 1.f);
+
+ chart.invalidate();
+ break;
+ }
+ case R.id.actionToggleHighlight: {
+ if (chart.getData() != null) {
+ chart.getData().setHighlightEnabled(!chart.getData().isHighlightEnabled());
+ chart.invalidate();
+ }
+ break;
+ }
+ case R.id.actionSave: {
+ if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
+ saveToGallery();
+ } else {
+ requestStoragePermission(chart);
+ }
+ break;
+ }
+ case R.id.animateX: {
+ chart.animateX(2000);
+ break;
+ }
+ case R.id.animateY: {
+ chart.animateY(2000);
+ break;
+ }
+ case R.id.animateXY: {
+ chart.animateXY(2000, 2000);
+ break;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ protected void saveToGallery() {
+ saveToGallery(chart, "BarChartActivityMultiDataset");
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {}
+
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {}
+
+ @Override
+ public void onValueSelected(Entry e, Highlight h) {
+ Log.i("Activity", "Selected: " + e.toString() + ", dataSet: " + h.getDataSetIndex());
+ }
+
+ @Override
+ public void onNothingSelected() {
+ Log.i("Activity", "Nothing selected.");
+ }
+}
diff --git a/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/BarChartActivitySinus.java b/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/BarChartActivitySinus.java
new file mode 100644
index 0000000000..95443e8214
--- /dev/null
+++ b/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/BarChartActivitySinus.java
@@ -0,0 +1,239 @@
+
+package com.xxmassdeveloper.mpchartexample;
+
+import android.Manifest;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.graphics.Color;
+import android.net.Uri;
+import android.os.Bundle;
+import androidx.core.content.ContextCompat;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.WindowManager;
+import android.widget.SeekBar;
+import android.widget.SeekBar.OnSeekBarChangeListener;
+import android.widget.TextView;
+
+import com.github.mikephil.charting.charts.BarChart;
+import com.github.mikephil.charting.components.Legend;
+import com.github.mikephil.charting.components.Legend.LegendForm;
+import com.github.mikephil.charting.components.XAxis;
+import com.github.mikephil.charting.components.YAxis;
+import com.github.mikephil.charting.data.BarData;
+import com.github.mikephil.charting.data.BarDataSet;
+import com.github.mikephil.charting.data.BarEntry;
+import com.github.mikephil.charting.interfaces.datasets.IBarDataSet;
+import com.github.mikephil.charting.utils.FileUtils;
+import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class BarChartActivitySinus extends DemoBase implements OnSeekBarChangeListener {
+
+ private BarChart chart;
+ private SeekBar seekBarX;
+ private TextView tvX;
+
+ private List data;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
+ WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ setContentView(R.layout.activity_barchart_sinus);
+
+ setTitle("BarChartActivitySinus");
+
+ data = FileUtils.loadBarEntriesFromAssets(getAssets(), "othersine.txt");
+
+ tvX = findViewById(R.id.tvValueCount);
+
+ seekBarX = findViewById(R.id.seekbarValues);
+
+ chart = findViewById(R.id.chart1);
+
+ chart.setDrawBarShadow(false);
+ chart.setDrawValueAboveBar(true);
+
+ chart.getDescription().setEnabled(false);
+
+ // if more than 60 entries are displayed in the chart, no values will be
+ // drawn
+ chart.setMaxVisibleValueCount(60);
+
+ // scaling can now only be done on x- and y-axis separately
+ chart.setPinchZoom(false);
+
+ // draw shadows for each bar that show the maximum value
+ // chart.setDrawBarShadow(true);
+
+ // chart.setDrawXLabels(false);
+
+ chart.setDrawGridBackground(false);
+ // chart.setDrawYLabels(false);
+
+ XAxis xAxis = chart.getXAxis();
+ xAxis.setEnabled(false);
+
+ YAxis leftAxis = chart.getAxisLeft();
+ leftAxis.setTypeface(tfLight);
+ leftAxis.setLabelCount(6, false);
+ leftAxis.setAxisMinimum(-2.5f);
+ leftAxis.setAxisMaximum(2.5f);
+ leftAxis.setGranularityEnabled(true);
+ leftAxis.setGranularity(0.1f);
+
+ YAxis rightAxis = chart.getAxisRight();
+ rightAxis.setDrawGridLines(false);
+ rightAxis.setTypeface(tfLight);
+ rightAxis.setLabelCount(6, false);
+ rightAxis.setAxisMinimum(-2.5f);
+ rightAxis.setAxisMaximum(2.5f);
+ rightAxis.setGranularity(0.1f);
+
+ seekBarX.setOnSeekBarChangeListener(this);
+ seekBarX.setProgress(150); // set data
+
+ Legend l = chart.getLegend();
+ l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
+ l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.LEFT);
+ l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
+ l.setDrawInside(false);
+ l.setForm(LegendForm.SQUARE);
+ l.setFormSize(9f);
+ l.setTextSize(11f);
+ l.setXEntrySpace(4f);
+
+ chart.animateXY(1500, 1500);
+ }
+
+ private void setData(int count) {
+
+ ArrayList entries = new ArrayList<>();
+
+ for (int i = 0; i < count; i++) {
+ entries.add(data.get(i));
+ }
+
+ BarDataSet set;
+
+ if (chart.getData() != null &&
+ chart.getData().getDataSetCount() > 0) {
+ set = (BarDataSet) chart.getData().getDataSetByIndex(0);
+ set.setValues(entries);
+ chart.getData().notifyDataChanged();
+ chart.notifyDataSetChanged();
+ } else {
+ set = new BarDataSet(entries, "Sinus Function");
+ set.setColor(Color.rgb(240, 120, 124));
+ }
+
+ BarData data = new BarData(set);
+ data.setValueTextSize(10f);
+ data.setValueTypeface(tfLight);
+ data.setDrawValues(false);
+ data.setBarWidth(0.8f);
+
+ chart.setData(data);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.bar, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+
+ switch (item.getItemId()) {
+ case R.id.viewGithub: {
+ Intent i = new Intent(Intent.ACTION_VIEW);
+ i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/BarChartActivitySinus.java"));
+ startActivity(i);
+ break;
+ }
+ case R.id.actionToggleValues: {
+ for (IBarDataSet set : chart.getData().getDataSets())
+ set.setDrawValues(!set.isDrawValuesEnabled());
+
+ chart.invalidate();
+ break;
+ }
+ case R.id.actionToggleHighlight: {
+ if (chart.getData() != null) {
+ chart.getData().setHighlightEnabled(!chart.getData().isHighlightEnabled());
+ chart.invalidate();
+ }
+ break;
+ }
+ case R.id.actionTogglePinch: {
+ if (chart.isPinchZoomEnabled())
+ chart.setPinchZoom(false);
+ else
+ chart.setPinchZoom(true);
+
+ chart.invalidate();
+ break;
+ }
+ case R.id.actionToggleAutoScaleMinMax: {
+ chart.setAutoScaleMinMaxEnabled(!chart.isAutoScaleMinMaxEnabled());
+ chart.notifyDataSetChanged();
+ break;
+ }
+ case R.id.actionToggleBarBorders: {
+ for (IBarDataSet set : chart.getData().getDataSets())
+ ((BarDataSet) set).setBarBorderWidth(set.getBarBorderWidth() == 1.f ? 0.f : 1.f);
+
+ chart.invalidate();
+ break;
+ }
+ case R.id.animateX: {
+ chart.animateX(2000);
+ break;
+ }
+ case R.id.animateY: {
+ chart.animateY(2000);
+ break;
+ }
+ case R.id.animateXY: {
+
+ chart.animateXY(2000, 2000);
+ break;
+ }
+ case R.id.actionSave: {
+ if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
+ saveToGallery();
+ } else {
+ requestStoragePermission(chart);
+ }
+ break;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+
+ tvX.setText(String.valueOf(seekBarX.getProgress()));
+
+ setData(seekBarX.getProgress());
+ chart.invalidate();
+ }
+
+ @Override
+ protected void saveToGallery() {
+ saveToGallery(chart, "BarChartActivitySinus");
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {}
+
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {}
+
+}
diff --git a/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/BarChartPositiveNegative.java b/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/BarChartPositiveNegative.java
new file mode 100644
index 0000000000..4fec7dd6ab
--- /dev/null
+++ b/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/BarChartPositiveNegative.java
@@ -0,0 +1,200 @@
+
+package com.xxmassdeveloper.mpchartexample;
+
+import android.content.Intent;
+import android.graphics.Color;
+import android.net.Uri;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.WindowManager;
+
+import com.github.mikephil.charting.charts.BarChart;
+import com.github.mikephil.charting.components.AxisBase;
+import com.github.mikephil.charting.components.XAxis;
+import com.github.mikephil.charting.components.XAxis.XAxisPosition;
+import com.github.mikephil.charting.components.YAxis;
+import com.github.mikephil.charting.data.BarData;
+import com.github.mikephil.charting.data.BarDataSet;
+import com.github.mikephil.charting.data.BarEntry;
+import com.github.mikephil.charting.data.Entry;
+import com.github.mikephil.charting.formatter.IAxisValueFormatter;
+import com.github.mikephil.charting.formatter.IValueFormatter;
+import com.github.mikephil.charting.utils.ViewPortHandler;
+import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
+
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+public class BarChartPositiveNegative extends DemoBase {
+
+ private BarChart chart;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
+ WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ setContentView(R.layout.activity_barchart_noseekbar);
+
+ setTitle("BarChartPositiveNegative");
+
+ chart = findViewById(R.id.chart1);
+ chart.setBackgroundColor(Color.WHITE);
+ chart.setExtraTopOffset(-30f);
+ chart.setExtraBottomOffset(10f);
+ chart.setExtraLeftOffset(70f);
+ chart.setExtraRightOffset(70f);
+
+ chart.setDrawBarShadow(false);
+ chart.setDrawValueAboveBar(true);
+
+ chart.getDescription().setEnabled(false);
+
+ // scaling can now only be done on x- and y-axis separately
+ chart.setPinchZoom(false);
+
+ chart.setDrawGridBackground(false);
+
+ XAxis xAxis = chart.getXAxis();
+ xAxis.setPosition(XAxisPosition.BOTTOM);
+ xAxis.setTypeface(tfRegular);
+ xAxis.setDrawGridLines(false);
+ xAxis.setDrawAxisLine(false);
+ xAxis.setTextColor(Color.LTGRAY);
+ xAxis.setTextSize(13f);
+ xAxis.setLabelCount(5);
+ xAxis.setCenterAxisLabels(true);
+ xAxis.setGranularity(1f);
+
+ YAxis left = chart.getAxisLeft();
+ left.setDrawLabels(false);
+ left.setSpaceTop(25f);
+ left.setSpaceBottom(25f);
+ left.setDrawAxisLine(false);
+ left.setDrawGridLines(false);
+ left.setDrawZeroLine(true); // draw a zero line
+ left.setZeroLineColor(Color.GRAY);
+ left.setZeroLineWidth(0.7f);
+ chart.getAxisRight().setEnabled(false);
+ chart.getLegend().setEnabled(false);
+
+ // THIS IS THE ORIGINAL DATA YOU WANT TO PLOT
+ final List data = new ArrayList<>();
+ data.add(new Data(0f, -224.1f, "12-29"));
+ data.add(new Data(1f, 238.5f, "12-30"));
+ data.add(new Data(2f, 1280.1f, "12-31"));
+ data.add(new Data(3f, -442.3f, "01-01"));
+ data.add(new Data(4f, -2280.1f, "01-02"));
+
+ xAxis.setValueFormatter(new IAxisValueFormatter() {
+ @Override
+ public String getFormattedValue(float value, AxisBase axis) {
+ return data.get(Math.min(Math.max((int) value, 0), data.size()-1)).xAxisValue;
+ }
+ });
+
+ setData(data);
+ }
+
+ private void setData(List dataList) {
+
+ ArrayList values = new ArrayList<>();
+ List colors = new ArrayList<>();
+
+ int green = Color.rgb(110, 190, 102);
+ int red = Color.rgb(211, 74, 88);
+
+ for (int i = 0; i < dataList.size(); i++) {
+
+ Data d = dataList.get(i);
+ BarEntry entry = new BarEntry(d.xValue, d.yValue);
+ values.add(entry);
+
+ // specific colors
+ if (d.yValue >= 0)
+ colors.add(red);
+ else
+ colors.add(green);
+ }
+
+ BarDataSet set;
+
+ if (chart.getData() != null &&
+ chart.getData().getDataSetCount() > 0) {
+ set = (BarDataSet) chart.getData().getDataSetByIndex(0);
+ set.setValues(values);
+ chart.getData().notifyDataChanged();
+ chart.notifyDataSetChanged();
+ } else {
+ set = new BarDataSet(values, "Values");
+ set.setColors(colors);
+ set.setValueTextColors(colors);
+
+ BarData data = new BarData(set);
+ data.setValueTextSize(13f);
+ data.setValueTypeface(tfRegular);
+ data.setValueFormatter(new ValueFormatter());
+ data.setBarWidth(0.8f);
+
+ chart.setData(data);
+ chart.invalidate();
+ }
+ }
+
+ /**
+ * Demo class representing data.
+ */
+ private class Data {
+
+ final String xAxisValue;
+ final float yValue;
+ final float xValue;
+
+ Data(float xValue, float yValue, String xAxisValue) {
+ this.xAxisValue = xAxisValue;
+ this.yValue = yValue;
+ this.xValue = xValue;
+ }
+ }
+
+ private class ValueFormatter implements IValueFormatter
+ {
+
+ private final DecimalFormat mFormat;
+
+ ValueFormatter() {
+ mFormat = new DecimalFormat("######.0");
+ }
+
+ @Override
+ public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
+ return mFormat.format(value);
+ }
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.only_github, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+
+ switch (item.getItemId()) {
+ case R.id.viewGithub: {
+ Intent i = new Intent(Intent.ACTION_VIEW);
+ i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/BarChartPositiveNegative.java"));
+ startActivity(i);
+ break;
+ }
+ }
+
+ return true;
+ }
+
+ @Override
+ public void saveToGallery() { /* Intentionally left empty */ }
+}
diff --git a/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/BubbleChartActivity.java b/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/BubbleChartActivity.java
new file mode 100644
index 0000000000..6288dda2be
--- /dev/null
+++ b/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/BubbleChartActivity.java
@@ -0,0 +1,248 @@
+
+package com.xxmassdeveloper.mpchartexample;
+
+import android.Manifest;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.graphics.Color;
+import android.net.Uri;
+import android.os.Bundle;
+import androidx.core.content.ContextCompat;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.WindowManager;
+import android.widget.SeekBar;
+import android.widget.SeekBar.OnSeekBarChangeListener;
+import android.widget.TextView;
+
+import com.github.mikephil.charting.charts.BubbleChart;
+import com.github.mikephil.charting.components.Legend;
+import com.github.mikephil.charting.components.XAxis;
+import com.github.mikephil.charting.components.YAxis;
+import com.github.mikephil.charting.data.BubbleData;
+import com.github.mikephil.charting.data.BubbleDataSet;
+import com.github.mikephil.charting.data.BubbleEntry;
+import com.github.mikephil.charting.data.Entry;
+import com.github.mikephil.charting.highlight.Highlight;
+import com.github.mikephil.charting.interfaces.datasets.IBubbleDataSet;
+import com.github.mikephil.charting.interfaces.datasets.IDataSet;
+import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
+import com.github.mikephil.charting.utils.ColorTemplate;
+import com.github.mikephil.charting.utils.MPPointF;
+import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
+
+import java.util.ArrayList;
+
+public class BubbleChartActivity extends DemoBase implements OnSeekBarChangeListener,
+ OnChartValueSelectedListener {
+
+ private BubbleChart chart;
+ private SeekBar seekBarX, seekBarY;
+ private TextView tvX, tvY;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
+ WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ setContentView(R.layout.activity_bubblechart);
+
+ setTitle("BubbleChartActivity");
+
+ tvX = findViewById(R.id.tvXMax);
+ tvY = findViewById(R.id.tvYMax);
+
+ seekBarX = findViewById(R.id.seekBar1);
+ seekBarX.setOnSeekBarChangeListener(this);
+
+ seekBarY = findViewById(R.id.seekBar2);
+ seekBarY.setOnSeekBarChangeListener(this);
+
+ chart = findViewById(R.id.chart1);
+ chart.getDescription().setEnabled(false);
+
+ chart.setOnChartValueSelectedListener(this);
+
+ chart.setDrawGridBackground(false);
+
+ chart.setTouchEnabled(true);
+
+ // enable scaling and dragging
+ chart.setDragEnabled(true);
+ chart.setScaleEnabled(true);
+
+ chart.setMaxVisibleValueCount(200);
+ chart.setPinchZoom(true);
+
+ seekBarX.setProgress(10);
+ seekBarY.setProgress(50);
+
+ Legend l = chart.getLegend();
+ l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
+ l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
+ l.setOrientation(Legend.LegendOrientation.VERTICAL);
+ l.setDrawInside(false);
+ l.setTypeface(tfLight);
+
+ YAxis yl = chart.getAxisLeft();
+ yl.setTypeface(tfLight);
+ yl.setSpaceTop(30f);
+ yl.setSpaceBottom(30f);
+ yl.setDrawZeroLine(false);
+
+ chart.getAxisRight().setEnabled(false);
+
+ XAxis xl = chart.getXAxis();
+ xl.setPosition(XAxis.XAxisPosition.BOTTOM);
+ xl.setTypeface(tfLight);
+ }
+
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+
+ int count = seekBarX.getProgress();
+ int range = seekBarY.getProgress();
+
+ tvX.setText(String.valueOf(count));
+ tvY.setText(String.valueOf(range));
+
+ ArrayList values1 = new ArrayList<>();
+ ArrayList values2 = new ArrayList<>();
+ ArrayList values3 = new ArrayList<>();
+
+ for (int i = 0; i < count; i++) {
+ values1.add(new BubbleEntry(i, (float) (Math.random() * range), (float) (Math.random() * range), getResources().getDrawable(R.drawable.star)));
+ values2.add(new BubbleEntry(i, (float) (Math.random() * range), (float) (Math.random() * range), getResources().getDrawable(R.drawable.star)));
+ values3.add(new BubbleEntry(i, (float) (Math.random() * range), (float) (Math.random() * range)));
+ }
+
+ // create a dataset and give it a type
+ BubbleDataSet set1 = new BubbleDataSet(values1, "DS 1");
+ set1.setDrawIcons(false);
+ set1.setColor(ColorTemplate.COLORFUL_COLORS[0], 130);
+ set1.setDrawValues(true);
+
+ BubbleDataSet set2 = new BubbleDataSet(values2, "DS 2");
+ set2.setDrawIcons(false);
+ set2.setIconsOffset(new MPPointF(0, 15));
+ set2.setColor(ColorTemplate.COLORFUL_COLORS[1], 130);
+ set2.setDrawValues(true);
+
+ BubbleDataSet set3 = new BubbleDataSet(values3, "DS 3");
+ set3.setColor(ColorTemplate.COLORFUL_COLORS[2], 130);
+ set3.setDrawValues(true);
+
+ ArrayList dataSets = new ArrayList<>();
+ dataSets.add(set1); // add the data sets
+ dataSets.add(set2);
+ dataSets.add(set3);
+
+ // create a data object with the data sets
+ BubbleData data = new BubbleData(dataSets);
+ data.setDrawValues(false);
+ data.setValueTypeface(tfLight);
+ data.setValueTextSize(8f);
+ data.setValueTextColor(Color.WHITE);
+ data.setHighlightCircleWidth(1.5f);
+
+ chart.setData(data);
+ chart.invalidate();
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.bubble, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+
+ switch (item.getItemId()) {
+ case R.id.viewGithub: {
+ Intent i = new Intent(Intent.ACTION_VIEW);
+ i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/BubbleChartActivity.java"));
+ startActivity(i);
+ break;
+ }
+ case R.id.actionToggleValues: {
+ for (IDataSet set : chart.getData().getDataSets())
+ set.setDrawValues(!set.isDrawValuesEnabled());
+
+ chart.invalidate();
+ break;
+ }
+ case R.id.actionToggleIcons: {
+ for (IDataSet set : chart.getData().getDataSets())
+ set.setDrawIcons(!set.isDrawIconsEnabled());
+
+ chart.invalidate();
+ break;
+ }
+ case R.id.actionToggleHighlight: {
+ if(chart.getData() != null) {
+ chart.getData().setHighlightEnabled(!chart.getData().isHighlightEnabled());
+ chart.invalidate();
+ }
+ break;
+ }
+ case R.id.actionTogglePinch: {
+ if (chart.isPinchZoomEnabled())
+ chart.setPinchZoom(false);
+ else
+ chart.setPinchZoom(true);
+
+ chart.invalidate();
+ break;
+ }
+ case R.id.actionToggleAutoScaleMinMax: {
+ chart.setAutoScaleMinMaxEnabled(!chart.isAutoScaleMinMaxEnabled());
+ chart.notifyDataSetChanged();
+ break;
+ }
+ case R.id.actionSave: {
+ if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
+ saveToGallery();
+ } else {
+ requestStoragePermission(chart);
+ }
+ break;
+ }
+ case R.id.animateX: {
+ chart.animateX(2000);
+ break;
+ }
+ case R.id.animateY: {
+ chart.animateY(2000);
+ break;
+ }
+ case R.id.animateXY: {
+ chart.animateXY(2000, 2000);
+ break;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ protected void saveToGallery() {
+ saveToGallery(chart, "BubbleChartActivity");
+ }
+
+ @Override
+ public void onValueSelected(Entry e, Highlight h) {
+ Log.i("VAL SELECTED",
+ "Value: " + e.getY() + ", xIndex: " + e.getX()
+ + ", DataSet index: " + h.getDataSetIndex());
+ }
+
+ @Override
+ public void onNothingSelected() {}
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {}
+
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {}
+}
diff --git a/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/CandleStickChartActivity.java b/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/CandleStickChartActivity.java
new file mode 100644
index 0000000000..ecf7167a62
--- /dev/null
+++ b/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/CandleStickChartActivity.java
@@ -0,0 +1,238 @@
+
+package com.xxmassdeveloper.mpchartexample;
+
+import android.Manifest;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.net.Uri;
+import android.os.Bundle;
+import androidx.core.content.ContextCompat;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.WindowManager;
+import android.widget.SeekBar;
+import android.widget.SeekBar.OnSeekBarChangeListener;
+import android.widget.TextView;
+
+import com.github.mikephil.charting.charts.CandleStickChart;
+import com.github.mikephil.charting.components.XAxis;
+import com.github.mikephil.charting.components.XAxis.XAxisPosition;
+import com.github.mikephil.charting.components.YAxis;
+import com.github.mikephil.charting.components.YAxis.AxisDependency;
+import com.github.mikephil.charting.data.CandleData;
+import com.github.mikephil.charting.data.CandleDataSet;
+import com.github.mikephil.charting.data.CandleEntry;
+import com.github.mikephil.charting.interfaces.datasets.ICandleDataSet;
+import com.github.mikephil.charting.interfaces.datasets.IDataSet;
+import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
+
+import java.util.ArrayList;
+
+public class CandleStickChartActivity extends DemoBase implements OnSeekBarChangeListener {
+
+ private CandleStickChart chart;
+ private SeekBar seekBarX, seekBarY;
+ private TextView tvX, tvY;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
+ WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ setContentView(R.layout.activity_candlechart);
+
+ setTitle("CandleStickChartActivity");
+
+ tvX = findViewById(R.id.tvXMax);
+ tvY = findViewById(R.id.tvYMax);
+
+ seekBarX = findViewById(R.id.seekBar1);
+ seekBarX.setOnSeekBarChangeListener(this);
+
+ seekBarY = findViewById(R.id.seekBar2);
+ seekBarY.setOnSeekBarChangeListener(this);
+
+ chart = findViewById(R.id.chart1);
+ chart.setBackgroundColor(Color.WHITE);
+
+ chart.getDescription().setEnabled(false);
+
+ // if more than 60 entries are displayed in the chart, no values will be
+ // drawn
+ chart.setMaxVisibleValueCount(60);
+
+ // scaling can now only be done on x- and y-axis separately
+ chart.setPinchZoom(false);
+
+ chart.setDrawGridBackground(false);
+
+ XAxis xAxis = chart.getXAxis();
+ xAxis.setPosition(XAxisPosition.BOTTOM);
+ xAxis.setDrawGridLines(false);
+
+ YAxis leftAxis = chart.getAxisLeft();
+// leftAxis.setEnabled(false);
+ leftAxis.setLabelCount(7, false);
+ leftAxis.setDrawGridLines(false);
+ leftAxis.setDrawAxisLine(false);
+
+ YAxis rightAxis = chart.getAxisRight();
+ rightAxis.setEnabled(false);
+// rightAxis.setStartAtZero(false);
+
+ // setting data
+ seekBarX.setProgress(40);
+ seekBarY.setProgress(100);
+
+ chart.getLegend().setEnabled(false);
+ }
+
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+
+ progress = (seekBarX.getProgress());
+
+ tvX.setText(String.valueOf(progress));
+ tvY.setText(String.valueOf(seekBarY.getProgress()));
+
+ chart.resetTracking();
+
+ ArrayList values = new ArrayList<>();
+
+ for (int i = 0; i < progress; i++) {
+ float multi = (seekBarY.getProgress() + 1);
+ float val = (float) (Math.random() * 40) + multi;
+
+ float high = (float) (Math.random() * 9) + 8f;
+ float low = (float) (Math.random() * 9) + 8f;
+
+ float open = (float) (Math.random() * 6) + 1f;
+ float close = (float) (Math.random() * 6) + 1f;
+
+ boolean even = i % 2 == 0;
+
+ values.add(new CandleEntry(
+ i, val + high,
+ val - low,
+ even ? val + open : val - open,
+ even ? val - close : val + close,
+ getResources().getDrawable(R.drawable.star)
+ ));
+ }
+
+ CandleDataSet set1 = new CandleDataSet(values, "Data Set");
+
+ set1.setDrawIcons(false);
+ set1.setAxisDependency(AxisDependency.LEFT);
+// set1.setColor(Color.rgb(80, 80, 80));
+ set1.setShadowColor(Color.DKGRAY);
+ set1.setShadowWidth(0.7f);
+ set1.setDecreasingColor(Color.RED);
+ set1.setDecreasingPaintStyle(Paint.Style.FILL);
+ set1.setIncreasingColor(Color.rgb(122, 242, 84));
+ set1.setIncreasingPaintStyle(Paint.Style.STROKE);
+ set1.setNeutralColor(Color.BLUE);
+ //set1.setHighlightLineWidth(1f);
+
+ CandleData data = new CandleData(set1);
+
+ chart.setData(data);
+ chart.invalidate();
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.candle, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+
+ switch (item.getItemId()) {
+ case R.id.viewGithub: {
+ Intent i = new Intent(Intent.ACTION_VIEW);
+ i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/CandleStickChartActivity.java"));
+ startActivity(i);
+ break;
+ }
+ case R.id.actionToggleValues: {
+ for (IDataSet set : chart.getData().getDataSets())
+ set.setDrawValues(!set.isDrawValuesEnabled());
+
+ chart.invalidate();
+ break;
+ }
+ case R.id.actionToggleIcons: {
+ for (IDataSet set : chart.getData().getDataSets())
+ set.setDrawIcons(!set.isDrawIconsEnabled());
+
+ chart.invalidate();
+ break;
+ }
+ case R.id.actionToggleHighlight: {
+ if(chart.getData() != null) {
+ chart.getData().setHighlightEnabled(!chart.getData().isHighlightEnabled());
+ chart.invalidate();
+ }
+ break;
+ }
+ case R.id.actionTogglePinch: {
+ if (chart.isPinchZoomEnabled())
+ chart.setPinchZoom(false);
+ else
+ chart.setPinchZoom(true);
+
+ chart.invalidate();
+ break;
+ }
+ case R.id.actionToggleAutoScaleMinMax: {
+ chart.setAutoScaleMinMaxEnabled(!chart.isAutoScaleMinMaxEnabled());
+ chart.notifyDataSetChanged();
+ break;
+ }
+ case R.id.actionToggleMakeShadowSameColorAsCandle: {
+ for (ICandleDataSet set : chart.getData().getDataSets()) {
+ ((CandleDataSet) set).setShadowColorSameAsCandle(!set.getShadowColorSameAsCandle());
+ }
+
+ chart.invalidate();
+ break;
+ }
+ case R.id.animateX: {
+ chart.animateX(2000);
+ break;
+ }
+ case R.id.animateY: {
+ chart.animateY(2000);
+ break;
+ }
+ case R.id.animateXY: {
+ chart.animateXY(2000, 2000);
+ break;
+ }
+ case R.id.actionSave: {
+ if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
+ saveToGallery();
+ } else {
+ requestStoragePermission(chart);
+ }
+ break;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ protected void saveToGallery() {
+ saveToGallery(chart, "CandleStickChartActivity");
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {}
+
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {}
+}
diff --git a/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/CombinedChartActivity.java b/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/CombinedChartActivity.java
new file mode 100644
index 0000000000..0308b9a891
--- /dev/null
+++ b/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/CombinedChartActivity.java
@@ -0,0 +1,282 @@
+
+package com.xxmassdeveloper.mpchartexample;
+
+import android.content.Intent;
+import android.graphics.Color;
+import android.net.Uri;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.WindowManager;
+
+import com.github.mikephil.charting.charts.CombinedChart;
+import com.github.mikephil.charting.charts.CombinedChart.DrawOrder;
+import com.github.mikephil.charting.components.AxisBase;
+import com.github.mikephil.charting.components.Legend;
+import com.github.mikephil.charting.components.XAxis;
+import com.github.mikephil.charting.components.XAxis.XAxisPosition;
+import com.github.mikephil.charting.components.YAxis;
+import com.github.mikephil.charting.data.BarData;
+import com.github.mikephil.charting.data.BarDataSet;
+import com.github.mikephil.charting.data.BarEntry;
+import com.github.mikephil.charting.data.BubbleData;
+import com.github.mikephil.charting.data.BubbleDataSet;
+import com.github.mikephil.charting.data.BubbleEntry;
+import com.github.mikephil.charting.data.CandleData;
+import com.github.mikephil.charting.data.CandleDataSet;
+import com.github.mikephil.charting.data.CandleEntry;
+import com.github.mikephil.charting.data.CombinedData;
+import com.github.mikephil.charting.data.Entry;
+import com.github.mikephil.charting.data.LineData;
+import com.github.mikephil.charting.data.LineDataSet;
+import com.github.mikephil.charting.data.ScatterData;
+import com.github.mikephil.charting.data.ScatterDataSet;
+import com.github.mikephil.charting.formatter.IAxisValueFormatter;
+import com.github.mikephil.charting.interfaces.datasets.IDataSet;
+import com.github.mikephil.charting.utils.ColorTemplate;
+import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
+
+import java.util.ArrayList;
+
+public class CombinedChartActivity extends DemoBase {
+
+ private CombinedChart chart;
+ private final int count = 12;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
+ WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ setContentView(R.layout.activity_combined);
+
+ setTitle("CombinedChartActivity");
+
+ chart = findViewById(R.id.chart1);
+ chart.getDescription().setEnabled(false);
+ chart.setBackgroundColor(Color.WHITE);
+ chart.setDrawGridBackground(false);
+ chart.setDrawBarShadow(false);
+ chart.setHighlightFullBarEnabled(false);
+
+ // draw bars behind lines
+ chart.setDrawOrder(new DrawOrder[]{
+ DrawOrder.BAR, DrawOrder.BUBBLE, DrawOrder.CANDLE, DrawOrder.LINE, DrawOrder.SCATTER
+ });
+
+ Legend l = chart.getLegend();
+ l.setWordWrapEnabled(true);
+ l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
+ l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
+ l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
+ l.setDrawInside(false);
+
+ YAxis rightAxis = chart.getAxisRight();
+ rightAxis.setDrawGridLines(false);
+ rightAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
+
+ YAxis leftAxis = chart.getAxisLeft();
+ leftAxis.setDrawGridLines(false);
+ leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
+
+ XAxis xAxis = chart.getXAxis();
+ xAxis.setPosition(XAxisPosition.BOTH_SIDED);
+ xAxis.setAxisMinimum(0f);
+ xAxis.setGranularity(1f);
+ xAxis.setValueFormatter(new IAxisValueFormatter() {
+ @Override
+ public String getFormattedValue(float value, AxisBase axis) {
+ return months[(int) value % months.length];
+ }
+ });
+
+ CombinedData data = new CombinedData();
+
+ data.setData(generateLineData());
+ data.setData(generateBarData());
+ data.setData(generateBubbleData());
+ data.setData(generateScatterData());
+ data.setData(generateCandleData());
+ data.setValueTypeface(tfLight);
+
+ xAxis.setAxisMaximum(data.getXMax() + 0.25f);
+
+ chart.setData(data);
+ chart.invalidate();
+ }
+
+ private LineData generateLineData() {
+
+ LineData d = new LineData();
+
+ ArrayList entries = new ArrayList<>();
+
+ for (int index = 0; index < count; index++)
+ entries.add(new Entry(index + 0.5f, getRandom(15, 5)));
+
+ LineDataSet set = new LineDataSet(entries, "Line DataSet");
+ set.setColor(Color.rgb(240, 238, 70));
+ set.setLineWidth(2.5f);
+ set.setCircleColor(Color.rgb(240, 238, 70));
+ set.setCircleRadius(5f);
+ set.setFillColor(Color.rgb(240, 238, 70));
+ set.setMode(LineDataSet.Mode.CUBIC_BEZIER);
+ set.setDrawValues(true);
+ set.setValueTextSize(10f);
+ set.setValueTextColor(Color.rgb(240, 238, 70));
+
+ set.setAxisDependency(YAxis.AxisDependency.LEFT);
+ d.addDataSet(set);
+
+ return d;
+ }
+
+ private BarData generateBarData() {
+
+ ArrayList entries1 = new ArrayList<>();
+ ArrayList entries2 = new ArrayList<>();
+
+ for (int index = 0; index < count; index++) {
+ entries1.add(new BarEntry(0, getRandom(25, 25)));
+
+ // stacked
+ entries2.add(new BarEntry(0, new float[]{getRandom(13, 12), getRandom(13, 12)}));
+ }
+
+ BarDataSet set1 = new BarDataSet(entries1, "Bar 1");
+ set1.setColor(Color.rgb(60, 220, 78));
+ set1.setValueTextColor(Color.rgb(60, 220, 78));
+ set1.setValueTextSize(10f);
+ set1.setAxisDependency(YAxis.AxisDependency.LEFT);
+
+ BarDataSet set2 = new BarDataSet(entries2, "");
+ set2.setStackLabels(new String[]{"Stack 1", "Stack 2"});
+ set2.setColors(Color.rgb(61, 165, 255), Color.rgb(23, 197, 255));
+ set2.setValueTextColor(Color.rgb(61, 165, 255));
+ set2.setValueTextSize(10f);
+ set2.setAxisDependency(YAxis.AxisDependency.LEFT);
+
+ float groupSpace = 0.06f;
+ float barSpace = 0.02f; // x2 dataset
+ float barWidth = 0.45f; // x2 dataset
+ // (0.45 + 0.02) * 2 + 0.06 = 1.00 -> interval per "group"
+
+ BarData d = new BarData(set1, set2);
+ d.setBarWidth(barWidth);
+
+ // make this BarData object grouped
+ d.groupBars(0, groupSpace, barSpace); // start at x = 0
+
+ return d;
+ }
+
+ private ScatterData generateScatterData() {
+
+ ScatterData d = new ScatterData();
+
+ ArrayList entries = new ArrayList<>();
+
+ for (float index = 0; index < count; index += 0.5f)
+ entries.add(new Entry(index + 0.25f, getRandom(10, 55)));
+
+ ScatterDataSet set = new ScatterDataSet(entries, "Scatter DataSet");
+ set.setColors(ColorTemplate.MATERIAL_COLORS);
+ set.setScatterShapeSize(7.5f);
+ set.setDrawValues(false);
+ set.setValueTextSize(10f);
+ d.addDataSet(set);
+
+ return d;
+ }
+
+ private CandleData generateCandleData() {
+
+ CandleData d = new CandleData();
+
+ ArrayList entries = new ArrayList<>();
+
+ for (int index = 0; index < count; index += 2)
+ entries.add(new CandleEntry(index + 1f, 90, 70, 85, 75f));
+
+ CandleDataSet set = new CandleDataSet(entries, "Candle DataSet");
+ set.setDecreasingColor(Color.rgb(142, 150, 175));
+ set.setShadowColor(Color.DKGRAY);
+ set.setBarSpace(0.3f);
+ set.setValueTextSize(10f);
+ set.setDrawValues(false);
+ d.addDataSet(set);
+
+ return d;
+ }
+
+ private BubbleData generateBubbleData() {
+
+ BubbleData bd = new BubbleData();
+
+ ArrayList entries = new ArrayList<>();
+
+ for (int index = 0; index < count; index++) {
+ float y = getRandom(10, 105);
+ float size = getRandom(100, 105);
+ entries.add(new BubbleEntry(index + 0.5f, y, size));
+ }
+
+ BubbleDataSet set = new BubbleDataSet(entries, "Bubble DataSet");
+ set.setColors(ColorTemplate.VORDIPLOM_COLORS);
+ set.setValueTextSize(10f);
+ set.setValueTextColor(Color.WHITE);
+ set.setHighlightCircleWidth(1.5f);
+ set.setDrawValues(true);
+ bd.addDataSet(set);
+
+ return bd;
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.combined, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.viewGithub: {
+ Intent i = new Intent(Intent.ACTION_VIEW);
+ i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/CombinedChartActivity.java"));
+ startActivity(i);
+ break;
+ }
+ case R.id.actionToggleLineValues: {
+ for (IDataSet set : chart.getData().getDataSets()) {
+ if (set instanceof LineDataSet)
+ set.setDrawValues(!set.isDrawValuesEnabled());
+ }
+
+ chart.invalidate();
+ break;
+ }
+ case R.id.actionToggleBarValues: {
+ for (IDataSet set : chart.getData().getDataSets()) {
+ if (set instanceof BarDataSet)
+ set.setDrawValues(!set.isDrawValuesEnabled());
+ }
+
+ chart.invalidate();
+ break;
+ }
+ case R.id.actionRemoveDataSet: {
+ int rnd = (int) getRandom(chart.getData().getDataSetCount(), 0);
+ chart.getData().removeDataSet(chart.getData().getDataSetByIndex(rnd));
+ chart.getData().notifyDataChanged();
+ chart.notifyDataSetChanged();
+ chart.invalidate();
+ break;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public void saveToGallery() { /* Intentionally left empty */ }
+}
diff --git a/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/CubicLineChartActivity.java b/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/CubicLineChartActivity.java
new file mode 100644
index 0000000000..996e088f43
--- /dev/null
+++ b/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/CubicLineChartActivity.java
@@ -0,0 +1,320 @@
+
+package com.xxmassdeveloper.mpchartexample;
+
+import android.Manifest;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.graphics.Color;
+import android.net.Uri;
+import android.os.Bundle;
+import androidx.core.content.ContextCompat;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.WindowManager;
+import android.widget.SeekBar;
+import android.widget.SeekBar.OnSeekBarChangeListener;
+import android.widget.TextView;
+
+import com.github.mikephil.charting.charts.LineChart;
+import com.github.mikephil.charting.components.XAxis;
+import com.github.mikephil.charting.components.YAxis;
+import com.github.mikephil.charting.data.Entry;
+import com.github.mikephil.charting.data.LineData;
+import com.github.mikephil.charting.data.LineDataSet;
+import com.github.mikephil.charting.formatter.IFillFormatter;
+import com.github.mikephil.charting.interfaces.dataprovider.LineDataProvider;
+import com.github.mikephil.charting.interfaces.datasets.IDataSet;
+import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
+import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class CubicLineChartActivity extends DemoBase implements OnSeekBarChangeListener {
+
+ private LineChart chart;
+ private SeekBar seekBarX, seekBarY;
+ private TextView tvX, tvY;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
+ WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ setContentView(R.layout.activity_linechart);
+
+ setTitle("CubicLineChartActivity");
+
+ tvX = findViewById(R.id.tvXMax);
+ tvY = findViewById(R.id.tvYMax);
+
+ seekBarX = findViewById(R.id.seekBar1);
+ seekBarY = findViewById(R.id.seekBar2);
+
+ chart = findViewById(R.id.chart1);
+ chart.setViewPortOffsets(0, 0, 0, 0);
+ chart.setBackgroundColor(Color.rgb(104, 241, 175));
+
+ // no description text
+ chart.getDescription().setEnabled(false);
+
+ // enable touch gestures
+ chart.setTouchEnabled(true);
+
+ // enable scaling and dragging
+ chart.setDragEnabled(true);
+ chart.setScaleEnabled(true);
+
+ // if disabled, scaling can be done on x- and y-axis separately
+ chart.setPinchZoom(false);
+
+ chart.setDrawGridBackground(false);
+ chart.setMaxHighlightDistance(300);
+
+ XAxis x = chart.getXAxis();
+ x.setEnabled(false);
+
+ YAxis y = chart.getAxisLeft();
+ y.setTypeface(tfLight);
+ y.setLabelCount(6, false);
+ y.setTextColor(Color.WHITE);
+ y.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
+ y.setDrawGridLines(false);
+ y.setAxisLineColor(Color.WHITE);
+
+ chart.getAxisRight().setEnabled(false);
+
+ // add data
+ seekBarY.setOnSeekBarChangeListener(this);
+ seekBarX.setOnSeekBarChangeListener(this);
+
+ // lower max, as cubic runs significantly slower than linear
+ seekBarX.setMax(700);
+
+ seekBarX.setProgress(45);
+ seekBarY.setProgress(100);
+
+ chart.getLegend().setEnabled(false);
+
+ chart.animateXY(2000, 2000);
+
+ // don't forget to refresh the drawing
+ chart.invalidate();
+ }
+
+ private void setData(int count, float range) {
+
+ ArrayList values = new ArrayList<>();
+
+ for (int i = 0; i < count; i++) {
+ float val = (float) (Math.random() * (range + 1)) + 20;
+ values.add(new Entry(i, val));
+ }
+
+ LineDataSet set1;
+
+ if (chart.getData() != null &&
+ chart.getData().getDataSetCount() > 0) {
+ set1 = (LineDataSet) chart.getData().getDataSetByIndex(0);
+ set1.setValues(values);
+ chart.getData().notifyDataChanged();
+ chart.notifyDataSetChanged();
+ } else {
+ // create a dataset and give it a type
+ set1 = new LineDataSet(values, "DataSet 1");
+
+ set1.setMode(LineDataSet.Mode.CUBIC_BEZIER);
+ set1.setCubicIntensity(0.2f);
+ set1.setDrawFilled(true);
+ set1.setDrawCircles(false);
+ set1.setLineWidth(1.8f);
+ set1.setCircleRadius(4f);
+ set1.setCircleColor(Color.WHITE);
+ set1.setHighLightColor(Color.rgb(244, 117, 117));
+ set1.setColor(Color.WHITE);
+ set1.setFillColor(Color.WHITE);
+ set1.setFillAlpha(100);
+ set1.setDrawHorizontalHighlightIndicator(false);
+ set1.setFillFormatter(new IFillFormatter() {
+ @Override
+ public float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider) {
+ return chart.getAxisLeft().getAxisMinimum();
+ }
+ });
+
+ // create a data object with the data sets
+ LineData data = new LineData(set1);
+ data.setValueTypeface(tfLight);
+ data.setValueTextSize(9f);
+ data.setDrawValues(false);
+
+ // set data
+ chart.setData(data);
+ }
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.line, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+
+ switch (item.getItemId()) {
+ case R.id.viewGithub: {
+ Intent i = new Intent(Intent.ACTION_VIEW);
+ i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/CubicLineChartActivity.java"));
+ startActivity(i);
+ break;
+ }
+ case R.id.actionToggleValues: {
+ for (IDataSet set : chart.getData().getDataSets())
+ set.setDrawValues(!set.isDrawValuesEnabled());
+
+ chart.invalidate();
+ break;
+ }
+ case R.id.actionToggleHighlight: {
+ if(chart.getData() != null) {
+ chart.getData().setHighlightEnabled(!chart.getData().isHighlightEnabled());
+ chart.invalidate();
+ }
+ break;
+ }
+ case R.id.actionToggleFilled: {
+
+ List sets = chart.getData()
+ .getDataSets();
+
+ for (ILineDataSet iSet : sets) {
+
+ LineDataSet set = (LineDataSet) iSet;
+
+ if (set.isDrawFilledEnabled())
+ set.setDrawFilled(false);
+ else
+ set.setDrawFilled(true);
+ }
+ chart.invalidate();
+ break;
+ }
+ case R.id.actionToggleCircles: {
+ List sets = chart.getData()
+ .getDataSets();
+
+ for (ILineDataSet iSet : sets) {
+
+ LineDataSet set = (LineDataSet) iSet;
+ if (set.isDrawCirclesEnabled())
+ set.setDrawCircles(false);
+ else
+ set.setDrawCircles(true);
+ }
+ chart.invalidate();
+ break;
+ }
+ case R.id.actionToggleCubic: {
+ List sets = chart.getData()
+ .getDataSets();
+
+ for (ILineDataSet iSet : sets) {
+
+ LineDataSet set = (LineDataSet) iSet;
+ set.setMode(set.getMode() == LineDataSet.Mode.CUBIC_BEZIER
+ ? LineDataSet.Mode.LINEAR
+ : LineDataSet.Mode.CUBIC_BEZIER);
+ }
+ chart.invalidate();
+ break;
+ }
+ case R.id.actionToggleStepped: {
+ List sets = chart.getData()
+ .getDataSets();
+
+ for (ILineDataSet iSet : sets) {
+
+ LineDataSet set = (LineDataSet) iSet;
+ set.setMode(set.getMode() == LineDataSet.Mode.STEPPED
+ ? LineDataSet.Mode.LINEAR
+ : LineDataSet.Mode.STEPPED);
+ }
+ chart.invalidate();
+ break;
+ }
+ case R.id.actionToggleHorizontalCubic: {
+ List sets = chart.getData()
+ .getDataSets();
+
+ for (ILineDataSet iSet : sets) {
+
+ LineDataSet set = (LineDataSet) iSet;
+ set.setMode(set.getMode() == LineDataSet.Mode.HORIZONTAL_BEZIER
+ ? LineDataSet.Mode.LINEAR
+ : LineDataSet.Mode.HORIZONTAL_BEZIER);
+ }
+ chart.invalidate();
+ break;
+ }
+ case R.id.actionTogglePinch: {
+ if (chart.isPinchZoomEnabled())
+ chart.setPinchZoom(false);
+ else
+ chart.setPinchZoom(true);
+
+ chart.invalidate();
+ break;
+ }
+ case R.id.actionToggleAutoScaleMinMax: {
+ chart.setAutoScaleMinMaxEnabled(!chart.isAutoScaleMinMaxEnabled());
+ chart.notifyDataSetChanged();
+ break;
+ }
+ case R.id.animateX: {
+ chart.animateX(2000);
+ break;
+ }
+ case R.id.animateY: {
+ chart.animateY(2000);
+ break;
+ }
+ case R.id.animateXY: {
+ chart.animateXY(2000, 2000);
+ break;
+ }
+ case R.id.actionSave: {
+ if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
+ saveToGallery();
+ } else {
+ requestStoragePermission(chart);
+ }
+ break;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+
+ tvX.setText(String.valueOf(seekBarX.getProgress()));
+ tvY.setText(String.valueOf(seekBarY.getProgress()));
+
+ setData(seekBarX.getProgress(), seekBarY.getProgress());
+
+ // redraw
+ chart.invalidate();
+ }
+
+ @Override
+ protected void saveToGallery() {
+ saveToGallery(chart, "CubicLineChartActivity");
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {}
+
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {}
+}
diff --git a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/DrawChartActivity.java b/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/DrawChartActivity.java
similarity index 61%
rename from MPChartExample/src/com/xxmassdeveloper/mpchartexample/DrawChartActivity.java
rename to MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/DrawChartActivity.java
index d12b3ecbd7..7a32e5329c 100644
--- a/MPChartExample/src/com/xxmassdeveloper/mpchartexample/DrawChartActivity.java
+++ b/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/DrawChartActivity.java
@@ -1,8 +1,10 @@
-
+// TODO: Finish and add to main activity list
package com.xxmassdeveloper.mpchartexample;
-import android.graphics.Typeface;
+import android.Manifest;
+import android.content.pm.PackageManager;
import android.os.Bundle;
+import androidx.core.content.ContextCompat;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
@@ -16,10 +18,10 @@
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.LineDataSet;
+import com.github.mikephil.charting.highlight.Highlight;
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
import com.github.mikephil.charting.listener.OnDrawListener;
-import com.github.mikephil.charting.highlight.Highlight;
import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
import java.util.ArrayList;
@@ -28,13 +30,13 @@
/**
* This Activity demonstrates drawing into the Chart with the finger. Both line,
* bar and scatter charts can be used for drawing.
- *
+ *
* @author Philipp Jahoda
*/
public class DrawChartActivity extends DemoBase implements OnChartValueSelectedListener,
OnDrawListener {
- private LineChart mChart;
+ private LineChart chart;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -43,56 +45,49 @@ protected void onCreate(Bundle savedInstanceState) {
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_draw_chart);
- mChart = (LineChart) findViewById(R.id.chart1);
+ setTitle("DrawChartActivity");
+
+ chart = findViewById(R.id.chart1);
// listener for selecting and drawing
- mChart.setOnChartValueSelectedListener(this);
- mChart.setOnDrawListener(this);
+ chart.setOnChartValueSelectedListener(this);
+ chart.setOnDrawListener(this);
- // if disabled, drawn datasets with the finger will not be automatically
+ // if disabled, drawn data sets with the finger will not be automatically
// finished
- // mChart.setAutoFinish(true);
- mChart.setDrawGridBackground(false);
+ // chart.setAutoFinish(true);
+ chart.setDrawGridBackground(false);
// add dummy-data to the chart
initWithDummyData();
- Typeface tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
-
- XAxis xl = mChart.getXAxis();
- xl.setTypeface(tf);
+ XAxis xl = chart.getXAxis();
+ xl.setTypeface(tfRegular);
xl.setAvoidFirstLastClipping(true);
- YAxis yl = mChart.getAxisLeft();
- yl.setTypeface(tf);
+ YAxis yl = chart.getAxisLeft();
+ yl.setTypeface(tfRegular);
- mChart.getLegend().setEnabled(false);
+ chart.getLegend().setEnabled(false);
- // mChart.setYRange(-40f, 40f, true);
+ // chart.setYRange(-40f, 40f, true);
// call this to reset the changed y-range
- // mChart.resetYRange(true);
+ // chart.resetYRange(true);
}
private void initWithDummyData() {
- ArrayList xVals = new ArrayList();
- for (int i = 0; i < 24; i++) {
- xVals.add((i) + ":00");
- }
- ArrayList yVals = new ArrayList();
+ ArrayList values = new ArrayList<>();
// create a dataset and give it a type (0)
- LineDataSet set1 = new LineDataSet(yVals, "DataSet");
+ LineDataSet set1 = new LineDataSet(values, "DataSet");
set1.setLineWidth(3f);
set1.setCircleRadius(5f);
- ArrayList dataSets = new ArrayList();
- dataSets.add(set1); // add the datasets
+ // create a data object with the data sets
+ LineData data = new LineData(set1);
- // create a data object with the datasets
- LineData data = new LineData(xVals, dataSets);
-
- mChart.setData(data);
+ chart.setData(data);
}
@Override
@@ -106,7 +101,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.actionToggleValues: {
- List sets = mChart.getData()
+ List sets = chart.getData()
.getDataSets();
for (ILineDataSet iSet : sets) {
@@ -115,33 +110,36 @@ public boolean onOptionsItemSelected(MenuItem item) {
set.setDrawValues(!set.isDrawValuesEnabled());
}
- mChart.invalidate();
+ chart.invalidate();
break;
}
case R.id.actionToggleHighlight: {
- if(mChart.getData() != null) {
- mChart.getData().setHighlightEnabled(!mChart.getData().isHighlightEnabled());
- mChart.invalidate();
+ if(chart.getData() != null) {
+ chart.getData().setHighlightEnabled(!chart.getData().isHighlightEnabled());
+ chart.invalidate();
}
break;
}
case R.id.actionTogglePinch: {
- if (mChart.isPinchZoomEnabled())
- mChart.setPinchZoom(false);
+ if (chart.isPinchZoomEnabled())
+ chart.setPinchZoom(false);
else
- mChart.setPinchZoom(true);
+ chart.setPinchZoom(true);
- mChart.invalidate();
+ chart.invalidate();
break;
}
case R.id.actionToggleAutoScaleMinMax: {
- mChart.setAutoScaleMinMaxEnabled(!mChart.isAutoScaleMinMaxEnabled());
- mChart.notifyDataSetChanged();
+ chart.setAutoScaleMinMaxEnabled(!chart.isAutoScaleMinMaxEnabled());
+ chart.notifyDataSetChanged();
break;
}
case R.id.actionSave: {
- // mChart.saveToGallery("title"+System.currentTimeMillis());
- mChart.saveToPath("title" + System.currentTimeMillis(), "");
+ if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
+ saveToGallery();
+ } else {
+ requestStoragePermission(chart);
+ }
break;
}
}
@@ -149,10 +147,15 @@ public boolean onOptionsItemSelected(MenuItem item) {
}
@Override
- public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
+ protected void saveToGallery() {
+ saveToGallery(chart, "DrawChartActivity");
+ }
+
+ @Override
+ public void onValueSelected(Entry e, Highlight h) {
Log.i("VAL SELECTED",
- "Value: " + e.getVal() + ", xIndex: " + e.getXIndex()
- + ", DataSet index: " + dataSetIndex);
+ "Value: " + e.getY() + ", xIndex: " + e.getX()
+ + ", DataSet index: " + h.getDataSetIndex());
}
@Override
@@ -171,7 +174,7 @@ public void onDrawFinished(DataSet> dataSet) {
Log.i(Chart.LOG_TAG, "DataSet drawn. " + dataSet.toSimpleString());
// prepare the legend again
- mChart.getLegendRenderer().computeLegend(mChart.getData());
+ chart.getLegendRenderer().computeLegend(chart.getData());
}
@Override
diff --git a/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/DynamicalAddingActivity.java b/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/DynamicalAddingActivity.java
new file mode 100644
index 0000000000..84de449283
--- /dev/null
+++ b/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/DynamicalAddingActivity.java
@@ -0,0 +1,242 @@
+
+package com.xxmassdeveloper.mpchartexample;
+
+import android.Manifest;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.graphics.Color;
+import android.net.Uri;
+import android.os.Bundle;
+import androidx.core.content.ContextCompat;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.WindowManager;
+import android.widget.Toast;
+
+import com.github.mikephil.charting.charts.LineChart;
+import com.github.mikephil.charting.components.YAxis.AxisDependency;
+import com.github.mikephil.charting.data.Entry;
+import com.github.mikephil.charting.data.LineData;
+import com.github.mikephil.charting.data.LineDataSet;
+import com.github.mikephil.charting.highlight.Highlight;
+import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
+import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
+import com.github.mikephil.charting.utils.ColorTemplate;
+import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
+
+import java.util.ArrayList;
+
+public class DynamicalAddingActivity extends DemoBase implements OnChartValueSelectedListener {
+
+ private LineChart chart;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
+ WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ setContentView(R.layout.activity_linechart_noseekbar);
+
+ setTitle("DynamicalAddingActivity");
+
+ chart = findViewById(R.id.chart1);
+ chart.setOnChartValueSelectedListener(this);
+ chart.setDrawGridBackground(false);
+ chart.getDescription().setEnabled(false);
+ chart.setNoDataText("No chart data available. Use the menu to add entries and data sets!");
+
+// chart.getXAxis().setDrawLabels(false);
+// chart.getXAxis().setDrawGridLines(false);
+
+ chart.invalidate();
+ }
+
+ private final int[] colors = ColorTemplate.VORDIPLOM_COLORS;
+
+ private void addEntry() {
+
+ LineData data = chart.getData();
+
+ if (data == null) {
+ data = new LineData();
+ chart.setData(data);
+ }
+
+ ILineDataSet set = data.getDataSetByIndex(0);
+ // set.addEntry(...); // can be called as well
+
+ if (set == null) {
+ set = createSet();
+ data.addDataSet(set);
+ }
+
+ // choose a random dataSet
+ int randomDataSetIndex = (int) (Math.random() * data.getDataSetCount());
+ ILineDataSet randomSet = data.getDataSetByIndex(randomDataSetIndex);
+ float value = (float) (Math.random() * 50) + 50f * (randomDataSetIndex + 1);
+
+ data.addEntry(new Entry(randomSet.getEntryCount(), value), randomDataSetIndex);
+ data.notifyDataChanged();
+
+ // let the chart know it's data has changed
+ chart.notifyDataSetChanged();
+
+ chart.setVisibleXRangeMaximum(6);
+ //chart.setVisibleYRangeMaximum(15, AxisDependency.LEFT);
+//
+// // this automatically refreshes the chart (calls invalidate())
+ chart.moveViewTo(data.getEntryCount() - 7, 50f, AxisDependency.LEFT);
+
+ }
+
+ private void removeLastEntry() {
+
+ LineData data = chart.getData();
+
+ if (data != null) {
+
+ ILineDataSet set = data.getDataSetByIndex(0);
+
+ if (set != null) {
+
+ Entry e = set.getEntryForXValue(set.getEntryCount() - 1, Float.NaN);
+
+ data.removeEntry(e, 0);
+ // or remove by index
+ // mData.removeEntryByXValue(xIndex, dataSetIndex);
+ data.notifyDataChanged();
+ chart.notifyDataSetChanged();
+ chart.invalidate();
+ }
+ }
+ }
+
+ private void addDataSet() {
+
+ LineData data = chart.getData();
+
+ if (data == null) {
+ chart.setData(new LineData());
+ } else {
+ int count = (data.getDataSetCount() + 1);
+ int amount = data.getDataSetByIndex(0).getEntryCount();
+
+ ArrayList values = new ArrayList<>();
+
+ for (int i = 0; i < amount; i++) {
+ values.add(new Entry(i, (float) (Math.random() * 50f) + 50f * count));
+ }
+
+ LineDataSet set = new LineDataSet(values, "DataSet " + count);
+ set.setLineWidth(2.5f);
+ set.setCircleRadius(4.5f);
+
+ int color = colors[count % colors.length];
+
+ set.setColor(color);
+ set.setCircleColor(color);
+ set.setHighLightColor(color);
+ set.setValueTextSize(10f);
+ set.setValueTextColor(color);
+
+ data.addDataSet(set);
+ data.notifyDataChanged();
+ chart.notifyDataSetChanged();
+ chart.invalidate();
+ }
+ }
+
+ private void removeDataSet() {
+
+ LineData data = chart.getData();
+
+ if (data != null) {
+
+ data.removeDataSet(data.getDataSetByIndex(data.getDataSetCount() - 1));
+
+ chart.notifyDataSetChanged();
+ chart.invalidate();
+ }
+ }
+
+ private LineDataSet createSet() {
+
+ LineDataSet set = new LineDataSet(null, "DataSet 1");
+ set.setLineWidth(2.5f);
+ set.setCircleRadius(4.5f);
+ set.setColor(Color.rgb(240, 99, 99));
+ set.setCircleColor(Color.rgb(240, 99, 99));
+ set.setHighLightColor(Color.rgb(190, 190, 190));
+ set.setAxisDependency(AxisDependency.LEFT);
+ set.setValueTextSize(10f);
+
+ return set;
+ }
+
+ @Override
+ public void onValueSelected(Entry e, Highlight h) {
+ Toast.makeText(this, e.toString(), Toast.LENGTH_SHORT).show();
+ }
+
+ @Override
+ public void onNothingSelected() {}
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.dynamical, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+
+ switch (item.getItemId()) {
+ case R.id.viewGithub: {
+ Intent i = new Intent(Intent.ACTION_VIEW);
+ i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/DynamicalAddingActivity.java"));
+ startActivity(i);
+ break;
+ }
+ case R.id.actionAddEntry: {
+ addEntry();
+ Toast.makeText(this, "Entry added!", Toast.LENGTH_SHORT).show();
+ break;
+ }
+ case R.id.actionRemoveEntry: {
+ removeLastEntry();
+ Toast.makeText(this, "Entry removed!", Toast.LENGTH_SHORT).show();
+ break;
+ }
+ case R.id.actionAddDataSet: {
+ addDataSet();
+ Toast.makeText(this, "DataSet added!", Toast.LENGTH_SHORT).show();
+ break;
+ }
+ case R.id.actionRemoveDataSet: {
+ removeDataSet();
+ Toast.makeText(this, "DataSet removed!", Toast.LENGTH_SHORT).show();
+ break;
+ }
+ case R.id.actionClear: {
+ chart.clear();
+ Toast.makeText(this, "Chart cleared!", Toast.LENGTH_SHORT).show();
+ break;
+ }
+ case R.id.actionSave: {
+ if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
+ saveToGallery();
+ } else {
+ requestStoragePermission(chart);
+ }
+ break;
+ }
+ }
+
+ return true;
+ }
+
+ @Override
+ protected void saveToGallery() {
+ saveToGallery(chart, "DynamicalAddingActivity");
+ }
+}
diff --git a/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/FilledLineActivity.java b/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/FilledLineActivity.java
new file mode 100644
index 0000000000..e821a04969
--- /dev/null
+++ b/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/FilledLineActivity.java
@@ -0,0 +1,189 @@
+
+package com.xxmassdeveloper.mpchartexample;
+
+import android.content.Intent;
+import android.graphics.Color;
+import android.net.Uri;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.WindowManager;
+
+import com.github.mikephil.charting.charts.LineChart;
+import com.github.mikephil.charting.components.Legend;
+import com.github.mikephil.charting.components.XAxis;
+import com.github.mikephil.charting.components.YAxis;
+import com.github.mikephil.charting.data.Entry;
+import com.github.mikephil.charting.data.LineData;
+import com.github.mikephil.charting.data.LineDataSet;
+import com.github.mikephil.charting.formatter.IFillFormatter;
+import com.github.mikephil.charting.interfaces.dataprovider.LineDataProvider;
+import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
+import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
+
+import java.util.ArrayList;
+
+/**
+ * This works by inverting the background and desired "fill" color. First, we draw the fill color
+ * that we want between the lines as the actual background of the chart. Then, we fill the area
+ * above the highest line and the area under the lowest line with the desired background color.
+ *
+ * This method makes it look like we filled the area between the lines, but really we are filling
+ * the area OUTSIDE the lines!
+ */
+@SuppressWarnings("SameParameterValue")
+public class FilledLineActivity extends DemoBase {
+
+ private LineChart chart;
+ private final int fillColor = Color.argb(150, 51, 181, 229);
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
+ WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ setContentView(R.layout.activity_linechart_noseekbar);
+
+ setTitle("FilledLineActivity");
+
+ chart = findViewById(R.id.chart1);
+ chart.setBackgroundColor(Color.WHITE);
+ chart.setGridBackgroundColor(fillColor);
+ chart.setDrawGridBackground(true);
+
+ chart.setDrawBorders(true);
+
+ // no description text
+ chart.getDescription().setEnabled(false);
+
+ // if disabled, scaling can be done on x- and y-axis separately
+ chart.setPinchZoom(false);
+
+ Legend l = chart.getLegend();
+ l.setEnabled(false);
+
+ XAxis xAxis = chart.getXAxis();
+ xAxis.setEnabled(false);
+
+ YAxis leftAxis = chart.getAxisLeft();
+ leftAxis.setAxisMaximum(900f);
+ leftAxis.setAxisMinimum(-250f);
+ leftAxis.setDrawAxisLine(false);
+ leftAxis.setDrawZeroLine(false);
+ leftAxis.setDrawGridLines(false);
+
+ chart.getAxisRight().setEnabled(false);
+
+ // add data
+ setData(100, 60);
+
+ chart.invalidate();
+ }
+
+ private void setData(int count, float range) {
+
+ ArrayList values1 = new ArrayList<>();
+
+ for (int i = 0; i < count; i++) {
+ float val = (float) (Math.random() * range) + 50;
+ values1.add(new Entry(i, val));
+ }
+
+ ArrayList