Compare commits

...

377 commits

Author SHA1 Message Date
yoksnod
a6c3808fd5
Merge pull request #2 from yoksnod/marker-interface-improvements
Added jitpack integration
2020-02-12 14:54:18 +03:00
Dmitry Donskoy
941579e10f Added jitpack integration 2020-02-12 14:53:16 +03:00
yoksnod
21c811ff9a
Merge pull request #1 from yoksnod/marker-interface-improvements
Modified and expanded, made more flexible  marker interaction interface
2020-02-12 14:49:13 +03:00
Dmitry Donskoy
f3a2ec21c9 Modified and expanded, made more flexible marker interaction interface 2020-02-12 14:47:18 +03:00
Daniel Cohen Gindi
9347dd1af7
Merge pull request #4802 from oatrice/fix_crash_solid_color_barchart
fix NPE when use solid color with barchart
2020-02-09 07:34:02 +02:00
Anirut Teerabut
90e523042c
Update BarChartRenderer.java 2020-02-07 22:09:57 +07:00
Anirut Teerabut
33240f9225
Update HorizontalBarChartRenderer.java 2020-02-07 22:09:07 +07:00
Anirut Teerabut
4b67673da9
Update BarChartRenderer.java 2020-02-07 22:03:20 +07:00
Anirut Teerabut
cef967fd71 fix NPE when use solid color with barchart 2020-02-07 17:53:40 +07:00
Daniel Cohen Gindi
eae977306e Merge branch 'fill'
* fill:
  Implement a more generic Fill class instead of GradientColor
2020-01-24 12:53:07 +02:00
Daniel Cohen Gindi
c0e7f56b5d Implement a more generic Fill class instead of GradientColor
Support HorizontalBarChart too.
2020-01-24 12:52:27 +02:00
Daniel Cohen Gindi
351e341ee7 Fixed merge residue 2020-01-24 11:42:03 +02:00
Daniel Cohen Gindi
f05337768d Finalized vertical line collision check 2020-01-23 15:45:57 +02:00
Daniel Cohen Gindi
f8d068d377
Merge pull request #4787 from danielgindi/feature/catching_up_to_ios
Feature/catching up to ios
2020-01-23 15:38:53 +02:00
Daniel Cohen Gindi
5e4a32eb41 Corrected check for line in vertical bounds
https://github.com/danielgindi/Charts/pull/4100
2020-01-23 12:09:06 +02:00
Daniel Cohen Gindi
1de836ac65 Remove unexpected dash line during linear animation
https://github.com/danielgindi/Charts/pull/4094
2020-01-23 11:19:07 +02:00
Daniel Cohen Gindi
0668d30a6b Fixed a bug where a pie slice without highlight enabled is hidden
https://github.com/danielgindi/Charts/pull/3969
2020-01-23 10:54:28 +02:00
Daniel Cohen Gindi
34fefd28e1 maxHeight didn't account for the last label
https://github.com/danielgindi/Charts/pull/3900
2020-01-23 10:18:28 +02:00
Daniel Cohen Gindi
45240c3723 Improved negative offset for horz bar chart
https://github.com/danielgindi/Charts/pull/3854
2020-01-22 16:01:42 +02:00
Daniel Cohen Gindi
14456f475f Renamed values -> entries for consistency
https://github.com/danielgindi/Charts/pull/3847
2020-01-22 14:24:37 +02:00
Daniel Cohen Gindi
e02e9be2fa Multiple colors for valueline
https://github.com/danielgindi/Charts/pull/3709
2020-01-22 14:13:31 +02:00
Daniel Cohen Gindi
fcc5af71ce Call onChartScale listener after double-tap-zoom
https://github.com/danielgindi/Charts/pull/3770
2020-01-22 13:49:10 +02:00
Daniel Cohen Gindi
13aee592b1 Improve min/max calculation
https://github.com/danielgindi/Charts/pull/3650
2020-01-22 13:43:42 +02:00
Daniel Cohen Gindi
c97c8d247f Fixed index out of bounds issue when using stacked bar chart
b03cf16ec4
2020-01-22 13:23:12 +02:00
Daniel Cohen Gindi
ae59e7a19e This is for the inline bubble selection
https://github.com/danielgindi/Charts/pull/3548
2020-01-22 13:12:04 +02:00
Daniel Cohen Gindi
7752efef7e Support for labelXOffset for YAxis label 2020-01-22 13:04:11 +02:00
Daniel Cohen Gindi
58545bbbfa Add option to disable clipping data to contentRect
https://github.com/danielgindi/Charts/pull/3360
2020-01-22 12:46:37 +02:00
Daniel Cohen Gindi
4ce14e6cc9 Add a warning message if pie chart has more than one data set
https://github.com/danielgindi/Charts/pull/3286
2020-01-22 12:42:32 +02:00
Daniel Cohen Gindi
8df9eda7af Call notifyDataChanged for an opportunity for subclasses 2020-01-22 12:39:03 +02:00
Daniel Cohen Gindi
34c3ceaa05 Reset min/max when clearing ChartDataSet
https://github.com/danielgindi/Charts/pull/3265
2020-01-22 12:29:47 +02:00
Daniel Cohen Gindi
ea816e8d6d Added dataIndex param for highlightValue (combined charts)
https://github.com/danielgindi/Charts/pull/2852
2020-01-22 12:25:34 +02:00
Daniel Cohen Gindi
bafb0fbbe4 Use correct color index for bubble chart
https://github.com/danielgindi/Charts/pull/3202
2020-01-22 12:16:48 +02:00
Daniel Cohen Gindi
4549ae17b7 Select correct axis for legend distance calculation in horz bar chart
https://github.com/danielgindi/Charts/pull/2214
2020-01-22 12:15:02 +02:00
Daniel Cohen Gindi
912427e543 Custom text alignment for no-data
https://github.com/danielgindi/Charts/pull/3199
2020-01-22 12:07:37 +02:00
Daniel Cohen Gindi
3f5475077e Avoid race condition for interval/intervalMagnitude
https://github.com/danielgindi/Charts/pull/2377
2020-01-22 11:59:43 +02:00
Daniel Cohen Gindi
2e725e49d3 Make min/max axis labels configurable
https://github.com/danielgindi/Charts/pull/2894
2020-01-22 11:54:08 +02:00
Daniel Cohen Gindi
a4ca1f3fba Fixed axis label disappearing when zooming in
https://github.com/danielgindi/Charts/pull/3132
2020-01-22 11:47:45 +02:00
Daniel Cohen Gindi
634a690d6a Added an implementation of Douglas Peucker with resultCount input
https://github.com/danielgindi/Charts/pull/2848
2020-01-22 11:44:27 +02:00
Daniel Cohen Gindi
1987d7eb64 Consider axis dependency in Combined chart
https://github.com/danielgindi/Charts/pull/2874
2020-01-22 11:04:57 +02:00
Daniel Cohen Gindi
6ebf3fa57a Added highlightColor parameter for pie charts
https://github.com/danielgindi/Charts/pull/2961
2020-01-22 10:27:55 +02:00
Daniel Cohen Gindi
95027fa6a7 Safe guards
These will be even more important when moving to Kotlin ranges
2020-01-22 09:55:00 +02:00
Philipp Jahoda
d86f39cc91
Update README.md 2020-01-20 11:15:12 +01:00
Philipp Jahoda
cb26ed4ef4
Update FUNDING.yml 2019-10-08 14:15:52 +02:00
Philipp Jahoda
dc59171524
Create FUNDING.yml 2019-10-08 14:15:21 +02:00
Philipp Jahoda
726616d079 Merge branch 'master' of github.com:PhilJay/MPAndroidChart 2019-04-27 17:38:41 +02:00
Philipp Jahoda
fffe9a297e Update gradle 2019-04-27 17:38:37 +02:00
Philipp Jahoda
2340e12800
Merge pull request #4512 from duchampdev/percent_formatter_sign_spacing
PercentFormatter: make space between number and percent sign optional
2019-04-27 17:37:13 +02:00
duchampdev
c5667d4f14 fix little typo 2019-04-27 16:06:37 +02:00
duchampdev
0563fb48b0 PercentFormatter: make space between number and percent sign optional 2019-04-27 16:06:10 +02:00
Philipp Jahoda
ed8876cef2
Update README.md 2019-04-07 16:37:14 +02:00
Philipp Jahoda
12b4351d0c
Update README.md 2019-04-07 16:27:59 +02:00
Philipp Jahoda
adb56e75bd
Update README.md 2019-04-07 16:20:14 +02:00
Philipp Jahoda
e95c1eb26a
Update README.md 2019-03-20 17:56:58 +01:00
Philipp Jahoda
0c2ac2d9cc New example app release 2019-03-16 11:53:42 +01:00
Philipp Jahoda
2058f7bf5d Minor changes to project and example 2019-03-16 11:42:04 +01:00
Philipp Jahoda
971640b29d
Update Support_help.md 2019-02-21 09:05:06 +01:00
Philipp Jahoda
7df8a4cedc
Update Feature_request.md 2019-02-21 09:04:40 +01:00
Philipp Jahoda
59028d3bf3
Update Bug_report.md 2019-02-21 09:04:28 +01:00
Philipp Jahoda
c886bb342a
Update README.md 2019-02-20 22:51:10 +01:00
almic
aea2ff3417
Add option to set minimum angles
Allows to force minimum slice angles when drawing charts, which means that any
slices with angles lower than the minimum will be drawn with the minimum angle.

When changing this setting on the fly, you have to call
`notifyDataSetChanged()` and `invalidate()` for the minimum angle to take
effect.

This only functions if all slices can be drawn with the minimum angle. For
example if a chart has 5 slices, the largest functioning minimum angle is
`72f` degrees on a 360 degree chart, or 20% of the chart's `maxAngle`.
2018-11-15 09:51:46 -07:00
almic
42cdba535f
Add Curved Slices to Pie Chart
Finally added support for rounded slices, and somewhat improved the code
for the PieChartRenderer class.
2018-11-12 10:59:48 -07:00
almic
29f4cc5c2c
Remove unnecessary API checks
Also added run configuration for the MPChartExample.
Removed deprecated Legend stuff.
2018-11-11 09:40:37 -07:00
almic
fc0e234298
Remove Deprecated Things
Long deprecated Legend constructor and positioning has been removed, it was
replaced with a new way to position the Legend.

The old Easing options have been removed now, accessing them is as easy as
removing the `EasingOption` part, such that the names look like
`Easing.Linear` or `Easing.EaseInOutQuad` now.
2018-11-07 14:52:25 -07:00
almic
e5b66192e7
New ValueFormatter
I created a simplified value formatter class, which is an abstract class rather
than an interface.

The switch was chosen because the new format has all the methods predefined
(something an interface wouldn't allow) meaning you can extend it and only
change what you want. This also means that you only need one value formatting
class for labels rather than two different classes, it just makes more sense.

Please check the method signatures to learn how to use them, I'm sure you'll
find this new format is much more customizable and faster to use.

I've made the class abstract even though there are no abstract methods or
fields, this is because it would certainly be a mistake to create a
ValueFormatter and not override any methods.

To convert existing code, just use 'extends' instead of 'implements' and change
the names to 'ValueFormatter'. You'll need to change the methods you overwrite
as well, just check the class and use the one you need.
2018-11-07 12:41:53 -07:00
Mick A
608d9e29f5
Fix link error 2018-10-30 08:59:58 -06:00
almic
9148f37f9e
Bump version to 3.1.0-alpha 2018-10-29 13:23:18 -06:00
Mick A
6ce99326ae
Merge pull request #2273 from vpop/update/unused-local
Remove unused local variable
2018-10-27 21:56:40 -06:00
Mick A
129ad15fd0
Merge pull request #2187 from vpop/update/redundant-nullcheck
Remove nullcheck for known non-null variable
2018-10-27 21:42:36 -06:00
almic
5030b36c86
More Cleanup
I've removed the realm examples, mainly because the library was buggy.
In the previous commit, I already removed the examples from the list
since they didn't add anything to the overall demonstration. I thought
that if anyone wants to use realm.io with the charts, they can see the
actual library.

The file structure has been updated to match how Android Studio does
things. Some files added way back when have been deleted as they don't
do anything but cause the linter to freak out about 'unused properties'

All 'build.gradle' files have been refreshed as well.

Small addition to the README file to add a quick way to reach sections
of the page.
2018-10-27 18:00:06 -06:00
almic
db7dda2b7e
More Linting
Lots of things in the example app are now marked with the 'final' modifier, and saveToGallery() is protected in classes that implement it. As well, new suppressions are in a few places.

NEW text is now removed completely. Looks like this has been unused for a long time and it's just stuck around anyway.
2018-10-27 14:02:04 -06:00
almic
d67ea481af
Huge Project Refresh
Before anyone freaks out, all these changes are under-the-hood, meaning that you probably won't even notice them at all.

The biggest difference is raising the minSdkVersion from 9 to 14. Recently android bumped this number interally as there are basically no devices running lower than 14 anymore. Sorry but you are just wasting your time if you are trying to support anything lower than 14 now.

The next biggest change is updating the project to the new AndroidX libraries, which changes some imports and nothing else really.

The third biggest change is fixing a few bugs in the code that cause values to be drawn even if there are none, which results in your app crashing. Surprisingly, these checks already existed in a few of the newer chart types, but most lacked this simple check.

Other than those three changes, nothing else is functionally different. Well, saving to gallery works on all charts in the example app now, and you can quickly see the code for each example in the menus.

The only real potential "breaking" change is that charts are now saved as PNGs by default instead of JPGs if you go the route of not specifying as a JPG. You may want to double check your file sizes as PNGs can be larger than low quality JPGs.

I still have more plans for simplifying the API and fixing other issues with the project, for the small few that closely pay attention to individual commits: there's going to be more soon.
2018-10-26 10:30:22 -06:00
Philipp Jahoda
20bca4a8ca
Update README.md 2018-08-26 20:31:44 +02:00
Philipp Jahoda
e2a9110d38
Update README.md 2018-08-26 20:31:00 +02:00
Philipp Jahoda
2316f8500f
Update README.md 2018-08-26 20:21:49 +02:00
Philipp Jahoda
6f0b7432ac
Update README.md 2018-08-26 20:21:19 +02:00
Philipp Jahoda
073ad3c877
Update README.md 2018-08-26 20:14:32 +02:00
Philipp Jahoda
c1f6fcebf0
Update README.md 2018-06-06 09:14:41 +02:00
Philipp Jahoda
b65ba08324
Update README.md 2018-05-15 15:57:09 +02:00
Mick A
fe7a0f8bc3
Merge pull request #4018 from RobertZagorski/feature/remove-redundant-findViewById-casts
[Enhancement] Remove redundant findViewById casts in example application
2018-05-12 21:28:06 -06:00
almic
536a35a6fd
docs(README): Update & simplify README
- Re-ordered some of the sections
- Simplified some sections
- Reformatted here and there
- Added a few emojis, how cute!

The goal of this change was to hopefully further reduce the amount of
issue support/ question spam. By moving the sections around to show the
more important parts higher up, like usage and documentation links, I
hope this will make it easier for people to find the documentation.
2018-05-10 11:03:03 -06:00
RobertZagorski
75dd04cc42 Remove redundant findViewById casts, that became obsolete after migration to API 26. 2018-05-10 08:01:03 +02:00
Mick A
1485cdc687
Merge pull request #3451 from davidgoli/add-grid-lines-on-top-of-data
Add option to draw limit lines on top of data
2018-05-09 09:12:49 -06:00
Mick A
53de181607
Merge pull request #3478 from MaximPestryakov/patch-1
Refactored LargeValueFormatter
2018-05-09 09:07:06 -06:00
Mick A
9ee3a74633
Merge pull request #4013 from RobertZagorski/bugfix/#2369-legend-offset-is-not-calculated-twice-for-line-chart
Remove mLabelRotatedHeight counted twice, when calculating legend offset
2018-05-09 08:36:07 -06:00
Mick A
73054bedc3
Merge pull request #3642 from pagrzybe/autoscale_restrictions
Option to set restrictions for Y axis autoscaling.
2018-05-09 08:29:22 -06:00
Maxim Pestryakov
5869c9de23
Fixed Javadoc 2018-05-09 16:03:48 +03:00
RobertZagorski
89436221db Remove mLabelRotatedHeight counted twice, when calculating legend offsets. (Fix for #2369).
Removed statements where completely not needed as calculating offsets is alredy done in BarLineCharBase#calculateOffsets(...)
2018-05-09 08:44:22 +02:00
Pawel Grzybek
92c14db5b4 Fixed code review comments. 2018-05-09 08:09:03 +02:00
Mick A
0b6632f2cb
Merge pull request #4008 from RobertZagorski/bugfix/#1604-update-and-reorganise--copy-data-sets-methods
Update and reorganise copy data sets methods (Fix for #1604).
2018-05-08 09:42:03 -06:00
RobertZagorski
7abc9cd669 Update and reorganise copy data sets methods (Fix for #1604).
Copying class properties is always done in protected copy method.
2018-05-08 16:19:09 +02:00
almic
9583a18b84
chore(template): Move templates to .github folder 2018-05-06 00:29:31 -06:00
almic
03c538fc34
docs(templates): Update Issue & PR templates
I've updated the issue and pull request templates, again. This time I
looked to the node.js request library for inspiration.

It's no secret that this project has been attracting a LOT of very
low-quality issues. Almost all are asking questions that can be easily
answered if the person looked at the example project or the wiki.

Specifically, the new Support_help.md file.

This file will hopefully bait these low-quality support questions and
reduce the number of opened issues regarding debugging or support
significantly.

I've updated the default ISSUE_TEMPLATE.md to be a copy of Bug_report.md
to force people to read that notice text if they decide to not choose
any of the templates.
2018-05-06 00:27:57 -06:00
Mick A
c08ec81fc0
Merge pull request #4001 from oatrice/feature/muti_gradient
[Feature] Multiple gradient color for barchart
2018-05-05 09:18:14 -06:00
Anirut Teerabut
e4ba3cdc20 - multiple gradient color 2018-05-04 04:21:26 +07:00
almic
689d484615
Delete lingering MyEasingFunction.java
I made the decision to remove this file instead of updating it, as I'm
sure most will instead prefer to look at the actual Easing class. If you
miss this example class... ¯\_(ツ)_/¯
2018-05-03 08:37:00 -06:00
Philipp Jahoda
9b9d2a68cb
Update README.md 2018-05-03 16:22:32 +02:00
Mick A
0378e763ae
Merge pull request #2856 from stephenmcbride/master
Fix for missing setters in getInstance method
2018-05-02 10:42:40 -06:00
Mick A
1ff676ecaf
Update CONTRIBUTING.md
Condensed CONTRIBUTING and added helpful reference links.

And cake!
2018-05-02 00:44:47 -06:00
Mick A
00e284c043
Update Bug_report.md
quick fix
2018-05-01 23:02:01 -06:00
Mick A
a7eb395b81
Downgrade ISSUE_TEMPLATE.md to generic issue 2018-05-01 22:59:06 -06:00
Mick A
11bf7aa812 Update issue templates 2018-05-01 22:57:40 -06:00
Mick A
89e50c8c9b
Merge pull request #3982 from almic/yaxis-calc
Remove YAxis Custom Min/Max Check for Padding
2018-05-01 21:29:15 -06:00
Mick A
640208c8ff
Merge pull request #3820 from longup/master
Fix last entry clipping bug #3819
2018-05-01 21:19:05 -06:00
Mick A
5519c5170d
fix(docs): Broken Contributing link 2018-04-30 17:42:35 -06:00
almic
35c9fc937e
refactor(EasingFunction): Simplified EasingFunction
EasingFunction has been simplified greatly, and I've added a MUCH needed
annotation to relevant methods.

Easing.EasingOptions has been deprecated, as well as any methods using
them. Converting is as simple as deleting the "EasingOptions" part.

A new signature is available for animateXY()!

You are now able to pass one EasingFunction to animateXY() if you want
both axes to be animated the same way.

Quietly included are some gradle build updates, incrementing the
appcompat version to 27.1.1, and using the new `javacompiler` to avoid
deprecation of `javacompile`
2018-04-30 12:24:18 -06:00
Mick A
89d18a7f67
Merge pull request #3207 from scottkennedy/weakref-fixes
Fix some potential NPEs with WeakReference usage
2018-04-30 08:15:48 -06:00
Mick A
6fbd492761
Create PULL_REQUEST_TEMPLATE.md 2018-04-29 09:58:33 -06:00
Mick A
7286f8703f
Create ISSUE_TEMPLATE.md 2018-04-29 09:48:01 -06:00
Mick A
9997a33524
Merge pull request #3975 from hannesa2/AndroidStudio3.1.2
update to Android Studio 3.1.2
2018-04-28 19:12:26 -06:00
Hannes Achleitner
d8ea67aa21 update to Android Studio 3.1.2 2018-04-28 19:54:22 +02:00
Mick A
40adb57f68
Merge pull request #3898 from sembozdemir/pie_chart_value_line_colors
PieChart: Add option for using slice color as value line color
2018-04-28 10:53:08 -06:00
Mick A
215e0dfc05
Merge pull request #3949 from WilderPereira/master
Rename RadarChartActivitry to RadarChartActivity
2018-04-28 10:37:07 -06:00
almic
e1411f169e
Remove Custom Check
calculate() no longer checks if min and max is custom, it just adds the padding.
2018-04-27 00:08:27 -06:00
Wilder Pereira
993a8554c0 Remove unused imports 2018-04-15 21:51:35 -03:00
Wilder Pereira
508cc565a9 Rename RadarChartActivitry to RadarChartActivity 2018-04-15 21:51:15 -03:00
sembozdemir
1e6e58d2c0 Add option for using slice color as value line color
Fixes: #3897
2018-03-28 20:23:51 +03:00
zhanglong
aee6058dbb Avoid that the last label entry in the x-labels clip off the edge of the screen #3819 2018-02-27 15:04:47 +08:00
Philipp Jahoda
3e1eb1445a
Delete googlee1205ea43aa2c32a.html 2018-02-24 12:51:49 +01:00
Philipp Jahoda
82668ebc34
Add files via upload 2018-02-24 12:50:04 +01:00
Philipp Jahoda
a5250888b9
Update README.md 2018-01-12 15:27:40 +01:00
Philipp Jahoda
297ce9f2cc
Update README.md 2018-01-12 14:07:02 +01:00
Philipp Jahoda
b3e2358334
Update README.md 2018-01-12 14:06:19 +01:00
Philipp Jahoda
8fd1a86b0a
Update README.md 2017-12-27 16:25:56 +01:00
Philipp Jahoda
6ccaf940d8
Update README.md 2017-12-27 16:24:45 +01:00
Philipp Jahoda
c50f03cf39
Update README.md 2017-12-25 20:09:46 +01:00
Philipp Jahoda
c867d7cb37
Update README.md 2017-12-25 20:06:18 +01:00
Philipp Jahoda
2c08b560d6
Update README.md 2017-12-25 20:05:18 +01:00
Philipp Jahoda
779e0f5665
Update README.md 2017-12-25 19:58:23 +01:00
Philipp Jahoda
8954409575
Update README.md 2017-12-20 14:03:05 +01:00
Philipp Jahoda
44125a87dd
Update README.md 2017-12-20 10:59:50 +01:00
Philipp Jahoda
4b7eb1fd04
Update README.md 2017-12-19 14:38:34 +01:00
Philipp Jahoda
21ad19661b
Update README.md 2017-12-19 14:19:30 +01:00
Philipp Jahoda
b06439f36d
Update README.md 2017-12-19 14:14:54 +01:00
Philipp Jahoda
62910171f1 Merge branch 'master' of github.com:PhilJay/MPAndroidChart 2017-12-14 19:37:16 +01:00
Philipp Jahoda
16a9be8ea0 Update gitignore, add assets 2017-12-14 19:37:09 +01:00
Pawel Grzybek
e416736ad5 Added option to set restrictions for Y axis autoscaling. 2017-12-10 20:19:06 +01:00
Philipp Jahoda
d9000987c7
Update README.md 2017-11-30 13:40:49 +01:00
Philipp Jahoda
1ac72ea811
Update README.md 2017-11-30 09:27:59 +01:00
Philipp Jahoda
41aff3f13d Merge 2017-11-29 16:07:13 +01:00
Philipp Jahoda
5e97f561f7 Update version 2017-11-29 16:06:58 +01:00
Philipp Jahoda
47485f8364
Update README.md 2017-11-29 16:03:11 +01:00
Philipp Jahoda
0868d9bf89 Add new google repo 2017-11-29 15:57:30 +01:00
Philipp Jahoda
23aef1a0ab Add new google repo 2017-11-29 15:55:18 +01:00
Philipp Jahoda
dfaffa39cc Add maven plugin to example 2017-11-29 15:48:42 +01:00
Philipp Jahoda
ed9340ea51 Update maven android plugin 2017-11-29 15:47:10 +01:00
Philipp Jahoda
796dfb21f8 Out comment gradle wrapper 2017-11-29 15:28:03 +01:00
Philipp Jahoda
f2dedb30de Update gradle and dependencies 2017-11-29 15:23:57 +01:00
Philipp Jahoda
a5a482fbdc
Update README.md 2017-11-28 10:50:37 +01:00
Maxim Pestryakov
d3c339da10 Refactored LargeValueFormatter 2017-10-06 17:12:46 +03:00
davidgoli
c97b8d531d add option to draw limit lines on top of data 2017-09-22 18:57:07 -07:00
Daniel Cohen Gindi
72031d33ca Allow locking drag on either axes 2017-09-08 11:00:45 +03:00
Daniel Cohen Gindi
ea93823f63 Fix CombinedChartView not drawing markers 2017-09-08 10:13:12 +03:00
Daniel Cohen Gindi
ed770762fb Add default x spacing (half width) for scatter chart as well 2017-08-25 12:15:42 +03:00
Daniel Cohen Gindi
98f97f0df1 Run view port jobs after applying changes 2017-08-25 12:13:45 +03:00
Philipp Jahoda
4f77a154bf Update README.md 2017-08-11 16:31:29 +02:00
Philipp Jahoda
ad3c82f634 Update README.md 2017-08-04 17:05:42 +02:00
Scott Kennedy
43ae497ecf Fix some potential NPEs with WeakReference usage
Even if the WeakReference field is not null, the contained value may be null.  Additionally, you always need a strong reference to the value to ensure it isn't garbage collected while you're using it.
2017-06-26 10:51:58 -07:00
Philipp Jahoda
695f481077 Merge pull request #3204 from PhilJay/add-license-1
Create LICENSE
2017-06-26 09:16:47 +02:00
Philipp Jahoda
fcb506c219 Create LICENSE 2017-06-26 09:16:23 +02:00
Daniel Cohen Gindi
acf985ff0c Clear lastHighlighted when clear is called 2017-04-26 20:45:12 +03:00
Philipp Jahoda
0af86819ea Update README.md 2017-04-04 10:29:38 +02:00
Philipp Jahoda
f6a398b6b2 Update README.md 2017-03-24 11:36:12 +01:00
Philipp Jahoda
208bf181ad Update README.md 2017-03-23 16:23:45 +01:00
PhilJay
557e55653b Remove line width minimum constraint 2017-03-23 16:15:16 +01:00
PhilJay
b564704b82 Updating versions 2017-03-23 16:13:21 +01:00
Philipp Jahoda
6df13dd66e Update README.md 2017-03-15 15:55:23 +01:00
Philipp Jahoda
2eb12901a9 Update README.md 2017-03-14 10:39:45 +01:00
Philipp Jahoda
993d273a52 Update README.md 2017-03-14 10:39:05 +01:00
Stephen McBride
6c54f0b0a9 Fix for missing setters in getInstance method
The zoomAndCenterAnimated method in BarLineChartBase crashes with a NullPointer exception because the yAxis variable is null when onAnimationUpdate is called. The yAxis is null because of missing setters in the getInstance method of AnimatedZoomJob.
2017-02-28 15:58:42 +13:00
Daniel Cohen Gindi
0c919ab02d Consider isEnabled in more axis rendering cases 2017-02-22 17:29:33 +02:00
Daniel Cohen Gindi
493e3d238d Merge pull request #2463 from maheshgaya/master
Fix: typo for October
2017-02-21 16:39:50 +02:00
Daniel Cohen Gindi
3ec493fc0c Merge pull request #2414 from Ewg777/patch-1
Fixed docs typo in AxisBase.java
2017-02-21 16:39:27 +02:00
Daniel Cohen Gindi
31b60225d0 Merge pull request #2622 from patrick-iv/fix_circle_inherit_alpha
Fix circles inherit alpha #2620
2017-02-21 16:38:39 +02:00
Daniel Cohen Gindi
886cc9f85d Merge pull request #2621 from patrick-iv/fix_default_text_size
Fix for default text size being set in PX instead of DP
2017-02-21 16:36:02 +02:00
Daniel Cohen Gindi
528e2e8d61 Merge pull request #2811 from travisfw/master
fix tests for java executable location in gradlew to be compatible with bash 4.3.42
2017-02-21 16:34:00 +02:00
Daniel Cohen Gindi
28166a01d1 Merge pull request #2814 from travisfw/utf8-javadoc
Set javadoc character encoding to utf8
2017-02-21 16:33:11 +02:00
Daniel Cohen Gindi
a5e0a9b86c Moved auto scale before render of axis lines
https://github.com/danielgindi/Charts/pull/2177
2017-02-21 14:24:13 +02:00
Daniel Cohen Gindi
94957fad33 Improved feb29 formula 2017-02-20 13:55:16 +02:00
Daniel Cohen Gindi
23e0178dbb Merge pull request #2825 from danielgindi/icons
Entry cons in all chart types
2017-02-20 13:45:21 +02:00
Daniel Cohen Gindi
144af7b295 Added examples for icon entries 2017-02-20 13:33:53 +02:00
Daniel Cohen Gindi
a02e108f46 Implemented icon support 2017-02-20 13:33:39 +02:00
travisfw
749827798b fix https://github.com/PhilJay/MPAndroidChart/issues/2813 2017-02-14 11:07:10 -08:00
travisfw
ed618084f9 fix tests for java executable location. bug #2805
https://github.com/PhilJay/MPAndroidChart/issues/2805
2017-02-13 14:02:55 -08:00
Patrick Ivarsson
30a331781f Fix circles inherit alpha (Fixes #2620)
ISSUE:
When using multiple LineDataSets like the follows:

    int solidColor = 0xFFFF00FF;
    dataSet.setColor(solidColor);
    dataSet.setCircleColor(solidColor);

    int semiTransparentColor = 0x8A000000;
    fadedSet.setColor(semiTransparentColor);

    LineData data = new LineData(dataSet, fadedSet);

the circles in 'dataSet' will rendered with the alpha from
fadedSet (0x8A).

The reason for this is that mRenderPaint is not reset properly
before drawing the circles. The first time drawCircles is called
the imageCache.fill(...) method is used where the color is set by
mRenderPaint.setColor(set.getCircleColor(i)), restoring the alpha
to 0xFF. The second time homever, imageCache.fill(...) is not called
which means that mRenderPaint will use it's old color/alpha,
which in this case is from fadedSet.

TEST INFO:
To trigger the issue, add the following to LineChartActivity1:

    final ArrayList<Entry> fadedEntries = new ArrayList<>();
    for (int i = 0; i < count; i++) {

        float val = (float) (Math.random() * range) + 3;
        fadedEntries.add(new Entry(i, val));
    }
    final LineDataSet fadedDateSet = new LineDataSet(fadedEntries, "Faded");
    fadedDateSet.setColor(0x42000000);

    dataSets.add(fadedDateSet); // add the datasets

and launch the first item in the example app.

SOLUTION:
This commit replaces mRenderPaint with null when drawing the circle
bitmap. If circleColor has been defined with a semi-transparent
color, it will be drawn that way in the cached bitmap, hence the the
bitmap itself does not need to be drawn with an alpha.
2016-12-23 15:01:23 +01:00
Patrick Ivarsson
6966b8117e Fix for default text size being set in PX instead of DP
The default text size in ComponentBase was defined as 10 pixels
instead of 10dp, which causes tiny text and does not reflect
the javadoc and the general behavior of setTextSize(...)
2016-12-23 12:38:42 +01:00
Daniel Cohen Gindi
ccf6b7e3b1 Correctly position 0 in stacked bar 2016-12-19 22:50:08 +02:00
Daniel Cohen Gindi
d5e5ec3a92 resetZoom() 2016-12-19 22:06:41 +02:00
Daniel Cohen Gindi
a934501315 Gradle updates 2016-12-19 21:56:16 +02:00
Daniel Cohen Gindi
34e7f44979 drawBottomYLabelEntryEnabled 2016-12-19 21:56:03 +02:00
Philipp Jahoda
8abe7e84ad Update README.md 2016-12-10 10:35:56 +01:00
Philipp Jahoda
9aaa3328f0 Update README.md 2016-12-10 10:35:28 +01:00
Philipp Jahoda
345b4bc97e Update README.md 2016-11-19 10:01:13 +01:00
PhilJay
08f295eae1 Upgrade manifest 2016-11-17 19:01:53 +01:00
PhilJay
a7fd778fc8 Upgrade version 2016-11-17 19:01:21 +01:00
Daniel Cohen Gindi
2e80fada31 Fixed a bug where the mod-360 bypass draws a full-circle for 0 slices. 2016-11-16 12:04:57 +02:00
Daniel Cohen Gindi
4cb83a7b91 Added IndexAxisValueFormatter, to allow for easy x-axis labels like MPAndroidChart 2.0 2016-11-16 11:19:50 +02:00
Daniel Cohen Gindi
0818d766db Fixed EPSILON. (Closes #2432)
Closes #2424
Closes #2394
Closes #2393
Closes #2385
2016-11-16 11:01:34 +02:00
Daniel Cohen Gindi
ee020bba67 Gradle updates 2016-11-16 11:01:34 +02:00
Mahesh Gaya
262d877b9f Fix: typo for October 2016-11-12 12:23:36 -06:00
Daniel Cohen Gindi
3928e285ae Fixed double calculation of xAxis spacing 2016-11-08 17:25:19 +02:00
Daniel Cohen Gindi
00f36054c7 Fixed weird glitch in mixed (pos/neg) stacked bars highlight
https://github.com/danielgindi/Charts/pull/1744
https://github.com/danielgindi/Charts/issues/1726
2016-10-31 15:35:16 +02:00
Daniel Cohen Gindi
3a879e9402 Added missing isDrawBordersEnabled getter 2016-10-31 13:34:22 +02:00
Daniel Cohen Gindi
8045d64260 Added clipValuesToContent property for clipping values 2016-10-31 13:32:47 +02:00
Daniel Cohen Gindi
6a5580b101 Renamed new property getter 2016-10-31 13:26:25 +02:00
Daniel Cohen Gindi
70691bea41 Fixed glitch in clipping rects.
It's the Android's renderer's bug.
When specifying exact clipping rects,
  they are clipping more than they should!
So drawing a thin 1px line on the edge of a clipping rect fail.
Instead of insetting by half the line width, inset by full line width.
2016-10-31 13:10:11 +02:00
Daniel Cohen Gindi
49b4d1a96b Bugfix: Corrected clipRect on the proper rect variable 2016-10-31 12:09:49 +02:00
Daniel Cohen Gindi
fb8094e9f2 Make automatically disabling slice-spacing an opt-in feature 2016-10-31 11:45:05 +02:00
Evgeniy
bc13bc2c17 Update AxisBase.java
Mistake fixed
2016-10-27 08:45:39 +03:00
PhilJay
9a19bf6670 Migrate to Realm v2.0.2, fix example 2016-10-23 00:02:49 +02:00
PhilJay
9b7cffa274 Move to Realm v2.0.2, update example 2016-10-22 23:54:31 +02:00
Philipp Jahoda
49b61e92a4 Update README.md 2016-10-22 15:54:26 +02:00
Philipp Jahoda
3ce2016048 Update README.md 2016-10-19 23:09:03 +02:00
Philipp Jahoda
b618524a19 Update README.md 2016-10-19 23:03:54 +02:00
Daniel Cohen Gindi
810c99c579 Make highlightFullBarEnabled feature work again 2016-10-19 10:08:42 +03:00
PhilJay
0fec2ef06b Clear up grouped bar example 2016-10-18 22:40:45 +02:00
Daniel Cohen Gindi
d65ffb8871 Fixed bar chart demo first value being empty 2016-10-18 18:39:04 +03:00
Daniel Cohen Gindi
730e5d3d9b Fixed last label of line chart not rendering 2016-10-18 18:27:21 +03:00
Daniel Cohen Gindi
c83d2f4ff4 Default spaceMin/max for xAxis in candlestick charts 2016-10-18 18:17:16 +03:00
PhilJay
8ed6dd24bf Update gradle & android sdk 2016-10-16 19:09:42 +02:00
Philipp Jahoda
221cd1313a Merge pull request #2342 from nielsz/patch-1
Fix typo
2016-10-16 18:49:41 +02:00
Daniel Cohen Gindi
555176bcdb Avoid crash when dataset is empty 2016-10-10 17:24:59 +03:00
Daniel Cohen Gindi
e10628958f Improved highlight for scatter/bubble, and fixes highlightValueWithX 2016-10-10 16:33:43 +03:00
Daniel Cohen Gindi
8d65596266 Default spaceMin/spaceMax for bar charts
This avoids having to set custom axisMinimum/axisMaximum, or offsetting x
2016-10-08 22:25:44 +03:00
Daniel Cohen Gindi
b77063d818 Feature: spaceMin/spaceMax for axis 2016-10-08 22:24:08 +03:00
Daniel Cohen Gindi
815dee86a0 Corrected calcMinMaxY for autoScaleMinMax 2016-10-08 21:47:31 +03:00
nielsz
463ef829d7 Fix typo 2016-10-08 12:18:13 +02:00
PhilJay
3398cf4462 Refactoring, prepare example for testing highlight 2016-10-02 15:14:09 +02:00
PhilJay
323329d8a6 Extend test cases 2016-10-02 14:36:55 +02:00
Daniel Cohen Gindi
6f1d365176 Merge pull request #2314 from mikedream89/master
[FIX] not find centeringEnabled
2016-09-30 18:27:38 +03:00
Mark
cf0f1fca34 [FIX] not find centeringEnabled 2016-09-29 19:38:48 +08:00
Daniel Cohen Gindi
c8553da89c Set z-index of markers to be the highest 2016-09-29 09:09:05 +03:00
Daniel Cohen Gindi
06bed3332d Allow label centering for 1 label 2016-09-29 09:00:18 +03:00
Daniel Cohen Gindi
aa14ab262b Minor fixes for interval in axis labels 2016-09-29 08:59:33 +03:00
Daniel Cohen Gindi
028328b986 Guard roundToNextSignificant and decimal from invalids 2016-09-29 08:12:05 +03:00
PhilJay
01d8b24686 Update gradle 2016-09-24 18:21:50 +02:00
PhilJay
d4e2e697e6 Merge branch 'master' of https://github.com/PhilJay/MPAndroidChart 2016-09-22 16:23:48 +02:00
Daniel Cohen Gindi
6c0b9c1aab Removed redundant condition 2016-09-21 20:02:56 +03:00
Daniel Cohen Gindi
b1fe859ce8 Fixes for cubic bezier edges 2016-09-21 19:55:58 +03:00
Daniel Cohen Gindi
63684f02ca Avoid crash for centerAxisLabelsEnabled when entry count == 1 2016-09-21 17:56:00 +03:00
Daniel Cohen Gindi
21e778cb1f Move on from the deprecated property in the demos 2016-09-21 07:53:06 +03:00
Daniel Cohen Gindi
7ffa9caaa1 Fixed entry searching algorithm to handle sequential same values 2016-09-21 07:30:46 +03:00
Daniel Cohen Gindi
b53c8cdbd1 Removed redundancies 2016-09-19 22:15:26 +03:00
Voicu
89f10e928e Remove unused local variable 2016-09-18 09:32:34 -07:00
PhilJay
865c3dae18 Extend test cases (for bugfix) 2016-09-18 17:33:04 +02:00
PhilJay
5b9bd6e633 Fix time chart example 2016-09-18 11:13:25 +02:00
PhilJay
0aeddb025e Fix issue causing ANR for empty charts 2016-09-17 23:47:47 +02:00
PhilJay
e9459fb592 Remove unused mDrawPaint instance 2016-09-17 23:23:59 +02:00
PhilJay
d34670fa62 Remove noDataTextDescription - this can be done via noDataText as well 2016-09-17 23:23:12 +02:00
PhilJay
643f901b15 Make chart description a Component which allows to treat description similar to Legend or Axis (issue #2249) 2016-09-17 21:36:59 +02:00
Daniel Cohen Gindi
a3c1fe6bbf Added missing clip rect for zero line 2016-09-15 09:12:59 +03:00
Daniel Cohen Gindi
a6dd5bb4a1 Improved naming before the big release 2016-09-14 23:47:55 +03:00
Daniel Cohen Gindi
8f5a898a95 Improved naming 2016-09-14 22:22:32 +03:00
PhilJay
7b33554d5b Minor changes & documentation 2016-09-04 10:44:23 +02:00
Philipp Jahoda
02cf2c1b97 Merge pull request #2193 from relair/PieChart_FixForBackgroundIssue_WhenSliceIsTooSmall
Pie chart, fix for small values appearing as background
2016-09-03 19:01:39 +02:00
PhilJay
01419f795b Remove psd 2016-08-31 09:19:05 +02:00
Daniel Cohen Gindi
fd3b71f780 Reuse index 2016-08-29 22:22:14 +03:00
Marcin
afcb72f50f Fix for pie chart, so small values won't appear as "background" (which really is a huge circle) 2016-08-24 14:52:42 +01:00
Voicu
e5d03ba640 Remove nullcheck for known non-null value 2016-08-22 23:30:43 -07:00
Philipp Jahoda
8134d7f056 Merge pull request #2110 from Akylas/dasheffect
AxisLine DashEffect
2016-08-18 20:58:17 +02:00
Philipp Jahoda
e3c240bd9b Merge pull request #2172 from redwarp/master
Correct documentation for ComponentBase#setTextSize
2016-08-18 20:57:32 +02:00
Philipp Jahoda
2b04973813 Merge pull request #2168 from Sin-Wave/master
Fixed Bug in LineChartRenderer
2016-08-18 20:57:14 +02:00
Benoit Vermont
26a69592d3 Merge pull request #1 from redwarp/setTextSize-Documentation
Update ComponentBase.java
2016-08-18 16:49:10 +02:00
Benoit Vermont
9d0b0fd955 Update ComponentBase.java
Update the documentation for setTextSize, to reflect that the parameter size is in DP, and not in pixel.
2016-08-18 16:48:28 +02:00
Julian Köpke
918950b6ad respect phaseX when drawing cubicFill 2016-08-18 08:35:33 +02:00
Julian Köpke
cc971a7d02 fixed LineChartRenderer to get correct x values when using cubicFill 2016-08-17 19:44:48 +02:00
Daniel Cohen Gindi
5daa6dc23c Fill before stroke - because the fill may cover half of a thick stroke 2016-08-15 15:59:33 +03:00
Daniel Cohen Gindi
73148a6aa4 Simplified some code 2016-08-15 15:50:08 +03:00
Daniel Cohen Gindi
e556275e29 range may also be Infinite when xMin/xMax are MAX 2016-08-15 15:23:44 +03:00
Daniel Cohen Gindi
6c17ca45de Take care of edge cases when calculating intervals (labelCount == 0) 2016-08-15 15:21:33 +03:00
Philipp Jahoda
1bbf4be1ee Fixes and finishing up of autoScaleMinMax feature 2016-08-14 22:22:48 +02:00
Philipp Jahoda
336dfb93e5 Fix autoScaleMinMax 2016-08-14 21:48:05 +02:00
Philipp Jahoda
66ea845e14 Merge branch 'master' of https://github.com/PhilJay/MPAndroidChart 2016-08-14 21:25:52 +02:00
Philipp Jahoda
62bc0de28a Cleanup, preparations for autoScaleMinMax fix 2016-08-14 21:25:41 +02:00
Daniel Cohen Gindi
dab8db488f neededWidth should be enough here. formSize has no meaning globally.
If more offset is needed - use extraOffsets, or adjust the maxSizePercent).
2016-08-14 16:53:20 +03:00
Daniel Cohen Gindi
38cdf1b206 Set those sizes to dps, convert internally.
Until now it was set-dps, get-pixels.
2016-08-14 16:53:20 +03:00
Daniel Cohen Gindi
7a10c05e3a Added feature for dashing legend line forms (Closes #1843) 2016-08-14 16:53:20 +03:00
Daniel Cohen Gindi
ea6b0e8e1c Simplified legend entries configuration. Option to style dataset form... 2016-08-14 16:53:20 +03:00
Daniel Cohen Gindi
7747c34552 Add half line width to clipping rect of grid/limit lines (Closes #2081)
https://github.com/danielgindi/Charts/issues/1204
2016-08-14 11:07:26 +03:00
Philipp Jahoda
12d5b858f2 Merge 2016-08-14 09:54:32 +02:00
Philipp Jahoda
092e8a80f7 Changes related to #2119 2016-08-14 09:51:47 +02:00
Daniel Cohen Gindi
be12f155ba We need an "equals or less" here 2016-08-14 10:10:53 +03:00
Daniel Cohen Gindi
bab5b9dd6c Refined scaleXEnabled/scaleYEnabled conditioning 2016-08-14 09:37:45 +03:00
Daniel Cohen Gindi
3c8bf8cb94 Use an actual Epsilon here 2016-08-14 08:54:20 +03:00
Philipp Jahoda
d342760357 Fix issue #2102 2016-08-13 15:38:40 +02:00
Philipp Jahoda
d912964dd3 Cleanup 2016-08-13 15:27:40 +02:00
Philipp Jahoda
7462c083f9 Fix #2119 2016-08-12 21:02:25 +02:00
Philipp Jahoda
0f04e9c6f5 Documentation update 2016-08-12 20:55:59 +02:00
Philipp Jahoda
5a4a6d4065 Fix crash related to circle size (#2115) 2016-08-12 20:50:57 +02:00
Philipp Jahoda
f0e1deb763 Update image 2016-08-11 18:28:34 +02:00
Philipp Jahoda
077365c9af Add barchart wiki image 2016-08-11 18:25:29 +02:00
Philipp Jahoda
e158ef15e2 Renaming of setAxisMinValue etc to setAxisMinimum for consistency 2016-08-11 12:46:52 +02:00
Daniel Cohen Gindi
788539001f Choose a default that matches the default v2 behavior
To avoid hurting existing stylings drastically
2016-08-10 22:43:54 +03:00
Daniel Cohen Gindi
31b0fd9ff9 Updated Realm sample 2016-08-10 00:24:41 +03:00
Daniel Cohen Gindi
30cb069974 Brought back the Realm demos, were removed by mistake 2016-08-10 00:15:34 +03:00
Daniel Cohen Gindi
86d05e989a Corrected formula for 29-feb :-) 2016-08-09 20:46:04 +03:00
Daniel Cohen Gindi
71ac434a2d Pie's x is deprecated - log it out, and avoid in calcMinMax 2016-08-09 16:17:19 +03:00
Daniel Cohen Gindi
2176873271 Avoid creating a new formatter if null
This can improve performance in certain cases,
  and has the advantage of controlling the "global" default formatter
  that is used for null cases.
2016-08-09 16:02:07 +03:00
Daniel Cohen Gindi
18eec8f0e6 If we are at it - rename those interfaces too
FillFormatter -> IFillFormatter
ValueFormatter -> IValueFormatter
AxisValueFormatter -> IAxisValueFormatter
2016-08-09 15:44:03 +03:00
Daniel Cohen Gindi
02bf21df50 Reverse string formatter caches
These *will* cause trouble.
We know of users who format the strings based on the entry's location,
  view port scroll/scale, etc.

The cache will repeat irrelevant values, and gain no benefit for us.
2016-08-09 15:34:11 +03:00
Daniel Cohen Gindi
e841b697be Reversed "array access optimization"
A `for-each` loop allocates only one iterator for the whole loop,
  not for each iteration.
So this "optimization" is not needed, and just introduces additional
  clutter.

http://stackoverflow.com/questions/14640184/does-the-java-foreach-loop-create-a-new-object
2016-08-09 15:34:11 +03:00
Daniel Cohen Gindi
8cf2a6c3d0 Removed the extra offset that messed up legend location 2016-08-09 11:33:09 +03:00
Daniel Cohen Gindi
713f467ba8 Renamed Highlighter -> IHighlighter 2016-08-09 11:16:58 +03:00
Daniel Cohen Gindi
4d9dc0aa06 Safeguard for cubic bezier drawing 2016-08-08 23:32:11 +03:00
Daniel Cohen Gindi
339fa16324 Added back missing new CombinedChartRenderer 2016-08-08 22:26:05 +03:00
Daniel Cohen Gindi
aaec1f5d2c DRYed scatter code, simplified IShapeRenderer implementations 2016-08-08 22:15:57 +03:00
Daniel Cohen Gindi
51f0e53a7f Reinvented Markers - interface based, enhanced default behaviour
Two default implementations exist now: MarkerView, MarkerImage
The default behaviour constraints the marker to the view's bounds.
2016-08-08 18:25:44 +03:00
Daniel Cohen Gindi
f63002e196 Renamed x-pos to x-value where appropriate 2016-08-08 10:14:58 +03:00
Daniel Cohen Gindi
77c10fc9e5 These return a single pixel (x/y), for values (x value and y value) 2016-08-08 10:03:51 +03:00
Daniel Cohen Gindi
2d54fd1f3f Call createRenderers() instead of recreating the renderer each time 2016-08-08 09:56:04 +03:00
Daniel Cohen Gindi
79f5ed0200 Simplified scatter shape enum model
(Why would anyone try to subclass an enum?)
2016-08-08 09:56:04 +03:00
Daniel Cohen Gindi
99379d7bcf Renamed ShapeRenderer -> IShapeRenderer 2016-08-08 09:56:04 +03:00
Daniel Cohen Gindi
d2e8ee220a Renamed zoomCenter to zoomToCenter 2016-08-08 09:56:04 +03:00
Daniel Cohen Gindi
9c5a46c9f8 Gradle required 2048 heap for multidex 2016-08-08 09:56:04 +03:00
Daniel Cohen Gindi
1096719e8f drawBarShadowEnabled is working again 2016-08-08 09:56:04 +03:00
Daniel Cohen Gindi
0c00b09bdb DRYed that code 2016-08-08 09:56:04 +03:00
Daniel Cohen Gindi
1eae18b657 Keep that in a variable 2016-08-08 09:56:04 +03:00
Daniel Cohen Gindi
b2250e0155 Use scientific EPSILON 2016-08-08 09:56:04 +03:00
Daniel Cohen Gindi
164bfd7fca Fixed legend anchor for TOP 2016-08-08 09:56:04 +03:00
Daniel Cohen Gindi
f9108b9ad9 Groundwork for future support of highlight for multiple bubbles per x 2016-08-08 09:56:04 +03:00
Philipp Jahoda
342d41cbc4 Add linechart wiki 2016-08-07 23:17:11 +02:00
Philipp Jahoda
79e6a5d747 Add wiki piechart 2016-08-07 22:52:40 +02:00
Philipp Jahoda
946475b6d5 Add grouped barchart wiki image 2016-08-07 22:34:41 +02:00
Philipp Jahoda
099a9cf8c1 Minor changes 2016-08-07 10:55:42 +02:00
Martin Guillon
2f6fb103a2 method to set the dash effect 2016-08-07 10:17:32 +02:00
Martin Guillon
a91de26a52 axis line dash effect 2016-08-07 10:17:18 +02:00
Philipp Jahoda
3ea1db57ab Create example for XYMarkerView (#2029) 2016-07-16 22:53:01 +02:00
Philipp Jahoda
e000c42744 Create new XYMarkerView (#2029) 2016-07-16 22:52:10 +02:00
Philipp Jahoda
ef575decbb Remove old screenshot 2016-07-16 15:43:26 +02:00
Philipp
37c4eef38e Update build tools 2016-07-16 15:41:37 +02:00
Philipp
4d5ce149dd Ignore ds_store files 2016-07-16 15:17:54 +02:00
Philipp Jahoda
d7e659a1fa Change max-highlight-distance default to 500dp 2016-07-09 15:42:17 +02:00
Philipp Jahoda
8c67ec19f7 Fix #1978 2016-07-08 19:15:52 +02:00
Philipp Jahoda
c3dc2822ce Merge 2016-07-07 16:49:13 +02:00
Philipp Jahoda
9ccf58feab Fixes related to legend rendering (issue #1969) 2016-07-07 16:48:59 +02:00
Philipp Jahoda
2fa4a094e7 Update README.md 2016-07-07 11:36:01 +02:00
Philipp Jahoda
89104c2858 Update README.md 2016-07-07 11:34:08 +02:00
Philipp Jahoda
eb44a13434 Merge readme 2016-07-03 20:38:30 +02:00
Philipp Jahoda
16738ef480 Import cleanup 2016-07-03 20:38:12 +02:00
Philipp Jahoda
e2cbafa049 Code cleanup & new zoom method 2016-07-03 20:22:56 +02:00
Philipp Jahoda
75ba4f69fc Update README.md 2016-07-03 14:54:43 +02:00
Philipp Jahoda
db70835cbc Update README.md 2016-07-03 14:53:58 +02:00
Philipp Jahoda
1a39ac9b12 Update README.md 2016-07-03 14:49:47 +02:00
Philipp Jahoda
bad43a5e13 Move example to realm v1.1.0 2016-07-03 11:48:04 +02:00
Philipp Jahoda
83a4bf9075 Update README.md 2016-07-03 09:50:34 +02:00
Philipp Jahoda
a4ac12aebf Update README.md 2016-07-03 01:17:15 +02:00
Philipp Jahoda
08b2d55049 Update README.md 2016-07-03 00:26:11 +02:00
Philipp Jahoda
3f0f3a82c2 Improve setColors methods, cleanup 2016-07-03 00:23:56 +02:00
Philipp Jahoda
360cc24b97 Cleanup 2016-07-03 00:11:48 +02:00
Philipp Jahoda
94a67ccea0 Fixes & improvements related to circle cache 2016-07-02 21:05:00 +02:00
Philipp Jahoda
6d21817c8a Rename PointD to MPPointD 2016-07-02 12:36:16 +02:00
Philipp Jahoda
43fa1e6cec Merge #1947 2016-07-02 12:29:50 +02:00
Tony Patino
40c5c87d13 Perf + Bug (#1892) (#1895)
This changeset merges all performance updates related to #1892, as well as the bug fix for #1895 for master.
2016-07-01 13:53:51 -07:00
Tony Patino
b5da8dcdb5 Crash fix - Create small clip paths (#1895)
With large data sets, the Path object created was sufficiently large as to cause an OutOfMemory error. This is resolved by only pathing a limited number of points on the chart at a time, then clearing the path and resuming. Stress testing with 1500 entries.
2016-07-01 13:19:37 -07:00
Tony Patino
87758604d3 Revert "Crash fix - Create small clip paths (#1895)"
This reverts commit d5df3ad795.
2016-07-01 13:17:49 -07:00
Tony Patino
d5df3ad795 Crash fix - Create small clip paths (#1895)
With large data sets, the Path object created was sufficiently large as to cause an OutOfMemory error.  This is resolved by only pathing a limited number of points on the chart at a time, then clearing the path and resuming.  Stress testing with 1500 entries.
2016-07-01 13:16:22 -07:00
Tony Patino
523c7e5b21 Render bug fix - circle bitmap sizes (#1892)
Zooming in on the circle bitmaps, they were slightly small.  Allocate a little more space in the circle's bitmap to correct this.
2016-06-30 17:24:32 -07:00
Tony Patino
66094db764 Eliminate allocs - Copy arrays without new[] (#1892)
Make sure we copy List<> into [] if the size is identical to the length, instead of instantiating a new [].
2016-06-30 16:28:15 -07:00
Tony Patino
37f2498487 Eliminate allocs - MFPoint recycle (#1892)
Noticed a couple of stray un-recycled MFPoint and FSize instances.  These accounted for a bit of the remaining generated garbage.
2016-06-30 16:26:53 -07:00
Tony Patino
38fbefe66b Eliminate allocs - Move and Zoom Job Pools (#1892)
Create object pools for the Zoom, move, and animation jobs.  Their constructors remain public, to make this easier to roll back from if needed.
2016-06-30 15:33:02 -07:00
Tony Patino
5a18d0ef22 Eliminate allocs - Adjust pool replenishing (#1892)
Replenish fewer objects in utils pools when empty, in case the pool size grows large.
2016-06-30 15:30:45 -07:00
Tony Patino
b037f55d73 Eliminate allocs - XAxisRender array (#1892)
Found an array that was instantiated frequently without need.  Placed bounds on its instantiation.
2016-06-30 15:29:40 -07:00
Tony Patino
afdbd2c5f0 Eliminate allocs - Tests for StringCache (#1892)
Created unit tests for the FormattedStringCache classes.  Also, took this opportunity to create a FormattedStringCache.Generic<K,V> static class to take over what was previously simply FormattedStringCache.  Verified that all unit tests still pass.
2016-06-30 11:30:39 -07:00
Tony Patino
69f17b2a79 Eliminate allocs - Buffer ArrayLists (#1892)
Many short-lived ArrayLists were created in various methods, which could easily have been extracted to field level variable.  This has been done, and the arrays cleared before use.
2016-06-29 18:30:21 -07:00
Tony Patino
7fd18d2177 Eliminate allocs - Buffer Paint.FontMetrics (#1892)
paint.getFontMetrics() has a hidden allocation.  paint.getFontMetrics(fontMetrics) is used internally inside of Paint, so caching and holding onto a metrics buffer helps reduce allocations.
2016-06-29 17:48:31 -07:00
Tony Patino
424ee02ce2 Eliminate allocs - String Caches now have Prim subtypes (#1892)
By creating versions of the FormattedStringCache that don't require auto boxing, allocations are cut tremendously in this commit.
2016-06-29 17:36:15 -07:00
Tony Patino
a04ad28cec Eliminate allocs - Cache XBounds in Renderer (#1892)
getXBounds creates a disposable XBounds instance on every call.  Cache it and update the values with a set method.  This means XBounds values are now mutable.
2016-06-29 17:12:47 -07:00
Tony Patino
d372fd305c Eliminate allocs - Rect and RectF buffers (#1892)
Buffering temporary Rect and RectF instances.  Created methods to modify RectF instances as performance alternatives to methods that create disposable RectF instances.
2016-06-29 17:05:07 -07:00
Tony Patino
0b72b5588b Eliminate allocs - Cache formatted Strings (#1892)
ValueFormatter objects now rely on a FormattedStringCache to return already-formatted Strings.  We might want to create primitive-enabled versions since all our values to format are float or double primitives, and the keys are also all primitives.  This will eliminate auto-boxing penalties.
2016-06-29 16:43:33 -07:00
Tony Patino
bd45d73bc6 Eliminate allocs - Array Access (#1892)
foreach(:) arrays on Android carry the cost that each iteration creates an implicit instantiation.  for(;;) arrays are uglier but guarantee that no unwanted allocations occur while iterating.
2016-06-28 18:18:49 -07:00
Tony Patino
c59b46affc Eliminate allocs - Cache drawn circles as bitmaps (#1892)
LineChartRenderer now caches drawn circles as bitmaps.  ILineDataSet now has a method that returns the number of available colors in the set.
2016-06-28 17:39:42 -07:00
Tony Patino
56cfd2b42b Eliminate allocs - Matrix and Path buffers (#1892)
Created buffers for short lived Matrix and Path objects, resetting them instead of instantiating new ones.  Also created some matrix transform methods that accept output Matrix objects to facilitate caching.
2016-06-28 17:22:48 -07:00
Tony Patino
d946f3e3ff Eliminate allocs - float array buffers (#1892)
Creating field level buffers for frequently instantiated float arrays.  Cuts instantiations of many small objects.
2016-06-28 16:34:49 -07:00
Tony Patino
f86c1632a7 Eliminate allocs - MPPointF replace PointF (#1892)
In order to have a poolable alternative to PointF, this changeset introduces MPPointF.  Convenience methods exist that accept output MPPointF variables for extra savings on pool access.  Methods that return recyclable MPPointF instances are documented.
2016-06-28 15:48:48 -07:00
Tony Patino
0f2e2133d3 Eliminate allocs - Legend arrays (#1892)
In addition to creating a resized label sizes array, copy old FSize instances to the new array to cut down on the need to get instances from pool.  Recycle to pool if the labels shrank.
2016-06-28 14:48:57 -07:00
Tony Patino
fcf26aa6ad Eliminate allocs - PointD pooling (#1892)
Replace all "new PointD()" instantiations with PointD.getInstance() / PointD.recycleInstance() pairs. Helper methods overloaded to include void return / output PointD variable signatures.  Old methods remain as convenience, with notations that they return recyclable instances.
2016-06-28 14:26:27 -07:00
Tony Patino
d299546ebd Eliminate allocs - FSize pooling (#1892)
Replace all "new FSize()" instantiations with FSize.getInstance() / FSize.recycleInstance() pairs.  Smarter FSize array usage inside Legend.
2016-06-28 13:54:10 -07:00
Tony Patino
cb6dabbdec Eliminate allocs - ObjectPool and Tests (#1892) 2016-06-28 12:42:05 -07:00
365 changed files with 16490 additions and 12498 deletions

12
.github/FUNDING.yml vendored Normal file
View file

@ -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']

37
.github/ISSUE_TEMPLATE.md vendored Normal file
View file

@ -0,0 +1,37 @@
<!---
BEFORE YOU SUBMIT please read the following:
Please search open/closed issues before submitting since someone might have asked
the same thing before!
If you have a support request or question please submit them on StackOverflow:
https://stackoverflow.com/questions/tagged/mpandroidchart
using the tags `android` & `mpandroidchart`
Please also look at the CONTRIBUTING file before opening an issue:
https://github.com/PhilJay/MPAndroidChart/blob/master/CONTRIBUTING.md
Issues on GitHub are only related to problems with MPAndroidChart itself and we
cannot answer support questions here. We will close your issue without a response.
-->
**Summary**
<!-- A clear and concise description of what the bug is. -->
**Expected Behavior**
<!-- A clear and concise description of what you expected to happen. -->
**Possible Solution**
<!-- Not required, but suggest a fix/ reason for the bug, -->
<!-- or ideas how to implement the addition or change -->
**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 any other context about the problem here.
If you have source code demonstrating this bug, create a Gist:
https://help.github.com/articles/creating-gists/
and link to it here. -->

44
.github/ISSUE_TEMPLATE/Bug_report.md vendored Normal file
View file

@ -0,0 +1,44 @@
---
name: Bugs
about: Create a bug report to help us improve
---
<!---
BEFORE YOU SUBMIT please read the following:
Please search open/closed issues before submitting since someone might have asked the same thing before!
If you have a support request or question please submit them on StackOverflow:
https://stackoverflow.com/questions/tagged/mpandroidchart
using the tags `android` & `mpandroidchart`
Please also look at the CONTRIBUTING file before opening an issue:
https://github.com/PhilJay/MPAndroidChart/blob/master/CONTRIBUTING.md
Issues on GitHub are only related to problems with MPAndroidChart itself and we cannot answer
support questions here. We will close your issue without a response.
-->
**Summary**
<!-- A clear and concise description of what the bug is. -->
**Expected Behavior**
<!-- A clear and concise description of what you expected to happen. -->
**Possible Solution**
<!-- Not required, but suggest a fix/ reason for the bug, -->
<!-- or ideas how to implement the addition or change -->
**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 any other context about the problem here.
If you have source code demonstrating this bug, create a Gist:
https://help.github.com/articles/creating-gists/
and link to it here. -->
ADD A REWARD using [Speed](speedoss.com) to SOLVE this issue QUICKLY and SUPPORT this project.

View file

@ -0,0 +1,34 @@
---
name: Feature Request
about: Suggest an idea for this project
---
<!---
BEFORE YOU SUBMIT please read the following:
Please search open/closed issues before submitting since someone might have asked the same thing before!
If you have a support request or question please submit them on StackOverflow:
https://stackoverflow.com/questions/tagged/mpandroidchart
using the tags `android` & `mpandroidchart`
Please also look at the CONTRIBUTING file before opening an issue:
https://github.com/PhilJay/MPAndroidChart/blob/master/CONTRIBUTING.md
Issues on GitHub are only related to problems with MPAndroidChart itself and we cannot answer
support questions here. We will close your issue without a response.
-->
**Is your feature request related to a problem? Please describe.**
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
**Describe the solution you'd like**
<!-- A clear and concise description of what you want to happen. -->
**Describe alternatives you've considered**
<!-- A clear and concise description of any alternative solutions or features you've considered. -->
**Additional context**
<!-- Add any other context or screenshots about the feature request here. -->
ADD A REWARD using [Speed](speedoss.com) to SOLVE this issue QUICKLY and SUPPORT this project.

27
.github/ISSUE_TEMPLATE/Support_help.md vendored Normal file
View file

@ -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.

15
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View file

@ -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]
<!-- If you'd like to suggest a significant change, please
create an issue to discuss those changes and gather
feedback BEFORE submitting your PR. -->
## PR Description
<!-- Describe Your PR Here! -->
<!-- What does this add/ remove/ fix/ change? -->
<!-- WHY should this PR be merged into the main library? -->

9
.gitignore vendored
View file

@ -12,8 +12,8 @@
bin/
gen/
generated/
docs/
finalOutput/
projectFilesBackup/
build.xml
@ -23,6 +23,8 @@ local.properties
# Eclipse project files
.classpath
.project
.settings/
.vscode/
# Proguard folder generated by Eclipse
proguard/
@ -31,7 +33,8 @@ proguard/
*.iml
*.ipr
*.iws
.idea/
/.idea/*
!/.idea/runConfigurations
.directory
@ -42,3 +45,5 @@ build/
# maven
target/
.DS_Store

View file

@ -0,0 +1,52 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="MPChartExample" type="AndroidRunConfigurationType" factoryName="Android App" activateToolWindowBeforeRun="false">
<module name="MPChartExample" />
<option name="DEPLOY" value="true" />
<option name="DEPLOY_APK_FROM_BUNDLE" value="false" />
<option name="ARTIFACT_NAME" value="" />
<option name="PM_INSTALL_OPTIONS" value="" />
<option name="DYNAMIC_FEATURES_DISABLED_LIST" value="" />
<option name="ACTIVITY_EXTRA_FLAGS" value="" />
<option name="MODE" value="default_activity" />
<option name="CLEAR_LOGCAT" value="false" />
<option name="SHOW_LOGCAT_AUTOMATICALLY" value="false" />
<option name="SKIP_NOOP_APK_INSTALLATIONS" value="true" />
<option name="FORCE_STOP_RUNNING_APP" value="true" />
<option name="TARGET_SELECTION_MODE" value="SHOW_DIALOG" />
<option name="USE_LAST_SELECTED_DEVICE" value="false" />
<option name="PREFERRED_AVD" value="" />
<option name="SELECTED_CLOUD_MATRIX_CONFIGURATION_ID" value="-1" />
<option name="SELECTED_CLOUD_MATRIX_PROJECT_ID" value="" />
<option name="DEBUGGER_TYPE" value="Auto" />
<Auto>
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
<option name="SHOW_STATIC_VARS" value="true" />
<option name="WORKING_DIR" value="" />
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
</Auto>
<Hybrid>
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
<option name="SHOW_STATIC_VARS" value="true" />
<option name="WORKING_DIR" value="" />
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
</Hybrid>
<Java />
<Native>
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
<option name="SHOW_STATIC_VARS" value="true" />
<option name="WORKING_DIR" value="" />
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
</Native>
<Profilers>
<option name="ADVANCED_PROFILING_ENABLED" value="false" />
<option name="STARTUP_CPU_PROFILING_ENABLED" value="false" />
<option name="STARTUP_CPU_PROFILING_CONFIGURATION_NAME" value="Sampled (Java)" />
</Profilers>
<option name="DEEP_LINK" value="" />
<option name="ACTIVITY_CLASS" value="" />
<method />
</configuration>
</component>

View file

@ -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=

View file

@ -1,49 +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.
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.
## Simple issues and bug reports
## Creating Issues
If you are reporting a bug which can be observed visually, please add to your issue either:
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.
* Screenshots, if the bug is easily explainable
* A working sample project that we can compile, run, and immediately observe the issue
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!
## Getting Started with Contributions
## Making Pull Requests
* Make sure you have a [GitHub account](https://github.com/signup/free)
* Submit a ticket for your issue, assuming one does not already exist.
* Clearly describe the issue including steps to reproduce when it is a bug.
* Make sure you fill in the earliest version (or commit number) that you know has the issue.
* Fork the repository on GitHub
Careful! If you fail to follow these guidlines, you're pull request may be closed, *even if it's really awesome*.
## Making Changes
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.
* Create a topic branch from where you want to base your work. This is usually the master branch.
* Make commits of logical units.
* Make sure your code conforms to the code style around it. It's easy, just look around!
* If you have made changes back and forth, or have made merges, your commit history might look messy and hard to understand. A single issue or change should still be in one commit. So please squash those commits together and rebase them however you need to - to make our lives easier when reading it later.
* Check for unnecessary whitespace with `git diff --check` before committing.
* Make sure your commit messages are in the proper format.
Check out [#3975](https://github.com/PhilJay/MPAndroidChart/pull/3975) for an example of a good-made-better pull request.
````
First line must be up to 50 chars (Fixes #1234)
## Commit Style
The first line should be a short statement as to what have changed, and should also include an issue number, prefixed with a dash.
The body of the message comes after an empty new line, and describes the changes
more thoroughly, especially if there was a special case handled there,
or maybe some trickery that only code wizards can understand.
````
* **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
* Make sure you have tested your changes well.
* If your changes could theoretically affect some other component or case, which you do not necessarily use, you still have to test it.
* Create a Pull Request from your topic branch to the relevant branch in the main repo. If you go to the main repo of the framework, you'll see a big green button which pretty much prepares the PR for you. You just have to hit it.
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.
## Making Trivial Changes
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.
```
For changes of a trivial nature to comments and documentation, it is not
always necessary to create a new ticket. In this case, it is
appropriate to start the first line of a commit with '(doc)' instead of
a ticket number. Even the default commit message the GitHub generates is fine with us.
## 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

201
LICENSE Normal file
View file

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file 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.

View file

@ -1 +1,2 @@
/build
/release

View file

@ -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=..

View file

@ -1,71 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xxmassdeveloper.mpchartexample"
android:versionCode="52"
android:versionName="3.0.0" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="23" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.xxmassdeveloper.mpchartexample.notimportant.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="LineChartActivity1"></activity> <!-- android:configChanges="keyboardHidden|orientation|screenSize" -->
<activity android:name="LineChartActivity2"></activity>
<activity android:name=".LineChartTime"></activity>
<activity android:name="BarChartActivity"></activity>
<activity android:name="HorizontalBarChartActivity"></activity>
<activity android:name="PieChartActivity"></activity>
<activity android:name="PiePolylineChartActivity"></activity>
<activity android:name="MultiLineChartActivity"></activity>
<activity android:name="BarChartActivityMultiDataset"></activity>
<activity android:name="DrawChartActivity"></activity>
<activity android:name="ScatterChartActivity"></activity>
<activity android:name="BubbleChartActivity"></activity>
<activity android:name="com.xxmassdeveloper.mpchartexample.fragments.SimpleChartDemo"></activity>
<activity android:name="ListViewBarChartActivity"></activity>
<activity android:name="ListViewMultiChartActivity"></activity>
<activity android:name="StackedBarActivity"></activity>
<activity android:name="AnotherBarActivity"></activity>
<activity android:name="InvertedLineChartActivity"></activity>
<activity android:name="CandleStickChartActivity"></activity>
<activity android:name="CubicLineChartActivity"></activity>
<activity android:name="RadarChartActivitry"></activity>
<activity android:name="LineChartActivityColored"></activity>
<activity android:name="DynamicalAddingActivity"></activity>
<activity android:name=".realm.RealmDatabaseActivityLine"></activity>
<activity android:name=".realm.RealmDatabaseActivityBar"></activity>
<activity android:name=".realm.RealmDatabaseActivityHorizontalBar"></activity>
<activity android:name=".realm.RealmDatabaseActivityScatter"></activity>
<activity android:name=".realm.RealmDatabaseActivityCandle"></activity>
<activity android:name=".realm.RealmDatabaseActivityBubble"></activity>
<activity android:name=".realm.RealmDatabaseActivityPie"></activity>
<activity android:name=".realm.RealmDatabaseActivityRadar"></activity>
<activity android:name=".realm.RealmMainActivity"></activity>
<activity android:name="RealtimeLineChartActivity"></activity>
<activity android:name="CombinedChartActivity"></activity>
<activity android:name="PerformanceLineChart"></activity>
<activity android:name="BarChartActivitySinus"></activity>
<activity android:name="ScrollViewActivity"></activity>
<activity android:name="StackedBarActivityNegative"></activity>
<activity android:name=".realm.RealmWikiExample"></activity>
<activity android:name=".BarChartPositiveNegative"></activity>
<activity android:name=".FilledLineActivity"></activity>
<activity android:name=".HalfPieChartActivity"></activity>
</application>
</manifest>

View file

@ -1,65 +1,26 @@
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
compileSdkVersion 28
defaultConfig {
applicationId "com.xxmassdeveloper.mpchartexample"
minSdkVersion 16
targetSdkVersion 23
versionCode 52
versionName '3.0.0'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
sourceSets {
main {
java.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
manifest.srcFile 'AndroidManifest.xml'
}
}
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:2.1.2'
//classpath 'io.realm:realm-gradle-plugin:0.88.2'
// 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-Realm') // clone "https://github.com/PhilJay/MPAndroidChart-Realm" to get this or uncomment the gradle dependency below:
compile 'com.github.PhilJay:MPAndroidChart-Realm:v1.0.0@aar'
compile project(':MPChartLib')
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.5'
implementation "androidx.appcompat:appcompat:1.0.2"
implementation 'com.google.android.material:material:1.0.0'
implementation project(':MPChartLib')
}

View file

@ -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 *;
#}

21
MPChartExample/proguard-rules.pro vendored Normal file
View file

@ -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

View file

@ -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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

View file

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:width="2dp"
android:color="#FA6185" />
<solid android:color="#FA6185" />
<corners android:radius="5dp" />
</shape>

View file

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.github.mikephil.charting.charts.BubbleChart
android:id="@+id/chart1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>

View file

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.github.mikephil.charting.charts.CandleStickChart
android:id="@+id/chart1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>

View file

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.github.mikephil.charting.charts.HorizontalBarChart
android:id="@+id/chart1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>

View file

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.github.mikephil.charting.charts.PieChart
android:id="@+id/chart1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>

View file

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.6"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="YOUR PREFERENCES"
android:id="@+id/textView"/>
<com.github.mikephil.charting.charts.RadarChart
android:id="@+id/chart1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2" />
</LinearLayout>

View file

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:orientation="vertical">
<com.github.mikephil.charting.charts.LineChart
android:id="@+id/lineChart"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<com.github.mikephil.charting.charts.BarChart
android:id="@+id/barChart"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>

View file

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.github.mikephil.charting.charts.ScatterChart
android:id="@+id/chart1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>

View file

@ -1,41 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/actionToggleValues"
android:title="Toggle Values">
</item>
<item
android:id="@+id/actionToggleHighlight"
android:title="Toggle Highlight">
</item>
<item
android:id="@+id/actionToggleAdjustXLegend"
android:title="Toggle AdjustXLegend">
</item>
<item
android:id="@+id/animateX"
android:title="Animate X">
</item>
<item
android:id="@+id/animateY"
android:title="Animate Y">
</item>
<item
android:id="@+id/animateXY"
android:title="Animate XY">
</item>
<item
android:id="@+id/actionSave"
android:title="Save to Gallery">
</item>
<item
android:id="@+id/actionTogglePinch"
android:title="Toggle PinchZoom">
</item>
<item
android:id="@+id/actionToggleAutoScaleMinMax"
android:title="Toggle auto scale min/max">
</item>
</menu>

View file

@ -1,41 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/actionToggleHighlight"
android:title="Toggle Highlight">
</item>
<item
android:id="@+id/animateX"
android:title="Animate X">
</item>
<item
android:id="@+id/animateY"
android:title="Animate Y">
</item>
<item
android:id="@+id/animateXY"
android:title="Animate XY">
</item>
<item
android:id="@+id/actionToggleAdjustXLegend"
android:title="Toggle AdjustXLegend">
</item>
<item
android:id="@+id/actionSave"
android:title="Save to SD-Card">
</item>
<item
android:id="@+id/actionTogglePinch"
android:title="Toggle PinchZoom">
</item>
<item
android:id="@+id/actionToggleAutoScaleMinMax"
android:title="Toggle auto scale min/max">
</item>
<item
android:id="@+id/actionToggleMakeShadowSameColorAsCandle"
android:title="Toggle shadow same color">
</item>
</menu>

View file

@ -1,33 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/actionAddEntry"
android:title="Add Entry">
</item>
<item
android:id="@+id/actionRemoveEntry"
android:title="Remove Entry">
</item>
<item
android:id="@+id/actionAddDataSet"
android:title="Add DataSet">
</item>
<item
android:id="@+id/actionRemoveDataSet"
android:title="Remove DataSet">
</item>
<item
android:id="@+id/actionAddEmptyLineData"
android:title="Add empty LineData">
</item>
<item
android:id="@+id/actionClear"
android:title="Clear chart">
</item>
</menu>

View file

@ -1,45 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/actionToggleValues"
android:title="Toggle Y-Values">
</item>
<item
android:id="@+id/actionToggleXVals"
android:title="Toggle X-Values">
</item>
<item
android:id="@+id/actionTogglePercent"
android:title="Toggle Percent">
</item>
<item
android:id="@+id/actionToggleHole"
android:title="Toggle Hole">
</item>
<item
android:id="@+id/animateX"
android:title="Animate X">
</item>
<item
android:id="@+id/animateY"
android:title="Animate Y">
</item>
<item
android:id="@+id/animateXY"
android:title="Animate XY">
</item>
<item
android:id="@+id/actionDrawCenter"
android:title="Draw CenterText">
</item>
<item
android:id="@+id/actionSave"
android:title="Save to Gallery">
</item>
<item
android:id="@+id/actionToggleSpin"
android:title="Spin Animation">
</item>
</menu>

View file

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/actionAdd"
android:title="Feed new Entry">
</item>
<item
android:id="@+id/actionClear"
android:title="Clear Values">
</item>
<item
android:id="@+id/actionFeedMultiple"
android:title="Fast feed multiple">
</item>
</menu>

View file

@ -1,8 +0,0 @@
<resources>
<!--
Customize dimensions originally defined in res/values/dimens.xml (such as
screen margins) for sw600dp devices (e.g. 7" tablets) here.
-->
</resources>

View file

@ -1,9 +0,0 @@
<resources>
<!--
Customize dimensions originally defined in res/values/dimens.xml (such as
screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
-->
<dimen name="activity_horizontal_margin">128dp</dimen>
</resources>

View file

@ -1,11 +0,0 @@
<resources>
<!--
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<!-- API 11 theme customizations can go here. -->
</style>
</resources>

View file

@ -1,12 +0,0 @@
<resources>
<!--
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>
</resources>

View file

@ -1,7 +0,0 @@
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>

View file

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">MPAndroidChart Example</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
</resources>

View file

@ -1,20 +0,0 @@
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>

View file

@ -1,200 +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.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.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);
}
@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.actionToggleBarBorders: {
for (IBarDataSet set : mChart.getData().getDataSets())
((BarDataSet)set).setBarBorderWidth(set.getBarBorderWidth() == 1.f ? 0.f : 1.f);
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<BarEntry> yVals1 = new ArrayList<BarEntry>();
for (int i = 0; i < mSeekBarX.getProgress() + 1; i++) {
float mult = (mSeekBarY.getProgress() + 1);
float val = (float) (Math.random() * mult) + mult / 3;
yVals1.add(new BarEntry(i, val));
}
BarDataSet set1;
if (mChart.getData() != null &&
mChart.getData().getDataSetCount() > 0) {
set1 = (BarDataSet)mChart.getData().getDataSetByIndex(0);
set1.setValues(yVals1);
mChart.getData().notifyDataChanged();
mChart.notifyDataSetChanged();
} else {
set1 = new BarDataSet(yVals1, "Data Set");
set1.setColors(ColorTemplate.VORDIPLOM_COLORS);
set1.setDrawValues(false);
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(set1);
BarData data = new BarData(dataSets);
mChart.setData(data);
mChart.setFitBars(true);
}
mChart.invalidate();
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
}

View file

@ -1,279 +0,0 @@
package com.xxmassdeveloper.mpchartexample;
import android.annotation.SuppressLint;
import android.graphics.PointF;
import android.graphics.RectF;
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.formatter.AxisValueFormatter;
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.ColorTemplate;
import com.xxmassdeveloper.mpchartexample.custom.DayAxisValueFormatter;
import com.xxmassdeveloper.mpchartexample.custom.MyAxisValueFormatter;
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;
@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);
XAxis xAxis = mChart.getXAxis();
xAxis.setPosition(XAxisPosition.BOTTOM);
xAxis.setTypeface(mTfLight);
xAxis.setDrawGridLines(false);
xAxis.setGranularity(1f); // only intervals of 1 day
xAxis.setLabelCount(7);
xAxis.setValueFormatter(new DayAxisValueFormatter(mChart));
AxisValueFormatter custom = new MyAxisValueFormatter();
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setTypeface(mTfLight);
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(mTfLight);
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.actionToggleBarBorders: {
for (IBarDataSet set : mChart.getData().getDataSets())
((BarDataSet) set).setBarBorderWidth(set.getBarBorderWidth() == 1.f ? 0.f : 1.f);
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() + 2));
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) {
float start = 0f;
mChart.getXAxis().setAxisMinValue(start);
mChart.getXAxis().setAxisMaxValue(start + count + 2);
ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>();
for (int i = (int) start; i < start + count + 1; i++) {
float mult = (range + 1);
float val = (float) (Math.random() * mult);
yVals1.add(new BarEntry(i + 1f, val));
}
BarDataSet set1;
if (mChart.getData() != null &&
mChart.getData().getDataSetCount() > 0) {
set1 = (BarDataSet) mChart.getData().getDataSetByIndex(0);
set1.setValues(yVals1);
mChart.getData().notifyDataChanged();
mChart.notifyDataSetChanged();
} else {
set1 = new BarDataSet(yVals1, "The year 2017");
set1.setColors(ColorTemplate.MATERIAL_COLORS);
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(set1);
BarData data = new BarData(dataSets);
data.setValueTextSize(10f);
data.setValueTypeface(mTfLight);
data.setBarWidth(0.9f);
mChart.setData(data);
}
}
@SuppressLint("NewApi")
@Override
public void onValueSelected(Entry e, 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.getLowestVisibleX() + ", high: "
+ mChart.getHighestVisibleX());
}
@Override
public void onNothingSelected() { }
}

View file

@ -1,280 +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.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.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.AxisValueFormatter;
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;
@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);
// set the marker to the chart
mChart.setMarkerView(mv);
mSeekBarX.setProgress(10);
mSeekBarY.setProgress(100);
Legend l = mChart.getLegend();
l.setPosition(LegendPosition.RIGHT_OF_CHART_INSIDE);
l.setTypeface(mTfLight);
l.setYOffset(0f);
l.setYEntrySpace(0f);
l.setTextSize(8f);
XAxis xl = mChart.getXAxis();
xl.setTypeface(mTfLight);
xl.setGranularity(1f);
xl.setCenterAxisLabels(true);
xl.setValueFormatter(new AxisValueFormatter() {
@Override
public String getFormattedValue(float value, AxisBase axis) {
return String.valueOf((int) value);
}
@Override
public int getDecimalDigits() {
return 0;
}
});
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setTypeface(mTfLight);
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.actionToggleBarBorders: {
for (IBarDataSet set : mChart.getData().getDataSets())
((BarDataSet)set).setBarBorderWidth(set.getBarBorderWidth() == 1.f ? 0.f : 1.f);
mChart.invalidate();
break;
}
case R.id.actionToggleHighlight: {
if(mChart.getData() != null) {
mChart.getData().setHighlightEnabled(!mChart.getData().isHighlightEnabled());
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) {
float groupSpace = 0.04f;
float barSpace = 0.02f; // x3 dataset
float barWidth = 0.3f; // x3 dataset
// (0.3 + 0.02) * 3 + 0.04 = 1.00 -> interval per "group"
int startYear = 1980;
int endYear = startYear + mSeekBarX.getProgress();
tvX.setText(startYear + "\n-" + endYear);
tvY.setText("" + (mSeekBarY.getProgress()));
ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>();
ArrayList<BarEntry> yVals2 = new ArrayList<BarEntry>();
ArrayList<BarEntry> yVals3 = new ArrayList<BarEntry>();
float mult = mSeekBarY.getProgress() * 100000f;
for (int i = startYear; i < endYear; i++) {
float val = (float) (Math.random() * mult) + 3;
yVals1.add(new BarEntry(i, val));
}
for (int i = startYear; i < endYear; i++) {
float val = (float) (Math.random() * mult) + 3;
yVals2.add(new BarEntry(i, val));
}
for (int i = startYear; i < endYear; i++) {
float val = (float) (Math.random() * mult) + 3;
yVals3.add(new BarEntry(i, val));
}
BarDataSet set1, set2, set3;
if (mChart.getData() != null &&
mChart.getData().getDataSetCount() > 0) {
set1 = (BarDataSet)mChart.getData().getDataSetByIndex(0);
set2 = (BarDataSet)mChart.getData().getDataSetByIndex(1);
set3 = (BarDataSet)mChart.getData().getDataSetByIndex(2);
set1.setValues(yVals1);
set2.setValues(yVals2);
set3.setValues(yVals3);
mChart.getData().notifyDataChanged();
mChart.notifyDataSetChanged();
} else {
// create 3 datasets with different types
set1 = new BarDataSet(yVals1, "Company A");
// set1.setColors(ColorTemplate.createColors(getApplicationContext(),
// ColorTemplate.FRESH_COLORS));
set1.setColor(Color.rgb(104, 241, 175));
set2 = new BarDataSet(yVals2, "Company B");
set2.setColor(Color.rgb(164, 228, 251));
set3 = new BarDataSet(yVals3, "Company C");
set3.setColor(Color.rgb(242, 247, 158));
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(set1);
dataSets.add(set2);
dataSets.add(set3);
BarData data = new BarData(dataSets);
data.setValueFormatter(new LargeValueFormatter());
// add space between the dataset groups in percent of bar-width
data.setValueTypeface(mTfLight);
mChart.setData(data);
}
mChart.getBarData().setBarWidth(barWidth);
mChart.getXAxis().setAxisMinValue(startYear);
mChart.getXAxis().setAxisMaxValue(mChart.getBarData().getGroupWidth(groupSpace, barSpace) * mSeekBarX.getProgress() + startYear);
mChart.groupBars(startYear, groupSpace, barSpace);
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, Highlight h) {
Log.i("Activity", "Selected: " + e.toString() + ", dataSet: " + h.getDataSetIndex());
}
@Override
public void onNothingSelected() {
Log.i("Activity", "Nothing selected.");
}
}

View file

@ -1,226 +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.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.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 {
protected BarChart mChart;
private SeekBar mSeekBarX;
private TextView tvX;
private List<BarEntry> 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);
XAxis xAxis = mChart.getXAxis();
xAxis.setEnabled(false);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setTypeface(mTfLight);
leftAxis.setLabelCount(6, false);
leftAxis.setAxisMinValue(-2.5f);
leftAxis.setAxisMaxValue(2.5f);
leftAxis.setGranularityEnabled(true);
leftAxis.setGranularity(0.1f);
YAxis rightAxis = mChart.getAxisRight();
rightAxis.setDrawGridLines(false);
rightAxis.setTypeface(mTfLight);
rightAxis.setLabelCount(6, false);
rightAxis.setAxisMinValue(-2.5f);
rightAxis.setAxisMaxValue(2.5f);
rightAxis.setGranularity(0.1f);
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.actionToggleBarBorders: {
for (IBarDataSet set : mChart.getData().getDataSets())
((BarDataSet) set).setBarBorderWidth(set.getBarBorderWidth() == 1.f ? 0.f : 1.f);
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<BarEntry> entries = new ArrayList<BarEntry>();
for (int i = 0; i < count; i++) {
entries.add(mSinusData.get(i));
}
BarDataSet set;
if (mChart.getData() != null &&
mChart.getData().getDataSetCount() > 0) {
set = (BarDataSet) mChart.getData().getDataSetByIndex(0);
set.setValues(entries);
mChart.getData().notifyDataChanged();
mChart.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(mTfLight);
data.setDrawValues(false);
data.setBarWidth(0.8f);
mChart.setData(data);
}
}

View file

@ -1,236 +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.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.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;
@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("");
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(10);
mSeekBarY.setProgress(50);
Legend l = mChart.getLegend();
l.setPosition(LegendPosition.RIGHT_OF_CHART);
l.setTypeface(mTfLight);
YAxis yl = mChart.getAxisLeft();
yl.setTypeface(mTfLight);
yl.setSpaceTop(30f);
yl.setSpaceBottom(30f);
yl.setDrawZeroLine(false);
mChart.getAxisRight().setEnabled(false);
XAxis xl = mChart.getXAxis();
xl.setPosition(XAxis.XAxisPosition.BOTTOM);
xl.setTypeface(mTfLight);
}
@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.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();
int range = mSeekBarY.getProgress();
tvX.setText("" + count);
tvY.setText("" + range);
ArrayList<BubbleEntry> yVals1 = new ArrayList<BubbleEntry>();
ArrayList<BubbleEntry> yVals2 = new ArrayList<BubbleEntry>();
ArrayList<BubbleEntry> yVals3 = new ArrayList<BubbleEntry>();
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<IBubbleDataSet> dataSets = new ArrayList<IBubbleDataSet>();
dataSets.add(set1); // add the datasets
dataSets.add(set2);
dataSets.add(set3);
// create a data object with the datasets
BubbleData data = new BubbleData(dataSets);
data.setDrawValues(false);
data.setValueTypeface(mTfLight);
data.setValueTextSize(8f);
data.setValueTextColor(Color.WHITE);
data.setHighlightCircleWidth(1.5f);
mChart.setData(data);
mChart.invalidate();
}
@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() {
// 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
}
}

View file

@ -1,207 +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.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);
}
@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<CandleEntry> yVals1 = new ArrayList<CandleEntry>();
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));
}
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(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
}
}

View file

@ -1,150 +0,0 @@
package com.xxmassdeveloper.mpchartexample;
import android.graphics.Color;
import android.os.Bundle;
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.FillFormatter;
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;
public class FilledLineActivity extends DemoBase {
private LineChart mChart;
private int mFillColor = 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);
mChart = (LineChart) findViewById(R.id.chart1);
mChart.setBackgroundColor(Color.WHITE);
mChart.setGridBackgroundColor(mFillColor);
mChart.setDrawGridBackground(true);
mChart.setDrawBorders(true);
// no description text
mChart.setDescription("");
// if disabled, scaling can be done on x- and y-axis separately
mChart.setPinchZoom(false);
Legend l = mChart.getLegend();
l.setEnabled(false);
XAxis xAxis = mChart.getXAxis();
xAxis.setEnabled(false);
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setAxisMaxValue(900f);
leftAxis.setAxisMinValue(-250f);
leftAxis.setDrawAxisLine(false);
leftAxis.setDrawZeroLine(false);
leftAxis.setDrawGridLines(false);
mChart.getAxisRight().setEnabled(false);
// add data
setData(100, 60);
mChart.invalidate();
}
private void setData(int count, float range) {
ArrayList<Entry> yVals1 = new ArrayList<Entry>();
for (int i = 0; i < count; i++) {
float val = (float) (Math.random() * range) + 50;// + (float)
// ((mult *
// 0.1) / 10);
yVals1.add(new Entry(i, val));
}
ArrayList<Entry> yVals2 = new ArrayList<Entry>();
for (int i = 0; i < count; i++) {
float val = (float) (Math.random() * range) + 450;// + (float)
// ((mult *
// 0.1) / 10);
yVals2.add(new Entry(i, val));
}
LineDataSet set1, set2;
if (mChart.getData() != null &&
mChart.getData().getDataSetCount() > 0) {
set1 = (LineDataSet)mChart.getData().getDataSetByIndex(0);
set2 = (LineDataSet)mChart.getData().getDataSetByIndex(1);
set1.setValues(yVals1);
set2.setValues(yVals2);
mChart.getData().notifyDataChanged();
mChart.notifyDataSetChanged();
} else {
// create a dataset and give it a type
set1 = new LineDataSet(yVals1, "DataSet 1");
set1.setAxisDependency(YAxis.AxisDependency.LEFT);
set1.setColor(Color.rgb(255, 241, 46));
set1.setDrawCircles(false);
set1.setLineWidth(2f);
set1.setCircleRadius(3f);
set1.setFillAlpha(255);
set1.setDrawFilled(true);
set1.setFillColor(Color.WHITE);
set1.setHighLightColor(Color.rgb(244, 117, 117));
set1.setDrawCircleHole(false);
set1.setFillFormatter(new FillFormatter() {
@Override
public float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider) {
return mChart.getAxisLeft().getAxisMinimum();
}
});
// create a dataset and give it a type
set2 = new LineDataSet(yVals2, "DataSet 2");
set2.setAxisDependency(YAxis.AxisDependency.LEFT);
set2.setColor(Color.rgb(255, 241, 46));
set2.setDrawCircles(false);
set2.setLineWidth(2f);
set2.setCircleRadius(3f);
set2.setFillAlpha(255);
set2.setDrawFilled(true);
set2.setFillColor(Color.WHITE);
set2.setDrawCircleHole(false);
set2.setHighLightColor(Color.rgb(244, 117, 117));
set2.setFillFormatter(new FillFormatter() {
@Override
public float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider) {
return mChart.getAxisLeft().getAxisMaximum();
}
});
ArrayList<ILineDataSet> dataSets = new ArrayList<ILineDataSet>();
dataSets.add(set1); // add the datasets
dataSets.add(set2);
// create a data object with the datasets
LineData data = new LineData(dataSets);
data.setDrawValues(false);
// set data
mChart.setData(data);
}
}
}

View file

@ -1,266 +0,0 @@
package com.xxmassdeveloper.mpchartexample;
import android.annotation.SuppressLint;
import android.graphics.PointF;
import android.graphics.RectF;
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.highlight.Highlight;
import com.github.mikephil.charting.interfaces.datasets.IBarDataSet;
import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
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;
@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.setDrawGridBackground(false);
XAxis xl = mChart.getXAxis();
xl.setPosition(XAxisPosition.BOTTOM);
xl.setTypeface(mTfLight);
xl.setDrawAxisLine(true);
xl.setDrawGridLines(false);
xl.setGranularity(10f);
YAxis yl = mChart.getAxisLeft();
yl.setTypeface(mTfLight);
yl.setDrawAxisLine(true);
yl.setDrawGridLines(true);
yl.setAxisMinValue(0f); // this replaces setStartAtZero(true)
// yl.setInverted(true);
YAxis yr = mChart.getAxisRight();
yr.setTypeface(mTfLight);
yr.setDrawAxisLine(true);
yr.setDrawGridLines(false);
yr.setAxisMinValue(0f); // this replaces setStartAtZero(true)
// yr.setInverted(true);
setData(12, 50);
mChart.setFitBars(true);
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);
}
@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<IBarDataSet> 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.actionToggleBarBorders: {
for (IBarDataSet set : mChart.getData().getDataSets())
((BarDataSet)set).setBarBorderWidth(set.getBarBorderWidth() == 1.f ? 0.f : 1.f);
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.setFitBars(true);
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) {
float barWidth = 9f;
float spaceForBar = 10f;
ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>();
for (int i = 0; i < count; i++) {
float val = (float) (Math.random() * range);
yVals1.add(new BarEntry(i * spaceForBar, val));
}
BarDataSet set1;
if (mChart.getData() != null &&
mChart.getData().getDataSetCount() > 0) {
set1 = (BarDataSet)mChart.getData().getDataSetByIndex(0);
set1.setValues(yVals1);
mChart.getData().notifyDataChanged();
mChart.notifyDataSetChanged();
} else {
set1 = new BarDataSet(yVals1, "DataSet 1");
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(set1);
BarData data = new BarData(dataSets);
data.setValueTextSize(10f);
data.setValueTypeface(mTfLight);
data.setBarWidth(barWidth);
mChart.setData(data);
}
}
@SuppressLint("NewApi")
@Override
public void onValueSelected(Entry e, Highlight h) {
if (e == null)
return;
RectF bounds = mChart.getBarBounds((BarEntry) e);
PointF position = mChart.getPosition(e, mChart.getData().getDataSetByIndex(h.getDataSetIndex())
.getAxisDependency());
Log.i("bounds", bounds.toString());
Log.i("position", position.toString());
}
@Override
public void onNothingSelected() {
};
}

View file

@ -1,448 +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.github.mikephil.charting.utils.Utils;
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.enableGridDashedLine(10f, 10f, 0f);
//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);
//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<ILineDataSet> 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<ILineDataSet> 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<ILineDataSet> 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<ILineDataSet> sets = mChart.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);
}
mChart.invalidate();
break;
}
case R.id.actionToggleStepped: {
List<ILineDataSet> sets = mChart.getData()
.getDataSets();
for (ILineDataSet iSet : sets) {
LineDataSet set = (LineDataSet) iSet;
set.setMode(set.getMode() == LineDataSet.Mode.STEPPED
? LineDataSet.Mode.LINEAR
: LineDataSet.Mode.STEPPED);
}
mChart.invalidate();
break;
}
case R.id.actionToggleHorizontalCubic: {
List<ILineDataSet> sets = mChart.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);
}
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<Entry> values = new ArrayList<Entry>();
for (int i = 0; i < count; i++) {
float val = (float) (Math.random() * range) + 3;
values.add(new Entry(i, val));
}
LineDataSet set1;
if (mChart.getData() != null &&
mChart.getData().getDataSetCount() > 0) {
set1 = (LineDataSet)mChart.getData().getDataSetByIndex(0);
set1.setValues(values);
mChart.getData().notifyDataChanged();
mChart.notifyDataSetChanged();
} else {
// create a dataset and give it a type
set1 = new LineDataSet(values, "DataSet 1");
// 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);
set1.setDrawFilled(true);
if (Utils.getSDKInt() >= 18) {
// fill drawable only supported on api level 18 and above
Drawable drawable = ContextCompat.getDrawable(this, R.drawable.fade_red);
set1.setFillDrawable(drawable);
}
else {
set1.setFillColor(Color.BLACK);
}
ArrayList<ILineDataSet> dataSets = new ArrayList<ILineDataSet>();
dataSets.add(set1); // add the datasets
// create a data object with the datasets
LineData data = new LineData(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, Highlight h) {
Log.i("Entry selected", e.toString());
Log.i("LOWHIGH", "low: " + mChart.getLowestVisibleX() + ", high: " + mChart.getHighestVisibleX());
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.");
}
}

View file

@ -1,242 +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.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().setEnabled(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<ILineDataSet> 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<ILineDataSet> 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<ILineDataSet> 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<ILineDataSet> dataSets = new ArrayList<ILineDataSet>();
for (int z = 0; z < 3; z++) {
ArrayList<Entry> values = new ArrayList<Entry>();
for (int i = 0; i < mSeekBarX.getProgress(); i++) {
double val = (Math.random() * mSeekBarY.getProgress()) + 3;
values.add(new Entry(i, (float) val));
}
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(dataSets);
mChart.setData(data);
mChart.invalidate();
}
@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() {
// TODO Auto-generated method stub
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
}

View file

@ -1,125 +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<Entry> yVals = new ArrayList<Entry>();
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(i * 0.001f, val));
}
// 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.setMode(LineDataSet.Mode.LINEAR);
set1.setDrawFilled(false);
// create a data object with the datasets
LineData data = new LineData(set1);
// set data
mChart.setData(data);
// get the legend (only possible after setting data)
Legend l = mChart.getLegend();
l.setEnabled(false);
}
}

View file

@ -1,279 +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.data.PieEntry;
import com.github.mikephil.charting.formatter.PercentFormatter;
import com.github.mikephil.charting.highlight.Highlight;
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 PieChartActivity extends DemoBase implements OnSeekBarChangeListener,
OnChartValueSelectedListener {
private PieChart 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_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);
mChart.setCenterTextTypeface(mTfLight);
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(4, 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);
// entry label styling
mChart.setEntryLabelColor(Color.WHITE);
mChart.setEntryLabelTypeface(mTfRegular);
mChart.setEntryLabelTextSize(12f);
}
@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.setDrawEntryLabels(!mChart.isDrawEntryLabelsEnabled());
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;
}
case R.id.actionToggleSpin: {
mChart.spin(1000, mChart.getRotationAngle(), mChart.getRotationAngle() + 360, Easing.EasingOption
.EaseInCubic);
break;
}
}
return true;
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
tvX.setText("" + (mSeekBarX.getProgress()));
tvY.setText("" + (mSeekBarY.getProgress()));
setData(mSeekBarX.getProgress(), mSeekBarY.getProgress());
}
private void setData(int count, float range) {
float mult = range;
ArrayList<PieEntry> entries = new ArrayList<PieEntry>();
// NOTE: The order of the entries when being added to the entries array determines their position around the center of
// the chart.
for (int i = 0; i < count ; i++) {
entries.add(new PieEntry((float) ((Math.random() * mult) + mult / 5), mParties[i % mParties.length]));
}
PieDataSet dataSet = new PieDataSet(entries, "Election Results");
dataSet.setSliceSpace(3f);
dataSet.setSelectionShift(5f);
// add a lot of colors
ArrayList<Integer> colors = new ArrayList<Integer>();
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(dataSet);
data.setValueFormatter(new PercentFormatter());
data.setValueTextSize(11f);
data.setValueTextColor(Color.WHITE);
data.setValueTypeface(mTfLight);
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, Highlight h) {
if (e == null)
return;
Log.i("VAL SELECTED",
"Value: " + e.getY() + ", index: " + h.getX()
+ ", DataSet index: " + h.getDataSetIndex());
}
@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
}
}

View file

@ -1,234 +0,0 @@
package com.xxmassdeveloper.mpchartexample;
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.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.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.custom.CustomScatterShapeRenderer;
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;
@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("");
mChart.setOnChartValueSelectedListener(this);
mChart.setDrawGridBackground(false);
mChart.setTouchEnabled(true);
mChart.setMaxHighlightDistance(50f);
// 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(mTfLight);
YAxis yl = mChart.getAxisLeft();
yl.setTypeface(mTfLight);
yl.setAxisMinValue(0f); // this replaces setStartAtZero(true)
mChart.getAxisRight().setEnabled(false);
XAxis xl = mChart.getXAxis();
xl.setTypeface(mTfLight);
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<IScatterDataSet> 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<Entry> yVals1 = new ArrayList<Entry>();
ArrayList<Entry> yVals2 = new ArrayList<Entry>();
ArrayList<Entry> yVals3 = new ArrayList<Entry>();
for (int i = 0; i < mSeekBarX.getProgress(); i++) {
float val = (float) (Math.random() * mSeekBarY.getProgress()) + 3;
yVals1.add(new Entry(i, val));
}
for (int i = 0; i < mSeekBarX.getProgress(); i++) {
float val = (float) (Math.random() * mSeekBarY.getProgress()) + 3;
yVals2.add(new Entry(i+0.33f, val));
}
for (int i = 0; i < mSeekBarX.getProgress(); i++) {
float val = (float) (Math.random() * mSeekBarY.getProgress()) + 3;
yVals3.add(new Entry(i+0.66f, val));
}
// create a dataset and give it a type
ScatterDataSet set1 = new ScatterDataSet(yVals1, "DS 1");
set1.setScatterShape(ScatterChart.ScatterShape.SQUARE);
set1.setColor(ColorTemplate.COLORFUL_COLORS[0]);
ScatterDataSet set2 = new ScatterDataSet(yVals2, "DS 2");
set2.setScatterShape(ScatterChart.ScatterShape.CIRCLE);
set2.setScatterShapeHoleColor(ColorTemplate.COLORFUL_COLORS[3]);
set2.setScatterShapeHoleRadius(3f);
set2.setColor(ColorTemplate.COLORFUL_COLORS[1]);
ScatterDataSet set3 = new ScatterDataSet(yVals3, "DS 3");
set3.setShapeRenderer(new CustomScatterShapeRenderer());
set3.setColor(ColorTemplate.COLORFUL_COLORS[2]);
set1.setScatterShapeSize(8f);
set2.setScatterShapeSize(8f);
set3.setScatterShapeSize(8f);
ArrayList<IScatterDataSet> dataSets = new ArrayList<IScatterDataSet>();
dataSets.add(set1); // add the datasets
dataSets.add(set2);
dataSets.add(set3);
// create a data object with the datasets
ScatterData data = new ScatterData(dataSets);
data.setValueTypeface(mTfLight);
mChart.setData(data);
mChart.invalidate();
}
@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() {
// 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
}
}

View file

@ -1,70 +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.setDrawGridLines(false);
mChart.getAxisLeft().setDrawGridLines(false);
mChart.getLegend().setEnabled(false);
setData(10);
mChart.setFitBars(true);
}
private void setData(int count) {
ArrayList<BarEntry> yVals = new ArrayList<BarEntry>();
for (int i = 0; i < count; i++) {
float val = (float) (Math.random() * count) + 15;
yVals.add(new BarEntry(i, (int) val));
}
BarDataSet set = new BarDataSet(yVals, "Data Set");
set.setColors(ColorTemplate.VORDIPLOM_COLORS);
set.setDrawValues(false);
BarData data = new BarData(set);
mChart.setData(data);
mChart.invalidate();
mChart.animateY(800);
}
}

View file

@ -1,260 +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.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.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.MyAxisValueFormatter;
import com.xxmassdeveloper.mpchartexample.custom.MyValueFormatter;
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(40);
// scaling can now only be done on x- and y-axis separately
mChart.setPinchZoom(false);
mChart.setDrawGridBackground(false);
mChart.setDrawBarShadow(false);
mChart.setDrawValueAboveBar(false);
mChart.setHighlightFullBarEnabled(false);
// change the position of the y-labels
YAxis leftAxis = mChart.getAxisLeft();
leftAxis.setValueFormatter(new MyAxisValueFormatter());
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<IBarDataSet> 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.actionToggleBarBorders: {
for (IBarDataSet set : mChart.getData().getDataSets())
((BarDataSet) set).setBarBorderWidth(set.getBarBorderWidth() == 1.f ? 0.f : 1.f);
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<BarEntry> yVals1 = new ArrayList<BarEntry>();
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(i, new float[]{val1, val2, val3}));
}
BarDataSet set1;
if (mChart.getData() != null &&
mChart.getData().getDataSetCount() > 0) {
set1 = (BarDataSet) mChart.getData().getDataSetByIndex(0);
set1.setValues(yVals1);
mChart.getData().notifyDataChanged();
mChart.notifyDataSetChanged();
} else {
set1 = new BarDataSet(yVals1, "Statistics Vienna 2014");
set1.setColors(getColors());
set1.setStackLabels(new String[]{"Births", "Divorces", "Marriages"});
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(set1);
BarData data = new BarData(dataSets);
data.setValueFormatter(new MyValueFormatter());
data.setValueTextColor(Color.WHITE);
mChart.setData(data);
}
mChart.setFitBars(true);
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, Highlight h) {
BarEntry entry = (BarEntry) e;
if (entry.getYVals() != null)
Log.i("VAL SELECTED", "Value: " + entry.getYVals()[h.getStackIndex()]);
else
Log.i("VAL SELECTED", "Value: " + entry.getY());
}
@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 < colors.length; i++) {
colors[i] = ColorTemplate.MATERIAL_COLORS[i];
}
return colors;
}
}

View file

@ -1,248 +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.AxisBase;
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.formatter.ValueFormatter;
import com.github.mikephil.charting.formatter.AxisValueFormatter;
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.ViewPortHandler;
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.setHighlightFullBarEnabled(false);
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);
xAxis.setAxisMinValue(0f);
xAxis.setAxisMaxValue(110f);
xAxis.setCenterAxisLabels(true);
xAxis.setLabelCount(12);
xAxis.setGranularity(10f);
xAxis.setValueFormatter(new AxisValueFormatter() {
private DecimalFormat format = new DecimalFormat("###");
@Override
public String getFormattedValue(float value, AxisBase axis) {
return format.format(value) + "-" + format.format(value + 10);
}
@Override
public int getDecimalDigits() {
return 0;
}
});
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<BarEntry> yValues = new ArrayList<BarEntry>();
yValues.add(new BarEntry(5, new float[]{ -10, 10 }));
yValues.add(new BarEntry(15, new float[]{ -12, 13 }));
yValues.add(new BarEntry(25, new float[]{ -15, 15 }));
yValues.add(new BarEntry(35, new float[]{ -17, 17 }));
yValues.add(new BarEntry(45, new float[]{ -19, 20 }));
yValues.add(new BarEntry(55, new float[]{ -19, 19 }));
yValues.add(new BarEntry(65, new float[]{ -16, 16 }));
yValues.add(new BarEntry(75, new float[]{ -13, 14 }));
yValues.add(new BarEntry(85, new float[]{ -10, 11 }));
yValues.add(new BarEntry(95, new float[]{ -5, 6 }));
yValues.add(new BarEntry(105, new float[]{ -1, 2 }));
BarDataSet set = new BarDataSet(yValues, "Age Distribution");
set.setValueFormatter(new CustomFormatter());
set.setValueTextSize(7f);
set.setAxisDependency(YAxis.AxisDependency.RIGHT);
set.setColors(new int[] {Color.rgb(67,67,72), Color.rgb(124,181,236)});
set.setStackLabels(new String[]{
"Men", "Women"
});
String []xLabels = 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(set);
data.setBarWidth(8.5f);
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<IBarDataSet> 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.actionToggleBarBorders: {
for (IBarDataSet set : mChart.getData().getDataSets())
((BarDataSet)set).setBarBorderWidth(set.getBarBorderWidth() == 1.f ? 0.f : 1.f);
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, Highlight h) {
BarEntry entry = (BarEntry) e;
Log.i("VAL SELECTED",
"Value: " + Math.abs(entry.getYVals()[h.getStackIndex()]));
}
@Override
public void onNothingSelected() {
// TODO Auto-generated method stub
Log.i("NOTING SELECTED", "");
}
private class CustomFormatter implements ValueFormatter, AxisValueFormatter {
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, AxisBase axis) {
return mFormat.format(Math.abs(value)) + "m";
}
@Override
public int getDecimalDigits() {
return 0;
}
}
}

View file

@ -1,42 +0,0 @@
package com.xxmassdeveloper.mpchartexample.custom;
import android.graphics.Canvas;
import android.graphics.Paint;
import com.github.mikephil.charting.buffer.ScatterBuffer;
import com.github.mikephil.charting.interfaces.datasets.IScatterDataSet;
import com.github.mikephil.charting.renderer.scatter.ShapeRenderer;
import com.github.mikephil.charting.utils.ViewPortHandler;
/**
* Custom shape renderer that draws a single line.
* Created by philipp on 26/06/16.
*/
public class CustomScatterShapeRenderer implements ShapeRenderer {
@Override
public void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler, ScatterBuffer buffer, Paint
renderPaint, float shapeSize) {
final float shapeHalf = shapeSize / 2f;
for (int i = 0; i < buffer.size(); i += 2) {
if (!viewPortHandler.isInBoundsRight(buffer.buffer[i]))
break;
if (!viewPortHandler.isInBoundsLeft(buffer.buffer[i])
|| !viewPortHandler.isInBoundsY(buffer.buffer[i + 1]))
continue;
renderPaint.setColor(dataSet.getColor(i / 2));
c.drawLine(
buffer.buffer[i] - shapeHalf,
buffer.buffer[i + 1] - shapeHalf,
buffer.buffer[i] + shapeHalf,
buffer.buffer[i + 1] + shapeHalf,
renderPaint);
}
}
}

View file

@ -1,25 +0,0 @@
package com.xxmassdeveloper.mpchartexample.custom;
import com.github.mikephil.charting.components.AxisBase;
import com.github.mikephil.charting.formatter.AxisValueFormatter;
import java.text.DecimalFormat;
public class MyAxisValueFormatter implements AxisValueFormatter {
private DecimalFormat mFormat;
public MyAxisValueFormatter() {
mFormat = new DecimalFormat("###,###,###,##0.0");
}
@Override
public String getFormattedValue(float value, AxisBase axis) {
return mFormat.format(value) + " $";
}
@Override
public int getDecimalDigits() {
return 1;
}
}

View file

@ -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;
}
}

View file

@ -1,21 +0,0 @@
package com.xxmassdeveloper.mpchartexample.custom;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.formatter.ValueFormatter;
import com.github.mikephil.charting.utils.ViewPortHandler;
import java.text.DecimalFormat;
public class MyValueFormatter implements ValueFormatter {
private DecimalFormat mFormat;
public MyValueFormatter() {
mFormat = new DecimalFormat("###,###,###,##0.0");
}
@Override
public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
return mFormat.format(value) + " $";
}
}

View file

@ -1,180 +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 yValue;
private float xValue;
private float open, close, high, low;
private float bubbleSize;
private RealmList<RealmFloat> stackValues;
private String someStringField;
/**
* label for pie entries
*/
private String label;
// ofc there could me more fields here...
public RealmDemoData() {
}
public RealmDemoData(float yValue) {
this.yValue = yValue;
}
public RealmDemoData(float xValue, float yValue) {
this.xValue = xValue;
this.yValue = yValue;
}
/**
* Constructor for stacked bars.
*
* @param xValue
* @param stackValues
*/
public RealmDemoData(float xValue, float[] stackValues) {
this.xValue = xValue;
this.stackValues = new RealmList<RealmFloat>();
for (float val : stackValues) {
this.stackValues.add(new RealmFloat(val));
}
}
/**
* Constructor for candles.
*
* @param xValue
* @param high
* @param low
* @param open
* @param close
*/
public RealmDemoData(float xValue, float high, float low, float open, float close) {
this.yValue = (high + low) / 2f;
this.high = high;
this.low = low;
this.open = open;
this.close = close;
this.xValue = xValue;
}
/**
* Constructor for bubbles.
*
* @param xValue
* @param yValue
* @param bubbleSize
*/
public RealmDemoData(float xValue, float yValue, float bubbleSize) {
this.xValue = xValue;
this.yValue = yValue;
this.bubbleSize = bubbleSize;
}
/**
* Constructor for pie chart.
*
* @param yValue
* @param label
*/
public RealmDemoData(float yValue, String label) {
this.yValue = yValue;
this.label = label;
}
public float getyValue() {
return yValue;
}
public void setyValue(float yValue) {
this.yValue = yValue;
}
public float getxValue() {
return xValue;
}
public void setxValue(float xValue) {
this.xValue = xValue;
}
public RealmList<RealmFloat> getStackValues() {
return stackValues;
}
public void setStackValues(RealmList<RealmFloat> stackValues) {
this.stackValues = stackValues;
}
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;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -1,50 +0,0 @@
package com.xxmassdeveloper.mpchartexample.notimportant;
import android.graphics.Typeface;
import android.os.Bundle;
import android.renderscript.Type;
import android.support.annotation.Nullable;
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"
};
protected Typeface mTfRegular;
protected Typeface mTfLight;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mTfRegular = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
mTfLight = Typeface.createFromAsset(getAssets(), "OpenSans-Light.ttf");
}
protected float getRandom(float range, float startsfrom) {
return (float) (Math.random() * range) + startsfrom;
}
@Override
public void onBackPressed() {
super.onBackPressed();
overridePendingTransition(R.anim.move_left_in_activity, R.anim.move_right_out_activity);
}
}

View file

@ -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<ContentItem> {
private Typeface mTypeFaceLight;
private Typeface mTypeFaceRegular;
public MyAdapter(Context context, List<ContentItem> 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;
}
}

View file

@ -1,203 +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.PercentFormatter;
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();
// Create a RealmConfiguration that saves the Realm file in the app's "files" directory.
RealmConfiguration realmConfig = new RealmConfiguration.Builder(getApplicationContext()).build();
Realm.setDefaultConfiguration(realmConfig);
mRealm = Realm.getDefaultInstance();
}
@Override
protected void onPause() {
super.onPause();
mRealm.close();
}
protected void writeToDB(int objectCount) {
mRealm.beginTransaction();
mRealm.delete(RealmDemoData.class);
for (int i = 0; i < objectCount; i++) {
float value = 40f + (float) (Math.random() * 60f);
RealmDemoData d = new RealmDemoData(i, value);
mRealm.copyToRealm(d);
}
mRealm.commitTransaction();
}
protected void writeToDBStack(int objectCount) {
mRealm.beginTransaction();
mRealm.delete(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(i, stack);
mRealm.copyToRealm(d);
}
mRealm.commitTransaction();
}
protected void writeToDBCandle(int objectCount) {
mRealm.beginTransaction();
mRealm.delete(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(i, val + high, val - low, even ? val + open : val - open,
even ? val - close : val + close);
mRealm.copyToRealm(d);
}
mRealm.commitTransaction();
}
protected void writeToDBBubble(int objectCount) {
mRealm.beginTransaction();
mRealm.delete(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(i, value, size);
mRealm.copyToRealm(d);
}
mRealm.commitTransaction();
}
protected void writeToDBPie() {
mRealm.beginTransaction();
mRealm.delete(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[] labels = new String[]{ "iOS", "Android", "WP 10", "BlackBerry", "Other"};
for (int i = 0; i < values.length; i++) {
RealmDemoData d = new RealmDemoData(values[i], labels[i]);
mRealm.copyToRealm(d);
}
mRealm.commitTransaction();
}
}

View file

@ -1,69 +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.BarData;
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<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll();
//RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "stackValues", "xIndex"); // normal entries
RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "xValue", "yValue"); // stacked entries
set.setColors(new int[] {ColorTemplate.rgb("#FF5722"), ColorTemplate.rgb("#03A9F4")});
set.setLabel("Realm BarDataSet");
ArrayList<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(set); // add the dataset
// create a data object with the dataset list
BarData data = new BarData(dataSets);
styleData(data);
// set data
mChart.setData(data);
mChart.setFitBars(true);
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
}
}

View file

@ -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.BubbleData;
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<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll();
RealmBubbleDataSet<RealmDemoData> set = new RealmBubbleDataSet<RealmDemoData>(result, "xValue", "yValue", "bubbleSize");
set.setLabel("Realm BubbleDataSet");
set.setColors(ColorTemplate.COLORFUL_COLORS, 110);
ArrayList<IBubbleDataSet> dataSets = new ArrayList<IBubbleDataSet>();
dataSets.add(set); // add the dataset
// create a data object with the dataset list
BubbleData data = new BubbleData(dataSets);
styleData(data);
// set data
mChart.setData(data);
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
}
}

View file

@ -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.CandleData;
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<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll();
RealmCandleDataSet<RealmDemoData> set = new RealmCandleDataSet<RealmDemoData>(result, "xValue", "high", "low", "open", "close");
set.setLabel("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<ICandleDataSet> dataSets = new ArrayList<ICandleDataSet>();
dataSets.add(set); // add the dataset
// create a data object with the dataset list
CandleData data = new CandleData(dataSets);
styleData(data);
// set data
mChart.setData(data);
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
}
}

View file

@ -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.BarData;
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<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll();
//RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "stackValues", "xIndex"); // normal entries
RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "xValue", "stackValues", "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<IBarDataSet> dataSets = new ArrayList<IBarDataSet>();
dataSets.add(set); // add the dataset
// create a data object with the dataset list
BarData data = new BarData(dataSets);
styleData(data);
data.setValueTextColor(Color.WHITE);
// set data
mChart.setData(data);
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
}
}

View file

@ -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.LineData;
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<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll();
RealmLineDataSet<RealmDemoData> set = new RealmLineDataSet<RealmDemoData>(result, "xValue", "yValue");
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<ILineDataSet> dataSets = new ArrayList<ILineDataSet>();
dataSets.add(set); // add the dataset
// create a data object with the dataset list
LineData data = new LineData(dataSets);
styleData(data);
// set data
mChart.setData(data);
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
}
}

View file

@ -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.PieData;
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<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll();
//RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "stackValues", "xIndex"); // normal entries
RealmPieDataSet<RealmDemoData> set = new RealmPieDataSet<RealmDemoData>(result, "yValue", "label"); // stacked entries
set.setColors(ColorTemplate.VORDIPLOM_COLORS);
set.setLabel("Example market share");
set.setSliceSpace(2);
// create a data object with the dataset list
PieData data = new PieData(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;
}
}

View file

@ -1,78 +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.getXAxis().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<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll();
//RealmBarDataSet<RealmDemoData> set = new RealmBarDataSet<RealmDemoData>(result, "stackValues", "xIndex"); // normal entries
RealmRadarDataSet<RealmDemoData> set = new RealmRadarDataSet<RealmDemoData>(result, "yValue"); // 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<IRadarDataSet> dataSets = new ArrayList<IRadarDataSet>();
dataSets.add(set); // add the dataset
// create a data object with the dataset list
RadarData data = new RadarData(dataSets);
styleData(data);
// set data
mChart.setData(data);
mChart.animateY(1400);
}
}

View file

@ -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.ScatterData;
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<RealmDemoData> result = mRealm.where(RealmDemoData.class).findAll();
RealmScatterDataSet<RealmDemoData> set = new RealmScatterDataSet<RealmDemoData>(result, "xValue", "yValue");
set.setLabel("Realm ScatterDataSet");
set.setScatterShapeSize(9f);
set.setColor(ColorTemplate.rgb("#CDDC39"));
set.setScatterShape(ScatterChart.ScatterShape.CIRCLE);
ArrayList<IScatterDataSet> dataSets = new ArrayList<IScatterDataSet>();
dataSets.add(set); // add the dataset
// create a data object with the dataset list
ScatterData data = new ScatterData(dataSets);
styleData(data);
// set data
mChart.setData(data);
mChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
}
}

View file

@ -1,131 +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;
import io.realm.Realm;
import io.realm.RealmConfiguration;
/**
* 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<ContentItem> objects = new ArrayList<ContentItem>();
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);
// Create a RealmConfiguration that saves the Realm file in the app's "files" directory.
RealmConfiguration realmConfig = new RealmConfiguration.Builder(getApplicationContext()).build();
Realm.setDefaultConfiguration(realmConfig);
Realm realm = Realm.getDefaultInstance();
realm.beginTransaction();
realm.deleteAll();
realm.commitTransaction();
}
@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);
}
}

View file

@ -1,137 +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.components.AxisBase;
import com.github.mikephil.charting.data.BarData;
import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.realm.implementation.RealmBarDataSet;
import com.github.mikephil.charting.data.realm.implementation.RealmLineDataSet;
import com.github.mikephil.charting.formatter.AxisValueFormatter;
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);
lineChart.getXAxis().setLabelCount(5);
lineChart.getXAxis().setGranularity(1f);
barChart.getAxisLeft().setDrawGridLines(false);
barChart.getXAxis().setDrawGridLines(false);
barChart.getXAxis().setLabelCount(5);
barChart.getXAxis().setGranularity(1f);
}
@Override
protected void onResume() {
super.onResume(); // setup realm
mRealm.beginTransaction();
// write some demo-data into the realm.io database
Score score1 = new Score(100f, 0f, "Peter");
mRealm.copyToRealm(score1);
Score score2 = new Score(110f, 1f, "Lisa");
mRealm.copyToRealm(score2);
Score score3 = new Score(130f, 2f, "Dennis");
mRealm.copyToRealm(score3);
Score score4 = new Score(70f, 3f, "Luke");
mRealm.copyToRealm(score4);
Score score5 = new Score(80f, 4f, "Sarah");
mRealm.copyToRealm(score5);
mRealm.commitTransaction();
// add data to the chart
setData();
}
private void setData() {
// LINE-CHART
final RealmResults<Score> results = mRealm.where(Score.class).findAll();
AxisValueFormatter formatter = new AxisValueFormatter() {
@Override
public String getFormattedValue(float value, AxisBase axis) {
return results.get((int) value).getPlayerName();
}
@Override
public int getDecimalDigits() {
return 0;
}
};
lineChart.getXAxis().setValueFormatter(formatter);
barChart.getXAxis().setValueFormatter(formatter);
RealmLineDataSet<Score> lineDataSet = new RealmLineDataSet<Score>(results, "scoreNr", "totalScore");
lineDataSet.setDrawCubic(false);
lineDataSet.setLabel("Result Scores");
lineDataSet.setDrawCircleHole(false);
lineDataSet.setColor(ColorTemplate.rgb("#FF5722"));
lineDataSet.setCircleColor(ColorTemplate.rgb("#FF5722"));
lineDataSet.setLineWidth(1.8f);
lineDataSet.setCircleSize(3.6f);
ArrayList<ILineDataSet> dataSets = new ArrayList<ILineDataSet>();
dataSets.add(lineDataSet);
LineData lineData = new LineData(dataSets);
styleData(lineData);
// set data
lineChart.setData(lineData);
lineChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
// BAR-CHART
RealmBarDataSet<Score> barDataSet = new RealmBarDataSet<Score>(results, "scoreNr", "totalScore");
barDataSet.setColors(new int[]{ColorTemplate.rgb("#FF5722"), ColorTemplate.rgb("#03A9F4")});
barDataSet.setLabel("Realm BarDataSet");
ArrayList<IBarDataSet> barDataSets = new ArrayList<IBarDataSet>();
barDataSets.add(barDataSet);
BarData barData = new BarData(barDataSets);
styleData(barData);
barChart.setData(barData);
barChart.setFitBars(true);
barChart.animateY(1400, Easing.EasingOption.EaseInOutQuart);
}
}

View file

@ -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 float scoreNr;
private String playerName;
public Score() {
}
public Score(float totalScore, float 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 float getScoreNr() {
return scoreNr;
}
public void setScoreNr(float scoreNr) {
this.scoreNr = scoreNr;
}
public String getPlayerName() {
return playerName;
}
public void setPlayerName(String playerName) {
this.playerName = playerName;
}
}

View file

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xxmassdeveloper.mpchartexample">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:allowBackup="false"
android:hardwareAccelerated="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name="com.xxmassdeveloper.mpchartexample.notimportant.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="LineChartActivity1" />
<activity android:name="LineChartActivity2" />
<activity android:name="LineChartTime" />
<activity android:name="BarChartActivity" />
<activity android:name="HorizontalBarChartActivity" />
<activity android:name="HorizontalBarNegativeChartActivity" />
<activity android:name="PieChartActivity" />
<activity android:name="PiePolylineChartActivity" />
<activity android:name="MultiLineChartActivity" />
<activity android:name="BarChartActivityMultiDataset" />
<activity android:name="DrawChartActivity" />
<activity android:name="ScatterChartActivity" />
<activity android:name="BubbleChartActivity" />
<activity android:name=".fragments.SimpleChartDemo" />
<activity android:name="ListViewBarChartActivity" />
<activity android:name="ListViewMultiChartActivity" />
<activity android:name="StackedBarActivity" />
<activity android:name="AnotherBarActivity" />
<activity android:name="InvertedLineChartActivity" />
<activity android:name="CandleStickChartActivity" />
<activity android:name="CubicLineChartActivity" />
<activity android:name="RadarChartActivity" />
<activity android:name="LineChartActivityColored" />
<activity android:name="DynamicalAddingActivity" />
<activity android:name="RealtimeLineChartActivity" />
<activity android:name="CombinedChartActivity" />
<activity android:name="PerformanceLineChart" />
<activity android:name="BarChartActivitySinus" />
<activity android:name="ScrollViewActivity" />
<activity android:name="StackedBarActivityNegative" />
<activity android:name="BarChartPositiveNegative" />
<activity android:name="FilledLineActivity" />
<activity android:name="HalfPieChartActivity" />
</application>
</manifest>

View file

Before

Width:  |  Height:  |  Size: 4 KiB

After

Width:  |  Height:  |  Size: 4 KiB

View file

@ -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<BarEntry> 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<IBarDataSet> 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) {}
}

Some files were not shown because too many files have changed in this diff Show more