Compare commits
1712 commits
Author | SHA1 | Date | |
---|---|---|---|
|
a6c3808fd5 | ||
|
941579e10f | ||
|
21c811ff9a | ||
|
f3a2ec21c9 | ||
|
9347dd1af7 | ||
|
90e523042c | ||
|
33240f9225 | ||
|
4b67673da9 | ||
|
cef967fd71 | ||
|
eae977306e | ||
|
c0e7f56b5d | ||
|
351e341ee7 | ||
|
f05337768d | ||
|
f8d068d377 | ||
|
5e4a32eb41 | ||
|
1de836ac65 | ||
|
0668d30a6b | ||
|
34fefd28e1 | ||
|
45240c3723 | ||
|
14456f475f | ||
|
e02e9be2fa | ||
|
fcc5af71ce | ||
|
13aee592b1 | ||
|
c97c8d247f | ||
|
ae59e7a19e | ||
|
7752efef7e | ||
|
58545bbbfa | ||
|
4ce14e6cc9 | ||
|
8df9eda7af | ||
|
34c3ceaa05 | ||
|
ea816e8d6d | ||
|
bafb0fbbe4 | ||
|
4549ae17b7 | ||
|
912427e543 | ||
|
3f5475077e | ||
|
2e725e49d3 | ||
|
a4ca1f3fba | ||
|
634a690d6a | ||
|
1987d7eb64 | ||
|
6ebf3fa57a | ||
|
95027fa6a7 | ||
|
d86f39cc91 | ||
|
cb26ed4ef4 | ||
|
dc59171524 | ||
|
726616d079 | ||
|
fffe9a297e | ||
|
2340e12800 | ||
|
c5667d4f14 | ||
|
0563fb48b0 | ||
|
ed8876cef2 | ||
|
12b4351d0c | ||
|
adb56e75bd | ||
|
e95c1eb26a | ||
|
0c2ac2d9cc | ||
|
2058f7bf5d | ||
|
971640b29d | ||
|
7df8a4cedc | ||
|
59028d3bf3 | ||
|
c886bb342a | ||
|
aea2ff3417 | ||
|
42cdba535f | ||
|
29f4cc5c2c | ||
|
fc0e234298 | ||
|
e5b66192e7 | ||
|
608d9e29f5 | ||
|
9148f37f9e | ||
|
6ce99326ae | ||
|
129ad15fd0 | ||
|
5030b36c86 | ||
|
db7dda2b7e | ||
|
d67ea481af | ||
|
20bca4a8ca | ||
|
e2a9110d38 | ||
|
2316f8500f | ||
|
6f0b7432ac | ||
|
073ad3c877 | ||
|
c1f6fcebf0 | ||
|
b65ba08324 | ||
|
fe7a0f8bc3 | ||
|
536a35a6fd | ||
|
75dd04cc42 | ||
|
1485cdc687 | ||
|
53de181607 | ||
|
9ee3a74633 | ||
|
73054bedc3 | ||
|
5869c9de23 | ||
|
89436221db | ||
|
92c14db5b4 | ||
|
0b6632f2cb | ||
|
7abc9cd669 | ||
|
9583a18b84 | ||
|
03c538fc34 | ||
|
c08ec81fc0 | ||
|
e4ba3cdc20 | ||
|
689d484615 | ||
|
9b9d2a68cb | ||
|
0378e763ae | ||
|
1ff676ecaf | ||
|
00e284c043 | ||
|
a7eb395b81 | ||
|
11bf7aa812 | ||
|
89e50c8c9b | ||
|
640208c8ff | ||
|
5519c5170d | ||
|
35c9fc937e | ||
|
89d18a7f67 | ||
|
6fbd492761 | ||
|
7286f8703f | ||
|
9997a33524 | ||
|
d8ea67aa21 | ||
|
40adb57f68 | ||
|
215e0dfc05 | ||
|
e1411f169e | ||
|
993a8554c0 | ||
|
508cc565a9 | ||
|
1e6e58d2c0 | ||
|
aee6058dbb | ||
|
3e1eb1445a | ||
|
82668ebc34 | ||
|
a5250888b9 | ||
|
297ce9f2cc | ||
|
b3e2358334 | ||
|
8fd1a86b0a | ||
|
6ccaf940d8 | ||
|
c50f03cf39 | ||
|
c867d7cb37 | ||
|
2c08b560d6 | ||
|
779e0f5665 | ||
|
8954409575 | ||
|
44125a87dd | ||
|
4b7eb1fd04 | ||
|
21ad19661b | ||
|
b06439f36d | ||
|
62910171f1 | ||
|
16a9be8ea0 | ||
|
e416736ad5 | ||
|
d9000987c7 | ||
|
1ac72ea811 | ||
|
41aff3f13d | ||
|
5e97f561f7 | ||
|
47485f8364 | ||
|
0868d9bf89 | ||
|
23aef1a0ab | ||
|
dfaffa39cc | ||
|
ed9340ea51 | ||
|
796dfb21f8 | ||
|
f2dedb30de | ||
|
a5a482fbdc | ||
|
d3c339da10 | ||
|
c97b8d531d | ||
|
72031d33ca | ||
|
ea93823f63 | ||
|
ed770762fb | ||
|
98f97f0df1 | ||
|
4f77a154bf | ||
|
ad3c82f634 | ||
|
43ae497ecf | ||
|
695f481077 | ||
|
fcb506c219 | ||
|
acf985ff0c | ||
|
0af86819ea | ||
|
f6a398b6b2 | ||
|
208bf181ad | ||
|
557e55653b | ||
|
b564704b82 | ||
|
6df13dd66e | ||
|
2eb12901a9 | ||
|
993d273a52 | ||
|
6c54f0b0a9 | ||
|
0c919ab02d | ||
|
493e3d238d | ||
|
3ec493fc0c | ||
|
31b60225d0 | ||
|
886cc9f85d | ||
|
528e2e8d61 | ||
|
28166a01d1 | ||
|
a5e0a9b86c | ||
|
94957fad33 | ||
|
23e0178dbb | ||
|
144af7b295 | ||
|
a02e108f46 | ||
|
749827798b | ||
|
ed618084f9 | ||
|
30a331781f | ||
|
6966b8117e | ||
|
ccf6b7e3b1 | ||
|
d5e5ec3a92 | ||
|
a934501315 | ||
|
34e7f44979 | ||
|
8abe7e84ad | ||
|
9aaa3328f0 | ||
|
345b4bc97e | ||
|
08f295eae1 | ||
|
a7fd778fc8 | ||
|
2e80fada31 | ||
|
4cb83a7b91 | ||
|
0818d766db | ||
|
ee020bba67 | ||
|
262d877b9f | ||
|
3928e285ae | ||
|
00f36054c7 | ||
|
3a879e9402 | ||
|
8045d64260 | ||
|
6a5580b101 | ||
|
70691bea41 | ||
|
49b4d1a96b | ||
|
fb8094e9f2 | ||
|
bc13bc2c17 | ||
|
9a19bf6670 | ||
|
9b7cffa274 | ||
|
49b61e92a4 | ||
|
3ce2016048 | ||
|
b618524a19 | ||
|
810c99c579 | ||
|
0fec2ef06b | ||
|
d65ffb8871 | ||
|
730e5d3d9b | ||
|
c83d2f4ff4 | ||
|
8ed6dd24bf | ||
|
221cd1313a | ||
|
555176bcdb | ||
|
e10628958f | ||
|
8d65596266 | ||
|
b77063d818 | ||
|
815dee86a0 | ||
|
463ef829d7 | ||
|
3398cf4462 | ||
|
323329d8a6 | ||
|
6f1d365176 | ||
|
cf0f1fca34 | ||
|
c8553da89c | ||
|
06bed3332d | ||
|
aa14ab262b | ||
|
028328b986 | ||
|
01d8b24686 | ||
|
d4e2e697e6 | ||
|
6c0b9c1aab | ||
|
b1fe859ce8 | ||
|
63684f02ca | ||
|
21e778cb1f | ||
|
7ffa9caaa1 | ||
|
b53c8cdbd1 | ||
|
89f10e928e | ||
|
865c3dae18 | ||
|
5b9bd6e633 | ||
|
0aeddb025e | ||
|
e9459fb592 | ||
|
d34670fa62 | ||
|
643f901b15 | ||
|
a3c1fe6bbf | ||
|
a6dd5bb4a1 | ||
|
8f5a898a95 | ||
|
7b33554d5b | ||
|
02cf2c1b97 | ||
|
01419f795b | ||
|
fd3b71f780 | ||
|
afcb72f50f | ||
|
e5d03ba640 | ||
|
8134d7f056 | ||
|
e3c240bd9b | ||
|
2b04973813 | ||
|
26a69592d3 | ||
|
9d0b0fd955 | ||
|
918950b6ad | ||
|
cc971a7d02 | ||
|
5daa6dc23c | ||
|
73148a6aa4 | ||
|
e556275e29 | ||
|
6c17ca45de | ||
|
1bbf4be1ee | ||
|
336dfb93e5 | ||
|
66ea845e14 | ||
|
62bc0de28a | ||
|
dab8db488f | ||
|
38cdf1b206 | ||
|
7a10c05e3a | ||
|
ea6b0e8e1c | ||
|
7747c34552 | ||
|
12d5b858f2 | ||
|
092e8a80f7 | ||
|
be12f155ba | ||
|
bab5b9dd6c | ||
|
3c8bf8cb94 | ||
|
d342760357 | ||
|
d912964dd3 | ||
|
7462c083f9 | ||
|
0f04e9c6f5 | ||
|
5a4a6d4065 | ||
|
f0e1deb763 | ||
|
077365c9af | ||
|
e158ef15e2 | ||
|
788539001f | ||
|
31b0fd9ff9 | ||
|
30cb069974 | ||
|
86d05e989a | ||
|
71ac434a2d | ||
|
2176873271 | ||
|
18eec8f0e6 | ||
|
02bf21df50 | ||
|
e841b697be | ||
|
8cf2a6c3d0 | ||
|
713f467ba8 | ||
|
4d9dc0aa06 | ||
|
339fa16324 | ||
|
aaec1f5d2c | ||
|
51f0e53a7f | ||
|
f63002e196 | ||
|
77c10fc9e5 | ||
|
2d54fd1f3f | ||
|
79f5ed0200 | ||
|
99379d7bcf | ||
|
d2e8ee220a | ||
|
9c5a46c9f8 | ||
|
1096719e8f | ||
|
0c00b09bdb | ||
|
1eae18b657 | ||
|
b2250e0155 | ||
|
164bfd7fca | ||
|
f9108b9ad9 | ||
|
342d41cbc4 | ||
|
79e6a5d747 | ||
|
946475b6d5 | ||
|
099a9cf8c1 | ||
|
2f6fb103a2 | ||
|
a91de26a52 | ||
|
3ea1db57ab | ||
|
e000c42744 | ||
|
ef575decbb | ||
|
37c4eef38e | ||
|
4d5ce149dd | ||
|
d7e659a1fa | ||
|
8c67ec19f7 | ||
|
c3dc2822ce | ||
|
9ccf58feab | ||
|
2fa4a094e7 | ||
|
89104c2858 | ||
|
eb44a13434 | ||
|
16738ef480 | ||
|
e2cbafa049 | ||
|
75ba4f69fc | ||
|
db70835cbc | ||
|
1a39ac9b12 | ||
|
bad43a5e13 | ||
|
83a4bf9075 | ||
|
a4ac12aebf | ||
|
08b2d55049 | ||
|
3f0f3a82c2 | ||
|
360cc24b97 | ||
|
94a67ccea0 | ||
|
6d21817c8a | ||
|
43fa1e6cec | ||
|
40c5c87d13 | ||
|
b5da8dcdb5 | ||
|
87758604d3 | ||
|
d5df3ad795 | ||
|
0789628197 | ||
|
6a2e6e5528 | ||
|
0597663392 | ||
|
efbea0a7ef | ||
|
12eee703a7 | ||
|
523c7e5b21 | ||
|
66094db764 | ||
|
37f2498487 | ||
|
38fbefe66b | ||
|
5a18d0ef22 | ||
|
b037f55d73 | ||
|
afdbd2c5f0 | ||
|
69f17b2a79 | ||
|
7fd18d2177 | ||
|
424ee02ce2 | ||
|
a04ad28cec | ||
|
d372fd305c | ||
|
0b72b5588b | ||
|
bd45d73bc6 | ||
|
c59b46affc | ||
|
56cfd2b42b | ||
|
d946f3e3ff | ||
|
f86c1632a7 | ||
|
0f2e2133d3 | ||
|
fcf26aa6ad | ||
|
d299546ebd | ||
|
cb6dabbdec | ||
|
a233e38978 | ||
|
da6ded7bce | ||
|
f54631175e | ||
|
1b4e9be07f | ||
|
bd5858e8c0 | ||
|
af114d180d | ||
|
0f3f4b75b0 | ||
|
f01b90668b | ||
|
eb76d21fe0 | ||
|
c5fa68eda5 | ||
|
98e090ca19 | ||
|
3b0be740cd | ||
|
b5bfc3e2bd | ||
|
f345d164ce | ||
|
5f8eb44d9f | ||
|
0eb69d246c | ||
|
cb0226b231 | ||
|
6878220e2e | ||
|
f83a7e3b26 | ||
|
ded930a2fa | ||
|
72890afc10 | ||
|
82d5fde6f2 | ||
|
c18a2e270c | ||
|
adfc9a5c77 | ||
|
95bd8a580e | ||
|
2dc7207f13 | ||
|
19265217bd | ||
|
005c166e07 | ||
|
8a6139b1fb | ||
|
f75ea845e0 | ||
|
735a9b9c98 | ||
|
bb0ad3ac22 | ||
|
3aa4daae32 | ||
|
4c4c76b1c7 | ||
|
93e4f77006 | ||
|
fb4590e6b0 | ||
|
a823d9c059 | ||
|
6fb2245845 | ||
|
a3720feb0e | ||
|
84160773ed | ||
|
b0a0af8427 | ||
|
bda3ccee35 | ||
|
53e57db562 | ||
|
9b2882e06d | ||
|
a2e88ebedd | ||
|
63eb7dfd91 | ||
|
09cfb2334b | ||
|
f324378de3 | ||
|
5ff8f9609b | ||
|
8a37bbda38 | ||
|
e853a80f78 | ||
|
44d5641fb8 | ||
|
dfc0b46f48 | ||
|
2b886a463e | ||
|
0d9c8545f2 | ||
|
4b00e83479 | ||
|
f283de1698 | ||
|
c28b41b05e | ||
|
858600dcd2 | ||
|
82ca5e7e91 | ||
|
694eb49162 | ||
|
4826f3be24 | ||
|
95dd249cf3 | ||
|
b0f5ec1bf1 | ||
|
e5af5692e4 | ||
|
df91cedee3 | ||
|
2e5217edef | ||
|
6cb3034b0c | ||
|
d507234cc8 | ||
|
455ff894cb | ||
|
c0bee1c1cd | ||
|
0c90c44a01 | ||
|
81dbd91344 | ||
|
e704fb87a0 | ||
|
3c47d0ade9 | ||
|
45f9a189b7 | ||
|
dad6cc0ce5 | ||
|
5a4b6f1532 | ||
|
f927517bea | ||
|
42ceaa9aa2 | ||
|
1ff1c8fcfa | ||
|
4367fbb8f6 | ||
|
72b4948aa3 | ||
|
ae2d917fa7 | ||
|
33b158147e | ||
|
0a55308975 | ||
|
dc03cf2593 | ||
|
280101bafc | ||
|
b4109d3248 | ||
|
67911b1317 | ||
|
68947023d4 | ||
|
40917f0dda | ||
|
f69ae3f76b | ||
|
92504fa81d | ||
|
33fbf34a7c | ||
|
073b477811 | ||
|
01f8a57550 | ||
|
6fd2ffa278 | ||
|
565c8a465e | ||
|
22c7a6dc03 | ||
|
1dd8c901d6 | ||
|
cee380be6c | ||
|
b5cf9e120b | ||
|
66434c6a8e | ||
|
084935d9e3 | ||
|
3076f259f9 | ||
|
5aa797fa96 | ||
|
40f078a2bf | ||
|
589bd0cbad | ||
|
6d39afa028 | ||
|
f39d8911d3 | ||
|
4b058a594f | ||
|
ac3eafaba9 | ||
|
423b885745 | ||
|
8751f608a4 | ||
|
639d335909 | ||
|
4ae9950632 | ||
|
bfcbae4263 | ||
|
a25290742d | ||
|
b4268fc502 | ||
|
0632fedfd2 | ||
|
11212eb72d | ||
|
ec880022ab | ||
|
5292cfc818 | ||
|
b857e58837 | ||
|
2ae37c3088 | ||
|
1a642899e0 | ||
|
5110dc6349 | ||
|
d2aa701eb2 | ||
|
90dc54a685 | ||
|
92cfe0a482 | ||
|
71be944ea9 | ||
|
6d23f7a3aa | ||
|
ceda923114 | ||
|
2d4cf0d4b7 | ||
|
8e2355c78f | ||
|
0d4b60800c | ||
|
6919a97f17 | ||
|
d33b27cde0 | ||
|
3d6f0b982b | ||
|
e2ccaf353b | ||
|
1bf2948f48 | ||
|
ddb03d4dec | ||
|
a0d39b918b | ||
|
0221ddfd24 | ||
|
cc81a21c64 | ||
|
530ab11157 | ||
|
690dd87a06 | ||
|
7db6b7ea4a | ||
|
ec6752567b | ||
|
d2cc49b525 | ||
|
d4e71d808c | ||
|
7de481bca3 | ||
|
1b9b3da3de | ||
|
0270470897 | ||
|
2a2cee5d1c | ||
|
8bca4c79d3 | ||
|
4ca511c4fd | ||
|
77f83cddc5 | ||
|
98fe348b21 | ||
|
43bc45b718 | ||
|
87193a3d2e | ||
|
b59cf564a0 | ||
|
881581fa2d | ||
|
17f919aa43 | ||
|
2cb255a9f4 | ||
|
4393b2710a | ||
|
92810c8d9a | ||
|
4cf9f59654 | ||
|
db19fdcb94 | ||
|
ea89dfef04 | ||
|
6a72ab8c18 | ||
|
e894e380f6 | ||
|
a002634d49 | ||
|
a3e4450c74 | ||
|
69d1b4d811 | ||
|
3baf89c25d | ||
|
4b3825c68d | ||
|
10676ea964 | ||
|
5424d799f9 | ||
|
b28aae50fc | ||
|
3f483b90db | ||
|
66068f5242 | ||
|
6d3faca19c | ||
|
358770cd13 | ||
|
6358f27f79 | ||
|
ab424e69d8 | ||
|
215ce2d82e | ||
|
b8ce47a78d | ||
|
fcd696a979 | ||
|
6f2f6a289c | ||
|
1c312e85a9 | ||
|
ff0b8c375f | ||
|
0b43eeaf2d | ||
|
4e50305dd3 | ||
|
cfb3fdf0a9 | ||
|
bef8db1af1 | ||
|
055b5a6c4c | ||
|
f7eabd0718 | ||
|
bc7ce8d0bd | ||
|
493da1d130 | ||
|
48f1b6f960 | ||
|
42981cc98d | ||
|
a1fa7ad5b2 | ||
|
9a9ae5141c | ||
|
e6915e25e2 | ||
|
58b640dc0b | ||
|
18e39237de | ||
|
0ab3dbfae1 | ||
|
cf463cad06 | ||
|
ccced3cc1f | ||
|
215be8ac75 | ||
|
e762b59a28 | ||
|
f74cead4e7 | ||
|
e0250bda49 | ||
|
986874866d | ||
|
a0b49fc8c4 | ||
|
545c633918 | ||
|
992dd5fc85 | ||
|
0c8cc700b3 | ||
|
d0ce8e7d5a | ||
|
34a6e3b5eb | ||
|
a599fb79f9 | ||
|
5b9665bf2d | ||
|
087aa1fda5 | ||
|
a9bd0c6191 | ||
|
d771bf4467 | ||
|
4c5a2b94a4 | ||
|
9d0be5d993 | ||
|
31f15a941d | ||
|
00f3e42278 | ||
|
995538cf0b | ||
|
937ea04062 | ||
|
727b860f11 | ||
|
af746314c7 | ||
|
d976b79ed0 | ||
|
411725bd5b | ||
|
8fffe4101c | ||
|
ae7df47637 | ||
|
122ba413ef | ||
|
56e59d8776 | ||
|
aa6bb7418d | ||
|
7ef82f2b00 | ||
|
135f9aa09e | ||
|
2e417148ce | ||
|
543075027a | ||
|
f5ed473085 | ||
|
3fd2a8a17b | ||
|
badb736070 | ||
|
1cecb828f7 | ||
|
528dd490d4 | ||
|
0ee538c734 | ||
|
9569cf577f | ||
|
b28f4aa8b8 | ||
|
35845ced62 | ||
|
e221117b8f | ||
|
a3238cb32d | ||
|
8e4d28d0df | ||
|
8e00d1f2e6 | ||
|
395742f09f | ||
|
8b4aa77237 | ||
|
7475b1292d | ||
|
676e148ea1 | ||
|
8939945267 | ||
|
96c518d3d9 | ||
|
0d1894770c | ||
|
fc72fbece1 | ||
|
303ea3d764 | ||
|
7e7b6e397e | ||
|
dfe68c519d | ||
|
1eebf84001 | ||
|
21584d1fbb | ||
|
06e63af1e1 | ||
|
fa2518dbe0 | ||
|
ffb615f09e | ||
|
f002a3a9cc | ||
|
a19ffad046 | ||
|
506b106277 | ||
|
d430dd61fb | ||
|
6347d680c8 | ||
|
a7da427e26 | ||
|
dd50c2e49e | ||
|
1ba4b413e8 | ||
|
20dd3b8ef1 | ||
|
71fede97b3 | ||
|
677d8ef2d4 | ||
|
f1bc0d05d9 | ||
|
39efc52c20 | ||
|
07d7813ccb | ||
|
7009cc8b96 | ||
|
21f43ed3f0 | ||
|
083e91a7fe | ||
|
f5f71ef31c | ||
|
a6ce45f9ac | ||
|
1015aee1c5 | ||
|
3995941c3c | ||
|
7b8203020d | ||
|
d4500e28ae | ||
|
e17e6dfd64 | ||
|
4845e1b0e3 | ||
|
3b70c23a06 | ||
|
f2771a6c88 | ||
|
6e35cf1c68 | ||
|
420d17391a | ||
|
c335897159 | ||
|
298e973819 | ||
|
f1d79dc67b | ||
|
2600018ff8 | ||
|
a990ed79a2 | ||
|
acd046d787 | ||
|
8f4432c52d | ||
|
ed77cb4523 | ||
|
5f51623993 | ||
|
03d91e41e6 | ||
|
922f1a8ab3 | ||
|
261720e94a | ||
|
028f4a54ca | ||
|
42de21f3ca | ||
|
1d1a07131f | ||
|
f0dcd68017 | ||
|
5f6e3092b8 | ||
|
042a4dd73a | ||
|
f317299176 | ||
|
d9c0fd76e5 | ||
|
badc1a8508 | ||
|
c3f2ec2faf | ||
|
4b1112d2ef | ||
|
bc8c0788e9 | ||
|
c2007bec12 | ||
|
7ffc20c11b | ||
|
fa49f2fc83 | ||
|
fc3deccbce | ||
|
81eb08ffa9 | ||
|
8fa30a3106 | ||
|
563767076d | ||
|
d1689b6f63 | ||
|
ebbea0651b | ||
|
4a8929e9ca | ||
|
3ddcd245ec | ||
|
9028b5613b | ||
|
2dd9d5aa34 | ||
|
1a0e90aacf | ||
|
27fbe57e3a | ||
|
7ac0fac8f2 | ||
|
a212d7ea6f | ||
|
36d7436106 | ||
|
7a67f25b7d | ||
|
9278b3d329 | ||
|
72cabd15aa | ||
|
b598ee1448 | ||
|
014c688633 | ||
|
016b760df4 | ||
|
acd8dc1337 | ||
|
dcb20889ba | ||
|
d1fb7bbe95 | ||
|
daa0115ab5 | ||
|
c979bdb535 | ||
|
4f1f5bc3ef | ||
|
9c92003c3e | ||
|
92e60e5eed | ||
|
bdac14c83c | ||
|
71c67892ff | ||
|
9104e77595 | ||
|
c53917a6d6 | ||
|
2a55eaceca | ||
|
8703a0b886 | ||
|
9297923f09 | ||
|
b47dd65227 | ||
|
80371bb5c8 | ||
|
98837e52c3 | ||
|
0895690ea4 | ||
|
61c2398d6b | ||
|
32fc58d8dd | ||
|
b8f3d49b11 | ||
|
95ce8b2bf6 | ||
|
f5c2336eb1 | ||
|
45a8960251 | ||
|
83ebea7fd2 | ||
|
5809f713c5 | ||
|
fad31d0e88 | ||
|
5bc1136800 | ||
|
08dfebcc08 | ||
|
661ed7dd70 | ||
|
28775755ef | ||
|
54dc87cf55 | ||
|
3592adf522 | ||
|
ccada2d3f1 | ||
|
2c62ac87f0 | ||
|
c3b8b1161a | ||
|
b73e3d0af2 | ||
|
9c546bcfa9 | ||
|
ce84fe270b | ||
|
31de4f2a29 | ||
|
9615cc2af1 | ||
|
a6e6fed0fa | ||
|
f19b8e862a | ||
|
93746fa017 | ||
|
7e35393ec2 | ||
|
1882d5ac25 | ||
|
43203db5c0 | ||
|
569f890ee4 | ||
|
f3bd299ab1 | ||
|
996948e829 | ||
|
ae231be566 | ||
|
21fc088f0d | ||
|
6ee101c5c6 | ||
|
19f1b3b444 | ||
|
295521c93a | ||
|
4f8b80b6cc | ||
|
99c87c4d89 | ||
|
9137956ec1 | ||
|
7b1239ccf2 | ||
|
4f5a32d667 | ||
|
4c4d25b246 | ||
|
95abc45133 | ||
|
e556ffb21e | ||
|
ca6f24ba15 | ||
|
cf3a09d3e0 | ||
|
981c7b4dc7 | ||
|
43fa3f2338 | ||
|
d9300cb744 | ||
|
f09770df38 | ||
|
bfae450eb1 | ||
|
420a444897 | ||
|
8acc87da75 | ||
|
963bb2a2b1 | ||
|
f64cff34d2 | ||
|
aa5730d19f | ||
|
49621cb4a0 | ||
|
b6289be3a9 | ||
|
d1839b41b7 | ||
|
ff5ddbbd92 | ||
|
3bd2110ecb | ||
|
1f1996c4d3 | ||
|
2dee57a0dc | ||
|
3fa3726f3a | ||
|
d01f03105d | ||
|
d487da7b42 | ||
|
4281ad1674 | ||
|
e1594999a5 | ||
|
d1464ce619 | ||
|
0759db0351 | ||
|
825bd2a40b | ||
|
4fcc7cca29 | ||
|
989c1ab64c | ||
|
9379008893 | ||
|
6b0e5f29f3 | ||
|
d20928ab0c | ||
|
ae7959ff8d | ||
|
090df226e0 | ||
|
deec97f261 | ||
|
cb78d48f3c | ||
|
6d870ac813 | ||
|
403b40d573 | ||
|
b2adb97cac | ||
|
7931ea0c7c | ||
|
ca672e4ff4 | ||
|
a7b038a43e | ||
|
a7dda129ff | ||
|
b315153b87 | ||
|
c44761016e | ||
|
2fc56c5fc7 | ||
|
61aeacdb4b | ||
|
b45127d9ec | ||
|
b74a4d3c57 | ||
|
d33c1b1558 | ||
|
3074744db7 | ||
|
4807eca145 | ||
|
c2fbd7ccf1 | ||
|
cbf55db314 | ||
|
b65086f7df | ||
|
59620060da | ||
|
c2d1c5a049 | ||
|
d64d70d07f | ||
|
6476ddc0d7 | ||
|
4e0e8bbc77 | ||
|
3f67ae7c53 | ||
|
43a729375a | ||
|
c56580b394 | ||
|
f3f7415b34 | ||
|
5446799103 | ||
|
cedebdae6a | ||
|
3f79bb538b | ||
|
c59e59e152 | ||
|
bfcfafe326 | ||
|
dd9aa1ae69 | ||
|
4d37aab147 | ||
|
dd0a8853dc | ||
|
331385e2ba | ||
|
9cf3801148 | ||
|
98943b128a | ||
|
200fba72a3 | ||
|
b19a42e71c | ||
|
2c12098281 | ||
|
c6e649903d | ||
|
f30c1c90a4 | ||
|
02780a321f | ||
|
c2666ec49c | ||
|
f596bf0eb5 | ||
|
3c2ecbee5e | ||
|
2d7e2382d2 | ||
|
f096b39b53 | ||
|
838f9bf434 | ||
|
8ee89e9048 | ||
|
8099446441 | ||
|
aa0558d87f | ||
|
1ff85cdb32 | ||
|
9a55419b0e | ||
|
e633c06df3 | ||
|
5cc8676689 | ||
|
5e67200a23 | ||
|
2a8c0f2358 | ||
|
a877526ab6 | ||
|
fc5099d452 | ||
|
7b90352473 | ||
|
db1fc396ef | ||
|
8e934788b8 | ||
|
e5e104b322 | ||
|
0796908917 | ||
|
44b8ebb341 | ||
|
6b2bfddfda | ||
|
9caca4b1cb | ||
|
67c4d41939 | ||
|
78aa0b034c | ||
|
f4421699bd | ||
|
aa24187673 | ||
|
d8a898f114 | ||
|
00574b75a5 | ||
|
3f942bf003 | ||
|
566e8018a0 | ||
|
60dcf5bd1d | ||
|
58e629fd1f | ||
|
c482df559e | ||
|
691ce133b8 | ||
|
ee0fd10fc4 | ||
|
6773bad9d5 | ||
|
b7e0e40d52 | ||
|
af541451d8 | ||
|
faa02b87ea | ||
|
0c729ac64c | ||
|
29fdf185cf | ||
|
9399db9ec7 | ||
|
5ca17914f0 | ||
|
5aab431cff | ||
|
5bc50bd780 | ||
|
fdf8a152af | ||
|
7d385a243d | ||
|
b495a7d9eb | ||
|
b257c0e7e7 | ||
|
277a19af4a | ||
|
e7201dc42f | ||
|
b2f4e26e67 | ||
|
5b31e14a98 | ||
|
d1432aaa8b | ||
|
293361fba1 | ||
|
20fa3ce17b | ||
|
6e66acb7a0 | ||
|
088d0ad6f3 | ||
|
41e52e791f | ||
|
20141a0499 | ||
|
a57104e6af | ||
|
98f375f9f9 | ||
|
3a451e238b | ||
|
642d648046 | ||
|
e0c518ecb2 | ||
|
a4d1946486 | ||
|
d687c8ff18 | ||
|
f8d8f4ce6c | ||
|
dad180ec96 | ||
|
0c9794180d | ||
|
af0c5acffb | ||
|
269ae4ca00 | ||
|
dd3bd71027 | ||
|
16ffc975f9 | ||
|
94b13d4200 | ||
|
72bd6d904e | ||
|
3fb8a54771 | ||
|
f71f85f16b | ||
|
8490f80d38 | ||
|
024cbbe1b0 | ||
|
548381bcf5 | ||
|
600496a3d5 | ||
|
fd3b2a164a | ||
|
ed8720f29e | ||
|
fd2add5f7a | ||
|
5aafe92e06 | ||
|
0298122d20 | ||
|
9a3d2ad1ca | ||
|
25336b88dc | ||
|
58845ebd7d | ||
|
f28c5ce67c | ||
|
5f5950b441 | ||
|
38ea630a7b | ||
|
f26a20652a | ||
|
a0f901c63a | ||
|
496f1b143a | ||
|
71cef8509b | ||
|
01b5826e73 | ||
|
aab951a5e0 | ||
|
063b395b8c | ||
|
3455343555 | ||
|
6f8158041d | ||
|
48a713affc | ||
|
9b655d186a | ||
|
0d6dc4e44d | ||
|
0307b7d76f | ||
|
7de07205ef | ||
|
a38b9f5daf | ||
|
f264c813d7 | ||
|
1482f9331e | ||
|
83e8911290 | ||
|
8065d17016 | ||
|
5190f8198c | ||
|
2e475b8d7d | ||
|
f6fd3abaa1 | ||
|
86e6a2e521 | ||
|
5cbc6b7245 | ||
|
18e3b07b9d | ||
|
1fdb182720 | ||
|
4f508dd7c0 | ||
|
c91507525b | ||
|
47b78b4308 | ||
|
7b27f47552 | ||
|
006e62a435 | ||
|
1615c4114e | ||
|
a7898f191a | ||
|
a2ecebca0c | ||
|
89ea5bd15c | ||
|
e3a7b0969b | ||
|
1eae8e050e | ||
|
280cb5c648 | ||
|
70e2c3899b | ||
|
d15f253336 | ||
|
657255e866 | ||
|
d1d590d48e | ||
|
a4b099ef7b | ||
|
78441499b8 | ||
|
7e4151e86e | ||
|
9dde506afb | ||
|
9fec6d0455 | ||
|
a277152d98 | ||
|
01916b5a72 | ||
|
a2d7a6896d | ||
|
662a846d22 | ||
|
4c06674012 | ||
|
8c973d3de5 | ||
|
0e379d31c1 | ||
|
0d0c056681 | ||
|
eae7df48a0 | ||
|
2dd38e2e06 | ||
|
764ed2fd27 | ||
|
cd04e50cb4 | ||
|
92ea5b3892 | ||
|
314a9d8104 | ||
|
0e9495261b | ||
|
f2e3e13a14 | ||
|
89b864f9b2 | ||
|
9c365ee36e | ||
|
497beacf9a | ||
|
8bb5e1ad54 | ||
|
ade17f5328 | ||
|
10a392d4dc | ||
|
beee1269bb | ||
|
5b1b98fabc | ||
|
5b31bb63fd | ||
|
c5c19d4f91 | ||
|
ae10a9fdb5 | ||
|
8cad9ec226 | ||
|
e4a6764361 | ||
|
5c06046ee2 | ||
|
507a75c006 | ||
|
48619deabb | ||
|
5effa1ed54 | ||
|
f11cd2caf8 | ||
|
c51f00e2a4 | ||
|
6ae1eefc40 | ||
|
eb04293027 | ||
|
5a15715b25 | ||
|
94dae2ef6f | ||
|
ba152072a6 | ||
|
2e6bfeb87e | ||
|
996c79f568 | ||
|
e21e919aa9 | ||
|
e198679f76 | ||
|
2c28843fc1 | ||
|
2da68a792a | ||
|
766fb9a009 | ||
|
97a4d44d4a | ||
|
a9cb766310 | ||
|
d93a5614d2 | ||
|
bfd781a4dc | ||
|
71965049c8 | ||
|
239cf862b5 | ||
|
4b9af4c189 | ||
|
0a0fca165c | ||
|
ff86e1772c | ||
|
1c2b45e52c | ||
|
f7f509ffb2 | ||
|
14810e3dfd | ||
|
da394b779e | ||
|
3712d8589d | ||
|
fcfea4e181 | ||
|
75be29ef03 | ||
|
16d011b2bf | ||
|
9ecce154e2 | ||
|
3235131b43 | ||
|
85738d6b2d | ||
|
fe95442413 | ||
|
5a028c56a6 | ||
|
f9d8e365f0 | ||
|
a7e9f19ecc | ||
|
318c308d1b | ||
|
ee183816b5 | ||
|
8c5e694f3f | ||
|
9952c222fd | ||
|
9eb6298960 | ||
|
72e4ec3c55 | ||
|
154997cbf7 | ||
|
d32a3f6da0 | ||
|
2e96670900 | ||
|
5f8666b4ee | ||
|
35d6928422 | ||
|
d51de23d8a | ||
|
c9623fc74b | ||
|
62f192e886 | ||
|
3cf2210184 | ||
|
1a52eff833 | ||
|
51f7940039 | ||
|
3e17def76c | ||
|
d473196b36 | ||
|
d722da590a | ||
|
4aabae1de0 | ||
|
4bb9076deb | ||
|
a451672c43 | ||
|
6dada9eaea | ||
|
39b4e0f70d | ||
|
af9ac446cf | ||
|
464bbd9133 | ||
|
54023aaf56 | ||
|
44154c9564 | ||
|
cd96679bda | ||
|
5ab7242aac | ||
|
d07ceda265 | ||
|
a09d6a7ac1 | ||
|
bc2c4e2b68 | ||
|
5d19d4b1bc | ||
|
8d529bd999 | ||
|
539a89446f | ||
|
232e4a3e1a | ||
|
3514aaedf9 | ||
|
374de0da4c | ||
|
3b089daa4c | ||
|
10f30768cd | ||
|
1f571a3d56 | ||
|
077b25446b | ||
|
37e971ef8e | ||
|
3fc5397fe3 | ||
|
9611421506 | ||
|
8963d04e51 | ||
|
5ac58fc69c | ||
|
034e05997d | ||
|
658aab0169 | ||
|
3419dff3eb | ||
|
3e08a13ebc | ||
|
0259079328 | ||
|
f502664158 | ||
|
d739467cb2 | ||
|
b5fb9e9761 | ||
|
d54efba3f1 | ||
|
4d2495c902 | ||
|
91103911c0 | ||
|
44e12a4e5e | ||
|
950d6a2354 | ||
|
bef5b0828c | ||
|
31419f04f5 | ||
|
3a9ad3db32 | ||
|
9a4c3287d1 | ||
|
adc268cb9a | ||
|
932405a2ef | ||
|
a9e335079d | ||
|
6b5f38811a | ||
|
15b0578aa1 | ||
|
4e8aaf4561 | ||
|
43e9c26ef5 | ||
|
0c81966d67 | ||
|
b6ab5f2475 | ||
|
10301a7359 | ||
|
6e456da042 | ||
|
8cf9336935 | ||
|
7f79c27469 | ||
|
9a9c9ab2a6 | ||
|
633722f90b | ||
|
be95c277e9 | ||
|
28c9eaf6bb | ||
|
19a0e03efa | ||
|
f3635b69f7 | ||
|
978201c072 | ||
|
9db1b2f2d6 | ||
|
425cb61c03 | ||
|
c92d32659b | ||
|
273828526f | ||
|
10fedf2e2b | ||
|
a4e1d26805 | ||
|
6e614c04c8 | ||
|
04bb22b6ef | ||
|
6f652724d7 | ||
|
a018e65957 | ||
|
73c60d58b9 | ||
|
2a40c87240 | ||
|
4ec22d7995 | ||
|
83ad059966 | ||
|
f32cfd04d2 | ||
|
b765b90959 | ||
|
f57b0a623e | ||
|
9f5123228f | ||
|
913e92ae01 | ||
|
ea80c0bf81 | ||
|
fde9ce83c6 | ||
|
3e4ff0be58 | ||
|
e07bbeaff1 | ||
|
0cdc041a00 | ||
|
9fdd30bbe0 | ||
|
66068538ce | ||
|
bc8b7105d8 | ||
|
87781bac31 | ||
|
2ac47eadaf | ||
|
1ee9fa7978 | ||
|
8760d9f2ff | ||
|
8040ebe52e | ||
|
8f0c29f34f | ||
|
16685844ff | ||
|
893c8f8a76 | ||
|
79af9181c3 | ||
|
328db4329b | ||
|
bdc3485843 | ||
|
78ca707f27 | ||
|
1330fc4a3f | ||
|
6224440a82 | ||
|
cd68c6f648 | ||
|
7c57220794 | ||
|
b4469dc9b4 | ||
|
13e0b11807 | ||
|
8be106f49e | ||
|
c3cae65b39 | ||
|
d8af1923fc | ||
|
1afbe59f72 | ||
|
40f2c6d776 | ||
|
8cdae745b1 | ||
|
35c5bec02a | ||
|
d8cb907465 | ||
|
d94bf5bc0d | ||
|
2eca41fc8f | ||
|
710d5de4e6 | ||
|
fb2439da71 | ||
|
3382c2f1af | ||
|
39a9d2ea29 | ||
|
a34e52ccc9 | ||
|
02b6e35664 | ||
|
df2a11d8ad | ||
|
faeac0cc0b | ||
|
2576308412 | ||
|
83cb3eec70 | ||
|
82d8881e9d | ||
|
207af8993a | ||
|
1c5819274d | ||
|
1301f1189e | ||
|
6a60e2c94b | ||
|
c7b6e07bef | ||
|
fb70ef74ae | ||
|
b78f4e8071 | ||
|
478c37ee3b | ||
|
e16c2de7de | ||
|
0b25bd3cbf | ||
|
d4b2422103 | ||
|
f629df992b | ||
|
e3af5cac01 | ||
|
1e59b095e0 | ||
|
21cb642441 | ||
|
fe9f904c35 | ||
|
4ba73f4c47 | ||
|
5d5f8348f4 | ||
|
872e121a9c | ||
|
ce069c60c6 | ||
|
3e5d4e6e6e | ||
|
9a2d5fcc8b | ||
|
24a3b1cdef | ||
|
36fb5734bd | ||
|
1a7413f550 | ||
|
f887144e00 | ||
|
24ad450813 | ||
|
9e100286f9 | ||
|
674cd8b975 | ||
|
a74d1d7bfb | ||
|
d86a5cbcb2 | ||
|
f86abe6bf8 | ||
|
591fd379a9 | ||
|
e9f8ae6385 | ||
|
3d9d292736 | ||
|
52d58c7098 | ||
|
5b6ab3cf32 | ||
|
80d32174d8 | ||
|
e249a15c58 | ||
|
497bc296cf | ||
|
2aa96b156c | ||
|
bff6171819 | ||
|
055050b4e2 | ||
|
55cc174732 | ||
|
c6980d40f8 | ||
|
65c6189bba | ||
|
847e6c3545 | ||
|
9531ba6989 | ||
|
1b351934e2 | ||
|
ca256ace28 | ||
|
791a487456 | ||
|
5d84b0055a | ||
|
aa7cbce033 | ||
|
43418902cd | ||
|
6b0a32aa90 | ||
|
80525905dc | ||
|
4a385ba5f3 | ||
|
2eb93e75dd | ||
|
b495c7a432 | ||
|
b40964b735 | ||
|
9e65dca8aa | ||
|
3561cb0b79 | ||
|
79bd4456f4 | ||
|
721ee5f3ca | ||
|
c962926b3e | ||
|
b9d22b4b3b | ||
|
1befb9a88d | ||
|
75cc593864 | ||
|
b6edbece67 | ||
|
cbaa52383b | ||
|
1b542a61f9 | ||
|
8e5f3b1513 | ||
|
a0347bb782 | ||
|
49ca2ad0e3 | ||
|
231a34f49f | ||
|
10c539c3dd | ||
|
fa1c6d5039 | ||
|
5dd5ab4b37 | ||
|
5de182214f | ||
|
32799d42bc | ||
|
9a8e63b4a7 | ||
|
6713dfc352 | ||
|
54b92ffc62 | ||
|
338afb31d1 | ||
|
0c45981aad | ||
|
8f62fda714 | ||
|
9c112a2c64 | ||
|
29fdd5cd43 | ||
|
71e3ca1b77 | ||
|
ebdcfc0899 | ||
|
809b44c69e | ||
|
d9ae5fae0a | ||
|
83eadc108b | ||
|
922e479364 | ||
|
5440639e3c | ||
|
03a6c49798 | ||
|
72170fd548 | ||
|
959c4e0d36 | ||
|
cbfd198e74 | ||
|
a4272e2646 | ||
|
dabcaa7ee6 | ||
|
d881e5f411 | ||
|
0809d3d667 | ||
|
34fbeb5882 | ||
|
7d9dcdbc80 | ||
|
b6a2d662d7 | ||
|
bed8d788fa | ||
|
1000b5d9b1 | ||
|
b8cee9dc64 | ||
|
787a481836 | ||
|
92d15d80bd | ||
|
2572740072 | ||
|
fef49b90cb | ||
|
05c8f9cc59 | ||
|
0b6b14fa36 | ||
|
ad4b340ea6 | ||
|
120a3b5bb4 | ||
|
45b5719bba | ||
|
89f4a406c7 | ||
|
6ace2785f1 | ||
|
456626f846 | ||
|
e0ff2af2f6 | ||
|
66d80a07bf | ||
|
64f6ab0a41 | ||
|
fba34b19b6 | ||
|
44eac7b564 | ||
|
2cfa247267 | ||
|
e87a6921d8 | ||
|
759f4d8b64 | ||
|
c0af43cd63 | ||
|
2e3687afe6 | ||
|
e4598fe7e2 | ||
|
5987862d46 | ||
|
0b867a07a7 | ||
|
829f93ab16 | ||
|
d2483fa054 | ||
|
fe8cfcea27 | ||
|
a0c091ee41 | ||
|
6ac95c9baa | ||
|
83dcabfe01 | ||
|
44b75a6b5d | ||
|
699a9f4ce9 | ||
|
66f97a25e0 | ||
|
efdd4f73e7 | ||
|
e00aad12fb | ||
|
633a5318f7 | ||
|
c42b88082d | ||
|
304415a84c | ||
|
45cedbc870 | ||
|
56c7c1105b | ||
|
4bd9efc1e9 | ||
|
d4ab6598d6 | ||
|
03a08220fb | ||
|
f1fd3d9324 | ||
|
524bc2530d | ||
|
908255b0ad | ||
|
052c550c29 | ||
|
5de0244a6a | ||
|
02d3a5dcf9 | ||
|
38fdac761d | ||
|
2b932395d5 | ||
|
0ee1299c4d | ||
|
d7455422c4 | ||
|
084b7e0f66 | ||
|
0fb67f31ec | ||
|
0cb2272f38 | ||
|
8ea97dbd1f | ||
|
08e5f5f3ea | ||
|
d57a86e8f2 | ||
|
0b153157de | ||
|
ddf205f57b | ||
|
a543bb2b36 | ||
|
67f0889723 | ||
|
f5d6a477de | ||
|
49373ac80e | ||
|
bdae6f5c0b | ||
|
94ee5e8d79 | ||
|
173c7e10de | ||
|
cf10bf9c6d | ||
|
26f8f655fb | ||
|
4484809ff7 | ||
|
191ec27d2c | ||
|
bdac172d2e | ||
|
6f74b3dff7 | ||
|
4dff747b02 | ||
|
f2945ec0ef | ||
|
bd6b122303 | ||
|
f4e58ba599 | ||
|
a493362de7 | ||
|
af1ed0fb15 | ||
|
1be6751615 | ||
|
32efcf18fb | ||
|
e58b9f7951 | ||
|
7735226b90 | ||
|
aca66bb6d4 | ||
|
5e2fb7bf9b | ||
|
fa97f6143a | ||
|
80ebcb7ab6 | ||
|
6020ed39ee | ||
|
4d223ba624 | ||
|
9fcb637069 | ||
|
c739d62713 | ||
|
cbbddd3231 | ||
|
edd513208b | ||
|
233c44eb01 | ||
|
143402a401 | ||
|
e0ede6054d | ||
|
32d4c1fb71 | ||
|
822e578f9b | ||
|
28bcb18271 | ||
|
6b57fa74d4 | ||
|
33ebc9d192 | ||
|
b622ea5561 | ||
|
ec7130acb4 | ||
|
68964e8683 | ||
|
8c649ed8a9 | ||
|
4a1a8027a4 | ||
|
226dced911 | ||
|
c35189ad4d | ||
|
ef2a10aeec | ||
|
9d9e330ed3 | ||
|
10b8e09a1d | ||
|
f52c3cedef | ||
|
1b1f639be2 | ||
|
4b69d8bb5b | ||
|
9f4bbeb336 | ||
|
049d5fc23b | ||
|
9dfa682f85 | ||
|
90c2662d33 | ||
|
542913082c | ||
|
350851c011 | ||
|
31dff04146 | ||
|
8ccc75ffe0 | ||
|
a2e92e6ef0 | ||
|
61b493deeb | ||
|
27b7ec16d1 | ||
|
7d37dcb975 | ||
|
ca027fdfda | ||
|
74fb504a7e | ||
|
1901fd82c5 | ||
|
370604bb4b | ||
|
85382309eb | ||
|
6927a6db99 | ||
|
c8d6d7fd73 | ||
|
43046425fc | ||
|
ebb1468560 | ||
|
0a00522d24 | ||
|
d41be04a3e | ||
|
365ea5fe38 | ||
|
02e8149f5d | ||
|
74c4c166a5 | ||
|
9bd5ce6b98 | ||
|
408eaeb127 | ||
|
47e251e1f1 | ||
|
951c3f1a3f | ||
|
f5e93c6efb | ||
|
82f2d5595a | ||
|
0a0c22cc73 | ||
|
b01c5e2b32 | ||
|
bd75e6c2a6 | ||
|
8b932a71ab | ||
|
598992c7a0 | ||
|
7b1fb38415 | ||
|
c755ab6472 | ||
|
657567b3d2 | ||
|
be4ea0e1dc | ||
|
e63c1fa870 | ||
|
c72f76577a | ||
|
93ff1bb5a4 | ||
|
7b31ec2ea1 | ||
|
4cb9089fe4 | ||
|
3d1649aa1d | ||
|
5bb32e16c9 | ||
|
536b9100dd | ||
|
2229715bea | ||
|
c8c0f08d65 | ||
|
6c1acd570b | ||
|
d2a46e90e4 | ||
|
ab5bf11726 | ||
|
f941206292 | ||
|
9f1b8f726b | ||
|
2de0ad65e4 | ||
|
bbfb6c6648 | ||
|
99bb96be0a | ||
|
85e9795a75 | ||
|
9b5e70fa01 | ||
|
865d5f33ec | ||
|
d386512b9c | ||
|
ae2b97bb53 | ||
|
918a91869f | ||
|
50edcd1868 | ||
|
a7dd58ab2a | ||
|
8e193e26d7 | ||
|
cf40c0846d | ||
|
5696d6d562 | ||
|
3fdc451758 | ||
|
61799c0932 | ||
|
74040310d1 | ||
|
ccfbf3da4a | ||
|
aee1ed09da | ||
|
de8322334c | ||
|
e29f40112b | ||
|
d6ddb47d20 | ||
|
8ea1b3b234 | ||
|
976dbbbdef | ||
|
c9df99a643 | ||
|
1871519f24 | ||
|
266fb4d5d6 | ||
|
28e8ae56d3 | ||
|
9bdfbf72a1 | ||
|
ddde6c8dc0 | ||
|
d91e47ea71 | ||
|
ac22b06a96 | ||
|
934b20bd5f | ||
|
58ad281d63 | ||
|
fb11b6e07c | ||
|
5bd73bcb0a | ||
|
bbc81841cf | ||
|
131ecce798 | ||
|
6492d59eb1 | ||
|
a59887f72c | ||
|
8029f91f2f | ||
|
576d5b6bd0 | ||
|
a621b1aee6 | ||
|
d78756e928 | ||
|
0ab6605e42 | ||
|
7beee61c22 | ||
|
eae0e80ce1 | ||
|
a84056024c | ||
|
7cdadaa410 | ||
|
a3bf07615f | ||
|
ed145616bc | ||
|
e3f3dded5b | ||
|
8d59446596 | ||
|
027f11adbd | ||
|
7c512cd7d4 | ||
|
442585756e | ||
|
174bf4da91 | ||
|
ba18feecf8 | ||
|
0a5202da00 | ||
|
7a01c2ac47 | ||
|
c2dd6d20d1 | ||
|
a6470f5ec0 | ||
|
f6ad237f6f | ||
|
ea89131832 | ||
|
ae7cbb4cc0 | ||
|
a12c5e5ab7 | ||
|
7599c6beca | ||
|
5cb2c1a6a6 | ||
|
4a52e26dbd | ||
|
2de56406b5 | ||
|
e5578bf8ba | ||
|
7240729df7 | ||
|
c5b79024db | ||
|
40f54dc862 | ||
|
b83a13415b | ||
|
13682a154c | ||
|
284702beb0 | ||
|
0e08509b0c | ||
|
30ee7af1c1 | ||
|
02309d118b | ||
|
4ab4c0ba2e | ||
|
cd5e3a42b7 | ||
|
4a57822706 | ||
|
30e301ffd8 | ||
|
ae428c2ef7 | ||
|
b0387da3e2 | ||
|
e562aeb301 | ||
|
85ed5e001d | ||
|
95d7eaae46 | ||
|
ade2a8f603 | ||
|
73724d17cf | ||
|
8904ed6cb5 | ||
|
ea1944edfe | ||
|
e893ca108a | ||
|
42f6fb6932 | ||
|
61755d4d77 | ||
|
249725fe96 | ||
|
9068563a2b | ||
|
553acb04f6 | ||
|
d6c5fe0ae6 | ||
|
c1c3715a14 | ||
|
49456e835f | ||
|
140a1ea5cf | ||
|
2b380fe188 | ||
|
ace7765ba2 | ||
|
e1b5fc1aa1 | ||
|
fdc70fb8de | ||
|
eeb160c7fe | ||
|
c5de8516e4 | ||
|
0d5db0e152 | ||
|
c6349bdc82 | ||
|
58b42df504 | ||
|
cb78c15a43 | ||
|
a0243154b2 | ||
|
6f55d8ea43 | ||
|
0ee2a7b35a | ||
|
20cde649b4 | ||
|
98eacbcdb0 | ||
|
d4a0a4cf85 | ||
|
2cb955268e | ||
|
b257057a66 | ||
|
63d1a1547f | ||
|
e1693dc65a | ||
|
cd2b2ac39c | ||
|
473134d39a | ||
|
d1cb68e707 | ||
|
806fdfe989 | ||
|
c1358af6fa | ||
|
7ad2cc5643 | ||
|
86f77709f2 | ||
|
b4d80e8aa4 | ||
|
22d855cee2 | ||
|
b98781e0a2 | ||
|
3a1abec3ac | ||
|
192dbe0fb5 | ||
|
60f4f52c5e | ||
|
04a3ed9c72 | ||
|
accdd0ef5c | ||
|
17fb4857b4 | ||
|
a31ed90353 | ||
|
e63dcdee00 | ||
|
c4f523e534 | ||
|
0816f7dbb7 | ||
|
2cd355b8eb | ||
|
b422a0bed6 | ||
|
e829b43460 | ||
|
b7c0c0b304 | ||
|
bf609b828b | ||
|
a7a349869e | ||
|
98824fc9c4 | ||
|
e12e521537 | ||
|
46f14a193f | ||
|
98acdda335 | ||
|
05d2b91333 | ||
|
bb6a556765 | ||
|
17091c7934 | ||
|
a4214dda7a | ||
|
cee10216fc | ||
|
2cde3f51cf | ||
|
454a7fc73e | ||
|
6084b81e13 | ||
|
c0d263c7a9 | ||
|
9c3bffdd97 | ||
|
254a16f079 | ||
|
2297afc332 | ||
|
5fcdda2da1 | ||
|
e2413a4a9e | ||
|
0fdf6d57e6 | ||
|
2e354e740e | ||
|
45cdfca994 | ||
|
2719cefbf3 | ||
|
3c5523b0d2 | ||
|
9eb932c3ce | ||
|
bb650946be | ||
|
1d99ab4108 | ||
|
6d32d76a71 | ||
|
e707cbe6f9 | ||
|
22b4d114fd | ||
|
43ca04697c | ||
|
cb5ca58c61 | ||
|
25cafdcfa8 | ||
|
42d40d8c35 | ||
|
bbb9df10a8 | ||
|
40eee50348 | ||
|
70454009bc | ||
|
f516b4587d |
455 changed files with 51721 additions and 19481 deletions
12
.github/FUNDING.yml
vendored
Normal file
12
.github/FUNDING.yml
vendored
Normal 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
37
.github/ISSUE_TEMPLATE.md
vendored
Normal 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
44
.github/ISSUE_TEMPLATE/Bug_report.md
vendored
Normal 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.
|
34
.github/ISSUE_TEMPLATE/Feature_request.md
vendored
Normal file
34
.github/ISSUE_TEMPLATE/Feature_request.md
vendored
Normal 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
27
.github/ISSUE_TEMPLATE/Support_help.md
vendored
Normal 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
15
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal 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? -->
|
12
.gitignore
vendored
12
.gitignore
vendored
|
@ -11,6 +11,11 @@
|
|||
# generated files
|
||||
bin/
|
||||
gen/
|
||||
generated/
|
||||
finalOutput/
|
||||
projectFilesBackup/
|
||||
|
||||
build.xml
|
||||
|
||||
# Local configuration file (sdk path, etc)
|
||||
local.properties
|
||||
|
@ -18,6 +23,8 @@ local.properties
|
|||
# Eclipse project files
|
||||
.classpath
|
||||
.project
|
||||
.settings/
|
||||
.vscode/
|
||||
|
||||
# Proguard folder generated by Eclipse
|
||||
proguard/
|
||||
|
@ -26,7 +33,8 @@ proguard/
|
|||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
/.idea/*
|
||||
!/.idea/runConfigurations
|
||||
|
||||
.directory
|
||||
|
||||
|
@ -37,3 +45,5 @@ build/
|
|||
|
||||
# maven
|
||||
target/
|
||||
|
||||
.DS_Store
|
||||
|
|
52
.idea/runConfigurations/MPChartExample.xml
generated
Normal file
52
.idea/runConfigurations/MPChartExample.xml
generated
Normal 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>
|
66
CONTRIBUTING.md
Normal file
66
CONTRIBUTING.md
Normal file
|
@ -0,0 +1,66 @@
|
|||
> ### Notice
|
||||
> *Before you continue, this is the* **ANDROID** *library. If you have an* **iOS** *device, please go here instead*:
|
||||
>
|
||||
> – https://github.com/danielgindi/Charts
|
||||
>
|
||||
> They might tell you to come back here, if they do, listen to them and ignore this notice.
|
||||
|
||||
# How to contribute
|
||||
|
||||
Bug-fixes and features often come from users of the MPAndroidChart library and improve it greatly. We want to keep it as easy as possible to contribute changes that improve the experience for users all around the world. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things.
|
||||
|
||||
## Creating Issues
|
||||
|
||||
There are two main issue templates, one for bugs and another for feature requests. Please use them! You're issue will be much easier to understand, and bugs easier to fix, if you follow the templates. If your issue doesn't fit into those, just use the generic template.
|
||||
|
||||
Search existing [issues] to see if your bug has already been reported or if a feature request already exists. Don't forget to remove `is:open` so you see all the issues! If you find that one already exists, use reactions to show how much you care!
|
||||
|
||||
## Making Pull Requests
|
||||
|
||||
Careful! If you fail to follow these guidlines, you're pull request may be closed, *even if it's really awesome*.
|
||||
|
||||
0. **Search** open [pull requests] AND existing [issues] to make sure what you want to do isn't already being worked on or already has an open pull request.
|
||||
1. **Fork** the repository
|
||||
1. **Create** a new branch based on `master`, and name it according to your changes
|
||||
1. **Add** your commits, they MUST follow the [Commit Style](#commit-style) below
|
||||
1. **Test** your changes by actually running the example app, or create a new example
|
||||
1. **Create** a pull request, following the auto-generated template
|
||||
1. ???
|
||||
1. Profit :money_with_wings:
|
||||
|
||||
You are encouraged to use [GitHub Desktop] to inspect your code changes before committing them. It can reveal small changes that might have gone unnoticed, and would be requested for removal before merging.
|
||||
|
||||
Check out [#3975](https://github.com/PhilJay/MPAndroidChart/pull/3975) for an example of a good-made-better pull request.
|
||||
|
||||
## Commit Style
|
||||
|
||||
* **Make commits of logical units**
|
||||
Don't load your commits with tons of changes, this makes it hard to follow what is happening. However, if you have done a lot of work, and there are commits and merges all over the place, squash them down into fewer commits.
|
||||
|
||||
* **Conform to the code style**
|
||||
It's easy, just look around!
|
||||
|
||||
* **Write good commit messages**
|
||||
You may prefer [Tim Pope's style], you might like the [commitizen-friendly] way. Regardless of the color you pick, you MUST stay within the lines!
|
||||
```
|
||||
The commit title CANNOT exceed 50 characters
|
||||
|
||||
The body of the message comes after an empty new line, and describes the
|
||||
changes more thoroughly. If the change is obvious and self-explanatory
|
||||
from the title, you can omit the body. You should describe all changes
|
||||
if many were made, or maybe some trickery that only code wizards can
|
||||
understand.
|
||||
|
||||
Be polite and wrap your lines to 72 characters, but if you prefer going
|
||||
to 100 characters then I guess we can't stop you.
|
||||
```
|
||||
|
||||
## Final Notes
|
||||
|
||||
Thanks for reading the contributing file! Have some cake! :cake:
|
||||
|
||||
[issues]: https://github.com/PhilJay/MPAndroidChart/issues
|
||||
[pull requests]: https://github.com/PhilJay/MPAndroidChart/pulls
|
||||
[GitHub Desktop]: https://desktop.github.com/
|
||||
[Tim Pope's style]: https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
|
||||
[commitizen-friendly]: https://github.com/commitizen/cz-cli
|
201
LICENSE
Normal file
201
LICENSE
Normal 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.
|
1
MPChartExample/.gitignore
vendored
1
MPChartExample/.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
/build
|
||||
/release
|
||||
|
|
|
@ -1,47 +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="22"
|
||||
android:versionName="1.6.2" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="8"
|
||||
android:targetSdkVersion="19" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
|
||||
<application
|
||||
android:allowBackup="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="LineChartActivity"></activity>
|
||||
<activity android:screenOrientation="landscape" android:name="MultipleChartsActivity"></activity>
|
||||
<activity android:name="BarChartActivity"></activity>
|
||||
<activity android:name="PieChartActivity"></activity>
|
||||
<activity android:name="MultiLineChartActivity"></activity>
|
||||
<activity android:name="BarChartActivityMultiDataset"></activity>
|
||||
<activity android:name="DrawChartActivity"></activity>
|
||||
<activity android:name="ScatterChartActivity"></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>
|
||||
</application>
|
||||
|
||||
</manifest>
|
|
@ -1,42 +1,26 @@
|
|||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 19
|
||||
buildToolsVersion '19.1.0'
|
||||
compileSdkVersion 28
|
||||
defaultConfig {
|
||||
applicationId 'com.xxmassdeveloper.mpchartexample'
|
||||
applicationId "com.xxmassdeveloper.mpchartexample"
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 19
|
||||
versionCode 22
|
||||
versionName '1.6.2'
|
||||
|
||||
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 {
|
||||
runProguard false
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
abortOnError false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
//compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
compile 'com.android.support:support-v4:19.+'
|
||||
compile project(':MPChartLib')
|
||||
implementation "androidx.appcompat:appcompat:1.0.2"
|
||||
implementation 'com.google.android.material:material:1.0.0'
|
||||
implementation project(':MPChartLib')
|
||||
}
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -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
21
MPChartExample/proguard-rules.pro
vendored
Normal 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
|
|
@ -1,14 +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-19
|
Binary file not shown.
Before Width: | Height: | Size: 12 KiB |
|
@ -1,53 +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/actionToggleHighlightArrow"
|
||||
android:title="Toggle Highlight Arrow">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/actionToggle3D"
|
||||
android:title="Toggle 3D">
|
||||
</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/actionToggleStartzero"
|
||||
android:title="Toggle StartZero">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/actionToggleAdjustXLegend"
|
||||
android:title="Toggle AdjustXLegend">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/actionToggleFilter"
|
||||
android:title="Toggle filter">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/actionSave"
|
||||
android:title="Save to Gallery">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/actionTogglePinch"
|
||||
android:title="Toggle PinchZoom">
|
||||
</item>
|
||||
|
||||
</menu>
|
|
@ -1,37 +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/actionToggleStartzero"
|
||||
android:title="Toggle StartZero">
|
||||
</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>
|
||||
|
||||
</menu>
|
|
@ -1,40 +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/actionToggleFilled"
|
||||
android:title="Toggle Filled">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/actionToggleCircles"
|
||||
android:title="Toggle Circles">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/actionToggleHighlight"
|
||||
android:title="Toggle Highlight">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/actionToggleStartzero"
|
||||
android:title="Toggle StartZero">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/actionToggleAdjustXLegend"
|
||||
android:title="Toggle AdjustXLegend">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/actionToggleFilter"
|
||||
android:title="Toggle filter">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/actionSave"
|
||||
android:title="Save to Gallery">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/actionTogglePinch"
|
||||
android:title="Toggle PinchZoom">
|
||||
</item>
|
||||
</menu>
|
|
@ -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>
|
|
@ -1,56 +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/actionToggleFilled"
|
||||
android:title="Toggle Filled">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/actionToggleCircles"
|
||||
android:title="Toggle Circles">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/actionToggleCubic"
|
||||
android:title="Toggle Cubic">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/actionToggleHighlight"
|
||||
android:title="Toggle Highlight">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/actionToggleStartzero"
|
||||
android:title="Toggle StartZero">
|
||||
</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/actionToggleFilter"
|
||||
android:title="Toggle filter">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/actionSave"
|
||||
android:title="Save to SD-Card">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/actionTogglePinch"
|
||||
android:title="Toggle PinchZoom">
|
||||
</item>
|
||||
</menu>
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<item android:id="@+id/viewGithub" android:title="View on GitHub"></item>
|
||||
<item android:id="@+id/website" android:title="Developer Website"></item>
|
||||
<item android:id="@+id/report" android:title="Problem Report"></item>
|
||||
</menu>
|
|
@ -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 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>
|
||||
|
||||
</menu>
|
|
@ -1,37 +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/actionToggleFilled"
|
||||
android:title="Toggle Filled">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/actionToggleHighlight"
|
||||
android:title="Toggle Highlight">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/actionSave"
|
||||
android:title="Save to SD">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/actionToggleRotate"
|
||||
android:title="Toggle Rotation">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/actionToggleYLabels"
|
||||
android:title="Toggle Y-Labels">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/actionToggleXLabels"
|
||||
android:title="Toggle X-Labels">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/actionToggleSpin"
|
||||
android:title="Spin Animation">
|
||||
</item>
|
||||
|
||||
</menu>
|
|
@ -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 Values">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/actionToggleHighlight"
|
||||
android:title="Toggle Highlight">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/actionToggleStartzero"
|
||||
android:title="Toggle StartZero">
|
||||
</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/actionToggleFilter"
|
||||
android:title="Toggle filter">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/actionSave"
|
||||
android:title="Save to Gallery">
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/actionTogglePinch"
|
||||
android:title="Toggle PinchZoom">
|
||||
</item>
|
||||
|
||||
</menu>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -1,247 +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.data.BarData;
|
||||
import com.github.mikephil.charting.data.BarDataSet;
|
||||
import com.github.mikephil.charting.data.BarEntry;
|
||||
import com.github.mikephil.charting.data.filter.Approximator;
|
||||
import com.github.mikephil.charting.data.filter.Approximator.ApproximatorType;
|
||||
import com.github.mikephil.charting.utils.ColorTemplate;
|
||||
import com.github.mikephil.charting.utils.XLabels;
|
||||
import com.github.mikephil.charting.utils.XLabels.XLabelPosition;
|
||||
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.setDrawYValues(false);
|
||||
|
||||
mChart.setUnit(" €");
|
||||
mChart.setDescription("");
|
||||
|
||||
mChart.setDrawYValues(true);
|
||||
|
||||
// if more than 60 entries are displayed in the chart, no values will be
|
||||
// drawn
|
||||
mChart.setMaxVisibleValueCount(60);
|
||||
|
||||
// disable 3D
|
||||
mChart.set3DEnabled(false);
|
||||
// scaling can now only be done on x- and y-axis separately
|
||||
mChart.setPinchZoom(false);
|
||||
|
||||
mChart.setDrawBarShadow(false);
|
||||
|
||||
mChart.setDrawVerticalGrid(false);
|
||||
mChart.setDrawHorizontalGrid(false);
|
||||
mChart.setDrawGridBackground(false);
|
||||
|
||||
XLabels xLabels = mChart.getXLabels();
|
||||
xLabels.setPosition(XLabelPosition.BOTTOM);
|
||||
xLabels.setCenterXLabelText(true);
|
||||
xLabels.setSpaceBetweenLabels(0);
|
||||
|
||||
mChart.setDrawYLabels(false);
|
||||
mChart.setDrawLegend(false);
|
||||
|
||||
// setting data
|
||||
mSeekBarX.setProgress(10);
|
||||
mSeekBarY.setProgress(100);
|
||||
|
||||
// add a nice and smooth animation
|
||||
mChart.animateY(2500);
|
||||
|
||||
// Legend l = mChart.getLegend();
|
||||
// l.setPosition(LegendPosition.BELOW_CHART_CENTER);
|
||||
// l.setFormSize(8f);
|
||||
// l.setFormToTextSpace(4f);
|
||||
// l.setXEntrySpace(6f);
|
||||
|
||||
// mChart.setDrawLegend(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.bar, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.actionToggleValues: {
|
||||
if (mChart.isDrawYValuesEnabled())
|
||||
mChart.setDrawYValues(false);
|
||||
else
|
||||
mChart.setDrawYValues(true);
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggle3D: {
|
||||
if (mChart.is3DEnabled())
|
||||
mChart.set3DEnabled(false);
|
||||
else
|
||||
mChart.set3DEnabled(true);
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleHighlight: {
|
||||
if (mChart.isHighlightEnabled())
|
||||
mChart.setHighlightEnabled(false);
|
||||
else
|
||||
mChart.setHighlightEnabled(true);
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionTogglePinch: {
|
||||
if (mChart.isPinchZoomEnabled())
|
||||
mChart.setPinchZoom(false);
|
||||
else
|
||||
mChart.setPinchZoom(true);
|
||||
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleHighlightArrow: {
|
||||
if (mChart.isDrawHighlightArrowEnabled())
|
||||
mChart.setDrawHighlightArrow(false);
|
||||
else
|
||||
mChart.setDrawHighlightArrow(true);
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleStartzero: {
|
||||
if (mChart.isStartAtZeroEnabled())
|
||||
mChart.setStartAtZero(false);
|
||||
else
|
||||
mChart.setStartAtZero(true);
|
||||
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleAdjustXLegend: {
|
||||
XLabels xLabels = mChart.getXLabels();
|
||||
|
||||
if (xLabels.isAdjustXLabelsEnabled())
|
||||
xLabels.setAdjustXLabels(false);
|
||||
else
|
||||
xLabels.setAdjustXLabels(true);
|
||||
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.animateX: {
|
||||
mChart.animateX(3000);
|
||||
break;
|
||||
}
|
||||
case R.id.animateY: {
|
||||
mChart.animateY(3000);
|
||||
break;
|
||||
}
|
||||
case R.id.animateXY: {
|
||||
|
||||
mChart.animateXY(3000, 3000);
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleFilter: {
|
||||
|
||||
Approximator a = new Approximator(ApproximatorType.DOUGLAS_PEUCKER, 25);
|
||||
|
||||
if (!mChart.isFilteringEnabled()) {
|
||||
mChart.enableFiltering(a);
|
||||
} else {
|
||||
mChart.disableFiltering();
|
||||
}
|
||||
mChart.invalidate();
|
||||
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;
|
||||
yVals1.add(new BarEntry((int) val1, i));
|
||||
}
|
||||
|
||||
ArrayList<String> xVals = new ArrayList<String>();
|
||||
for (int i = 0; i < mSeekBarX.getProgress()+1; i++) {
|
||||
xVals.add((int) yVals1.get(i).getVal() + " " + mChart.getUnit());
|
||||
}
|
||||
|
||||
BarDataSet set1 = new BarDataSet(yVals1, "Data Set");
|
||||
set1.setColors(ColorTemplate.VORDIPLOM_COLORS);
|
||||
|
||||
ArrayList<BarDataSet> dataSets = new ArrayList<BarDataSet>();
|
||||
dataSets.add(set1);
|
||||
|
||||
BarData data = new BarData(xVals, dataSets);
|
||||
|
||||
mChart.setData(data);
|
||||
mChart.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
|
@ -1,292 +0,0 @@
|
|||
|
||||
package com.xxmassdeveloper.mpchartexample;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.github.mikephil.charting.charts.BarChart;
|
||||
import com.github.mikephil.charting.data.BarData;
|
||||
import com.github.mikephil.charting.data.BarDataSet;
|
||||
import com.github.mikephil.charting.data.BarEntry;
|
||||
import com.github.mikephil.charting.data.Entry;
|
||||
import com.github.mikephil.charting.data.filter.Approximator;
|
||||
import com.github.mikephil.charting.data.filter.Approximator.ApproximatorType;
|
||||
import com.github.mikephil.charting.interfaces.OnChartValueSelectedListener;
|
||||
import com.github.mikephil.charting.utils.Legend;
|
||||
import com.github.mikephil.charting.utils.Legend.LegendPosition;
|
||||
import com.github.mikephil.charting.utils.XLabels;
|
||||
import com.github.mikephil.charting.utils.XLabels.XLabelPosition;
|
||||
import com.github.mikephil.charting.utils.YLabels;
|
||||
import com.github.mikephil.charting.utils.YLabels.YLabelPosition;
|
||||
import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class BarChartActivity 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);
|
||||
mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
|
||||
|
||||
mChart = (BarChart) findViewById(R.id.chart1);
|
||||
mChart.setOnChartValueSelectedListener(this);
|
||||
|
||||
// enable the drawing of values
|
||||
mChart.setDrawYValues(true);
|
||||
|
||||
mChart.setDescription("");
|
||||
|
||||
// if more than 60 entries are displayed in the chart, no values will be
|
||||
// drawn
|
||||
mChart.setMaxVisibleValueCount(60);
|
||||
|
||||
// disable 3D
|
||||
mChart.set3DEnabled(false);
|
||||
|
||||
// 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.setUnit(" €");
|
||||
|
||||
// mChart.setDrawXLabels(false);
|
||||
|
||||
mChart.setDrawGridBackground(false);
|
||||
mChart.setDrawHorizontalGrid(true);
|
||||
mChart.setDrawVerticalGrid(false);
|
||||
// mChart.setDrawYLabels(false);
|
||||
|
||||
// sets the text size of the values inside the chart
|
||||
mChart.setValueTextSize(10f);
|
||||
|
||||
mChart.setDrawBorder(false);
|
||||
// mChart.setBorderPositions(new BorderPosition[] {BorderPosition.LEFT,
|
||||
// BorderPosition.RIGHT});
|
||||
|
||||
Typeface tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
|
||||
|
||||
XLabels xl = mChart.getXLabels();
|
||||
xl.setPosition(XLabelPosition.BOTTOM);
|
||||
xl.setCenterXLabelText(true);
|
||||
xl.setTypeface(tf);
|
||||
|
||||
YLabels yl = mChart.getYLabels();
|
||||
yl.setTypeface(tf);
|
||||
yl.setLabelCount(8);
|
||||
yl.setPosition(YLabelPosition.BOTH_SIDED);
|
||||
|
||||
mChart.setValueTypeface(tf);
|
||||
|
||||
setData(12, 50);
|
||||
|
||||
// setting data
|
||||
mSeekBarY.setProgress(50);
|
||||
mSeekBarX.setProgress(12);
|
||||
|
||||
mSeekBarY.setOnSeekBarChangeListener(this);
|
||||
mSeekBarX.setOnSeekBarChangeListener(this);
|
||||
|
||||
Legend l = mChart.getLegend();
|
||||
l.setPosition(LegendPosition.BELOW_CHART_LEFT);
|
||||
l.setFormSize(8f);
|
||||
l.setXEntrySpace(4f);
|
||||
|
||||
// mChart.setDrawLegend(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.bar, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.actionToggleValues: {
|
||||
if (mChart.isDrawYValuesEnabled())
|
||||
mChart.setDrawYValues(false);
|
||||
else
|
||||
mChart.setDrawYValues(true);
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggle3D: {
|
||||
if (mChart.is3DEnabled())
|
||||
mChart.set3DEnabled(false);
|
||||
else
|
||||
mChart.set3DEnabled(true);
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleHighlight: {
|
||||
if (mChart.isHighlightEnabled())
|
||||
mChart.setHighlightEnabled(false);
|
||||
else
|
||||
mChart.setHighlightEnabled(true);
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionTogglePinch: {
|
||||
if (mChart.isPinchZoomEnabled())
|
||||
mChart.setPinchZoom(false);
|
||||
else
|
||||
mChart.setPinchZoom(true);
|
||||
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleHighlightArrow: {
|
||||
if (mChart.isDrawHighlightArrowEnabled())
|
||||
mChart.setDrawHighlightArrow(false);
|
||||
else
|
||||
mChart.setDrawHighlightArrow(true);
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleStartzero: {
|
||||
if (mChart.isStartAtZeroEnabled())
|
||||
mChart.setStartAtZero(false);
|
||||
else
|
||||
mChart.setStartAtZero(true);
|
||||
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.animateX: {
|
||||
mChart.animateX(3000);
|
||||
break;
|
||||
}
|
||||
case R.id.animateY: {
|
||||
mChart.animateY(3000);
|
||||
break;
|
||||
}
|
||||
case R.id.animateXY: {
|
||||
|
||||
mChart.animateXY(3000, 3000);
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleAdjustXLegend: {
|
||||
XLabels xLabels = mChart.getXLabels();
|
||||
|
||||
if (xLabels.isAdjustXLabelsEnabled())
|
||||
xLabels.setAdjustXLabels(false);
|
||||
else
|
||||
xLabels.setAdjustXLabels(true);
|
||||
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleFilter: {
|
||||
|
||||
Approximator a = new Approximator(ApproximatorType.DOUGLAS_PEUCKER, 25);
|
||||
|
||||
if (!mChart.isFilteringEnabled()) {
|
||||
mChart.enableFiltering(a);
|
||||
} else {
|
||||
mChart.disableFiltering();
|
||||
}
|
||||
mChart.invalidate();
|
||||
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(), mSeekBarY.getProgress());
|
||||
mChart.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
private void setData(int count, float range) {
|
||||
|
||||
ArrayList<String> xVals = new ArrayList<String>();
|
||||
for (int i = 0; i < count; i++) {
|
||||
xVals.add(mMonths[i % 12]);
|
||||
}
|
||||
|
||||
ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
float mult = (range + 1);
|
||||
float val = (float) (Math.random() * mult);
|
||||
yVals1.add(new BarEntry(val, i));
|
||||
}
|
||||
|
||||
BarDataSet set1 = new BarDataSet(yVals1, "DataSet");
|
||||
set1.setBarSpacePercent(35f);
|
||||
|
||||
ArrayList<BarDataSet> dataSets = new ArrayList<BarDataSet>();
|
||||
dataSets.add(set1);
|
||||
|
||||
BarData data = new BarData(xVals, dataSets);
|
||||
|
||||
mChart.setData(data);
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
public void onValueSelected(Entry e, int dataSetIndex) {
|
||||
|
||||
RectF bounds = mChart.getBarBounds((BarEntry) e);
|
||||
PointF position = mChart.getPosition(e);
|
||||
|
||||
Log.i("bounds", bounds.toString());
|
||||
Log.i("position", position.toString());
|
||||
}
|
||||
|
||||
public void onNothingSelected() {};
|
||||
}
|
|
@ -1,263 +0,0 @@
|
|||
|
||||
package com.xxmassdeveloper.mpchartexample;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.github.mikephil.charting.charts.BarChart;
|
||||
import com.github.mikephil.charting.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.interfaces.OnChartValueSelectedListener;
|
||||
import com.github.mikephil.charting.utils.Legend;
|
||||
import com.github.mikephil.charting.utils.Legend.LegendPosition;
|
||||
import com.github.mikephil.charting.utils.XLabels;
|
||||
import com.github.mikephil.charting.utils.YLabels;
|
||||
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("");
|
||||
|
||||
// disable the drawing of values
|
||||
mChart.setDrawYValues(false);
|
||||
|
||||
// scaling can now only be done on x- and y-axis separately
|
||||
mChart.setPinchZoom(false);
|
||||
|
||||
mChart.setDrawBarShadow(false);
|
||||
|
||||
mChart.setDrawGridBackground(false);
|
||||
mChart.setDrawHorizontalGrid(false);
|
||||
|
||||
// create a custom MarkerView (extend MarkerView) and specify the layout
|
||||
// to use for it
|
||||
MyMarkerView mv = new MyMarkerView(this, R.layout.custom_marker_view);
|
||||
|
||||
// define an offset to change the original position of the marker
|
||||
// (optional)
|
||||
mv.setOffsets(-mv.getMeasuredWidth() / 2, -mv.getMeasuredHeight());
|
||||
|
||||
// set the marker to the chart
|
||||
mChart.setMarkerView(mv);
|
||||
|
||||
mSeekBarX.setProgress(10);
|
||||
mSeekBarY.setProgress(100);
|
||||
|
||||
Typeface tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
|
||||
|
||||
Legend l = mChart.getLegend();
|
||||
l.setPosition(LegendPosition.RIGHT_OF_CHART);
|
||||
l.setTypeface(tf);
|
||||
|
||||
XLabels xl = mChart.getXLabels();
|
||||
xl.setCenterXLabelText(true);
|
||||
xl.setTypeface(tf);
|
||||
|
||||
YLabels yl = mChart.getYLabels();
|
||||
yl.setTypeface(tf);
|
||||
|
||||
mChart.setValueTypeface(tf);
|
||||
}
|
||||
|
||||
@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: {
|
||||
if (mChart.isDrawYValuesEnabled())
|
||||
mChart.setDrawYValues(false);
|
||||
else
|
||||
mChart.setDrawYValues(true);
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionTogglePinch: {
|
||||
if (mChart.isPinchZoomEnabled())
|
||||
mChart.setPinchZoom(false);
|
||||
else
|
||||
mChart.setPinchZoom(true);
|
||||
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggle3D: {
|
||||
if (mChart.is3DEnabled())
|
||||
mChart.set3DEnabled(false);
|
||||
else
|
||||
mChart.set3DEnabled(true);
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleHighlight: {
|
||||
if (mChart.isHighlightEnabled())
|
||||
mChart.setHighlightEnabled(false);
|
||||
else
|
||||
mChart.setHighlightEnabled(true);
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleHighlightArrow: {
|
||||
if (mChart.isDrawHighlightArrowEnabled())
|
||||
mChart.setDrawHighlightArrow(false);
|
||||
else
|
||||
mChart.setDrawHighlightArrow(true);
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleStartzero: {
|
||||
if (mChart.isStartAtZeroEnabled())
|
||||
mChart.setStartAtZero(false);
|
||||
else
|
||||
mChart.setStartAtZero(true);
|
||||
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleAdjustXLegend: {
|
||||
XLabels xLabels = mChart.getXLabels();
|
||||
|
||||
if (xLabels.isAdjustXLabelsEnabled())
|
||||
xLabels.setAdjustXLabels(false);
|
||||
else
|
||||
xLabels.setAdjustXLabels(true);
|
||||
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionSave: {
|
||||
// mChart.saveToGallery("title"+System.currentTimeMillis());
|
||||
mChart.saveToPath("title" + System.currentTimeMillis(), "");
|
||||
break;
|
||||
}
|
||||
case R.id.animateX: {
|
||||
mChart.animateX(3000);
|
||||
break;
|
||||
}
|
||||
case R.id.animateY: {
|
||||
mChart.animateY(3000);
|
||||
break;
|
||||
}
|
||||
case R.id.animateXY: {
|
||||
|
||||
mChart.animateXY(3000, 3000);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
|
||||
tvX.setText("" + (mSeekBarX.getProgress() + 1));
|
||||
tvY.setText("" + (mSeekBarY.getProgress()));
|
||||
|
||||
ArrayList<String> xVals = new ArrayList<String>();
|
||||
for (int i = 0; i < mSeekBarX.getProgress(); i++) {
|
||||
xVals.add((i+1990) + "");
|
||||
}
|
||||
|
||||
ArrayList<BarEntry> yVals1 = new ArrayList<BarEntry>();
|
||||
ArrayList<BarEntry> yVals2 = new ArrayList<BarEntry>();
|
||||
ArrayList<BarEntry> yVals3 = new ArrayList<BarEntry>();
|
||||
|
||||
for (int i = 0; i < mSeekBarX.getProgress(); i++) {
|
||||
float val = (float) (Math.random() * mSeekBarY.getProgress()) + 3;
|
||||
yVals1.add(new BarEntry(val, i));
|
||||
}
|
||||
|
||||
for (int i = 0; i < mSeekBarX.getProgress(); i++) {
|
||||
float val = (float) (Math.random() * mSeekBarY.getProgress()) + 3;
|
||||
yVals2.add(new BarEntry(val, i));
|
||||
}
|
||||
|
||||
for (int i = 0; i < mSeekBarX.getProgress(); i++) {
|
||||
float val = (float) (Math.random() * mSeekBarY.getProgress()) + 3;
|
||||
yVals3.add(new BarEntry(val, i));
|
||||
}
|
||||
|
||||
// create 3 datasets with different types
|
||||
BarDataSet set1 = new BarDataSet(yVals1, "Company A");
|
||||
// set1.setColors(ColorTemplate.createColors(getApplicationContext(), ColorTemplate.FRESH_COLORS));
|
||||
set1.setColor(Color.rgb(104, 241, 175));
|
||||
BarDataSet set2 = new BarDataSet(yVals2, "Company B");
|
||||
set2.setColor(Color.rgb(164, 228, 251));
|
||||
BarDataSet set3 = new BarDataSet(yVals3, "Company C");
|
||||
set3.setColor(Color.rgb(242, 247, 158));
|
||||
|
||||
ArrayList<BarDataSet> dataSets = new ArrayList<BarDataSet>();
|
||||
dataSets.add(set1);
|
||||
dataSets.add(set2);
|
||||
dataSets.add(set3);
|
||||
|
||||
BarData data = new BarData(xVals, dataSets);
|
||||
|
||||
// add space between the dataset groups in percent of bar-width
|
||||
data.setGroupSpace(110f);
|
||||
|
||||
mChart.setData(data);
|
||||
mChart.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueSelected(Entry e, int dataSetIndex) {
|
||||
Log.i("Activity", "Selected: " + e.toString() + ", dataSet: " + dataSetIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected() {
|
||||
Log.i("Activity", "Nothing selected.");
|
||||
}
|
||||
}
|
|
@ -1,211 +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.CandleStickChart;
|
||||
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.utils.XLabels;
|
||||
import com.github.mikephil.charting.utils.XLabels.XLabelPosition;
|
||||
import com.github.mikephil.charting.utils.YLabels;
|
||||
import com.github.mikephil.charting.utils.YLabels.YLabelPosition;
|
||||
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.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.setDrawVerticalGrid(false);
|
||||
mChart.setDrawGridBackground(false);
|
||||
|
||||
XLabels xLabels = mChart.getXLabels();
|
||||
xLabels.setPosition(XLabelPosition.BOTTOM);
|
||||
xLabels.setCenterXLabelText(true);
|
||||
xLabels.setSpaceBetweenLabels(2);
|
||||
|
||||
YLabels yLabels = mChart.getYLabels();
|
||||
yLabels.setLabelCount(7);
|
||||
yLabels.setPosition(YLabelPosition.LEFT);
|
||||
|
||||
mChart.setDrawYLabels(true);
|
||||
mChart.setDrawLegend(false);
|
||||
|
||||
// setting data
|
||||
mSeekBarX.setProgress(15);
|
||||
mSeekBarY.setProgress(100);
|
||||
|
||||
// Legend l = mChart.getLegend();
|
||||
// l.setPosition(LegendPosition.BELOW_CHART_CENTER);
|
||||
// l.setFormSize(8f);
|
||||
// l.setFormToTextSpace(4f);
|
||||
// l.setXEntrySpace(6f);
|
||||
|
||||
// mChart.setDrawLegend(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.candle, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.actionToggleHighlight: {
|
||||
if (mChart.isHighlightEnabled())
|
||||
mChart.setHighlightEnabled(false);
|
||||
else
|
||||
mChart.setHighlightEnabled(true);
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionTogglePinch: {
|
||||
if (mChart.isPinchZoomEnabled())
|
||||
mChart.setPinchZoom(false);
|
||||
else
|
||||
mChart.setPinchZoom(true);
|
||||
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleStartzero: {
|
||||
if (mChart.isStartAtZeroEnabled())
|
||||
mChart.setStartAtZero(false);
|
||||
else
|
||||
mChart.setStartAtZero(true);
|
||||
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleAdjustXLegend: {
|
||||
XLabels xLabels = mChart.getXLabels();
|
||||
|
||||
if (xLabels.isAdjustXLabelsEnabled())
|
||||
xLabels.setAdjustXLabels(false);
|
||||
else
|
||||
xLabels.setAdjustXLabels(true);
|
||||
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.animateX: {
|
||||
mChart.animateX(3000);
|
||||
break;
|
||||
}
|
||||
case R.id.animateY: {
|
||||
mChart.animateY(3000);
|
||||
break;
|
||||
}
|
||||
case R.id.animateXY: {
|
||||
|
||||
mChart.animateXY(3000, 3000);
|
||||
break;
|
||||
}
|
||||
case R.id.actionSave: {
|
||||
if (mChart.saveToGallery("title" + System.currentTimeMillis(), 50)) {
|
||||
Toast.makeText(getApplicationContext(), "Saving SUCCESSFUL!",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
} else
|
||||
Toast.makeText(getApplicationContext(), "Saving FAILED!", Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
|
||||
int prog = (mSeekBarX.getProgress() + 1) * 2;
|
||||
|
||||
tvX.setText("" + prog);
|
||||
tvY.setText("" + (mSeekBarY.getProgress()));
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
ArrayList<String> xVals = new ArrayList<String>();
|
||||
for (int i = 0; i < prog; i++) {
|
||||
xVals.add("" + (1990 + i));
|
||||
}
|
||||
|
||||
CandleDataSet set1 = new CandleDataSet(yVals1, "Data Set");
|
||||
set1.setColor(Color.rgb(80, 80, 80));
|
||||
|
||||
CandleData data = new CandleData(xVals, set1);
|
||||
|
||||
mChart.setData(data);
|
||||
mChart.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
|
@ -1,297 +0,0 @@
|
|||
|
||||
package com.xxmassdeveloper.mpchartexample;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.github.mikephil.charting.charts.LineChart;
|
||||
import com.github.mikephil.charting.data.Entry;
|
||||
import com.github.mikephil.charting.data.LineData;
|
||||
import com.github.mikephil.charting.data.LineDataSet;
|
||||
import com.github.mikephil.charting.data.filter.Approximator;
|
||||
import com.github.mikephil.charting.data.filter.Approximator.ApproximatorType;
|
||||
import com.github.mikephil.charting.utils.XLabels;
|
||||
import com.github.mikephil.charting.utils.YLabels;
|
||||
import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class CubicLineChartActivity extends DemoBase implements OnSeekBarChangeListener {
|
||||
|
||||
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);
|
||||
// if enabled, the chart will always start at zero on the y-axis
|
||||
mChart.setStartAtZero(true);
|
||||
|
||||
// disable the drawing of values into the chart
|
||||
mChart.setDrawYValues(false);
|
||||
|
||||
mChart.setDrawBorder(false);
|
||||
|
||||
mChart.setDrawLegend(false);
|
||||
|
||||
// no description text
|
||||
mChart.setDescription("");
|
||||
mChart.setUnit(" $");
|
||||
|
||||
// enable value highlighting
|
||||
mChart.setHighlightEnabled(true);
|
||||
|
||||
// enable touch gestures
|
||||
mChart.setTouchEnabled(true);
|
||||
|
||||
// enable scaling and dragging
|
||||
mChart.setDragScaleEnabled(true);
|
||||
|
||||
// if disabled, scaling can be done on x- and y-axis separately
|
||||
mChart.setPinchZoom(false);
|
||||
|
||||
mChart.setDrawGridBackground(false);
|
||||
mChart.setDrawVerticalGrid(false);
|
||||
|
||||
Typeface tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
|
||||
mChart.setValueTypeface(tf);
|
||||
|
||||
XLabels x = mChart.getXLabels();
|
||||
x.setTypeface(tf);
|
||||
|
||||
YLabels y = mChart.getYLabels();
|
||||
y.setTypeface(tf);
|
||||
y.setLabelCount(5);
|
||||
|
||||
// add data
|
||||
setData(45, 100);
|
||||
|
||||
mChart.animateXY(2000, 2000);
|
||||
|
||||
// dont forget to refresh the drawing
|
||||
mChart.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.line, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.actionToggleValues: {
|
||||
if (mChart.isDrawYValuesEnabled())
|
||||
mChart.setDrawYValues(false);
|
||||
else
|
||||
mChart.setDrawYValues(true);
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleHighlight: {
|
||||
if (mChart.isHighlightEnabled())
|
||||
mChart.setHighlightEnabled(false);
|
||||
else
|
||||
mChart.setHighlightEnabled(true);
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleFilled: {
|
||||
|
||||
ArrayList<LineDataSet> sets = (ArrayList<LineDataSet>) mChart.getDataCurrent()
|
||||
.getDataSets();
|
||||
|
||||
for (LineDataSet set : sets) {
|
||||
if (set.isDrawFilledEnabled())
|
||||
set.setDrawFilled(false);
|
||||
else
|
||||
set.setDrawFilled(true);
|
||||
}
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleCircles: {
|
||||
ArrayList<LineDataSet> sets = (ArrayList<LineDataSet>) mChart.getDataCurrent()
|
||||
.getDataSets();
|
||||
|
||||
for (LineDataSet set : sets) {
|
||||
if (set.isDrawCirclesEnabled())
|
||||
set.setDrawCircles(false);
|
||||
else
|
||||
set.setDrawCircles(true);
|
||||
}
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleCubic: {
|
||||
ArrayList<LineDataSet> sets = (ArrayList<LineDataSet>) mChart.getDataCurrent()
|
||||
.getDataSets();
|
||||
|
||||
for (LineDataSet set : sets) {
|
||||
if (set.isDrawCubicEnabled())
|
||||
set.setDrawCubic(false);
|
||||
else
|
||||
set.setDrawCubic(true);
|
||||
}
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleStartzero: {
|
||||
if (mChart.isStartAtZeroEnabled())
|
||||
mChart.setStartAtZero(false);
|
||||
else
|
||||
mChart.setStartAtZero(true);
|
||||
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionTogglePinch: {
|
||||
if (mChart.isPinchZoomEnabled())
|
||||
mChart.setPinchZoom(false);
|
||||
else
|
||||
mChart.setPinchZoom(true);
|
||||
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.animateX: {
|
||||
mChart.animateX(3000);
|
||||
break;
|
||||
}
|
||||
case R.id.animateY: {
|
||||
mChart.animateY(3000);
|
||||
break;
|
||||
}
|
||||
case R.id.animateXY: {
|
||||
mChart.animateXY(3000, 3000);
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleAdjustXLegend: {
|
||||
XLabels xLabels = mChart.getXLabels();
|
||||
|
||||
if (xLabels.isAdjustXLabelsEnabled())
|
||||
xLabels.setAdjustXLabels(false);
|
||||
else
|
||||
xLabels.setAdjustXLabels(true);
|
||||
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleFilter: {
|
||||
|
||||
// the angle of filtering is 35°
|
||||
Approximator a = new Approximator(ApproximatorType.DOUGLAS_PEUCKER, 35);
|
||||
|
||||
if (!mChart.isFilteringEnabled()) {
|
||||
mChart.enableFiltering(a);
|
||||
} else {
|
||||
mChart.disableFiltering();
|
||||
}
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionSave: {
|
||||
if (mChart.saveToPath("title" + System.currentTimeMillis(), "")) {
|
||||
Toast.makeText(getApplicationContext(), "Saving SUCCESSFUL!",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
} else
|
||||
Toast.makeText(getApplicationContext(), "Saving FAILED!", Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
|
||||
// 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<String> xVals = new ArrayList<String>();
|
||||
for (int i = 0; i < count; i++) {
|
||||
xVals.add((1990 +i) + "");
|
||||
}
|
||||
|
||||
ArrayList<Entry> vals1 = new ArrayList<Entry>();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
float mult = (range + 1);
|
||||
float val = (float) (Math.random() * mult) + 20;// + (float)
|
||||
// ((mult *
|
||||
// 0.1) / 10);
|
||||
vals1.add(new Entry(val, i));
|
||||
}
|
||||
|
||||
// create a dataset and give it a type
|
||||
LineDataSet set1 = new LineDataSet(vals1, "DataSet 1");
|
||||
set1.setDrawCubic(true);
|
||||
set1.setCubicIntensity(0.2f);
|
||||
set1.setDrawFilled(true);
|
||||
set1.setDrawCircles(false);
|
||||
set1.setLineWidth(2f);
|
||||
set1.setCircleSize(5f);
|
||||
set1.setHighLightColor(Color.rgb(244, 117, 117));
|
||||
set1.setColor(Color.rgb(104, 241, 175));
|
||||
|
||||
ArrayList<LineDataSet> dataSets = new ArrayList<LineDataSet>();
|
||||
dataSets.add(set1);
|
||||
|
||||
// create a data object with the datasets
|
||||
LineData data = new LineData(xVals, dataSets);
|
||||
|
||||
// set data
|
||||
mChart.setData(data);
|
||||
}
|
||||
}
|
|
@ -1,204 +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 com.github.mikephil.charting.charts.Chart;
|
||||
import com.github.mikephil.charting.charts.LineChart;
|
||||
import com.github.mikephil.charting.data.DataSet;
|
||||
import com.github.mikephil.charting.data.Entry;
|
||||
import com.github.mikephil.charting.data.LineData;
|
||||
import com.github.mikephil.charting.data.LineDataSet;
|
||||
import com.github.mikephil.charting.interfaces.OnChartValueSelectedListener;
|
||||
import com.github.mikephil.charting.interfaces.OnDrawListener;
|
||||
import com.github.mikephil.charting.utils.XLabels;
|
||||
import com.github.mikephil.charting.utils.YLabels;
|
||||
import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* This Activity demonstrates drawing into the Chart with the finger. Both line,
|
||||
* bar and scatter charts can be used for drawing.
|
||||
*
|
||||
* @author Philipp Jahoda
|
||||
*/
|
||||
public class DrawChartActivity extends DemoBase implements OnChartValueSelectedListener,
|
||||
OnDrawListener {
|
||||
|
||||
private LineChart mChart;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_draw_chart);
|
||||
|
||||
mChart = (LineChart) findViewById(R.id.chart1);
|
||||
|
||||
// listener for selecting and drawing
|
||||
mChart.setOnChartValueSelectedListener(this);
|
||||
mChart.setOnDrawListener(this);
|
||||
|
||||
// enable drawing with the finger
|
||||
// mChart.setDrawingEnabled(true);
|
||||
|
||||
// enable dragging and scaling
|
||||
mChart.setDragScaleEnabled(true);
|
||||
|
||||
mChart.setDrawYValues(false);
|
||||
// mChart.setLineWidth(5f);
|
||||
// mChart.setCircleSize(5f);
|
||||
|
||||
mChart.setHighlightEnabled(true);
|
||||
|
||||
// if disabled, drawn datasets with the finger will not be automatically
|
||||
// finished
|
||||
// mChart.setAutoFinish(true);
|
||||
mChart.setDrawGridBackground(false);
|
||||
|
||||
mChart.setDrawLegend(false);
|
||||
|
||||
// add dummy-data to the chart
|
||||
initWithDummyData();
|
||||
|
||||
Typeface tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
|
||||
|
||||
XLabels xl = mChart.getXLabels();
|
||||
xl.setTypeface(tf);
|
||||
xl.setAvoidFirstLastClipping(true);
|
||||
|
||||
YLabels yl = mChart.getYLabels();
|
||||
yl.setTypeface(tf);
|
||||
|
||||
mChart.setValueTypeface(tf);
|
||||
|
||||
mChart.setYRange(-40f, 40f, true);
|
||||
// call this to reset the changed y-range
|
||||
// mChart.resetYRange(true);
|
||||
}
|
||||
|
||||
private void initWithDummyData() {
|
||||
ArrayList<String> xVals = new ArrayList<String>();
|
||||
for (int i = 0; i < 24; i++) {
|
||||
xVals.add((i) + ":00");
|
||||
}
|
||||
|
||||
ArrayList<Entry> yVals = new ArrayList<Entry>();
|
||||
|
||||
// create a dataset and give it a type (0)
|
||||
LineDataSet set1 = new LineDataSet(yVals, "DataSet");
|
||||
set1.setLineWidth(3f);
|
||||
set1.setCircleSize(5f);
|
||||
|
||||
ArrayList<LineDataSet> dataSets = new ArrayList<LineDataSet>();
|
||||
dataSets.add(set1); // add the datasets
|
||||
|
||||
// create a data object with the datasets
|
||||
LineData data = new LineData(xVals, dataSets);
|
||||
|
||||
mChart.setData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.draw, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.actionToggleValues: {
|
||||
if (mChart.isDrawYValuesEnabled())
|
||||
mChart.setDrawYValues(false);
|
||||
else
|
||||
mChart.setDrawYValues(true);
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleHighlight: {
|
||||
if (mChart.isHighlightEnabled())
|
||||
mChart.setHighlightEnabled(false);
|
||||
else
|
||||
mChart.setHighlightEnabled(true);
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleStartzero: {
|
||||
if (mChart.isStartAtZeroEnabled())
|
||||
mChart.setStartAtZero(false);
|
||||
else
|
||||
mChart.setStartAtZero(true);
|
||||
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleAdjustXLegend: {
|
||||
XLabels xLabels = mChart.getXLabels();
|
||||
|
||||
if (xLabels.isAdjustXLabelsEnabled())
|
||||
xLabels.setAdjustXLabels(false);
|
||||
else
|
||||
xLabels.setAdjustXLabels(true);
|
||||
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionTogglePinch: {
|
||||
if (mChart.isPinchZoomEnabled())
|
||||
mChart.setPinchZoom(false);
|
||||
else
|
||||
mChart.setPinchZoom(true);
|
||||
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionSave: {
|
||||
// mChart.saveToGallery("title"+System.currentTimeMillis());
|
||||
mChart.saveToPath("title" + System.currentTimeMillis(), "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueSelected(Entry e, int dataSetIndex) {
|
||||
Log.i("VAL SELECTED",
|
||||
"Value: " + e.getVal() + ", xIndex: " + e.getXIndex()
|
||||
+ ", DataSet index: " + dataSetIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected() {
|
||||
}
|
||||
|
||||
/** callback for each new entry drawn with the finger */
|
||||
@Override
|
||||
public void onEntryAdded(Entry entry) {
|
||||
Log.i(Chart.LOG_TAG, entry.toString());
|
||||
}
|
||||
|
||||
/** callback when a DataSet has been drawn (when lifting the finger) */
|
||||
@Override
|
||||
public void onDrawFinished(DataSet dataSet) {
|
||||
Log.i(Chart.LOG_TAG, "DataSet drawn. " + dataSet.toSimpleString());
|
||||
|
||||
// prepare the legend again
|
||||
mChart.prepareLegend();
|
||||
|
||||
mChart.calculateLegendOffsets();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntryMoved(Entry entry) {
|
||||
Log.i(Chart.LOG_TAG, "Point moved " + entry.toString());
|
||||
}
|
||||
}
|
|
@ -1,210 +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.LineChart;
|
||||
import com.github.mikephil.charting.data.Entry;
|
||||
import com.github.mikephil.charting.data.LineData;
|
||||
import com.github.mikephil.charting.data.LineDataSet;
|
||||
import com.github.mikephil.charting.interfaces.OnChartValueSelectedListener;
|
||||
import com.github.mikephil.charting.utils.ColorTemplate;
|
||||
import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class DynamicalAddingActivity extends DemoBase implements OnChartValueSelectedListener {
|
||||
|
||||
private LineChart mChart;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_linechart_noseekbar);
|
||||
|
||||
mChart = (LineChart) findViewById(R.id.chart1);
|
||||
mChart.setOnChartValueSelectedListener(this);
|
||||
mChart.setDrawYValues(false);
|
||||
mChart.setDrawGridBackground(false);
|
||||
mChart.setDescription("");
|
||||
|
||||
addEmptyData();
|
||||
|
||||
mChart.invalidate();
|
||||
}
|
||||
|
||||
int[] mColors = ColorTemplate.VORDIPLOM_COLORS;
|
||||
|
||||
private void addEntry() {
|
||||
|
||||
LineData data = mChart.getDataOriginal();
|
||||
|
||||
if(data != null) {
|
||||
|
||||
LineDataSet set = data.getDataSetByIndex(0);
|
||||
// set.addEntry(...);
|
||||
|
||||
if (set == null) {
|
||||
set = createSet();
|
||||
data.addDataSet(set);
|
||||
}
|
||||
|
||||
data.addEntry(new Entry((float) (Math.random() * 50) + 50f, set.getEntryCount()), 0);
|
||||
|
||||
// let the chart know it's data has changed
|
||||
mChart.notifyDataSetChanged();
|
||||
|
||||
// redraw the chart
|
||||
mChart.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private void removeLastEntry() {
|
||||
|
||||
LineData data = mChart.getDataOriginal();
|
||||
|
||||
if(data != null) {
|
||||
|
||||
LineDataSet set = data.getDataSetByIndex(0);
|
||||
|
||||
if (set != null) {
|
||||
|
||||
Entry e = set.getEntryForXIndex(set.getEntryCount() - 1);
|
||||
|
||||
data.removeEntry(e, 0);
|
||||
// or remove by index
|
||||
// mData.removeEntry(xIndex, dataSetIndex);
|
||||
|
||||
mChart.notifyDataSetChanged();
|
||||
mChart.invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addDataSet() {
|
||||
|
||||
LineData data = mChart.getDataOriginal();
|
||||
|
||||
if(data != null) {
|
||||
|
||||
int count = (data.getDataSetCount() + 1);
|
||||
|
||||
// create 10 y-vals
|
||||
ArrayList<Entry> yVals = new ArrayList<Entry>();
|
||||
|
||||
for (int i = 0; i < data.getXValCount(); i++)
|
||||
yVals.add(new Entry((float) (Math.random() * 50f) + 50f * count, i));
|
||||
|
||||
LineDataSet set = new LineDataSet(yVals, "DataSet " + count);
|
||||
set.setLineWidth(2.5f);
|
||||
set.setCircleSize(4.5f);
|
||||
|
||||
int color = mColors[count % mColors.length];
|
||||
|
||||
set.setColor(color);
|
||||
set.setCircleColor(color);
|
||||
set.setHighLightColor(color);
|
||||
|
||||
data.addDataSet(set);
|
||||
mChart.notifyDataSetChanged();
|
||||
mChart.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private void removeDataSet() {
|
||||
|
||||
LineData data = mChart.getDataOriginal();
|
||||
|
||||
if(data != null) {
|
||||
|
||||
data.removeDataSet(data.getDataSetByIndex(data.getDataSetCount() - 1));
|
||||
|
||||
mChart.notifyDataSetChanged();
|
||||
mChart.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private void addEmptyData() {
|
||||
|
||||
// create 30 x-vals
|
||||
String[] xVals = new String[30];
|
||||
|
||||
for (int i = 0; i < 30; i++)
|
||||
xVals[i] = "" + i;
|
||||
|
||||
// create a chartdata object that contains only the x-axis labels (no entries or datasets)
|
||||
LineData data = new LineData(xVals);
|
||||
|
||||
mChart.setData(data);
|
||||
mChart.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueSelected(Entry e, int dataSetIndex) {
|
||||
Toast.makeText(this, e.toString(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.dynamical, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.actionAddEntry:
|
||||
addEntry();
|
||||
Toast.makeText(this, "Entry added!", Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
case R.id.actionRemoveEntry:
|
||||
removeLastEntry();
|
||||
Toast.makeText(this, "Entry removed!", Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
case R.id.actionAddDataSet:
|
||||
addDataSet();
|
||||
Toast.makeText(this, "DataSet added!", Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
case R.id.actionRemoveDataSet:
|
||||
removeDataSet();
|
||||
Toast.makeText(this, "DataSet removed!", Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
case R.id.actionAddEmptyLineData:
|
||||
addEmptyData();
|
||||
Toast.makeText(this, "Empty data added!", Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
case R.id.actionClear:
|
||||
mChart.clear();
|
||||
Toast.makeText(this, "Chart cleared!", Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private LineDataSet createSet() {
|
||||
|
||||
LineDataSet set = new LineDataSet(null, "DataSet 1");
|
||||
set.setLineWidth(2.5f);
|
||||
set.setCircleSize(4.5f);
|
||||
set.setColor(Color.rgb(240, 99, 99));
|
||||
set.setCircleColor(Color.rgb(240, 99, 99));
|
||||
set.setHighLightColor(Color.rgb(190, 190, 190));
|
||||
|
||||
return set;
|
||||
}
|
||||
}
|
|
@ -1,317 +0,0 @@
|
|||
|
||||
package com.xxmassdeveloper.mpchartexample;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.github.mikephil.charting.charts.BarLineChartBase.BorderPosition;
|
||||
import com.github.mikephil.charting.charts.LineChart;
|
||||
import com.github.mikephil.charting.data.Entry;
|
||||
import com.github.mikephil.charting.data.LineData;
|
||||
import com.github.mikephil.charting.data.LineDataSet;
|
||||
import com.github.mikephil.charting.data.filter.Approximator;
|
||||
import com.github.mikephil.charting.data.filter.Approximator.ApproximatorType;
|
||||
import com.github.mikephil.charting.interfaces.OnChartValueSelectedListener;
|
||||
import com.github.mikephil.charting.utils.Legend;
|
||||
import com.github.mikephil.charting.utils.Legend.LegendForm;
|
||||
import com.github.mikephil.charting.utils.XLabels;
|
||||
import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class InvertedLineChartActivity extends DemoBase implements OnSeekBarChangeListener,
|
||||
OnChartValueSelectedListener {
|
||||
|
||||
private LineChart mChart;
|
||||
private SeekBar mSeekBarX, mSeekBarY;
|
||||
private TextView tvX, tvY;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_linechart);
|
||||
|
||||
tvX = (TextView) findViewById(R.id.tvXMax);
|
||||
tvY = (TextView) findViewById(R.id.tvYMax);
|
||||
|
||||
mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
|
||||
mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
|
||||
|
||||
mSeekBarX.setProgress(45);
|
||||
mSeekBarY.setProgress(100);
|
||||
|
||||
mSeekBarY.setOnSeekBarChangeListener(this);
|
||||
mSeekBarX.setOnSeekBarChangeListener(this);
|
||||
|
||||
mChart = (LineChart) findViewById(R.id.chart1);
|
||||
mChart.setOnChartValueSelectedListener(this);
|
||||
|
||||
// if enabled, the chart will always start at zero on the y-axis
|
||||
mChart.setStartAtZero(true);
|
||||
|
||||
// enable the drawing of values into the chart
|
||||
mChart.setDrawYValues(true);
|
||||
|
||||
mChart.setDrawBorder(true);
|
||||
mChart.setBorderPositions(new BorderPosition[] {
|
||||
BorderPosition.BOTTOM
|
||||
});
|
||||
|
||||
// no description text
|
||||
mChart.setDescription("");
|
||||
|
||||
// invert the y-axis
|
||||
mChart.setInvertYAxisEnabled(true);
|
||||
|
||||
// enable value highlighting
|
||||
mChart.setHighlightEnabled(true);
|
||||
|
||||
// enable touch gestures
|
||||
mChart.setTouchEnabled(true);
|
||||
|
||||
// enable scaling and dragging
|
||||
mChart.setDragScaleEnabled(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);
|
||||
|
||||
// define an offset to change the original position of the marker
|
||||
// (optional)
|
||||
mv.setOffsets(-mv.getMeasuredWidth() / 2, -mv.getMeasuredHeight());
|
||||
|
||||
// set the marker to the chart
|
||||
mChart.setMarkerView(mv);
|
||||
|
||||
// enable/disable highlight indicators (the lines that indicate the
|
||||
// highlighted Entry)
|
||||
mChart.setHighlightIndicatorEnabled(false);
|
||||
|
||||
XLabels xl = mChart.getXLabels();
|
||||
xl.setAvoidFirstLastClipping(true);
|
||||
|
||||
// add data
|
||||
setData(25, 50);
|
||||
|
||||
// // restrain the maximum scale-out factor
|
||||
// mChart.setScaleMinima(3f, 3f);
|
||||
//
|
||||
// // center the view to a specific position inside the chart
|
||||
// mChart.centerViewPort(10, 50);
|
||||
|
||||
// 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 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: {
|
||||
if (mChart.isDrawYValuesEnabled())
|
||||
mChart.setDrawYValues(false);
|
||||
else
|
||||
mChart.setDrawYValues(true);
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleHighlight: {
|
||||
if (mChart.isHighlightEnabled())
|
||||
mChart.setHighlightEnabled(false);
|
||||
else
|
||||
mChart.setHighlightEnabled(true);
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleFilled: {
|
||||
|
||||
ArrayList<LineDataSet> sets = (ArrayList<LineDataSet>) mChart.getDataCurrent()
|
||||
.getDataSets();
|
||||
|
||||
for (LineDataSet set : sets) {
|
||||
if (set.isDrawFilledEnabled())
|
||||
set.setDrawFilled(false);
|
||||
else
|
||||
set.setDrawFilled(true);
|
||||
}
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleCircles: {
|
||||
ArrayList<LineDataSet> sets = (ArrayList<LineDataSet>) mChart.getDataCurrent()
|
||||
.getDataSets();
|
||||
|
||||
for (LineDataSet set : sets) {
|
||||
if (set.isDrawCirclesEnabled())
|
||||
set.setDrawCircles(false);
|
||||
else
|
||||
set.setDrawCircles(true);
|
||||
}
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleStartzero: {
|
||||
if (mChart.isStartAtZeroEnabled())
|
||||
mChart.setStartAtZero(false);
|
||||
else
|
||||
mChart.setStartAtZero(true);
|
||||
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.animateX: {
|
||||
mChart.animateX(3000);
|
||||
break;
|
||||
}
|
||||
case R.id.animateY: {
|
||||
mChart.animateY(3000);
|
||||
break;
|
||||
}
|
||||
case R.id.animateXY: {
|
||||
|
||||
mChart.animateXY(3000, 3000);
|
||||
break;
|
||||
}
|
||||
case R.id.actionTogglePinch: {
|
||||
if (mChart.isPinchZoomEnabled())
|
||||
mChart.setPinchZoom(false);
|
||||
else
|
||||
mChart.setPinchZoom(true);
|
||||
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleAdjustXLegend: {
|
||||
XLabels xLabels = mChart.getXLabels();
|
||||
|
||||
if (xLabels.isAdjustXLabelsEnabled())
|
||||
xLabels.setAdjustXLabels(false);
|
||||
else
|
||||
xLabels.setAdjustXLabels(true);
|
||||
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleFilter: {
|
||||
|
||||
// the angle of filtering is 35°
|
||||
Approximator a = new Approximator(ApproximatorType.DOUGLAS_PEUCKER, 35);
|
||||
|
||||
if (!mChart.isFilteringEnabled()) {
|
||||
mChart.enableFiltering(a);
|
||||
} else {
|
||||
mChart.disableFiltering();
|
||||
}
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionSave: {
|
||||
if (mChart.saveToPath("title" + System.currentTimeMillis(), "")) {
|
||||
Toast.makeText(getApplicationContext(), "Saving SUCCESSFUL!",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
} else
|
||||
Toast.makeText(getApplicationContext(), "Saving FAILED!", Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
|
||||
// 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 onValueSelected(Entry e, int dataSetIndex) {
|
||||
Log.i("VAL SELECTED",
|
||||
"Value: " + e.getVal() + ", xIndex: " + e.getXIndex()
|
||||
+ ", DataSet index: " + dataSetIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
private void setData(int count, float range) {
|
||||
|
||||
ArrayList<String> xVals = new ArrayList<String>();
|
||||
for (int i = 0; i < count; i++) {
|
||||
xVals.add((i % 30) + "/" + (i % 12) + "/14");
|
||||
}
|
||||
|
||||
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(val, i));
|
||||
}
|
||||
|
||||
// create a dataset and give it a type
|
||||
LineDataSet set1 = new LineDataSet(yVals, "DataSet 1");
|
||||
|
||||
set1.setLineWidth(1.5f);
|
||||
set1.setCircleSize(4f);
|
||||
|
||||
// create a data object with the datasets
|
||||
LineData data = new LineData(xVals, set1);
|
||||
|
||||
// set data
|
||||
mChart.setData(data);
|
||||
}
|
||||
}
|
|
@ -1,370 +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.BarLineChartBase.BorderPosition;
|
||||
import com.github.mikephil.charting.charts.LineChart;
|
||||
import com.github.mikephil.charting.data.Entry;
|
||||
import com.github.mikephil.charting.data.LineData;
|
||||
import com.github.mikephil.charting.data.LineDataSet;
|
||||
import com.github.mikephil.charting.data.filter.Approximator;
|
||||
import com.github.mikephil.charting.data.filter.Approximator.ApproximatorType;
|
||||
import com.github.mikephil.charting.interfaces.OnChartValueSelectedListener;
|
||||
import com.github.mikephil.charting.utils.Legend;
|
||||
import com.github.mikephil.charting.utils.Legend.LegendForm;
|
||||
import com.github.mikephil.charting.utils.LimitLine;
|
||||
import com.github.mikephil.charting.utils.XLabels;
|
||||
import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class LineChartActivity extends DemoBase implements OnSeekBarChangeListener,
|
||||
OnChartValueSelectedListener {
|
||||
|
||||
private LineChart mChart;
|
||||
private SeekBar mSeekBarX, mSeekBarY;
|
||||
private TextView tvX, tvY;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_linechart);
|
||||
|
||||
tvX = (TextView) findViewById(R.id.tvXMax);
|
||||
tvY = (TextView) findViewById(R.id.tvYMax);
|
||||
|
||||
mSeekBarX = (SeekBar) findViewById(R.id.seekBar1);
|
||||
mSeekBarY = (SeekBar) findViewById(R.id.seekBar2);
|
||||
|
||||
mSeekBarX.setProgress(45);
|
||||
mSeekBarY.setProgress(100);
|
||||
|
||||
mSeekBarY.setOnSeekBarChangeListener(this);
|
||||
mSeekBarX.setOnSeekBarChangeListener(this);
|
||||
|
||||
mChart = (LineChart) findViewById(R.id.chart1);
|
||||
mChart.setOnChartValueSelectedListener(this);
|
||||
|
||||
// if enabled, the chart will always start at zero on the y-axis
|
||||
mChart.setStartAtZero(false);
|
||||
|
||||
// disable the drawing of values into the chart
|
||||
mChart.setDrawYValues(false);
|
||||
|
||||
mChart.setDrawBorder(true);
|
||||
mChart.setBorderPositions(new BorderPosition[] {
|
||||
BorderPosition.BOTTOM
|
||||
});
|
||||
|
||||
// no description text
|
||||
mChart.setDescription("");
|
||||
mChart.setNoDataTextDescription("You need to provide data for the chart.");
|
||||
|
||||
// // enable / disable grid lines
|
||||
// mChart.setDrawVerticalGrid(false);
|
||||
// mChart.setDrawHorizontalGrid(false);
|
||||
//
|
||||
// // enable / disable grid background
|
||||
// mChart.setDrawGridBackground(false);
|
||||
//
|
||||
// mChart.setDrawXLegend(false);
|
||||
// mChart.setDrawYLegend(false);
|
||||
|
||||
// enable value highlighting
|
||||
mChart.setHighlightEnabled(true);
|
||||
|
||||
// enable touch gestures
|
||||
mChart.setTouchEnabled(true);
|
||||
|
||||
// enable scaling and dragging
|
||||
mChart.setDragScaleEnabled(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);
|
||||
|
||||
// define an offset to change the original position of the marker
|
||||
// (optional)
|
||||
mv.setOffsets(-mv.getMeasuredWidth() / 2, -mv.getMeasuredHeight());
|
||||
|
||||
// set the marker to the chart
|
||||
mChart.setMarkerView(mv);
|
||||
|
||||
// enable/disable highlight indicators (the lines that indicate the
|
||||
// highlighted Entry)
|
||||
mChart.setHighlightIndicatorEnabled(false);
|
||||
|
||||
// add data
|
||||
setData(45, 100);
|
||||
|
||||
mChart.animateX(2500);
|
||||
|
||||
// // restrain the maximum scale-out factor
|
||||
// mChart.setScaleMinima(3f, 3f);
|
||||
//
|
||||
// // center the view to a specific position inside the chart
|
||||
// mChart.centerViewPort(10, 50);
|
||||
|
||||
// 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 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: {
|
||||
if (mChart.isDrawYValuesEnabled())
|
||||
mChart.setDrawYValues(false);
|
||||
else
|
||||
mChart.setDrawYValues(true);
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleHighlight: {
|
||||
if (mChart.isHighlightEnabled())
|
||||
mChart.setHighlightEnabled(false);
|
||||
else
|
||||
mChart.setHighlightEnabled(true);
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleFilled: {
|
||||
|
||||
ArrayList<LineDataSet> sets = (ArrayList<LineDataSet>) mChart.getDataCurrent()
|
||||
.getDataSets();
|
||||
|
||||
for (LineDataSet set : sets) {
|
||||
if (set.isDrawFilledEnabled())
|
||||
set.setDrawFilled(false);
|
||||
else
|
||||
set.setDrawFilled(true);
|
||||
}
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleCircles: {
|
||||
ArrayList<LineDataSet> sets = (ArrayList<LineDataSet>) mChart.getDataCurrent()
|
||||
.getDataSets();
|
||||
|
||||
for (LineDataSet set : sets) {
|
||||
if (set.isDrawCirclesEnabled())
|
||||
set.setDrawCircles(false);
|
||||
else
|
||||
set.setDrawCircles(true);
|
||||
}
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleCubic: {
|
||||
ArrayList<LineDataSet> sets = (ArrayList<LineDataSet>) mChart.getDataCurrent()
|
||||
.getDataSets();
|
||||
|
||||
for (LineDataSet set : sets) {
|
||||
if (set.isDrawCubicEnabled())
|
||||
set.setDrawCubic(false);
|
||||
else
|
||||
set.setDrawCubic(true);
|
||||
}
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleStartzero: {
|
||||
if (mChart.isStartAtZeroEnabled())
|
||||
mChart.setStartAtZero(false);
|
||||
else
|
||||
mChart.setStartAtZero(true);
|
||||
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionTogglePinch: {
|
||||
if (mChart.isPinchZoomEnabled())
|
||||
mChart.setPinchZoom(false);
|
||||
else
|
||||
mChart.setPinchZoom(true);
|
||||
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.animateX: {
|
||||
mChart.animateX(3000);
|
||||
break;
|
||||
}
|
||||
case R.id.animateY: {
|
||||
mChart.animateY(3000);
|
||||
break;
|
||||
}
|
||||
case R.id.animateXY: {
|
||||
mChart.animateXY(3000, 3000);
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleAdjustXLegend: {
|
||||
XLabels xLabels = mChart.getXLabels();
|
||||
|
||||
if (xLabels.isAdjustXLabelsEnabled())
|
||||
xLabels.setAdjustXLabels(false);
|
||||
else
|
||||
xLabels.setAdjustXLabels(true);
|
||||
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleFilter: {
|
||||
|
||||
// the angle of filtering is 35°
|
||||
Approximator a = new Approximator(ApproximatorType.DOUGLAS_PEUCKER, 35);
|
||||
|
||||
if (!mChart.isFilteringEnabled()) {
|
||||
mChart.enableFiltering(a);
|
||||
} else {
|
||||
mChart.disableFiltering();
|
||||
}
|
||||
mChart.invalidate();
|
||||
|
||||
//
|
||||
// for(int i = 0; i < 10; i++) {
|
||||
// mChart.addEntry(new Entry((float) (Math.random() * 100), i+2), 0);
|
||||
// mChart.invalidate();
|
||||
// }
|
||||
//
|
||||
// Toast.makeText(getApplicationContext(), "valcount: " + mChart.getDataOriginal().getYValCount() + ", valsum: " + mChart.getDataOriginal().getYValueSum(), Toast.LENGTH_SHORT).show();
|
||||
//
|
||||
break;
|
||||
}
|
||||
case R.id.actionSave: {
|
||||
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 onValueSelected(Entry e, int dataSetIndex) {
|
||||
Log.i("VAL SELECTED",
|
||||
"Value: " + e.getVal() + ", xIndex: " + e.getXIndex()
|
||||
+ ", DataSet index: " + dataSetIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
private void setData(int count, float range) {
|
||||
|
||||
ArrayList<String> xVals = new ArrayList<String>();
|
||||
for (int i = 0; i < count; i++) {
|
||||
xVals.add((i) + "");
|
||||
}
|
||||
|
||||
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(val, i));
|
||||
}
|
||||
|
||||
// create a dataset and give it a type
|
||||
LineDataSet set1 = new LineDataSet(yVals, "DataSet 1");
|
||||
// set1.setFillAlpha(110);
|
||||
// set1.setFillColor(Color.RED);
|
||||
|
||||
// set the line to be drawn like this "- - - - - -"
|
||||
set1.enableDashedLine(10f, 5f, 0f);
|
||||
set1.setColor(Color.BLACK);
|
||||
set1.setCircleColor(Color.BLACK);
|
||||
set1.setLineWidth(1f);
|
||||
set1.setCircleSize(4f);
|
||||
set1.setFillAlpha(65);
|
||||
set1.setFillColor(Color.BLACK);
|
||||
// set1.setShader(new LinearGradient(0, 0, 0, mChart.getHeight(), Color.BLACK, Color.WHITE, Shader.TileMode.MIRROR));
|
||||
|
||||
ArrayList<LineDataSet> dataSets = new ArrayList<LineDataSet>();
|
||||
dataSets.add(set1); // add the datasets
|
||||
|
||||
// create a data object with the datasets
|
||||
LineData data = new LineData(xVals, dataSets);
|
||||
|
||||
LimitLine ll1 = new LimitLine(130f);
|
||||
ll1.setLineWidth(4f);
|
||||
ll1.enableDashedLine(10f, 10f, 0f);
|
||||
|
||||
LimitLine ll2 = new LimitLine(-30f);
|
||||
ll2.setLineWidth(4f);
|
||||
ll2.enableDashedLine(10f, 10f, 0f);
|
||||
|
||||
data.addLimitLine(ll1);
|
||||
data.addLimitLine(ll2);
|
||||
|
||||
// set data
|
||||
mChart.setData(data);
|
||||
}
|
||||
}
|
|
@ -1,149 +0,0 @@
|
|||
|
||||
package com.xxmassdeveloper.mpchartexample;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.github.mikephil.charting.charts.LineChart;
|
||||
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.utils.Legend;
|
||||
import com.github.mikephil.charting.utils.Legend.LegendForm;
|
||||
import com.github.mikephil.charting.utils.XLabels;
|
||||
import com.github.mikephil.charting.utils.YLabels;
|
||||
import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class LineChartActivityColored extends DemoBase {
|
||||
|
||||
private LineChart[] mCharts = new LineChart[4];
|
||||
private Typeface mTf;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_colored_lines);
|
||||
|
||||
mCharts[0] = (LineChart) findViewById(R.id.chart1);
|
||||
mCharts[1] = (LineChart) findViewById(R.id.chart2);
|
||||
mCharts[2] = (LineChart) findViewById(R.id.chart3);
|
||||
mCharts[3] = (LineChart) findViewById(R.id.chart4);
|
||||
|
||||
mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Bold.ttf");
|
||||
|
||||
LineData data = getData(36, 100);
|
||||
|
||||
for (int i = 0; i < mCharts.length; i++)
|
||||
// add some transparency to the color with "& 0x90FFFFFF"
|
||||
setupChart(mCharts[i], data, mColors[i % mColors.length]);
|
||||
}
|
||||
|
||||
private int[] mColors = new int[] {
|
||||
Color.rgb(137, 230, 81),
|
||||
Color.rgb(240, 240, 30),
|
||||
Color.rgb(89, 199, 250),
|
||||
Color.rgb(250, 104, 104)
|
||||
};
|
||||
|
||||
private void setupChart(LineChart chart, LineData data, int color) {
|
||||
|
||||
// if enabled, the chart will always start at zero on the y-axis
|
||||
chart.setStartAtZero(true);
|
||||
|
||||
// disable the drawing of values into the chart
|
||||
chart.setDrawYValues(false);
|
||||
|
||||
chart.setDrawBorder(false);
|
||||
|
||||
// no description text
|
||||
chart.setDescription("");
|
||||
chart.setNoDataTextDescription("You need to provide data for the chart.");
|
||||
|
||||
// enable / disable grid lines
|
||||
chart.setDrawVerticalGrid(false);
|
||||
// mChart.setDrawHorizontalGrid(false);
|
||||
//
|
||||
// enable / disable grid background
|
||||
chart.setDrawGridBackground(false);
|
||||
chart.setGridColor(Color.WHITE & 0x70FFFFFF);
|
||||
chart.setGridWidth(1.25f);
|
||||
|
||||
// enable touch gestures
|
||||
chart.setTouchEnabled(true);
|
||||
|
||||
// enable scaling and dragging
|
||||
chart.setDragScaleEnabled(true);
|
||||
|
||||
// if disabled, scaling can be done on x- and y-axis separately
|
||||
chart.setPinchZoom(false);
|
||||
|
||||
chart.setBackgroundColor(color);
|
||||
|
||||
chart.setValueTypeface(mTf);
|
||||
|
||||
// add data
|
||||
chart.setData(data);
|
||||
|
||||
// get the legend (only possible after setting data)
|
||||
Legend l = chart.getLegend();
|
||||
|
||||
// modify the legend ...
|
||||
// l.setPosition(LegendPosition.LEFT_OF_CHART);
|
||||
l.setForm(LegendForm.CIRCLE);
|
||||
l.setFormSize(6f);
|
||||
l.setTextColor(Color.WHITE);
|
||||
l.setTypeface(mTf);
|
||||
|
||||
YLabels y = chart.getYLabels();
|
||||
y.setTextColor(Color.WHITE);
|
||||
y.setTypeface(mTf);
|
||||
y.setLabelCount(4);
|
||||
|
||||
XLabels x = chart.getXLabels();
|
||||
x.setTextColor(Color.WHITE);
|
||||
x.setTypeface(mTf);
|
||||
|
||||
// animate calls invalidate()...
|
||||
chart.animateX(2500);
|
||||
}
|
||||
|
||||
private LineData getData(int count, float range) {
|
||||
|
||||
ArrayList<String> xVals = new ArrayList<String>();
|
||||
for (int i = 0; i < count; i++) {
|
||||
xVals.add(mMonths[i % 12]);
|
||||
}
|
||||
|
||||
ArrayList<Entry> yVals = new ArrayList<Entry>();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
float val = (float) (Math.random() * range) + 3;
|
||||
yVals.add(new Entry(val, i));
|
||||
}
|
||||
|
||||
// create a dataset and give it a type
|
||||
LineDataSet set1 = new LineDataSet(yVals, "DataSet 1");
|
||||
// set1.setFillAlpha(110);
|
||||
// set1.setFillColor(Color.RED);
|
||||
|
||||
set1.setLineWidth(1.75f);
|
||||
set1.setCircleSize(3f);
|
||||
set1.setColor(Color.WHITE);
|
||||
set1.setCircleColor(Color.WHITE);
|
||||
set1.setHighLightColor(Color.WHITE);
|
||||
|
||||
ArrayList<LineDataSet> dataSets = new ArrayList<LineDataSet>();
|
||||
dataSets.add(set1); // add the datasets
|
||||
|
||||
// create a data object with the datasets
|
||||
LineData data = new LineData(xVals, dataSets);
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
|
@ -1,162 +0,0 @@
|
|||
|
||||
package com.xxmassdeveloper.mpchartexample;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.github.mikephil.charting.charts.BarChart;
|
||||
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.github.mikephil.charting.utils.XLabels;
|
||||
import com.github.mikephil.charting.utils.XLabels.XLabelPosition;
|
||||
import com.github.mikephil.charting.utils.YLabels;
|
||||
import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Demonstrates the use of charts inside a ListView. IMPORTANT: provide a
|
||||
* specific height attribute for the chart inside your listview-item
|
||||
*
|
||||
* @author Philipp Jahoda
|
||||
*/
|
||||
public class ListViewBarChartActivity extends DemoBase {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_listview_chart);
|
||||
|
||||
ListView lv = (ListView) findViewById(R.id.listView1);
|
||||
|
||||
ArrayList<BarData> list = new ArrayList<BarData>();
|
||||
|
||||
// 20 items
|
||||
for (int i = 0; i < 20; i++) {
|
||||
list.add(generateData(i + 1));
|
||||
}
|
||||
|
||||
ChartDataAdapter cda = new ChartDataAdapter(getApplicationContext(), list);
|
||||
lv.setAdapter(cda);
|
||||
}
|
||||
|
||||
private class ChartDataAdapter extends ArrayAdapter<BarData> {
|
||||
|
||||
private Typeface mTf;
|
||||
|
||||
public ChartDataAdapter(Context context, List<BarData> objects) {
|
||||
super(context, 0, objects);
|
||||
|
||||
mTf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
|
||||
BarData c = getItem(position);
|
||||
|
||||
ViewHolder holder = null;
|
||||
|
||||
if (convertView == null) {
|
||||
|
||||
holder = new ViewHolder();
|
||||
|
||||
convertView = LayoutInflater.from(getContext()).inflate(
|
||||
R.layout.list_item_barchart, null);
|
||||
holder.chart = (BarChart) convertView.findViewById(R.id.chart);
|
||||
|
||||
convertView.setTag(holder);
|
||||
|
||||
} else {
|
||||
holder = (ViewHolder) convertView.getTag();
|
||||
}
|
||||
|
||||
// apply styling
|
||||
holder.chart.setValueTypeface(mTf);
|
||||
holder.chart.setDescription("");
|
||||
holder.chart.setDrawVerticalGrid(false);
|
||||
holder.chart.setDrawGridBackground(false);
|
||||
holder.chart.setValueTextColor(Color.WHITE);
|
||||
|
||||
XLabels xl = holder.chart.getXLabels();
|
||||
xl.setCenterXLabelText(true);
|
||||
xl.setPosition(XLabelPosition.BOTTOM);
|
||||
xl.setTypeface(mTf);
|
||||
|
||||
YLabels yl = holder.chart.getYLabels();
|
||||
yl.setTypeface(mTf);
|
||||
yl.setLabelCount(5);
|
||||
|
||||
// set data
|
||||
holder.chart.setData(c);
|
||||
|
||||
// do not forget to refresh the chart
|
||||
// holder.chart.invalidate();
|
||||
holder.chart.animateY(700);
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
||||
private class ViewHolder {
|
||||
|
||||
BarChart chart;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* generates a random ChartData object with just one DataSet
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private BarData generateData(int cnt) {
|
||||
|
||||
ArrayList<BarEntry> entries = new ArrayList<BarEntry>();
|
||||
|
||||
for (int i = 0; i < 12; i++) {
|
||||
entries.add(new BarEntry((int) (Math.random() * 70) + 30, i));
|
||||
}
|
||||
|
||||
BarDataSet d = new BarDataSet(entries, "New DataSet " + cnt);
|
||||
d.setBarSpacePercent(20f);
|
||||
d.setColors(ColorTemplate.VORDIPLOM_COLORS, getApplicationContext());
|
||||
d.setBarShadowColor(Color.rgb(203, 203, 203));
|
||||
|
||||
ArrayList<BarDataSet> sets = new ArrayList<BarDataSet>();
|
||||
sets.add(d);
|
||||
|
||||
BarData cd = new BarData(getMonths(), sets);
|
||||
return cd;
|
||||
}
|
||||
|
||||
private ArrayList<String> getMonths() {
|
||||
|
||||
ArrayList<String> m = new ArrayList<String>();
|
||||
m.add("Jan");
|
||||
m.add("Feb");
|
||||
m.add("Mar");
|
||||
m.add("Apr");
|
||||
m.add("May");
|
||||
m.add("Jun");
|
||||
m.add("Jul");
|
||||
m.add("Aug");
|
||||
m.add("Sep");
|
||||
m.add("Okt");
|
||||
m.add("Nov");
|
||||
m.add("Dec");
|
||||
|
||||
return m;
|
||||
}
|
||||
}
|
|
@ -1,260 +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.data.Entry;
|
||||
import com.github.mikephil.charting.data.LineData;
|
||||
import com.github.mikephil.charting.data.LineDataSet;
|
||||
import com.github.mikephil.charting.data.filter.Approximator;
|
||||
import com.github.mikephil.charting.data.filter.Approximator.ApproximatorType;
|
||||
import com.github.mikephil.charting.interfaces.OnChartValueSelectedListener;
|
||||
import com.github.mikephil.charting.utils.ColorTemplate;
|
||||
import com.github.mikephil.charting.utils.Legend;
|
||||
import com.github.mikephil.charting.utils.Legend.LegendPosition;
|
||||
import com.github.mikephil.charting.utils.XLabels;
|
||||
import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
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.setStartAtZero(true);
|
||||
|
||||
// disable the drawing of values into the chart
|
||||
mChart.setDrawYValues(false);
|
||||
|
||||
// enable value highlighting
|
||||
mChart.setHighlightEnabled(true);
|
||||
|
||||
// enable touch gestures
|
||||
mChart.setTouchEnabled(true);
|
||||
|
||||
// enable scaling and dragging
|
||||
mChart.setDragScaleEnabled(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: {
|
||||
if (mChart.isDrawYValuesEnabled())
|
||||
mChart.setDrawYValues(false);
|
||||
else
|
||||
mChart.setDrawYValues(true);
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionTogglePinch: {
|
||||
if (mChart.isPinchZoomEnabled())
|
||||
mChart.setPinchZoom(false);
|
||||
else
|
||||
mChart.setPinchZoom(true);
|
||||
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleHighlight: {
|
||||
if (mChart.isHighlightEnabled())
|
||||
mChart.setHighlightEnabled(false);
|
||||
else
|
||||
mChart.setHighlightEnabled(true);
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleFilled: {
|
||||
ArrayList<LineDataSet> sets = (ArrayList<LineDataSet>) mChart.getDataCurrent()
|
||||
.getDataSets();
|
||||
|
||||
for (LineDataSet set : sets) {
|
||||
if (set.isDrawFilledEnabled())
|
||||
set.setDrawFilled(false);
|
||||
else
|
||||
set.setDrawFilled(true);
|
||||
}
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleCircles: {
|
||||
ArrayList<LineDataSet> sets = (ArrayList<LineDataSet>) mChart.getDataCurrent()
|
||||
.getDataSets();
|
||||
|
||||
for (LineDataSet set : sets) {
|
||||
if (set.isDrawCirclesEnabled())
|
||||
set.setDrawCircles(false);
|
||||
else
|
||||
set.setDrawCircles(true);
|
||||
}
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleFilter: {
|
||||
|
||||
// the angle of filtering is 35°
|
||||
Approximator a = new Approximator(ApproximatorType.DOUGLAS_PEUCKER, 35);
|
||||
|
||||
if (!mChart.isFilteringEnabled()) {
|
||||
mChart.enableFiltering(a);
|
||||
} else {
|
||||
mChart.disableFiltering();
|
||||
}
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleStartzero: {
|
||||
if (mChart.isStartAtZeroEnabled())
|
||||
mChart.setStartAtZero(false);
|
||||
else
|
||||
mChart.setStartAtZero(true);
|
||||
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleAdjustXLegend: {
|
||||
XLabels xLabels = mChart.getXLabels();
|
||||
|
||||
if (xLabels.isAdjustXLabelsEnabled())
|
||||
xLabels.setAdjustXLabels(false);
|
||||
else
|
||||
xLabels.setAdjustXLabels(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) {
|
||||
|
||||
tvX.setText("" + (mSeekBarX.getProgress() + 1));
|
||||
tvY.setText("" + (mSeekBarY.getProgress()));
|
||||
|
||||
ArrayList<String> xVals = new ArrayList<String>();
|
||||
for (int i = 0; i < mSeekBarX.getProgress(); i++) {
|
||||
xVals.add((i) + "");
|
||||
}
|
||||
|
||||
ArrayList<LineDataSet> dataSets = new ArrayList<LineDataSet>();
|
||||
|
||||
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((float) val, i));
|
||||
}
|
||||
|
||||
LineDataSet d = new LineDataSet(values, "DataSet " + (z + 1));
|
||||
d.setLineWidth(2.5f);
|
||||
d.setCircleSize(4f);
|
||||
|
||||
int color = mColors[z % mColors.length];
|
||||
d.setColor(color);
|
||||
d.setCircleColor(color);
|
||||
dataSets.add(d);
|
||||
}
|
||||
|
||||
// make the first DataSet dashed
|
||||
dataSets.get(0).enableDashedLine(10, 10, 0);
|
||||
|
||||
LineData data = new LineData(xVals, dataSets);
|
||||
mChart.setData(data);
|
||||
mChart.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueSelected(Entry e, int dataSetIndex) {
|
||||
Log.i("VAL SELECTED",
|
||||
"Value: " + e.getVal() + ", xIndex: " + e.getXIndex()
|
||||
+ ", DataSet index: " + dataSetIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
|
||||
package com.xxmassdeveloper.mpchartexample;
|
||||
|
||||
import android.content.Context;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.github.mikephil.charting.data.CandleEntry;
|
||||
import com.github.mikephil.charting.data.Entry;
|
||||
import com.github.mikephil.charting.utils.MarkerView;
|
||||
import com.github.mikephil.charting.utils.Utils;
|
||||
|
||||
public class MyMarkerView extends MarkerView {
|
||||
|
||||
private TextView tvContent;
|
||||
|
||||
public MyMarkerView(Context context, int layoutResource) {
|
||||
super(context, layoutResource);
|
||||
|
||||
tvContent = (TextView) findViewById(R.id.tvContent);
|
||||
}
|
||||
|
||||
// callbacks everytime the MarkerView is redrawn, can be used to update the
|
||||
// content
|
||||
@Override
|
||||
public void refreshContent(Entry e, int dataSetIndex) {
|
||||
|
||||
if(e instanceof CandleEntry) {
|
||||
|
||||
CandleEntry ce = (CandleEntry) e;
|
||||
|
||||
tvContent.setText("" + Utils.formatNumber(ce.getHigh(), 0, true));
|
||||
} else {
|
||||
|
||||
tvContent.setText("" + Utils.formatNumber(e.getVal(), 0, true));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
|
||||
package com.xxmassdeveloper.mpchartexample;
|
||||
|
||||
import com.github.mikephil.charting.utils.ValueFormatter;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
public class MyValueFormatter implements ValueFormatter {
|
||||
|
||||
DecimalFormat mFormatter = new DecimalFormat("###,###,###");
|
||||
|
||||
@Override
|
||||
public String getFormattedValue(float value) {
|
||||
// do here whatever you want, avoid excessive calculations and memory
|
||||
// allocations
|
||||
return mFormatter.format(value);
|
||||
}
|
||||
}
|
|
@ -1,240 +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.PieChart;
|
||||
import com.github.mikephil.charting.data.Entry;
|
||||
import com.github.mikephil.charting.data.PieData;
|
||||
import com.github.mikephil.charting.data.PieDataSet;
|
||||
import com.github.mikephil.charting.interfaces.OnChartValueSelectedListener;
|
||||
import com.github.mikephil.charting.utils.ColorTemplate;
|
||||
import com.github.mikephil.charting.utils.Legend;
|
||||
import com.github.mikephil.charting.utils.Legend.LegendPosition;
|
||||
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);
|
||||
|
||||
mSeekBarX.setOnSeekBarChangeListener(this);
|
||||
mSeekBarY.setOnSeekBarChangeListener(this);
|
||||
|
||||
mChart = (PieChart) findViewById(R.id.chart1);
|
||||
|
||||
Typeface tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
|
||||
|
||||
mChart.setValueTypeface(tf);
|
||||
mChart.setCenterTextTypeface(Typeface.createFromAsset(getAssets(), "OpenSans-Light.ttf"));
|
||||
|
||||
mChart.setHoleRadius(60f);
|
||||
|
||||
mChart.setDescription("");
|
||||
|
||||
mChart.setDrawYValues(true);
|
||||
mChart.setDrawCenterText(true);
|
||||
|
||||
mChart.setDrawHoleEnabled(true);
|
||||
|
||||
mChart.setRotationAngle(0);
|
||||
|
||||
// draws the corresponding description value into the slice
|
||||
mChart.setDrawXValues(true);
|
||||
|
||||
// enable rotation of the chart by touch
|
||||
mChart.setRotationEnabled(true);
|
||||
|
||||
// display percentage values
|
||||
mChart.setUsePercentValues(true);
|
||||
// mChart.setUnit(" €");
|
||||
// mChart.setDrawUnitsInChart(true);
|
||||
|
||||
// add a selection listener
|
||||
mChart.setOnChartValueSelectedListener(this);
|
||||
// mChart.setTouchEnabled(false);
|
||||
|
||||
setData(3, 100);
|
||||
|
||||
mChart.animateXY(1500, 1500);
|
||||
// mChart.spin(2000, 0, 360);
|
||||
|
||||
Legend l = mChart.getLegend();
|
||||
l.setPosition(LegendPosition.RIGHT_OF_CHART);
|
||||
l.setXEntrySpace(7f);
|
||||
l.setYEntrySpace(5f);
|
||||
|
||||
}
|
||||
|
||||
@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: {
|
||||
if (mChart.isDrawYValuesEnabled())
|
||||
mChart.setDrawYValues(false);
|
||||
else
|
||||
mChart.setDrawYValues(true);
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionTogglePercent: {
|
||||
if (mChart.isUsePercentValuesEnabled())
|
||||
mChart.setUsePercentValues(false);
|
||||
else
|
||||
mChart.setUsePercentValues(true);
|
||||
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: {
|
||||
if (mChart.isDrawXValuesEnabled())
|
||||
mChart.setDrawXValues(false);
|
||||
else
|
||||
mChart.setDrawXValues(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(1800);
|
||||
break;
|
||||
}
|
||||
case R.id.animateY: {
|
||||
mChart.animateY(1800);
|
||||
break;
|
||||
}
|
||||
case R.id.animateXY: {
|
||||
mChart.animateXY(1800, 1800);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private String[] mParties = new String[] {
|
||||
"Party A", "Party B", "Party C", "Party D", "Party E"
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
|
||||
tvX.setText("" + (mSeekBarX.getProgress() + 1));
|
||||
tvY.setText("" + (mSeekBarY.getProgress()));
|
||||
|
||||
setData(mSeekBarX.getProgress(), mSeekBarY.getProgress());
|
||||
}
|
||||
|
||||
private void setData(int count, float range) {
|
||||
|
||||
float mult = range;
|
||||
|
||||
ArrayList<Entry> yVals1 = new ArrayList<Entry>();
|
||||
// ArrayList<Entry> yVals2 = new ArrayList<Entry>();
|
||||
|
||||
// IMPORTANT: In a PieChart, no values (Entry) should have the same
|
||||
// xIndex (even if from different DataSets), since no values can be
|
||||
// drawn above each other.
|
||||
for (int i = 0; i < count + 1; i++) {
|
||||
yVals1.add(new Entry((float) (Math.random() * mult) + mult / 5, i));
|
||||
}
|
||||
|
||||
// for (int i = mSeekBarX.getProgress() / 2; i <
|
||||
// mSeekBarX.getProgress(); i++) {
|
||||
// yVals2.add(new Entry((float) (Math.random() * mult) + mult / 5, i));
|
||||
// }
|
||||
|
||||
ArrayList<String> xVals = new ArrayList<String>();
|
||||
|
||||
for (int i = 0; i < count + 1; i++)
|
||||
xVals.add(mParties[i % mParties.length]);
|
||||
|
||||
PieDataSet set1 = new PieDataSet(yVals1, "Election Results");
|
||||
set1.setSliceSpace(3f);
|
||||
set1.setColors(ColorTemplate.VORDIPLOM_COLORS);
|
||||
|
||||
PieData data = new PieData(xVals, set1);
|
||||
mChart.setData(data);
|
||||
|
||||
// undo all highlights
|
||||
mChart.highlightValues(null);
|
||||
|
||||
// set a text for the chart center
|
||||
mChart.setCenterText("Total Value\n" + (int) mChart.getYValueSum() + "\n(all slices)");
|
||||
mChart.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueSelected(Entry e, int dataSetIndex) {
|
||||
Log.i("VAL SELECTED",
|
||||
"Value: " + e.getVal() + ", xIndex: " + e.getXIndex()
|
||||
+ ", DataSet index: " + dataSetIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected() {
|
||||
Log.i("PieChart", "nothing selected");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
|
@ -1,216 +0,0 @@
|
|||
|
||||
package com.xxmassdeveloper.mpchartexample;
|
||||
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.github.mikephil.charting.charts.RadarChart;
|
||||
import com.github.mikephil.charting.data.Entry;
|
||||
import com.github.mikephil.charting.data.RadarData;
|
||||
import com.github.mikephil.charting.data.RadarDataSet;
|
||||
import com.github.mikephil.charting.utils.Legend;
|
||||
import com.github.mikephil.charting.utils.Legend.LegendPosition;
|
||||
import com.github.mikephil.charting.utils.ColorTemplate;
|
||||
import com.github.mikephil.charting.utils.XLabels;
|
||||
import com.github.mikephil.charting.utils.YLabels;
|
||||
import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class RadarChartActivitry extends DemoBase {
|
||||
|
||||
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);
|
||||
|
||||
mChart = (RadarChart) findViewById(R.id.chart1);
|
||||
|
||||
Typeface tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
|
||||
|
||||
mChart.setValueTypeface(tf);
|
||||
|
||||
mChart.setDescription("");
|
||||
mChart.setUnit(" $");
|
||||
mChart.setDrawUnitsInChart(true);
|
||||
|
||||
mChart.setWebLineWidth(1.5f);
|
||||
mChart.setWebLineWidthInner(0.75f);
|
||||
mChart.setWebAlpha(100);
|
||||
|
||||
mChart.setDrawYValues(false);
|
||||
|
||||
// create a custom MarkerView (extend MarkerView) and specify the layout
|
||||
// to use for it
|
||||
MyMarkerView mv = new MyMarkerView(this, R.layout.custom_marker_view);
|
||||
|
||||
// define an offset to change the original position of the marker
|
||||
// (optional)
|
||||
mv.setOffsets(-mv.getMeasuredWidth() / 2, -mv.getMeasuredHeight());
|
||||
|
||||
// set the marker to the chart
|
||||
mChart.setMarkerView(mv);
|
||||
|
||||
setData();
|
||||
|
||||
XLabels xl = mChart.getXLabels();
|
||||
xl.setTypeface(tf);
|
||||
xl.setTextSize(9f);
|
||||
|
||||
YLabels yl = mChart.getYLabels();
|
||||
yl.setTypeface(tf);
|
||||
yl.setLabelCount(5);
|
||||
yl.setTextSize(9f);
|
||||
yl.setDrawUnitsInYLabel(true);
|
||||
|
||||
// mChart.animateXY(1500, 1500);
|
||||
|
||||
Legend l = mChart.getLegend();
|
||||
l.setPosition(LegendPosition.RIGHT_OF_CHART);
|
||||
l.setTypeface(tf);
|
||||
l.setXEntrySpace(7f);
|
||||
l.setYEntrySpace(5f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.radar, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.actionToggleValues: {
|
||||
if (mChart.isDrawYValuesEnabled())
|
||||
mChart.setDrawYValues(false);
|
||||
else
|
||||
mChart.setDrawYValues(true);
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleHighlight: {
|
||||
if (mChart.isHighlightEnabled())
|
||||
mChart.setHighlightEnabled(false);
|
||||
else
|
||||
mChart.setHighlightEnabled(true);
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleRotate: {
|
||||
if (mChart.isRotationEnabled())
|
||||
mChart.setRotationEnabled(false);
|
||||
else
|
||||
mChart.setRotationEnabled(true);
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleFilled: {
|
||||
|
||||
ArrayList<RadarDataSet> sets = (ArrayList<RadarDataSet>) mChart.getDataCurrent()
|
||||
.getDataSets();
|
||||
|
||||
for (RadarDataSet set : sets) {
|
||||
if (set.isDrawFilledEnabled())
|
||||
set.setDrawFilled(false);
|
||||
else
|
||||
set.setDrawFilled(true);
|
||||
}
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionSave: {
|
||||
if (mChart.saveToPath("title" + System.currentTimeMillis(), "")) {
|
||||
Toast.makeText(getApplicationContext(), "Saving SUCCESSFUL!",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
} else
|
||||
Toast.makeText(getApplicationContext(), "Saving FAILED!", Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleXLabels: {
|
||||
if (mChart.isDrawXLabelsEnabled())
|
||||
mChart.setDrawXLabels(false);
|
||||
else
|
||||
mChart.setDrawXLabels(true);
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleYLabels: {
|
||||
if (mChart.isDrawYLabelsEnabled())
|
||||
mChart.setDrawYLabels(false);
|
||||
else
|
||||
mChart.setDrawYLabels(true);
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleSpin: {
|
||||
mChart.spin(2000, mChart.getRotationAngle(), mChart.getRotationAngle() + 360);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private String[] mParties = new String[] {
|
||||
"Party A", "Party B", "Party C", "Party D", "Party E", "Party F", "Party G", "Party H",
|
||||
"Party I"
|
||||
};
|
||||
|
||||
public void setData() {
|
||||
|
||||
float mult = 150;
|
||||
int cnt = 9;
|
||||
|
||||
ArrayList<Entry> yVals1 = new ArrayList<Entry>();
|
||||
ArrayList<Entry> yVals2 = new ArrayList<Entry>();
|
||||
|
||||
// IMPORTANT: In a PieChart, no values (Entry) should have the same
|
||||
// xIndex (even if from different DataSets), since no values can be
|
||||
// drawn above each other.
|
||||
for (int i = 0; i < cnt; i++) {
|
||||
yVals1.add(new Entry((float) (Math.random() * mult) + mult / 2, i));
|
||||
}
|
||||
|
||||
for (int i = 0; i < cnt; i++) {
|
||||
yVals2.add(new Entry((float) (Math.random() * mult) + mult / 2, i));
|
||||
}
|
||||
|
||||
ArrayList<String> xVals = new ArrayList<String>();
|
||||
|
||||
for (int i = 0; i < cnt; i++)
|
||||
xVals.add(mParties[i % mParties.length]);
|
||||
|
||||
RadarDataSet set1 = new RadarDataSet(yVals1, "Set 1");
|
||||
set1.setColor(ColorTemplate.VORDIPLOM_COLORS[0]);
|
||||
set1.setDrawFilled(true);
|
||||
set1.setLineWidth(2f);
|
||||
|
||||
RadarDataSet set2 = new RadarDataSet(yVals2, "Set 2");
|
||||
set2.setColor(ColorTemplate.VORDIPLOM_COLORS[4]);
|
||||
set2.setDrawFilled(true);
|
||||
set2.setLineWidth(2f);
|
||||
|
||||
ArrayList<RadarDataSet> sets = new ArrayList<RadarDataSet>();
|
||||
sets.add(set1);
|
||||
sets.add(set2);
|
||||
|
||||
RadarData data = new RadarData(xVals, sets);
|
||||
|
||||
mChart.setData(data);
|
||||
|
||||
// undo all highlights
|
||||
mChart.highlightValues(null);
|
||||
|
||||
mChart.invalidate();
|
||||
}
|
||||
}
|
|
@ -1,257 +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.charts.ScatterChart.ScatterShape;
|
||||
import com.github.mikephil.charting.data.Entry;
|
||||
import com.github.mikephil.charting.data.ScatterData;
|
||||
import com.github.mikephil.charting.data.ScatterDataSet;
|
||||
import com.github.mikephil.charting.data.filter.Approximator;
|
||||
import com.github.mikephil.charting.data.filter.Approximator.ApproximatorType;
|
||||
import com.github.mikephil.charting.interfaces.OnChartValueSelectedListener;
|
||||
import com.github.mikephil.charting.utils.ColorTemplate;
|
||||
import com.github.mikephil.charting.utils.Legend;
|
||||
import com.github.mikephil.charting.utils.Legend.LegendPosition;
|
||||
import com.github.mikephil.charting.utils.XLabels;
|
||||
import com.github.mikephil.charting.utils.YLabels;
|
||||
import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
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("");
|
||||
|
||||
Typeface tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
|
||||
mChart.setValueTypeface(tf);
|
||||
|
||||
mChart.setOnChartValueSelectedListener(this);
|
||||
|
||||
mChart.setDrawGridBackground(false);
|
||||
|
||||
mChart.setTouchEnabled(true);
|
||||
mChart.setHighlightEnabled(true);
|
||||
mChart.setDrawYValues(false);
|
||||
|
||||
mChart.setDragScaleEnabled(true);
|
||||
|
||||
mChart.setMaxVisibleValueCount(200);
|
||||
mChart.setPinchZoom(true);
|
||||
|
||||
mSeekBarX.setProgress(45);
|
||||
mSeekBarY.setProgress(100);
|
||||
|
||||
Legend l = mChart.getLegend();
|
||||
l.setPosition(LegendPosition.RIGHT_OF_CHART);
|
||||
l.setTypeface(tf);
|
||||
|
||||
YLabels yl = mChart.getYLabels();
|
||||
yl.setTypeface(tf);
|
||||
|
||||
XLabels xl = mChart.getXLabels();
|
||||
xl.setTypeface(tf);
|
||||
}
|
||||
|
||||
@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: {
|
||||
if (mChart.isDrawYValuesEnabled())
|
||||
mChart.setDrawYValues(false);
|
||||
else
|
||||
mChart.setDrawYValues(true);
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleHighlight: {
|
||||
if (mChart.isHighlightEnabled())
|
||||
mChart.setHighlightEnabled(false);
|
||||
else
|
||||
mChart.setHighlightEnabled(true);
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionTogglePinch: {
|
||||
if (mChart.isPinchZoomEnabled())
|
||||
mChart.setPinchZoom(false);
|
||||
else
|
||||
mChart.setPinchZoom(true);
|
||||
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleStartzero: {
|
||||
if (mChart.isStartAtZeroEnabled())
|
||||
mChart.setStartAtZero(false);
|
||||
else
|
||||
mChart.setStartAtZero(true);
|
||||
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleAdjustXLegend: {
|
||||
XLabels xLabels = mChart.getXLabels();
|
||||
|
||||
if (xLabels.isAdjustXLabelsEnabled())
|
||||
xLabels.setAdjustXLabels(false);
|
||||
else
|
||||
xLabels.setAdjustXLabels(true);
|
||||
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleFilter: {
|
||||
|
||||
Approximator a = new Approximator(ApproximatorType.DOUGLAS_PEUCKER, 25);
|
||||
|
||||
if (!mChart.isFilteringEnabled()) {
|
||||
mChart.enableFiltering(a);
|
||||
} else {
|
||||
mChart.disableFiltering();
|
||||
}
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionSave: {
|
||||
// mChart.saveToGallery("title"+System.currentTimeMillis());
|
||||
mChart.saveToPath("title" + System.currentTimeMillis(), "");
|
||||
break;
|
||||
}
|
||||
case R.id.animateX: {
|
||||
mChart.animateX(3000);
|
||||
break;
|
||||
}
|
||||
case R.id.animateY: {
|
||||
mChart.animateY(3000);
|
||||
break;
|
||||
}
|
||||
case R.id.animateXY: {
|
||||
|
||||
mChart.animateXY(3000, 3000);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
|
||||
tvX.setText("" + (mSeekBarX.getProgress() + 1));
|
||||
tvY.setText("" + (mSeekBarY.getProgress()));
|
||||
|
||||
ArrayList<String> xVals = new ArrayList<String>();
|
||||
for (int i = 0; i < mSeekBarX.getProgress(); i++) {
|
||||
xVals.add((i) + "");
|
||||
}
|
||||
|
||||
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(val, i));
|
||||
}
|
||||
|
||||
for (int i = 0; i < mSeekBarX.getProgress(); i++) {
|
||||
float val = (float) (Math.random() * mSeekBarY.getProgress()) + 3;
|
||||
yVals2.add(new Entry(val, i));
|
||||
}
|
||||
|
||||
for (int i = 0; i < mSeekBarX.getProgress(); i++) {
|
||||
float val = (float) (Math.random() * mSeekBarY.getProgress()) + 3;
|
||||
yVals3.add(new Entry(val, i));
|
||||
}
|
||||
|
||||
// create a dataset and give it a type
|
||||
ScatterDataSet set1 = new ScatterDataSet(yVals1, "DS 1");
|
||||
set1.setScatterShape(ScatterShape.SQUARE);
|
||||
set1.setColor(ColorTemplate.COLORFUL_COLORS[0]);
|
||||
ScatterDataSet set2 = new ScatterDataSet(yVals2, "DS 2");
|
||||
set2.setScatterShape(ScatterShape.CIRCLE);
|
||||
set2.setColor(ColorTemplate.COLORFUL_COLORS[1]);
|
||||
ScatterDataSet set3 = new ScatterDataSet(yVals3, "DS 3");
|
||||
set3.setScatterShape(ScatterShape.TRIANGLE);
|
||||
set3.setColor(ColorTemplate.COLORFUL_COLORS[2]);
|
||||
|
||||
set1.setScatterShapeSize(8f);
|
||||
set2.setScatterShapeSize(8f);
|
||||
set3.setScatterShapeSize(8f);
|
||||
|
||||
ArrayList<ScatterDataSet> dataSets = new ArrayList<ScatterDataSet>();
|
||||
dataSets.add(set1); // add the datasets
|
||||
dataSets.add(set2);
|
||||
dataSets.add(set3);
|
||||
|
||||
// create a data object with the datasets
|
||||
ScatterData data = new ScatterData(xVals, dataSets);
|
||||
|
||||
mChart.setData(data);
|
||||
mChart.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueSelected(Entry e, int dataSetIndex) {
|
||||
Log.i("VAL SELECTED",
|
||||
"Value: " + e.getVal() + ", xIndex: " + e.getXIndex()
|
||||
+ ", DataSet index: " + dataSetIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
|
@ -1,282 +0,0 @@
|
|||
|
||||
package com.xxmassdeveloper.mpchartexample;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.github.mikephil.charting.charts.BarChart;
|
||||
import com.github.mikephil.charting.data.BarData;
|
||||
import com.github.mikephil.charting.data.BarDataSet;
|
||||
import com.github.mikephil.charting.data.BarEntry;
|
||||
import com.github.mikephil.charting.data.Entry;
|
||||
import com.github.mikephil.charting.data.filter.Approximator;
|
||||
import com.github.mikephil.charting.data.filter.Approximator.ApproximatorType;
|
||||
import com.github.mikephil.charting.interfaces.OnChartValueSelectedListener;
|
||||
import com.github.mikephil.charting.utils.ColorTemplate;
|
||||
import com.github.mikephil.charting.utils.Legend;
|
||||
import com.github.mikephil.charting.utils.Legend.LegendPosition;
|
||||
import com.github.mikephil.charting.utils.XLabels;
|
||||
import com.github.mikephil.charting.utils.XLabels.XLabelPosition;
|
||||
import com.github.mikephil.charting.utils.YLabels;
|
||||
import com.github.mikephil.charting.utils.YLabels.YLabelPosition;
|
||||
import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
|
||||
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);
|
||||
|
||||
// enable the drawing of values
|
||||
mChart.setDrawYValues(true);
|
||||
|
||||
mChart.setDescription("");
|
||||
|
||||
// if more than 60 entries are displayed in the chart, no values will be
|
||||
// drawn
|
||||
mChart.setMaxVisibleValueCount(60);
|
||||
|
||||
MyValueFormatter customFormatter = new MyValueFormatter();
|
||||
|
||||
// set a custom formatter for the values inside the chart
|
||||
mChart.setValueFormatter(customFormatter);
|
||||
|
||||
// if false values are only drawn for the stack sum, else each value is drawn
|
||||
mChart.setDrawValuesForWholeStack(true);
|
||||
|
||||
// disable 3D
|
||||
mChart.set3DEnabled(false);
|
||||
// scaling can now only be done on x- and y-axis separately
|
||||
mChart.setPinchZoom(false);
|
||||
|
||||
mChart.setDrawBarShadow(false);
|
||||
|
||||
// change the position of the y-labels
|
||||
YLabels yLabels = mChart.getYLabels();
|
||||
yLabels.setPosition(YLabelPosition.BOTH_SIDED);
|
||||
yLabels.setLabelCount(5);
|
||||
yLabels.setFormatter(customFormatter);
|
||||
|
||||
XLabels xLabels = mChart.getXLabels();
|
||||
xLabels.setPosition(XLabelPosition.TOP);
|
||||
xLabels.setCenterXLabelText(true);
|
||||
|
||||
// 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: {
|
||||
if (mChart.isDrawYValuesEnabled())
|
||||
mChart.setDrawYValues(false);
|
||||
else
|
||||
mChart.setDrawYValues(true);
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggle3D: {
|
||||
if (mChart.is3DEnabled())
|
||||
mChart.set3DEnabled(false);
|
||||
else
|
||||
mChart.set3DEnabled(true);
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleHighlight: {
|
||||
if (mChart.isHighlightEnabled())
|
||||
mChart.setHighlightEnabled(false);
|
||||
else
|
||||
mChart.setHighlightEnabled(true);
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionTogglePinch: {
|
||||
if (mChart.isPinchZoomEnabled())
|
||||
mChart.setPinchZoom(false);
|
||||
else
|
||||
mChart.setPinchZoom(true);
|
||||
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleHighlightArrow: {
|
||||
if (mChart.isDrawHighlightArrowEnabled())
|
||||
mChart.setDrawHighlightArrow(false);
|
||||
else
|
||||
mChart.setDrawHighlightArrow(true);
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleStartzero: {
|
||||
if (mChart.isStartAtZeroEnabled())
|
||||
mChart.setStartAtZero(false);
|
||||
else
|
||||
mChart.setStartAtZero(true);
|
||||
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleAdjustXLegend: {
|
||||
XLabels xLabels = mChart.getXLabels();
|
||||
|
||||
if (xLabels.isAdjustXLabelsEnabled())
|
||||
xLabels.setAdjustXLabels(false);
|
||||
else
|
||||
xLabels.setAdjustXLabels(true);
|
||||
|
||||
mChart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.animateX: {
|
||||
mChart.animateX(3000);
|
||||
break;
|
||||
}
|
||||
case R.id.animateY: {
|
||||
mChart.animateY(3000);
|
||||
break;
|
||||
}
|
||||
case R.id.animateXY: {
|
||||
|
||||
mChart.animateXY(3000, 3000);
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleFilter: {
|
||||
|
||||
Approximator a = new Approximator(ApproximatorType.DOUGLAS_PEUCKER, 25);
|
||||
|
||||
if (!mChart.isFilteringEnabled()) {
|
||||
mChart.enableFiltering(a);
|
||||
} else {
|
||||
mChart.disableFiltering();
|
||||
}
|
||||
mChart.invalidate();
|
||||
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<String> xVals = new ArrayList<String>();
|
||||
for (int i = 0; i < mSeekBarX.getProgress()+1; i++) {
|
||||
xVals.add(mMonths[i % mMonths.length]);
|
||||
}
|
||||
|
||||
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(new float[] {
|
||||
val1, val2, val3
|
||||
}, i));
|
||||
}
|
||||
|
||||
BarDataSet set1 = new BarDataSet(yVals1, "Statistics Vienna 2014");
|
||||
set1.setColors(ColorTemplate.VORDIPLOM_COLORS);
|
||||
set1.setStackLabels(new String[] {
|
||||
"Births", "Divorces", "Marriages"
|
||||
});
|
||||
|
||||
ArrayList<BarDataSet> dataSets = new ArrayList<BarDataSet>();
|
||||
dataSets.add(set1);
|
||||
|
||||
BarData data = new BarData(xVals, dataSets);
|
||||
|
||||
mChart.setData(data);
|
||||
mChart.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueSelected(Entry e, int dataSetIndex) {
|
||||
Log.i("VAL SELECTED",
|
||||
"Value: " + e.getVal() + ", xIndex: " + e.getXIndex()
|
||||
+ ", DataSet index: " + dataSetIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
|
@ -1,65 +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 android.widget.FrameLayout;
|
||||
|
||||
import com.github.mikephil.charting.charts.BarChart;
|
||||
import com.github.mikephil.charting.utils.Legend;
|
||||
import com.github.mikephil.charting.utils.YLabels;
|
||||
import com.xxmassdeveloper.mpchartexample.MyMarkerView;
|
||||
import com.xxmassdeveloper.mpchartexample.R;
|
||||
|
||||
|
||||
public class BarChartFrag extends SimpleFragment {
|
||||
|
||||
public static Fragment newInstance() {
|
||||
return new BarChartFrag();
|
||||
}
|
||||
|
||||
private BarChart mChart;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View v = inflater.inflate(R.layout.frag_simple_bar, container, false);
|
||||
|
||||
// create a new chart object
|
||||
mChart = new BarChart(getActivity());
|
||||
mChart.setDescription("");
|
||||
|
||||
MyMarkerView mv = new MyMarkerView(getActivity(), R.layout.custom_marker_view);
|
||||
mv.setOffsets(-mv.getMeasuredWidth() / 2, -mv.getMeasuredHeight());
|
||||
|
||||
mChart.setMarkerView(mv);
|
||||
|
||||
mChart.setHighlightIndicatorEnabled(false);
|
||||
mChart.setDrawBorder(false);
|
||||
// mChart.setBorderStyles(new BorderStyle[] { BorderStyle.LEFT });
|
||||
mChart.setDrawGridBackground(false);
|
||||
mChart.setDrawVerticalGrid(false);
|
||||
mChart.setDrawXLabels(false);
|
||||
mChart.setDrawYValues(false);
|
||||
mChart.setUnit(" €");
|
||||
mChart.setDrawBarShadow(false);
|
||||
|
||||
Typeface tf = Typeface.createFromAsset(getActivity().getAssets(),"OpenSans-Light.ttf");
|
||||
|
||||
mChart.setData(generateBarData(1, 20000, 12));
|
||||
|
||||
Legend l = mChart.getLegend();
|
||||
l.setTypeface(tf);
|
||||
|
||||
YLabels labels = mChart.getYLabels();
|
||||
labels.setTypeface(tf);
|
||||
// labels.setPosition(YLabelPosition.BOTH_SIDED);
|
||||
|
||||
// programatically add the chart
|
||||
FrameLayout parent = (FrameLayout) v.findViewById(R.id.parentLayout);
|
||||
parent.addView(mChart);
|
||||
|
||||
return v;
|
||||
}
|
||||
}
|
|
@ -1,56 +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.utils.Legend;
|
||||
import com.github.mikephil.charting.utils.YLabels;
|
||||
import com.xxmassdeveloper.mpchartexample.R;
|
||||
|
||||
|
||||
public class ComplexityFragment extends SimpleFragment {
|
||||
|
||||
public static Fragment newInstance() {
|
||||
return new ComplexityFragment();
|
||||
}
|
||||
|
||||
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.setDrawYValues(false);
|
||||
|
||||
mChart.setHighlightIndicatorEnabled(false);
|
||||
mChart.setDrawBorder(false);
|
||||
mChart.setDrawGridBackground(false);
|
||||
mChart.setDrawVerticalGrid(false);
|
||||
mChart.setDrawXLabels(false);
|
||||
mChart.setDrawYValues(false);
|
||||
mChart.setStartAtZero(false);
|
||||
|
||||
mChart.setData(getComplexity());
|
||||
mChart.animateX(3000);
|
||||
|
||||
// mChart.setScaleMinima(3f, 3f);
|
||||
// mChart.centerViewPort(300, 0);
|
||||
|
||||
Typeface tf = Typeface.createFromAsset(getActivity().getAssets(),"OpenSans-Light.ttf");
|
||||
|
||||
Legend l = mChart.getLegend();
|
||||
l.setTypeface(tf);
|
||||
|
||||
YLabels labels = mChart.getYLabels();
|
||||
labels.setTypeface(tf);
|
||||
|
||||
return v;
|
||||
}
|
||||
}
|
|
@ -1,53 +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.PieChart;
|
||||
import com.github.mikephil.charting.utils.Legend;
|
||||
import com.github.mikephil.charting.utils.Legend.LegendPosition;
|
||||
import com.xxmassdeveloper.mpchartexample.R;
|
||||
|
||||
|
||||
public class PieChartFrag extends SimpleFragment {
|
||||
|
||||
public static Fragment newInstance() {
|
||||
return new PieChartFrag();
|
||||
}
|
||||
|
||||
private PieChart mChart;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View v = inflater.inflate(R.layout.frag_simple_pie, container, false);
|
||||
|
||||
mChart = (PieChart) v.findViewById(R.id.pieChart1);
|
||||
mChart.setDescription("");
|
||||
|
||||
Typeface tf = Typeface.createFromAsset(getActivity().getAssets(), "OpenSans-Regular.ttf");
|
||||
|
||||
mChart.setValueTypeface(tf);
|
||||
mChart.setCenterTextTypeface(Typeface.createFromAsset(getActivity().getAssets(), "OpenSans-Light.ttf"));
|
||||
mChart.setUsePercentValues(true);
|
||||
mChart.setCenterText("Quarterly\nRevenue");
|
||||
mChart.setCenterTextSize(22f);
|
||||
|
||||
// radius of the center hole in percent of maximum radius
|
||||
mChart.setHoleRadius(45f);
|
||||
mChart.setTransparentCircleRadius(50f);
|
||||
|
||||
// enable / disable drawing of x- and y-values
|
||||
// mChart.setDrawYValues(false);
|
||||
// mChart.setDrawXValues(false);
|
||||
|
||||
mChart.setData(generatePieData());
|
||||
|
||||
Legend l = mChart.getLegend();
|
||||
l.setPosition(LegendPosition.RIGHT_OF_CHART);
|
||||
|
||||
return v;
|
||||
}
|
||||
}
|
|
@ -1,57 +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.ScatterChart;
|
||||
import com.github.mikephil.charting.utils.Legend;
|
||||
import com.github.mikephil.charting.utils.YLabels;
|
||||
import com.xxmassdeveloper.mpchartexample.MyMarkerView;
|
||||
import com.xxmassdeveloper.mpchartexample.R;
|
||||
|
||||
|
||||
public class ScatterChartFrag extends SimpleFragment {
|
||||
|
||||
public static Fragment newInstance() {
|
||||
return new ScatterChartFrag();
|
||||
}
|
||||
|
||||
private ScatterChart mChart;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View v = inflater.inflate(R.layout.frag_simple_scatter, container, false);
|
||||
|
||||
mChart = (ScatterChart) v.findViewById(R.id.scatterChart1);
|
||||
mChart.setDrawYValues(false);
|
||||
mChart.setDescription("");
|
||||
|
||||
Typeface tf = Typeface.createFromAsset(getActivity().getAssets(),"OpenSans-Light.ttf");
|
||||
|
||||
YLabels labels = mChart.getYLabels();
|
||||
labels.setTypeface(tf);
|
||||
|
||||
MyMarkerView mv = new MyMarkerView(getActivity(), R.layout.custom_marker_view);
|
||||
mv.setOffsets(-mv.getMeasuredWidth() / 2, -mv.getMeasuredHeight());
|
||||
|
||||
mChart.setMarkerView(mv);
|
||||
|
||||
mChart.setHighlightIndicatorEnabled(false);
|
||||
mChart.setDrawBorder(false);
|
||||
// mChart.setBorderStyles(new BorderStyle[] { BorderStyle.LEFT });
|
||||
mChart.setDrawGridBackground(false);
|
||||
mChart.setDrawVerticalGrid(false);
|
||||
mChart.setDrawXLabels(false);
|
||||
mChart.setUnit(" $");
|
||||
|
||||
mChart.setData(generateScatterData(3, 10000, 150));
|
||||
|
||||
Legend l = mChart.getLegend();
|
||||
l.setTypeface(tf);
|
||||
|
||||
return v;
|
||||
}
|
||||
}
|
|
@ -1,186 +0,0 @@
|
|||
package com.xxmassdeveloper.mpchartexample.fragments;
|
||||
|
||||
import android.support.v4.app.Fragment;
|
||||
|
||||
import com.github.mikephil.charting.charts.ScatterChart;
|
||||
import com.github.mikephil.charting.charts.ScatterChart.ScatterShape;
|
||||
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.ChartData;
|
||||
import com.github.mikephil.charting.data.Entry;
|
||||
import com.github.mikephil.charting.data.LineData;
|
||||
import com.github.mikephil.charting.data.LineDataSet;
|
||||
import com.github.mikephil.charting.data.PieData;
|
||||
import com.github.mikephil.charting.data.PieDataSet;
|
||||
import com.github.mikephil.charting.data.ScatterData;
|
||||
import com.github.mikephil.charting.data.ScatterDataSet;
|
||||
import com.github.mikephil.charting.utils.ColorTemplate;
|
||||
import com.github.mikephil.charting.utils.FileUtils;
|
||||
import com.xxmassdeveloper.mpchartexample.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public abstract class SimpleFragment extends Fragment {
|
||||
|
||||
protected BarData generateBarData(int dataSets, float range, int count) {
|
||||
|
||||
ArrayList<BarDataSet> sets = new ArrayList<BarDataSet>();
|
||||
|
||||
for(int i = 0; i < dataSets; i++) {
|
||||
|
||||
ArrayList<BarEntry> entries = new ArrayList<BarEntry>();
|
||||
|
||||
// entries = FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "stacked_bars.txt");
|
||||
|
||||
for(int j = 0; j < count; j++) {
|
||||
entries.add(new BarEntry((float) (Math.random() * range) + range / 4, j));
|
||||
}
|
||||
|
||||
BarDataSet ds = new BarDataSet(entries, getLabel(i));
|
||||
ds.setColors(ColorTemplate.VORDIPLOM_COLORS);
|
||||
sets.add(ds);
|
||||
}
|
||||
|
||||
BarData d = new BarData(ChartData.generateXVals(0, count), sets);
|
||||
return d;
|
||||
}
|
||||
|
||||
protected ScatterData generateScatterData(int dataSets, float range, int count) {
|
||||
|
||||
ArrayList<ScatterDataSet> sets = new ArrayList<ScatterDataSet>();
|
||||
|
||||
ScatterShape[] shapes = ScatterChart.getAllPossibleShapes();
|
||||
|
||||
for(int i = 0; i < dataSets; i++) {
|
||||
|
||||
ArrayList<Entry> entries = new ArrayList<Entry>();
|
||||
|
||||
for(int j = 0; j < count; j++) {
|
||||
entries.add(new Entry((float) (Math.random() * range) + range / 4, j));
|
||||
}
|
||||
|
||||
ScatterDataSet ds = new ScatterDataSet(entries, getLabel(i));
|
||||
ds.setScatterShapeSize(12f);
|
||||
ds.setScatterShape(shapes[i % shapes.length]);
|
||||
ds.setColors(ColorTemplate.COLORFUL_COLORS);
|
||||
ds.setScatterShapeSize(9f);
|
||||
sets.add(ds);
|
||||
}
|
||||
|
||||
ScatterData d = new ScatterData(ChartData.generateXVals(0, count), sets);
|
||||
return d;
|
||||
}
|
||||
|
||||
/**
|
||||
* generates less data (1 DataSet, 4 values)
|
||||
* @return
|
||||
*/
|
||||
protected PieData generatePieData() {
|
||||
|
||||
int count = 4;
|
||||
|
||||
ArrayList<Entry> entries1 = new ArrayList<Entry>();
|
||||
ArrayList<String> xVals = new ArrayList<String>();
|
||||
|
||||
xVals.add("Quarter 1");
|
||||
xVals.add("Quarter 2");
|
||||
xVals.add("Quarter 3");
|
||||
xVals.add("Quarter 4");
|
||||
|
||||
for(int i = 0; i < count; i++) {
|
||||
xVals.add("entry" + (i+1));
|
||||
|
||||
entries1.add(new Entry((float) (Math.random() * 60) + 40, i));
|
||||
}
|
||||
|
||||
PieDataSet ds1 = new PieDataSet(entries1, "Quarterly Revenues 2014");
|
||||
ds1.setColors(ColorTemplate.VORDIPLOM_COLORS);
|
||||
ds1.setSliceSpace(2f);
|
||||
|
||||
PieData d = new PieData(xVals, ds1);
|
||||
return d;
|
||||
}
|
||||
|
||||
protected LineData generateLineData() {
|
||||
|
||||
// DataSet ds1 = new DataSet(n, "O(n)");
|
||||
// DataSet ds2 = new DataSet(nlogn, "O(nlogn)");
|
||||
// DataSet ds3 = new DataSet(nsquare, "O(n\u00B2)");
|
||||
// DataSet ds4 = new DataSet(nthree, "O(n\u00B3)");
|
||||
|
||||
ArrayList<LineDataSet> sets = new ArrayList<LineDataSet>();
|
||||
|
||||
LineDataSet ds1 = new LineDataSet(FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "sine.txt"), "Sine function");
|
||||
LineDataSet ds2 = new LineDataSet(FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "cosine.txt"), "Cosine function");
|
||||
|
||||
ds1.setLineWidth(2f);
|
||||
ds2.setLineWidth(2f);
|
||||
|
||||
ds1.setDrawCircles(false);
|
||||
ds2.setDrawCircles(false);
|
||||
|
||||
ds1.setColor(ColorTemplate.VORDIPLOM_COLORS[0]);
|
||||
ds2.setColor(ColorTemplate.VORDIPLOM_COLORS[1]);
|
||||
|
||||
// load DataSets from textfiles in assets folders
|
||||
sets.add(ds1);
|
||||
sets.add(ds2);
|
||||
|
||||
// sets.add(FileUtils.dataSetFromAssets(getActivity().getAssets(), "n.txt"));
|
||||
// sets.add(FileUtils.dataSetFromAssets(getActivity().getAssets(), "nlogn.txt"));
|
||||
// sets.add(FileUtils.dataSetFromAssets(getActivity().getAssets(), "square.txt"));
|
||||
// sets.add(FileUtils.dataSetFromAssets(getActivity().getAssets(), "three.txt"));
|
||||
|
||||
int max = Math.max(sets.get(0).getEntryCount(), sets.get(1).getEntryCount());
|
||||
|
||||
LineData d = new LineData(ChartData.generateXVals(0, max), sets);
|
||||
return d;
|
||||
}
|
||||
|
||||
protected LineData getComplexity() {
|
||||
|
||||
ArrayList<LineDataSet> sets = new ArrayList<LineDataSet>();
|
||||
|
||||
LineDataSet ds1 = new LineDataSet(FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "n.txt"), "O(n)");
|
||||
LineDataSet ds2 = new LineDataSet(FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "nlogn.txt"), "O(nlogn)");
|
||||
LineDataSet ds3 = new LineDataSet(FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "square.txt"), "O(n\u00B2)");
|
||||
LineDataSet ds4 = new LineDataSet(FileUtils.loadEntriesFromAssets(getActivity().getAssets(), "three.txt"), "O(n\u00B3)");
|
||||
|
||||
ds1.setColor(ColorTemplate.VORDIPLOM_COLORS[0]);
|
||||
ds2.setColor(ColorTemplate.VORDIPLOM_COLORS[1]);
|
||||
ds3.setColor(ColorTemplate.VORDIPLOM_COLORS[2]);
|
||||
ds4.setColor(ColorTemplate.VORDIPLOM_COLORS[3]);
|
||||
|
||||
ds1.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[0]);
|
||||
ds2.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[1]);
|
||||
ds3.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[2]);
|
||||
ds4.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[3]);
|
||||
|
||||
ds1.setLineWidth(2.5f);
|
||||
ds1.setCircleSize(3f);
|
||||
ds2.setLineWidth(2.5f);
|
||||
ds2.setCircleSize(3f);
|
||||
ds3.setLineWidth(2.5f);
|
||||
ds3.setCircleSize(3f);
|
||||
ds4.setLineWidth(2.5f);
|
||||
ds4.setCircleSize(3f);
|
||||
|
||||
|
||||
// load DataSets from textfiles in assets folders
|
||||
sets.add(ds1);
|
||||
sets.add(ds2);
|
||||
sets.add(ds3);
|
||||
sets.add(ds4);
|
||||
|
||||
LineData d = new LineData(ChartData.generateXVals(0, ds1.getEntryCount()), sets);
|
||||
return d;
|
||||
}
|
||||
|
||||
private String[] mLabels = new String[] { "Company A", "Company B", "Company C", "Company D", "Company E", "Company F" };
|
||||
// private String[] mXVals = new String[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec" };
|
||||
|
||||
private String getLabel(int i) {
|
||||
return mLabels[i];
|
||||
}
|
||||
}
|
|
@ -1,59 +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.utils.Legend;
|
||||
import com.github.mikephil.charting.utils.YLabels;
|
||||
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.setDrawYValues(false);
|
||||
// mChart.setCircleSize(5f);
|
||||
|
||||
mChart.setHighlightIndicatorEnabled(false);
|
||||
mChart.setDrawBorder(false);
|
||||
mChart.setDrawGridBackground(false);
|
||||
mChart.setDrawVerticalGrid(false);
|
||||
mChart.setDrawXLabels(false);
|
||||
mChart.setDrawYValues(false);
|
||||
mChart.setStartAtZero(false);
|
||||
|
||||
mChart.setYRange(-1.2f, 1.2f, false);
|
||||
|
||||
mChart.setData(generateLineData());
|
||||
mChart.animateX(3000);
|
||||
|
||||
// mChart.setScaleMinima(3f, 3f);
|
||||
// mChart.centerViewPort(300, 0);
|
||||
|
||||
Typeface tf = Typeface.createFromAsset(getActivity().getAssets(),"OpenSans-Light.ttf");
|
||||
|
||||
Legend l = mChart.getLegend();
|
||||
l.setTypeface(tf);
|
||||
|
||||
YLabels labels = mChart.getYLabels();
|
||||
labels.setTypeface(tf);
|
||||
|
||||
return v;
|
||||
}
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
|
||||
package com.xxmassdeveloper.mpchartexample.listviewitems;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Typeface;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
||||
import com.github.mikephil.charting.charts.PieChart;
|
||||
import com.github.mikephil.charting.data.ChartData;
|
||||
import com.github.mikephil.charting.data.PieData;
|
||||
import com.github.mikephil.charting.utils.Legend;
|
||||
import com.github.mikephil.charting.utils.Legend.LegendPosition;
|
||||
import com.xxmassdeveloper.mpchartexample.R;
|
||||
|
||||
public class PieChartItem extends ChartItem {
|
||||
|
||||
private Typeface mTf;
|
||||
|
||||
public PieChartItem(ChartData cd, Context c) {
|
||||
super(cd);
|
||||
|
||||
mTf = Typeface.createFromAsset(c.getAssets(), "OpenSans-Regular.ttf");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemType() {
|
||||
return TYPE_PIECHART;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, Context c) {
|
||||
|
||||
ViewHolder holder = null;
|
||||
|
||||
if (convertView == null) {
|
||||
|
||||
holder = new ViewHolder();
|
||||
|
||||
convertView = LayoutInflater.from(c).inflate(
|
||||
R.layout.list_item_piechart, null);
|
||||
holder.chart = (PieChart) convertView.findViewById(R.id.chart);
|
||||
|
||||
convertView.setTag(holder);
|
||||
|
||||
} else {
|
||||
holder = (ViewHolder) convertView.getTag();
|
||||
}
|
||||
|
||||
// apply styling
|
||||
holder.chart.setValueTypeface(mTf);
|
||||
holder.chart.setDescription("");
|
||||
holder.chart.setHoleRadius(60f);
|
||||
holder.chart.setTransparentCircleRadius(65f);
|
||||
holder.chart.setCenterText("MPChart\nAndroid");
|
||||
holder.chart.setCenterTextTypeface(mTf);
|
||||
holder.chart.setCenterTextSize(18f);
|
||||
holder.chart.setDrawXValues(false);
|
||||
holder.chart.setUsePercentValues(true);
|
||||
|
||||
// set data
|
||||
holder.chart.setData((PieData) mChartData);
|
||||
|
||||
Legend l = holder.chart.getLegend();
|
||||
l.setPosition(LegendPosition.RIGHT_OF_CHART);
|
||||
|
||||
// do not forget to refresh the chart
|
||||
// holder.chart.invalidate();
|
||||
holder.chart.animateXY(900, 900);
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
||||
private static class ViewHolder {
|
||||
PieChart chart;
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package com.xxmassdeveloper.mpchartexample.notimportant;
|
||||
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
|
||||
import com.xxmassdeveloper.mpchartexample.R;
|
||||
|
||||
public abstract class DemoBase extends FragmentActivity {
|
||||
|
||||
protected String[] mMonths = new String[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec" };
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
overridePendingTransition(R.anim.move_left_in_activity, R.anim.move_right_out_activity);
|
||||
}
|
||||
}
|
|
@ -1,281 +0,0 @@
|
|||
|
||||
package com.xxmassdeveloper.mpchartexample.notimportant;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.github.mikephil.charting.utils.Utils;
|
||||
import com.xxmassdeveloper.mpchartexample.AnotherBarActivity;
|
||||
import com.xxmassdeveloper.mpchartexample.BarChartActivity;
|
||||
import com.xxmassdeveloper.mpchartexample.BarChartActivityMultiDataset;
|
||||
import com.xxmassdeveloper.mpchartexample.CandleStickChartActivity;
|
||||
import com.xxmassdeveloper.mpchartexample.CubicLineChartActivity;
|
||||
import com.xxmassdeveloper.mpchartexample.DynamicalAddingActivity;
|
||||
import com.xxmassdeveloper.mpchartexample.InvertedLineChartActivity;
|
||||
import com.xxmassdeveloper.mpchartexample.LineChartActivity;
|
||||
import com.xxmassdeveloper.mpchartexample.LineChartActivityColored;
|
||||
import com.xxmassdeveloper.mpchartexample.ListViewBarChartActivity;
|
||||
import com.xxmassdeveloper.mpchartexample.ListViewMultiChartActivity;
|
||||
import com.xxmassdeveloper.mpchartexample.MultiLineChartActivity;
|
||||
import com.xxmassdeveloper.mpchartexample.PieChartActivity;
|
||||
import com.xxmassdeveloper.mpchartexample.R;
|
||||
import com.xxmassdeveloper.mpchartexample.RadarChartActivitry;
|
||||
import com.xxmassdeveloper.mpchartexample.ScatterChartActivity;
|
||||
import com.xxmassdeveloper.mpchartexample.StackedBarActivity;
|
||||
import com.xxmassdeveloper.mpchartexample.fragments.SimpleChartDemo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MainActivity extends Activity implements 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);
|
||||
|
||||
// initialize the utilities
|
||||
Utils.init(getResources());
|
||||
|
||||
ArrayList<ContentItem> objects = new ArrayList<ContentItem>();
|
||||
|
||||
objects.add(new ContentItem("Line Chart", "A simple demonstration of the linechart."));
|
||||
objects.add(new ContentItem("Bar Chart", "A simple demonstration of the bar chart."));
|
||||
objects.add(new ContentItem("Pie Chart", "A simple demonstration of the pie chart."));
|
||||
objects.add(new ContentItem("Scatter Chart", "A simple demonstration of the scatter chart."));
|
||||
objects.add(new ContentItem("Stacked Bar Chart",
|
||||
"A simple demonstration of a bar chart with stacked bars."));
|
||||
objects.add(new ContentItem("Another Bar Chart",
|
||||
"Implementation of a BarChart that only shows values at the bottom."));
|
||||
objects.add(new ContentItem("Multiple Lines Chart",
|
||||
"A line chart with multiple DataSet objects. One color per DataSet."));
|
||||
objects.add(new ContentItem("Multiple Bars Chart",
|
||||
"A bar chart with multiple DataSet objects. One multiple colors per DataSet."));
|
||||
objects.add(new ContentItem("Draw Chart",
|
||||
"Demonstration of drawing values into the chart per touch-gesture. With callbacks."));
|
||||
objects.add(new ContentItem(
|
||||
"Charts in Fragments, awesome design.",
|
||||
"Demonstration of charts inside Fragments. In this example the focus was on the design and look and feel of the chart."));
|
||||
objects.add(new ContentItem(
|
||||
"BarChart inside ListView",
|
||||
"Demonstrates the usage of a BarChart inside a ListView item."));
|
||||
objects.add(new ContentItem(
|
||||
"Multiple charts inside ListView",
|
||||
"Demonstrates the usage of different chart types inside a ListView."));
|
||||
objects.add(new ContentItem(
|
||||
"Inverted Line Chart",
|
||||
"Demonstrates the feature of inverting the y-axis."));
|
||||
objects.add(new ContentItem(
|
||||
"Candle Stick Chart",
|
||||
"Demonstrates usage of the CandleStickChart."));
|
||||
objects.add(new ContentItem(
|
||||
"Cubic Line Chart",
|
||||
"Demonstrates cubic lines in a LineChart."));
|
||||
objects.add(new ContentItem(
|
||||
"Radar Chart",
|
||||
"Demonstrates the use of a spider-web like (net) chart."));
|
||||
objects.add(new ContentItem(
|
||||
"Colored Line Chart",
|
||||
"Shows a LineChart with different background and line color."));
|
||||
objects.add(new ContentItem(
|
||||
"Dynamical data adding",
|
||||
"This Activity demonstrates dynamical adding of Entries and DataSets (real time graph)."));
|
||||
|
||||
MyAdapter adapter = new MyAdapter(this, objects);
|
||||
|
||||
ListView lv = (ListView) findViewById(R.id.listView1);
|
||||
lv.setAdapter(adapter);
|
||||
|
||||
lv.setOnItemClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> av, View v, int pos, long arg3) {
|
||||
|
||||
Intent i;
|
||||
|
||||
switch (pos) {
|
||||
case 0:
|
||||
i = new Intent(this, LineChartActivity.class);
|
||||
startActivity(i);
|
||||
break;
|
||||
case 1:
|
||||
i = new Intent(this, BarChartActivity.class);
|
||||
startActivity(i);
|
||||
break;
|
||||
case 2:
|
||||
i = new Intent(this, PieChartActivity.class);
|
||||
startActivity(i);
|
||||
break;
|
||||
case 3:
|
||||
i = new Intent(this, ScatterChartActivity.class);
|
||||
startActivity(i);
|
||||
break;
|
||||
case 4:
|
||||
i = new Intent(this, StackedBarActivity.class);
|
||||
startActivity(i);
|
||||
break;
|
||||
case 5:
|
||||
i = new Intent(this, AnotherBarActivity.class);
|
||||
startActivity(i);
|
||||
break;
|
||||
case 6:
|
||||
i = new Intent(this, MultiLineChartActivity.class);
|
||||
startActivity(i);
|
||||
|
||||
break;
|
||||
case 7:
|
||||
i = new Intent(this, BarChartActivityMultiDataset.class);
|
||||
startActivity(i);
|
||||
break;
|
||||
case 8:
|
||||
// i = new Intent(this, DrawChartActivity.class);
|
||||
// startActivity(i);
|
||||
|
||||
AlertDialog.Builder b = new AlertDialog.Builder(this);
|
||||
b.setTitle("Feature not available");
|
||||
b.setMessage("Due to recent changes to the data model of the library, this feature is temporarily not available.");
|
||||
b.setPositiveButton("OK", null);
|
||||
b.create().show();
|
||||
break;
|
||||
case 9:
|
||||
i = new Intent(this, SimpleChartDemo.class);
|
||||
startActivity(i);
|
||||
break;
|
||||
case 10:
|
||||
i = new Intent(this, ListViewBarChartActivity.class);
|
||||
startActivity(i);
|
||||
break;
|
||||
case 11:
|
||||
i = new Intent(this, ListViewMultiChartActivity.class);
|
||||
startActivity(i);
|
||||
break;
|
||||
case 12:
|
||||
i = new Intent(this, InvertedLineChartActivity.class);
|
||||
startActivity(i);
|
||||
break;
|
||||
case 13:
|
||||
i = new Intent(this, CandleStickChartActivity.class);
|
||||
startActivity(i);
|
||||
break;
|
||||
case 14:
|
||||
i = new Intent(this, CubicLineChartActivity.class);
|
||||
startActivity(i);
|
||||
break;
|
||||
case 15:
|
||||
i = new Intent(this, RadarChartActivitry.class);
|
||||
startActivity(i);
|
||||
break;
|
||||
case 16:
|
||||
i = new Intent(this, LineChartActivityColored.class);
|
||||
startActivity(i);
|
||||
break;
|
||||
case 17:
|
||||
i = new Intent(this, DynamicalAddingActivity.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.main, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
Intent i = null;
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.viewGithub:
|
||||
i = new Intent(Intent.ACTION_VIEW);
|
||||
i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart"));
|
||||
startActivity(i);
|
||||
break;
|
||||
case R.id.report:
|
||||
i = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
|
||||
"mailto", "philjay.librarysup@gmail.com", null));
|
||||
i.putExtra(Intent.EXTRA_SUBJECT, "MPAndroidChart Issue");
|
||||
i.putExtra(Intent.EXTRA_TEXT, "Your error report here...");
|
||||
startActivity(Intent.createChooser(i, "Report Problem"));
|
||||
break;
|
||||
case R.id.website:
|
||||
i = new Intent(Intent.ACTION_VIEW);
|
||||
i.setData(Uri.parse("http://www.xxmassdeveloper.com"));
|
||||
startActivity(i);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private class ContentItem {
|
||||
String name;
|
||||
String desc;
|
||||
|
||||
public ContentItem(String n, String d) {
|
||||
name = n;
|
||||
desc = d;
|
||||
}
|
||||
}
|
||||
|
||||
private class MyAdapter extends ArrayAdapter<ContentItem> {
|
||||
|
||||
public MyAdapter(Context context, List<ContentItem> objects) {
|
||||
super(context, 0, objects);
|
||||
}
|
||||
|
||||
@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);
|
||||
|
||||
convertView.setTag(holder);
|
||||
|
||||
} else {
|
||||
holder = (ViewHolder) convertView.getTag();
|
||||
}
|
||||
|
||||
holder.tvName.setText(c.name);
|
||||
holder.tvDesc.setText(c.desc);
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
||||
private class ViewHolder {
|
||||
|
||||
TextView tvName, tvDesc;
|
||||
}
|
||||
}
|
||||
}
|
57
MPChartExample/src/main/AndroidManifest.xml
Normal file
57
MPChartExample/src/main/AndroidManifest.xml
Normal 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>
|
8000
MPChartExample/src/main/assets/othersine.txt
Normal file
8000
MPChartExample/src/main/assets/othersine.txt
Normal file
File diff suppressed because it is too large
Load diff
Before Width: | Height: | Size: 4 KiB After Width: | Height: | Size: 4 KiB |
|
@ -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) {}
|
||||
}
|
|
@ -0,0 +1,326 @@
|
|||
package com.xxmassdeveloper.mpchartexample;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.RectF;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.github.mikephil.charting.charts.BarChart;
|
||||
import com.github.mikephil.charting.components.Legend;
|
||||
import com.github.mikephil.charting.components.Legend.LegendForm;
|
||||
import com.github.mikephil.charting.components.XAxis;
|
||||
import com.github.mikephil.charting.components.XAxis.XAxisPosition;
|
||||
import com.github.mikephil.charting.components.YAxis;
|
||||
import com.github.mikephil.charting.components.YAxis.AxisDependency;
|
||||
import com.github.mikephil.charting.components.YAxis.YAxisLabelPosition;
|
||||
import com.github.mikephil.charting.data.BarData;
|
||||
import com.github.mikephil.charting.data.BarDataSet;
|
||||
import com.github.mikephil.charting.data.BarEntry;
|
||||
import com.github.mikephil.charting.data.Entry;
|
||||
import com.github.mikephil.charting.formatter.ValueFormatter;
|
||||
import com.github.mikephil.charting.highlight.Highlight;
|
||||
import com.github.mikephil.charting.interfaces.datasets.IBarDataSet;
|
||||
import com.github.mikephil.charting.interfaces.datasets.IDataSet;
|
||||
import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
|
||||
import com.github.mikephil.charting.utils.Fill;
|
||||
import com.github.mikephil.charting.utils.MPPointF;
|
||||
import com.xxmassdeveloper.mpchartexample.custom.DayAxisValueFormatter;
|
||||
import com.xxmassdeveloper.mpchartexample.custom.MyValueFormatter;
|
||||
import com.xxmassdeveloper.mpchartexample.custom.XYMarkerView;
|
||||
import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BarChartActivity extends DemoBase implements OnSeekBarChangeListener,
|
||||
OnChartValueSelectedListener {
|
||||
|
||||
private BarChart chart;
|
||||
private SeekBar seekBarX, seekBarY;
|
||||
private TextView tvX, tvY;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_barchart);
|
||||
|
||||
setTitle("BarChartActivity");
|
||||
|
||||
tvX = findViewById(R.id.tvXMax);
|
||||
tvY = findViewById(R.id.tvYMax);
|
||||
|
||||
seekBarX = findViewById(R.id.seekBar1);
|
||||
seekBarY = findViewById(R.id.seekBar2);
|
||||
|
||||
seekBarY.setOnSeekBarChangeListener(this);
|
||||
seekBarX.setOnSeekBarChangeListener(this);
|
||||
|
||||
chart = findViewById(R.id.chart1);
|
||||
chart.setOnChartValueSelectedListener(this);
|
||||
|
||||
chart.setDrawBarShadow(false);
|
||||
chart.setDrawValueAboveBar(true);
|
||||
|
||||
chart.getDescription().setEnabled(false);
|
||||
|
||||
// if more than 60 entries are displayed in the chart, no values will be
|
||||
// drawn
|
||||
chart.setMaxVisibleValueCount(60);
|
||||
|
||||
// scaling can now only be done on x- and y-axis separately
|
||||
chart.setPinchZoom(false);
|
||||
|
||||
chart.setDrawGridBackground(false);
|
||||
// chart.setDrawYLabels(false);
|
||||
|
||||
ValueFormatter xAxisFormatter = new DayAxisValueFormatter(chart);
|
||||
|
||||
XAxis xAxis = chart.getXAxis();
|
||||
xAxis.setPosition(XAxisPosition.BOTTOM);
|
||||
xAxis.setTypeface(tfLight);
|
||||
xAxis.setDrawGridLines(false);
|
||||
xAxis.setGranularity(1f); // only intervals of 1 day
|
||||
xAxis.setLabelCount(7);
|
||||
xAxis.setValueFormatter(xAxisFormatter);
|
||||
|
||||
ValueFormatter custom = new MyValueFormatter("$");
|
||||
|
||||
YAxis leftAxis = chart.getAxisLeft();
|
||||
leftAxis.setTypeface(tfLight);
|
||||
leftAxis.setLabelCount(8, false);
|
||||
leftAxis.setValueFormatter(custom);
|
||||
leftAxis.setPosition(YAxisLabelPosition.OUTSIDE_CHART);
|
||||
leftAxis.setSpaceTop(15f);
|
||||
leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
|
||||
|
||||
YAxis rightAxis = chart.getAxisRight();
|
||||
rightAxis.setDrawGridLines(false);
|
||||
rightAxis.setTypeface(tfLight);
|
||||
rightAxis.setLabelCount(8, false);
|
||||
rightAxis.setValueFormatter(custom);
|
||||
rightAxis.setSpaceTop(15f);
|
||||
rightAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
|
||||
|
||||
Legend l = chart.getLegend();
|
||||
l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
|
||||
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.LEFT);
|
||||
l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
|
||||
l.setDrawInside(false);
|
||||
l.setForm(LegendForm.SQUARE);
|
||||
l.setFormSize(9f);
|
||||
l.setTextSize(11f);
|
||||
l.setXEntrySpace(4f);
|
||||
|
||||
XYMarkerView mv = new XYMarkerView(this, xAxisFormatter);
|
||||
mv.setChartView(chart); // For bounds control
|
||||
chart.setMarker(mv); // Set the marker to the chart
|
||||
|
||||
// setting data
|
||||
seekBarY.setProgress(50);
|
||||
seekBarX.setProgress(12);
|
||||
|
||||
// chart.setDrawLegend(false);
|
||||
}
|
||||
|
||||
private void setData(int count, float range) {
|
||||
|
||||
float start = 1f;
|
||||
|
||||
ArrayList<BarEntry> values = new ArrayList<>();
|
||||
|
||||
for (int i = (int) start; i < start + count; i++) {
|
||||
float val = (float) (Math.random() * (range + 1));
|
||||
|
||||
if (Math.random() * 100 < 25) {
|
||||
values.add(new BarEntry(i, val, getResources().getDrawable(R.drawable.star)));
|
||||
} else {
|
||||
values.add(new BarEntry(i, val));
|
||||
}
|
||||
}
|
||||
|
||||
BarDataSet set1;
|
||||
|
||||
if (chart.getData() != null &&
|
||||
chart.getData().getDataSetCount() > 0) {
|
||||
set1 = (BarDataSet) chart.getData().getDataSetByIndex(0);
|
||||
set1.setValues(values);
|
||||
chart.getData().notifyDataChanged();
|
||||
chart.notifyDataSetChanged();
|
||||
|
||||
} else {
|
||||
set1 = new BarDataSet(values, "The year 2017");
|
||||
|
||||
set1.setDrawIcons(false);
|
||||
|
||||
int startColor1 = ContextCompat.getColor(this, android.R.color.holo_orange_light);
|
||||
int startColor2 = ContextCompat.getColor(this, android.R.color.holo_blue_light);
|
||||
int startColor3 = ContextCompat.getColor(this, android.R.color.holo_orange_light);
|
||||
int startColor4 = ContextCompat.getColor(this, android.R.color.holo_green_light);
|
||||
int startColor5 = ContextCompat.getColor(this, android.R.color.holo_red_light);
|
||||
int endColor1 = ContextCompat.getColor(this, android.R.color.holo_blue_dark);
|
||||
int endColor2 = ContextCompat.getColor(this, android.R.color.holo_purple);
|
||||
int endColor3 = ContextCompat.getColor(this, android.R.color.holo_green_dark);
|
||||
int endColor4 = ContextCompat.getColor(this, android.R.color.holo_red_dark);
|
||||
int endColor5 = ContextCompat.getColor(this, android.R.color.holo_orange_dark);
|
||||
|
||||
List<Fill> gradientFills = new ArrayList<>();
|
||||
gradientFills.add(new Fill(startColor1, endColor1));
|
||||
gradientFills.add(new Fill(startColor2, endColor2));
|
||||
gradientFills.add(new Fill(startColor3, endColor3));
|
||||
gradientFills.add(new Fill(startColor4, endColor4));
|
||||
gradientFills.add(new Fill(startColor5, endColor5));
|
||||
|
||||
set1.setFills(gradientFills);
|
||||
|
||||
ArrayList<IBarDataSet> dataSets = new ArrayList<>();
|
||||
dataSets.add(set1);
|
||||
|
||||
BarData data = new BarData(dataSets);
|
||||
data.setValueTextSize(10f);
|
||||
data.setValueTypeface(tfLight);
|
||||
data.setBarWidth(0.9f);
|
||||
|
||||
chart.setData(data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.bar, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.viewGithub: {
|
||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||
i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/BarChartActivity.java"));
|
||||
startActivity(i);
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleValues: {
|
||||
for (IDataSet set : chart.getData().getDataSets())
|
||||
set.setDrawValues(!set.isDrawValuesEnabled());
|
||||
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleIcons: {
|
||||
for (IDataSet set : chart.getData().getDataSets())
|
||||
set.setDrawIcons(!set.isDrawIconsEnabled());
|
||||
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleHighlight: {
|
||||
if (chart.getData() != null) {
|
||||
chart.getData().setHighlightEnabled(!chart.getData().isHighlightEnabled());
|
||||
chart.invalidate();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case R.id.actionTogglePinch: {
|
||||
if (chart.isPinchZoomEnabled())
|
||||
chart.setPinchZoom(false);
|
||||
else
|
||||
chart.setPinchZoom(true);
|
||||
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleAutoScaleMinMax: {
|
||||
chart.setAutoScaleMinMaxEnabled(!chart.isAutoScaleMinMaxEnabled());
|
||||
chart.notifyDataSetChanged();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleBarBorders: {
|
||||
for (IBarDataSet set : chart.getData().getDataSets())
|
||||
((BarDataSet) set).setBarBorderWidth(set.getBarBorderWidth() == 1.f ? 0.f : 1.f);
|
||||
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.animateX: {
|
||||
chart.animateX(2000);
|
||||
break;
|
||||
}
|
||||
case R.id.animateY: {
|
||||
chart.animateY(2000);
|
||||
break;
|
||||
}
|
||||
case R.id.animateXY: {
|
||||
chart.animateXY(2000, 2000);
|
||||
break;
|
||||
}
|
||||
case R.id.actionSave: {
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
|
||||
saveToGallery();
|
||||
} else {
|
||||
requestStoragePermission(chart);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
|
||||
tvX.setText(String.valueOf(seekBarX.getProgress()));
|
||||
tvY.setText(String.valueOf(seekBarY.getProgress()));
|
||||
|
||||
setData(seekBarX.getProgress(), seekBarY.getProgress());
|
||||
chart.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void saveToGallery() {
|
||||
saveToGallery(chart, "BarChartActivity");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {}
|
||||
|
||||
private final RectF onValueSelectedRectF = new RectF();
|
||||
|
||||
@Override
|
||||
public void onValueSelected(Entry e, Highlight h) {
|
||||
|
||||
if (e == null)
|
||||
return;
|
||||
|
||||
RectF bounds = onValueSelectedRectF;
|
||||
chart.getBarBounds((BarEntry) e, bounds);
|
||||
MPPointF position = chart.getPosition(e, AxisDependency.LEFT);
|
||||
|
||||
Log.i("bounds", bounds.toString());
|
||||
Log.i("position", position.toString());
|
||||
|
||||
Log.i("x-index",
|
||||
"low: " + chart.getLowestVisibleX() + ", high: "
|
||||
+ chart.getHighestVisibleX());
|
||||
|
||||
MPPointF.recycleInstance(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected() { }
|
||||
}
|
|
@ -0,0 +1,287 @@
|
|||
package com.xxmassdeveloper.mpchartexample;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.github.mikephil.charting.charts.BarChart;
|
||||
import com.github.mikephil.charting.components.Legend;
|
||||
import com.github.mikephil.charting.components.XAxis;
|
||||
import com.github.mikephil.charting.components.YAxis;
|
||||
import com.github.mikephil.charting.data.BarData;
|
||||
import com.github.mikephil.charting.data.BarDataSet;
|
||||
import com.github.mikephil.charting.data.BarEntry;
|
||||
import com.github.mikephil.charting.data.Entry;
|
||||
import com.github.mikephil.charting.formatter.LargeValueFormatter;
|
||||
import com.github.mikephil.charting.formatter.ValueFormatter;
|
||||
import com.github.mikephil.charting.highlight.Highlight;
|
||||
import com.github.mikephil.charting.interfaces.datasets.IBarDataSet;
|
||||
import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
|
||||
import com.xxmassdeveloper.mpchartexample.custom.MyMarkerView;
|
||||
import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
public class BarChartActivityMultiDataset extends DemoBase implements OnSeekBarChangeListener,
|
||||
OnChartValueSelectedListener {
|
||||
|
||||
private BarChart chart;
|
||||
private SeekBar seekBarX, seekBarY;
|
||||
private TextView tvX, tvY;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_barchart);
|
||||
|
||||
setTitle("BarChartActivityMultiDataset");
|
||||
|
||||
tvX = findViewById(R.id.tvXMax);
|
||||
tvX.setTextSize(10);
|
||||
tvY = findViewById(R.id.tvYMax);
|
||||
|
||||
seekBarX = findViewById(R.id.seekBar1);
|
||||
seekBarX.setMax(50);
|
||||
seekBarX.setOnSeekBarChangeListener(this);
|
||||
|
||||
seekBarY = findViewById(R.id.seekBar2);
|
||||
seekBarY.setOnSeekBarChangeListener(this);
|
||||
|
||||
chart = findViewById(R.id.chart1);
|
||||
chart.setOnChartValueSelectedListener(this);
|
||||
chart.getDescription().setEnabled(false);
|
||||
|
||||
// chart.setDrawBorders(true);
|
||||
|
||||
// scaling can now only be done on x- and y-axis separately
|
||||
chart.setPinchZoom(false);
|
||||
|
||||
chart.setDrawBarShadow(false);
|
||||
|
||||
chart.setDrawGridBackground(false);
|
||||
|
||||
// create a custom MarkerView (extend MarkerView) and specify the layout
|
||||
// to use for it
|
||||
MyMarkerView mv = new MyMarkerView(this, R.layout.custom_marker_view);
|
||||
mv.setChartView(chart); // For bounds control
|
||||
chart.setMarker(mv); // Set the marker to the chart
|
||||
|
||||
seekBarX.setProgress(10);
|
||||
seekBarY.setProgress(100);
|
||||
|
||||
Legend l = chart.getLegend();
|
||||
l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
|
||||
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
|
||||
l.setOrientation(Legend.LegendOrientation.VERTICAL);
|
||||
l.setDrawInside(true);
|
||||
l.setTypeface(tfLight);
|
||||
l.setYOffset(0f);
|
||||
l.setXOffset(10f);
|
||||
l.setYEntrySpace(0f);
|
||||
l.setTextSize(8f);
|
||||
|
||||
XAxis xAxis = chart.getXAxis();
|
||||
xAxis.setTypeface(tfLight);
|
||||
xAxis.setGranularity(1f);
|
||||
xAxis.setCenterAxisLabels(true);
|
||||
xAxis.setValueFormatter(new ValueFormatter() {
|
||||
@Override
|
||||
public String getFormattedValue(float value) {
|
||||
return String.valueOf((int) value);
|
||||
}
|
||||
});
|
||||
|
||||
YAxis leftAxis = chart.getAxisLeft();
|
||||
leftAxis.setTypeface(tfLight);
|
||||
leftAxis.setValueFormatter(new LargeValueFormatter());
|
||||
leftAxis.setDrawGridLines(false);
|
||||
leftAxis.setSpaceTop(35f);
|
||||
leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
|
||||
|
||||
chart.getAxisRight().setEnabled(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
|
||||
float groupSpace = 0.08f;
|
||||
float barSpace = 0.03f; // x4 DataSet
|
||||
float barWidth = 0.2f; // x4 DataSet
|
||||
// (0.2 + 0.03) * 4 + 0.08 = 1.00 -> interval per "group"
|
||||
|
||||
int groupCount = seekBarX.getProgress() + 1;
|
||||
int startYear = 1980;
|
||||
int endYear = startYear + groupCount;
|
||||
|
||||
tvX.setText(String.format(Locale.ENGLISH, "%d-%d", startYear, endYear));
|
||||
tvY.setText(String.valueOf(seekBarY.getProgress()));
|
||||
|
||||
ArrayList<BarEntry> values1 = new ArrayList<>();
|
||||
ArrayList<BarEntry> values2 = new ArrayList<>();
|
||||
ArrayList<BarEntry> values3 = new ArrayList<>();
|
||||
ArrayList<BarEntry> values4 = new ArrayList<>();
|
||||
|
||||
float randomMultiplier = seekBarY.getProgress() * 100000f;
|
||||
|
||||
for (int i = startYear; i < endYear; i++) {
|
||||
values1.add(new BarEntry(i, (float) (Math.random() * randomMultiplier)));
|
||||
values2.add(new BarEntry(i, (float) (Math.random() * randomMultiplier)));
|
||||
values3.add(new BarEntry(i, (float) (Math.random() * randomMultiplier)));
|
||||
values4.add(new BarEntry(i, (float) (Math.random() * randomMultiplier)));
|
||||
}
|
||||
|
||||
BarDataSet set1, set2, set3, set4;
|
||||
|
||||
if (chart.getData() != null && chart.getData().getDataSetCount() > 0) {
|
||||
|
||||
set1 = (BarDataSet) chart.getData().getDataSetByIndex(0);
|
||||
set2 = (BarDataSet) chart.getData().getDataSetByIndex(1);
|
||||
set3 = (BarDataSet) chart.getData().getDataSetByIndex(2);
|
||||
set4 = (BarDataSet) chart.getData().getDataSetByIndex(3);
|
||||
set1.setValues(values1);
|
||||
set2.setValues(values2);
|
||||
set3.setValues(values3);
|
||||
set4.setValues(values4);
|
||||
chart.getData().notifyDataChanged();
|
||||
chart.notifyDataSetChanged();
|
||||
|
||||
} else {
|
||||
// create 4 DataSets
|
||||
set1 = new BarDataSet(values1, "Company A");
|
||||
set1.setColor(Color.rgb(104, 241, 175));
|
||||
set2 = new BarDataSet(values2, "Company B");
|
||||
set2.setColor(Color.rgb(164, 228, 251));
|
||||
set3 = new BarDataSet(values3, "Company C");
|
||||
set3.setColor(Color.rgb(242, 247, 158));
|
||||
set4 = new BarDataSet(values4, "Company D");
|
||||
set4.setColor(Color.rgb(255, 102, 0));
|
||||
|
||||
BarData data = new BarData(set1, set2, set3, set4);
|
||||
data.setValueFormatter(new LargeValueFormatter());
|
||||
data.setValueTypeface(tfLight);
|
||||
|
||||
chart.setData(data);
|
||||
}
|
||||
|
||||
// specify the width each bar should have
|
||||
chart.getBarData().setBarWidth(barWidth);
|
||||
|
||||
// restrict the x-axis range
|
||||
chart.getXAxis().setAxisMinimum(startYear);
|
||||
|
||||
// barData.getGroupWith(...) is a helper that calculates the width each group needs based on the provided parameters
|
||||
chart.getXAxis().setAxisMaximum(startYear + chart.getBarData().getGroupWidth(groupSpace, barSpace) * groupCount);
|
||||
chart.groupBars(startYear, groupSpace, barSpace);
|
||||
chart.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.bar, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.viewGithub: {
|
||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||
i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/BarChartActivityMultiDataset.java"));
|
||||
startActivity(i);
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleValues: {
|
||||
for (IBarDataSet set : chart.getData().getDataSets())
|
||||
set.setDrawValues(!set.isDrawValuesEnabled());
|
||||
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionTogglePinch: {
|
||||
if (chart.isPinchZoomEnabled())
|
||||
chart.setPinchZoom(false);
|
||||
else
|
||||
chart.setPinchZoom(true);
|
||||
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleAutoScaleMinMax: {
|
||||
chart.setAutoScaleMinMaxEnabled(!chart.isAutoScaleMinMaxEnabled());
|
||||
chart.notifyDataSetChanged();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleBarBorders: {
|
||||
for (IBarDataSet set : chart.getData().getDataSets())
|
||||
((BarDataSet) set).setBarBorderWidth(set.getBarBorderWidth() == 1.f ? 0.f : 1.f);
|
||||
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleHighlight: {
|
||||
if (chart.getData() != null) {
|
||||
chart.getData().setHighlightEnabled(!chart.getData().isHighlightEnabled());
|
||||
chart.invalidate();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case R.id.actionSave: {
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
|
||||
saveToGallery();
|
||||
} else {
|
||||
requestStoragePermission(chart);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case R.id.animateX: {
|
||||
chart.animateX(2000);
|
||||
break;
|
||||
}
|
||||
case R.id.animateY: {
|
||||
chart.animateY(2000);
|
||||
break;
|
||||
}
|
||||
case R.id.animateXY: {
|
||||
chart.animateXY(2000, 2000);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void saveToGallery() {
|
||||
saveToGallery(chart, "BarChartActivityMultiDataset");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {}
|
||||
|
||||
@Override
|
||||
public void onValueSelected(Entry e, Highlight h) {
|
||||
Log.i("Activity", "Selected: " + e.toString() + ", dataSet: " + h.getDataSetIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected() {
|
||||
Log.i("Activity", "Nothing selected.");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,239 @@
|
|||
|
||||
package com.xxmassdeveloper.mpchartexample;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.github.mikephil.charting.charts.BarChart;
|
||||
import com.github.mikephil.charting.components.Legend;
|
||||
import com.github.mikephil.charting.components.Legend.LegendForm;
|
||||
import com.github.mikephil.charting.components.XAxis;
|
||||
import com.github.mikephil.charting.components.YAxis;
|
||||
import com.github.mikephil.charting.data.BarData;
|
||||
import com.github.mikephil.charting.data.BarDataSet;
|
||||
import com.github.mikephil.charting.data.BarEntry;
|
||||
import com.github.mikephil.charting.interfaces.datasets.IBarDataSet;
|
||||
import com.github.mikephil.charting.utils.FileUtils;
|
||||
import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BarChartActivitySinus extends DemoBase implements OnSeekBarChangeListener {
|
||||
|
||||
private BarChart chart;
|
||||
private SeekBar seekBarX;
|
||||
private TextView tvX;
|
||||
|
||||
private List<BarEntry> data;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_barchart_sinus);
|
||||
|
||||
setTitle("BarChartActivitySinus");
|
||||
|
||||
data = FileUtils.loadBarEntriesFromAssets(getAssets(), "othersine.txt");
|
||||
|
||||
tvX = findViewById(R.id.tvValueCount);
|
||||
|
||||
seekBarX = findViewById(R.id.seekbarValues);
|
||||
|
||||
chart = findViewById(R.id.chart1);
|
||||
|
||||
chart.setDrawBarShadow(false);
|
||||
chart.setDrawValueAboveBar(true);
|
||||
|
||||
chart.getDescription().setEnabled(false);
|
||||
|
||||
// if more than 60 entries are displayed in the chart, no values will be
|
||||
// drawn
|
||||
chart.setMaxVisibleValueCount(60);
|
||||
|
||||
// scaling can now only be done on x- and y-axis separately
|
||||
chart.setPinchZoom(false);
|
||||
|
||||
// draw shadows for each bar that show the maximum value
|
||||
// chart.setDrawBarShadow(true);
|
||||
|
||||
// chart.setDrawXLabels(false);
|
||||
|
||||
chart.setDrawGridBackground(false);
|
||||
// chart.setDrawYLabels(false);
|
||||
|
||||
XAxis xAxis = chart.getXAxis();
|
||||
xAxis.setEnabled(false);
|
||||
|
||||
YAxis leftAxis = chart.getAxisLeft();
|
||||
leftAxis.setTypeface(tfLight);
|
||||
leftAxis.setLabelCount(6, false);
|
||||
leftAxis.setAxisMinimum(-2.5f);
|
||||
leftAxis.setAxisMaximum(2.5f);
|
||||
leftAxis.setGranularityEnabled(true);
|
||||
leftAxis.setGranularity(0.1f);
|
||||
|
||||
YAxis rightAxis = chart.getAxisRight();
|
||||
rightAxis.setDrawGridLines(false);
|
||||
rightAxis.setTypeface(tfLight);
|
||||
rightAxis.setLabelCount(6, false);
|
||||
rightAxis.setAxisMinimum(-2.5f);
|
||||
rightAxis.setAxisMaximum(2.5f);
|
||||
rightAxis.setGranularity(0.1f);
|
||||
|
||||
seekBarX.setOnSeekBarChangeListener(this);
|
||||
seekBarX.setProgress(150); // set data
|
||||
|
||||
Legend l = chart.getLegend();
|
||||
l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
|
||||
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.LEFT);
|
||||
l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
|
||||
l.setDrawInside(false);
|
||||
l.setForm(LegendForm.SQUARE);
|
||||
l.setFormSize(9f);
|
||||
l.setTextSize(11f);
|
||||
l.setXEntrySpace(4f);
|
||||
|
||||
chart.animateXY(1500, 1500);
|
||||
}
|
||||
|
||||
private void setData(int count) {
|
||||
|
||||
ArrayList<BarEntry> entries = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
entries.add(data.get(i));
|
||||
}
|
||||
|
||||
BarDataSet set;
|
||||
|
||||
if (chart.getData() != null &&
|
||||
chart.getData().getDataSetCount() > 0) {
|
||||
set = (BarDataSet) chart.getData().getDataSetByIndex(0);
|
||||
set.setValues(entries);
|
||||
chart.getData().notifyDataChanged();
|
||||
chart.notifyDataSetChanged();
|
||||
} else {
|
||||
set = new BarDataSet(entries, "Sinus Function");
|
||||
set.setColor(Color.rgb(240, 120, 124));
|
||||
}
|
||||
|
||||
BarData data = new BarData(set);
|
||||
data.setValueTextSize(10f);
|
||||
data.setValueTypeface(tfLight);
|
||||
data.setDrawValues(false);
|
||||
data.setBarWidth(0.8f);
|
||||
|
||||
chart.setData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.bar, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.viewGithub: {
|
||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||
i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/BarChartActivitySinus.java"));
|
||||
startActivity(i);
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleValues: {
|
||||
for (IBarDataSet set : chart.getData().getDataSets())
|
||||
set.setDrawValues(!set.isDrawValuesEnabled());
|
||||
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleHighlight: {
|
||||
if (chart.getData() != null) {
|
||||
chart.getData().setHighlightEnabled(!chart.getData().isHighlightEnabled());
|
||||
chart.invalidate();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case R.id.actionTogglePinch: {
|
||||
if (chart.isPinchZoomEnabled())
|
||||
chart.setPinchZoom(false);
|
||||
else
|
||||
chart.setPinchZoom(true);
|
||||
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleAutoScaleMinMax: {
|
||||
chart.setAutoScaleMinMaxEnabled(!chart.isAutoScaleMinMaxEnabled());
|
||||
chart.notifyDataSetChanged();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleBarBorders: {
|
||||
for (IBarDataSet set : chart.getData().getDataSets())
|
||||
((BarDataSet) set).setBarBorderWidth(set.getBarBorderWidth() == 1.f ? 0.f : 1.f);
|
||||
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.animateX: {
|
||||
chart.animateX(2000);
|
||||
break;
|
||||
}
|
||||
case R.id.animateY: {
|
||||
chart.animateY(2000);
|
||||
break;
|
||||
}
|
||||
case R.id.animateXY: {
|
||||
|
||||
chart.animateXY(2000, 2000);
|
||||
break;
|
||||
}
|
||||
case R.id.actionSave: {
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
|
||||
saveToGallery();
|
||||
} else {
|
||||
requestStoragePermission(chart);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
|
||||
tvX.setText(String.valueOf(seekBarX.getProgress()));
|
||||
|
||||
setData(seekBarX.getProgress());
|
||||
chart.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void saveToGallery() {
|
||||
saveToGallery(chart, "BarChartActivitySinus");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {}
|
||||
|
||||
}
|
|
@ -0,0 +1,195 @@
|
|||
package com.xxmassdeveloper.mpchartexample;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.github.mikephil.charting.charts.BarChart;
|
||||
import com.github.mikephil.charting.components.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.formatter.ValueFormatter;
|
||||
import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BarChartPositiveNegative extends DemoBase {
|
||||
|
||||
private BarChart chart;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_barchart_noseekbar);
|
||||
|
||||
setTitle("BarChartPositiveNegative");
|
||||
|
||||
chart = findViewById(R.id.chart1);
|
||||
chart.setBackgroundColor(Color.WHITE);
|
||||
chart.setExtraTopOffset(-30f);
|
||||
chart.setExtraBottomOffset(10f);
|
||||
chart.setExtraLeftOffset(70f);
|
||||
chart.setExtraRightOffset(70f);
|
||||
|
||||
chart.setDrawBarShadow(false);
|
||||
chart.setDrawValueAboveBar(true);
|
||||
|
||||
chart.getDescription().setEnabled(false);
|
||||
|
||||
// scaling can now only be done on x- and y-axis separately
|
||||
chart.setPinchZoom(false);
|
||||
|
||||
chart.setDrawGridBackground(false);
|
||||
|
||||
XAxis xAxis = chart.getXAxis();
|
||||
xAxis.setPosition(XAxisPosition.BOTTOM);
|
||||
xAxis.setTypeface(tfRegular);
|
||||
xAxis.setDrawGridLines(false);
|
||||
xAxis.setDrawAxisLine(false);
|
||||
xAxis.setTextColor(Color.LTGRAY);
|
||||
xAxis.setTextSize(13f);
|
||||
xAxis.setLabelCount(5);
|
||||
xAxis.setCenterAxisLabels(true);
|
||||
xAxis.setGranularity(1f);
|
||||
|
||||
YAxis left = chart.getAxisLeft();
|
||||
left.setDrawLabels(false);
|
||||
left.setSpaceTop(25f);
|
||||
left.setSpaceBottom(25f);
|
||||
left.setDrawAxisLine(false);
|
||||
left.setDrawGridLines(false);
|
||||
left.setDrawZeroLine(true); // draw a zero line
|
||||
left.setZeroLineColor(Color.GRAY);
|
||||
left.setZeroLineWidth(0.7f);
|
||||
chart.getAxisRight().setEnabled(false);
|
||||
chart.getLegend().setEnabled(false);
|
||||
|
||||
// THIS IS THE ORIGINAL DATA YOU WANT TO PLOT
|
||||
final List<Data> data = new ArrayList<>();
|
||||
data.add(new Data(0f, -224.1f, "12-29"));
|
||||
data.add(new Data(1f, 238.5f, "12-30"));
|
||||
data.add(new Data(2f, 1280.1f, "12-31"));
|
||||
data.add(new Data(3f, -442.3f, "01-01"));
|
||||
data.add(new Data(4f, -2280.1f, "01-02"));
|
||||
|
||||
xAxis.setValueFormatter(new ValueFormatter() {
|
||||
@Override
|
||||
public String getFormattedValue(float value) {
|
||||
return data.get(Math.min(Math.max((int) value, 0), data.size()-1)).xAxisValue;
|
||||
}
|
||||
});
|
||||
|
||||
setData(data);
|
||||
}
|
||||
|
||||
private void setData(List<Data> dataList) {
|
||||
|
||||
ArrayList<BarEntry> values = new ArrayList<>();
|
||||
List<Integer> colors = new ArrayList<>();
|
||||
|
||||
int green = Color.rgb(110, 190, 102);
|
||||
int red = Color.rgb(211, 74, 88);
|
||||
|
||||
for (int i = 0; i < dataList.size(); i++) {
|
||||
|
||||
Data d = dataList.get(i);
|
||||
BarEntry entry = new BarEntry(d.xValue, d.yValue);
|
||||
values.add(entry);
|
||||
|
||||
// specific colors
|
||||
if (d.yValue >= 0)
|
||||
colors.add(red);
|
||||
else
|
||||
colors.add(green);
|
||||
}
|
||||
|
||||
BarDataSet set;
|
||||
|
||||
if (chart.getData() != null &&
|
||||
chart.getData().getDataSetCount() > 0) {
|
||||
set = (BarDataSet) chart.getData().getDataSetByIndex(0);
|
||||
set.setValues(values);
|
||||
chart.getData().notifyDataChanged();
|
||||
chart.notifyDataSetChanged();
|
||||
} else {
|
||||
set = new BarDataSet(values, "Values");
|
||||
set.setColors(colors);
|
||||
set.setValueTextColors(colors);
|
||||
|
||||
BarData data = new BarData(set);
|
||||
data.setValueTextSize(13f);
|
||||
data.setValueTypeface(tfRegular);
|
||||
data.setValueFormatter(new Formatter());
|
||||
data.setBarWidth(0.8f);
|
||||
|
||||
chart.setData(data);
|
||||
chart.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Demo class representing data.
|
||||
*/
|
||||
private class Data {
|
||||
|
||||
final String xAxisValue;
|
||||
final float yValue;
|
||||
final float xValue;
|
||||
|
||||
Data(float xValue, float yValue, String xAxisValue) {
|
||||
this.xAxisValue = xAxisValue;
|
||||
this.yValue = yValue;
|
||||
this.xValue = xValue;
|
||||
}
|
||||
}
|
||||
|
||||
private class Formatter extends ValueFormatter
|
||||
{
|
||||
|
||||
private final DecimalFormat mFormat;
|
||||
|
||||
Formatter() {
|
||||
mFormat = new DecimalFormat("######.0");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFormattedValue(float value) {
|
||||
return mFormat.format(value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.only_github, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.viewGithub: {
|
||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||
i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/BarChartPositiveNegative.java"));
|
||||
startActivity(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveToGallery() { /* Intentionally left empty */ }
|
||||
}
|
|
@ -0,0 +1,248 @@
|
|||
|
||||
package com.xxmassdeveloper.mpchartexample;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.github.mikephil.charting.charts.BubbleChart;
|
||||
import com.github.mikephil.charting.components.Legend;
|
||||
import com.github.mikephil.charting.components.XAxis;
|
||||
import com.github.mikephil.charting.components.YAxis;
|
||||
import com.github.mikephil.charting.data.BubbleData;
|
||||
import com.github.mikephil.charting.data.BubbleDataSet;
|
||||
import com.github.mikephil.charting.data.BubbleEntry;
|
||||
import com.github.mikephil.charting.data.Entry;
|
||||
import com.github.mikephil.charting.highlight.Highlight;
|
||||
import com.github.mikephil.charting.interfaces.datasets.IBubbleDataSet;
|
||||
import com.github.mikephil.charting.interfaces.datasets.IDataSet;
|
||||
import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
|
||||
import com.github.mikephil.charting.utils.ColorTemplate;
|
||||
import com.github.mikephil.charting.utils.MPPointF;
|
||||
import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class BubbleChartActivity extends DemoBase implements OnSeekBarChangeListener,
|
||||
OnChartValueSelectedListener {
|
||||
|
||||
private BubbleChart chart;
|
||||
private SeekBar seekBarX, seekBarY;
|
||||
private TextView tvX, tvY;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_bubblechart);
|
||||
|
||||
setTitle("BubbleChartActivity");
|
||||
|
||||
tvX = findViewById(R.id.tvXMax);
|
||||
tvY = findViewById(R.id.tvYMax);
|
||||
|
||||
seekBarX = findViewById(R.id.seekBar1);
|
||||
seekBarX.setOnSeekBarChangeListener(this);
|
||||
|
||||
seekBarY = findViewById(R.id.seekBar2);
|
||||
seekBarY.setOnSeekBarChangeListener(this);
|
||||
|
||||
chart = findViewById(R.id.chart1);
|
||||
chart.getDescription().setEnabled(false);
|
||||
|
||||
chart.setOnChartValueSelectedListener(this);
|
||||
|
||||
chart.setDrawGridBackground(false);
|
||||
|
||||
chart.setTouchEnabled(true);
|
||||
|
||||
// enable scaling and dragging
|
||||
chart.setDragEnabled(true);
|
||||
chart.setScaleEnabled(true);
|
||||
|
||||
chart.setMaxVisibleValueCount(200);
|
||||
chart.setPinchZoom(true);
|
||||
|
||||
seekBarX.setProgress(10);
|
||||
seekBarY.setProgress(50);
|
||||
|
||||
Legend l = chart.getLegend();
|
||||
l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
|
||||
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.RIGHT);
|
||||
l.setOrientation(Legend.LegendOrientation.VERTICAL);
|
||||
l.setDrawInside(false);
|
||||
l.setTypeface(tfLight);
|
||||
|
||||
YAxis yl = chart.getAxisLeft();
|
||||
yl.setTypeface(tfLight);
|
||||
yl.setSpaceTop(30f);
|
||||
yl.setSpaceBottom(30f);
|
||||
yl.setDrawZeroLine(false);
|
||||
|
||||
chart.getAxisRight().setEnabled(false);
|
||||
|
||||
XAxis xl = chart.getXAxis();
|
||||
xl.setPosition(XAxis.XAxisPosition.BOTTOM);
|
||||
xl.setTypeface(tfLight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
|
||||
int count = seekBarX.getProgress();
|
||||
int range = seekBarY.getProgress();
|
||||
|
||||
tvX.setText(String.valueOf(count));
|
||||
tvY.setText(String.valueOf(range));
|
||||
|
||||
ArrayList<BubbleEntry> values1 = new ArrayList<>();
|
||||
ArrayList<BubbleEntry> values2 = new ArrayList<>();
|
||||
ArrayList<BubbleEntry> values3 = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
values1.add(new BubbleEntry(i, (float) (Math.random() * range), (float) (Math.random() * range), getResources().getDrawable(R.drawable.star)));
|
||||
values2.add(new BubbleEntry(i, (float) (Math.random() * range), (float) (Math.random() * range), getResources().getDrawable(R.drawable.star)));
|
||||
values3.add(new BubbleEntry(i, (float) (Math.random() * range), (float) (Math.random() * range)));
|
||||
}
|
||||
|
||||
// create a dataset and give it a type
|
||||
BubbleDataSet set1 = new BubbleDataSet(values1, "DS 1");
|
||||
set1.setDrawIcons(false);
|
||||
set1.setColor(ColorTemplate.COLORFUL_COLORS[0], 130);
|
||||
set1.setDrawValues(true);
|
||||
|
||||
BubbleDataSet set2 = new BubbleDataSet(values2, "DS 2");
|
||||
set2.setDrawIcons(false);
|
||||
set2.setIconsOffset(new MPPointF(0, 15));
|
||||
set2.setColor(ColorTemplate.COLORFUL_COLORS[1], 130);
|
||||
set2.setDrawValues(true);
|
||||
|
||||
BubbleDataSet set3 = new BubbleDataSet(values3, "DS 3");
|
||||
set3.setColor(ColorTemplate.COLORFUL_COLORS[2], 130);
|
||||
set3.setDrawValues(true);
|
||||
|
||||
ArrayList<IBubbleDataSet> dataSets = new ArrayList<>();
|
||||
dataSets.add(set1); // add the data sets
|
||||
dataSets.add(set2);
|
||||
dataSets.add(set3);
|
||||
|
||||
// create a data object with the data sets
|
||||
BubbleData data = new BubbleData(dataSets);
|
||||
data.setDrawValues(false);
|
||||
data.setValueTypeface(tfLight);
|
||||
data.setValueTextSize(8f);
|
||||
data.setValueTextColor(Color.WHITE);
|
||||
data.setHighlightCircleWidth(1.5f);
|
||||
|
||||
chart.setData(data);
|
||||
chart.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.bubble, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.viewGithub: {
|
||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||
i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/BubbleChartActivity.java"));
|
||||
startActivity(i);
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleValues: {
|
||||
for (IDataSet set : chart.getData().getDataSets())
|
||||
set.setDrawValues(!set.isDrawValuesEnabled());
|
||||
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleIcons: {
|
||||
for (IDataSet set : chart.getData().getDataSets())
|
||||
set.setDrawIcons(!set.isDrawIconsEnabled());
|
||||
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleHighlight: {
|
||||
if(chart.getData() != null) {
|
||||
chart.getData().setHighlightEnabled(!chart.getData().isHighlightEnabled());
|
||||
chart.invalidate();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case R.id.actionTogglePinch: {
|
||||
if (chart.isPinchZoomEnabled())
|
||||
chart.setPinchZoom(false);
|
||||
else
|
||||
chart.setPinchZoom(true);
|
||||
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleAutoScaleMinMax: {
|
||||
chart.setAutoScaleMinMaxEnabled(!chart.isAutoScaleMinMaxEnabled());
|
||||
chart.notifyDataSetChanged();
|
||||
break;
|
||||
}
|
||||
case R.id.actionSave: {
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
|
||||
saveToGallery();
|
||||
} else {
|
||||
requestStoragePermission(chart);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case R.id.animateX: {
|
||||
chart.animateX(2000);
|
||||
break;
|
||||
}
|
||||
case R.id.animateY: {
|
||||
chart.animateY(2000);
|
||||
break;
|
||||
}
|
||||
case R.id.animateXY: {
|
||||
chart.animateXY(2000, 2000);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void saveToGallery() {
|
||||
saveToGallery(chart, "BubbleChartActivity");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueSelected(Entry e, Highlight h) {
|
||||
Log.i("VAL SELECTED",
|
||||
"Value: " + e.getY() + ", xIndex: " + e.getX()
|
||||
+ ", DataSet index: " + h.getDataSetIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected() {}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {}
|
||||
}
|
|
@ -0,0 +1,238 @@
|
|||
|
||||
package com.xxmassdeveloper.mpchartexample;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.github.mikephil.charting.charts.CandleStickChart;
|
||||
import com.github.mikephil.charting.components.XAxis;
|
||||
import com.github.mikephil.charting.components.XAxis.XAxisPosition;
|
||||
import com.github.mikephil.charting.components.YAxis;
|
||||
import com.github.mikephil.charting.components.YAxis.AxisDependency;
|
||||
import com.github.mikephil.charting.data.CandleData;
|
||||
import com.github.mikephil.charting.data.CandleDataSet;
|
||||
import com.github.mikephil.charting.data.CandleEntry;
|
||||
import com.github.mikephil.charting.interfaces.datasets.ICandleDataSet;
|
||||
import com.github.mikephil.charting.interfaces.datasets.IDataSet;
|
||||
import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class CandleStickChartActivity extends DemoBase implements OnSeekBarChangeListener {
|
||||
|
||||
private CandleStickChart chart;
|
||||
private SeekBar seekBarX, seekBarY;
|
||||
private TextView tvX, tvY;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_candlechart);
|
||||
|
||||
setTitle("CandleStickChartActivity");
|
||||
|
||||
tvX = findViewById(R.id.tvXMax);
|
||||
tvY = findViewById(R.id.tvYMax);
|
||||
|
||||
seekBarX = findViewById(R.id.seekBar1);
|
||||
seekBarX.setOnSeekBarChangeListener(this);
|
||||
|
||||
seekBarY = findViewById(R.id.seekBar2);
|
||||
seekBarY.setOnSeekBarChangeListener(this);
|
||||
|
||||
chart = findViewById(R.id.chart1);
|
||||
chart.setBackgroundColor(Color.WHITE);
|
||||
|
||||
chart.getDescription().setEnabled(false);
|
||||
|
||||
// if more than 60 entries are displayed in the chart, no values will be
|
||||
// drawn
|
||||
chart.setMaxVisibleValueCount(60);
|
||||
|
||||
// scaling can now only be done on x- and y-axis separately
|
||||
chart.setPinchZoom(false);
|
||||
|
||||
chart.setDrawGridBackground(false);
|
||||
|
||||
XAxis xAxis = chart.getXAxis();
|
||||
xAxis.setPosition(XAxisPosition.BOTTOM);
|
||||
xAxis.setDrawGridLines(false);
|
||||
|
||||
YAxis leftAxis = chart.getAxisLeft();
|
||||
// leftAxis.setEnabled(false);
|
||||
leftAxis.setLabelCount(7, false);
|
||||
leftAxis.setDrawGridLines(false);
|
||||
leftAxis.setDrawAxisLine(false);
|
||||
|
||||
YAxis rightAxis = chart.getAxisRight();
|
||||
rightAxis.setEnabled(false);
|
||||
// rightAxis.setStartAtZero(false);
|
||||
|
||||
// setting data
|
||||
seekBarX.setProgress(40);
|
||||
seekBarY.setProgress(100);
|
||||
|
||||
chart.getLegend().setEnabled(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
|
||||
progress = (seekBarX.getProgress());
|
||||
|
||||
tvX.setText(String.valueOf(progress));
|
||||
tvY.setText(String.valueOf(seekBarY.getProgress()));
|
||||
|
||||
chart.resetTracking();
|
||||
|
||||
ArrayList<CandleEntry> values = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < progress; i++) {
|
||||
float multi = (seekBarY.getProgress() + 1);
|
||||
float val = (float) (Math.random() * 40) + multi;
|
||||
|
||||
float high = (float) (Math.random() * 9) + 8f;
|
||||
float low = (float) (Math.random() * 9) + 8f;
|
||||
|
||||
float open = (float) (Math.random() * 6) + 1f;
|
||||
float close = (float) (Math.random() * 6) + 1f;
|
||||
|
||||
boolean even = i % 2 == 0;
|
||||
|
||||
values.add(new CandleEntry(
|
||||
i, val + high,
|
||||
val - low,
|
||||
even ? val + open : val - open,
|
||||
even ? val - close : val + close,
|
||||
getResources().getDrawable(R.drawable.star)
|
||||
));
|
||||
}
|
||||
|
||||
CandleDataSet set1 = new CandleDataSet(values, "Data Set");
|
||||
|
||||
set1.setDrawIcons(false);
|
||||
set1.setAxisDependency(AxisDependency.LEFT);
|
||||
// set1.setColor(Color.rgb(80, 80, 80));
|
||||
set1.setShadowColor(Color.DKGRAY);
|
||||
set1.setShadowWidth(0.7f);
|
||||
set1.setDecreasingColor(Color.RED);
|
||||
set1.setDecreasingPaintStyle(Paint.Style.FILL);
|
||||
set1.setIncreasingColor(Color.rgb(122, 242, 84));
|
||||
set1.setIncreasingPaintStyle(Paint.Style.STROKE);
|
||||
set1.setNeutralColor(Color.BLUE);
|
||||
//set1.setHighlightLineWidth(1f);
|
||||
|
||||
CandleData data = new CandleData(set1);
|
||||
|
||||
chart.setData(data);
|
||||
chart.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.candle, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.viewGithub: {
|
||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||
i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/CandleStickChartActivity.java"));
|
||||
startActivity(i);
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleValues: {
|
||||
for (IDataSet set : chart.getData().getDataSets())
|
||||
set.setDrawValues(!set.isDrawValuesEnabled());
|
||||
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleIcons: {
|
||||
for (IDataSet set : chart.getData().getDataSets())
|
||||
set.setDrawIcons(!set.isDrawIconsEnabled());
|
||||
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleHighlight: {
|
||||
if(chart.getData() != null) {
|
||||
chart.getData().setHighlightEnabled(!chart.getData().isHighlightEnabled());
|
||||
chart.invalidate();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case R.id.actionTogglePinch: {
|
||||
if (chart.isPinchZoomEnabled())
|
||||
chart.setPinchZoom(false);
|
||||
else
|
||||
chart.setPinchZoom(true);
|
||||
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleAutoScaleMinMax: {
|
||||
chart.setAutoScaleMinMaxEnabled(!chart.isAutoScaleMinMaxEnabled());
|
||||
chart.notifyDataSetChanged();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleMakeShadowSameColorAsCandle: {
|
||||
for (ICandleDataSet set : chart.getData().getDataSets()) {
|
||||
((CandleDataSet) set).setShadowColorSameAsCandle(!set.getShadowColorSameAsCandle());
|
||||
}
|
||||
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.animateX: {
|
||||
chart.animateX(2000);
|
||||
break;
|
||||
}
|
||||
case R.id.animateY: {
|
||||
chart.animateY(2000);
|
||||
break;
|
||||
}
|
||||
case R.id.animateXY: {
|
||||
chart.animateXY(2000, 2000);
|
||||
break;
|
||||
}
|
||||
case R.id.actionSave: {
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
|
||||
saveToGallery();
|
||||
} else {
|
||||
requestStoragePermission(chart);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void saveToGallery() {
|
||||
saveToGallery(chart, "CandleStickChartActivity");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {}
|
||||
}
|
|
@ -0,0 +1,280 @@
|
|||
package com.xxmassdeveloper.mpchartexample;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.github.mikephil.charting.charts.CombinedChart;
|
||||
import com.github.mikephil.charting.charts.CombinedChart.DrawOrder;
|
||||
import com.github.mikephil.charting.components.Legend;
|
||||
import com.github.mikephil.charting.components.XAxis;
|
||||
import com.github.mikephil.charting.components.XAxis.XAxisPosition;
|
||||
import com.github.mikephil.charting.components.YAxis;
|
||||
import com.github.mikephil.charting.data.BarData;
|
||||
import com.github.mikephil.charting.data.BarDataSet;
|
||||
import com.github.mikephil.charting.data.BarEntry;
|
||||
import com.github.mikephil.charting.data.BubbleData;
|
||||
import com.github.mikephil.charting.data.BubbleDataSet;
|
||||
import com.github.mikephil.charting.data.BubbleEntry;
|
||||
import com.github.mikephil.charting.data.CandleData;
|
||||
import com.github.mikephil.charting.data.CandleDataSet;
|
||||
import com.github.mikephil.charting.data.CandleEntry;
|
||||
import com.github.mikephil.charting.data.CombinedData;
|
||||
import com.github.mikephil.charting.data.Entry;
|
||||
import com.github.mikephil.charting.data.LineData;
|
||||
import com.github.mikephil.charting.data.LineDataSet;
|
||||
import com.github.mikephil.charting.data.ScatterData;
|
||||
import com.github.mikephil.charting.data.ScatterDataSet;
|
||||
import com.github.mikephil.charting.formatter.ValueFormatter;
|
||||
import com.github.mikephil.charting.interfaces.datasets.IDataSet;
|
||||
import com.github.mikephil.charting.utils.ColorTemplate;
|
||||
import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class CombinedChartActivity extends DemoBase {
|
||||
|
||||
private CombinedChart chart;
|
||||
private final int count = 12;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_combined);
|
||||
|
||||
setTitle("CombinedChartActivity");
|
||||
|
||||
chart = findViewById(R.id.chart1);
|
||||
chart.getDescription().setEnabled(false);
|
||||
chart.setBackgroundColor(Color.WHITE);
|
||||
chart.setDrawGridBackground(false);
|
||||
chart.setDrawBarShadow(false);
|
||||
chart.setHighlightFullBarEnabled(false);
|
||||
|
||||
// draw bars behind lines
|
||||
chart.setDrawOrder(new DrawOrder[]{
|
||||
DrawOrder.BAR, DrawOrder.BUBBLE, DrawOrder.CANDLE, DrawOrder.LINE, DrawOrder.SCATTER
|
||||
});
|
||||
|
||||
Legend l = chart.getLegend();
|
||||
l.setWordWrapEnabled(true);
|
||||
l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
|
||||
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
|
||||
l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
|
||||
l.setDrawInside(false);
|
||||
|
||||
YAxis rightAxis = chart.getAxisRight();
|
||||
rightAxis.setDrawGridLines(false);
|
||||
rightAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
|
||||
|
||||
YAxis leftAxis = chart.getAxisLeft();
|
||||
leftAxis.setDrawGridLines(false);
|
||||
leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
|
||||
|
||||
XAxis xAxis = chart.getXAxis();
|
||||
xAxis.setPosition(XAxisPosition.BOTH_SIDED);
|
||||
xAxis.setAxisMinimum(0f);
|
||||
xAxis.setGranularity(1f);
|
||||
xAxis.setValueFormatter(new ValueFormatter() {
|
||||
@Override
|
||||
public String getFormattedValue(float value) {
|
||||
return months[(int) value % months.length];
|
||||
}
|
||||
});
|
||||
|
||||
CombinedData data = new CombinedData();
|
||||
|
||||
data.setData(generateLineData());
|
||||
data.setData(generateBarData());
|
||||
data.setData(generateBubbleData());
|
||||
data.setData(generateScatterData());
|
||||
data.setData(generateCandleData());
|
||||
data.setValueTypeface(tfLight);
|
||||
|
||||
xAxis.setAxisMaximum(data.getXMax() + 0.25f);
|
||||
|
||||
chart.setData(data);
|
||||
chart.invalidate();
|
||||
}
|
||||
|
||||
private LineData generateLineData() {
|
||||
|
||||
LineData d = new LineData();
|
||||
|
||||
ArrayList<Entry> entries = new ArrayList<>();
|
||||
|
||||
for (int index = 0; index < count; index++)
|
||||
entries.add(new Entry(index + 0.5f, getRandom(15, 5)));
|
||||
|
||||
LineDataSet set = new LineDataSet(entries, "Line DataSet");
|
||||
set.setColor(Color.rgb(240, 238, 70));
|
||||
set.setLineWidth(2.5f);
|
||||
set.setCircleColor(Color.rgb(240, 238, 70));
|
||||
set.setCircleRadius(5f);
|
||||
set.setFillColor(Color.rgb(240, 238, 70));
|
||||
set.setMode(LineDataSet.Mode.CUBIC_BEZIER);
|
||||
set.setDrawValues(true);
|
||||
set.setValueTextSize(10f);
|
||||
set.setValueTextColor(Color.rgb(240, 238, 70));
|
||||
|
||||
set.setAxisDependency(YAxis.AxisDependency.LEFT);
|
||||
d.addDataSet(set);
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
private BarData generateBarData() {
|
||||
|
||||
ArrayList<BarEntry> entries1 = new ArrayList<>();
|
||||
ArrayList<BarEntry> entries2 = new ArrayList<>();
|
||||
|
||||
for (int index = 0; index < count; index++) {
|
||||
entries1.add(new BarEntry(0, getRandom(25, 25)));
|
||||
|
||||
// stacked
|
||||
entries2.add(new BarEntry(0, new float[]{getRandom(13, 12), getRandom(13, 12)}));
|
||||
}
|
||||
|
||||
BarDataSet set1 = new BarDataSet(entries1, "Bar 1");
|
||||
set1.setColor(Color.rgb(60, 220, 78));
|
||||
set1.setValueTextColor(Color.rgb(60, 220, 78));
|
||||
set1.setValueTextSize(10f);
|
||||
set1.setAxisDependency(YAxis.AxisDependency.LEFT);
|
||||
|
||||
BarDataSet set2 = new BarDataSet(entries2, "");
|
||||
set2.setStackLabels(new String[]{"Stack 1", "Stack 2"});
|
||||
set2.setColors(Color.rgb(61, 165, 255), Color.rgb(23, 197, 255));
|
||||
set2.setValueTextColor(Color.rgb(61, 165, 255));
|
||||
set2.setValueTextSize(10f);
|
||||
set2.setAxisDependency(YAxis.AxisDependency.LEFT);
|
||||
|
||||
float groupSpace = 0.06f;
|
||||
float barSpace = 0.02f; // x2 dataset
|
||||
float barWidth = 0.45f; // x2 dataset
|
||||
// (0.45 + 0.02) * 2 + 0.06 = 1.00 -> interval per "group"
|
||||
|
||||
BarData d = new BarData(set1, set2);
|
||||
d.setBarWidth(barWidth);
|
||||
|
||||
// make this BarData object grouped
|
||||
d.groupBars(0, groupSpace, barSpace); // start at x = 0
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
private ScatterData generateScatterData() {
|
||||
|
||||
ScatterData d = new ScatterData();
|
||||
|
||||
ArrayList<Entry> entries = new ArrayList<>();
|
||||
|
||||
for (float index = 0; index < count; index += 0.5f)
|
||||
entries.add(new Entry(index + 0.25f, getRandom(10, 55)));
|
||||
|
||||
ScatterDataSet set = new ScatterDataSet(entries, "Scatter DataSet");
|
||||
set.setColors(ColorTemplate.MATERIAL_COLORS);
|
||||
set.setScatterShapeSize(7.5f);
|
||||
set.setDrawValues(false);
|
||||
set.setValueTextSize(10f);
|
||||
d.addDataSet(set);
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
private CandleData generateCandleData() {
|
||||
|
||||
CandleData d = new CandleData();
|
||||
|
||||
ArrayList<CandleEntry> entries = new ArrayList<>();
|
||||
|
||||
for (int index = 0; index < count; index += 2)
|
||||
entries.add(new CandleEntry(index + 1f, 90, 70, 85, 75f));
|
||||
|
||||
CandleDataSet set = new CandleDataSet(entries, "Candle DataSet");
|
||||
set.setDecreasingColor(Color.rgb(142, 150, 175));
|
||||
set.setShadowColor(Color.DKGRAY);
|
||||
set.setBarSpace(0.3f);
|
||||
set.setValueTextSize(10f);
|
||||
set.setDrawValues(false);
|
||||
d.addDataSet(set);
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
private BubbleData generateBubbleData() {
|
||||
|
||||
BubbleData bd = new BubbleData();
|
||||
|
||||
ArrayList<BubbleEntry> entries = new ArrayList<>();
|
||||
|
||||
for (int index = 0; index < count; index++) {
|
||||
float y = getRandom(10, 105);
|
||||
float size = getRandom(100, 105);
|
||||
entries.add(new BubbleEntry(index + 0.5f, y, size));
|
||||
}
|
||||
|
||||
BubbleDataSet set = new BubbleDataSet(entries, "Bubble DataSet");
|
||||
set.setColors(ColorTemplate.VORDIPLOM_COLORS);
|
||||
set.setValueTextSize(10f);
|
||||
set.setValueTextColor(Color.WHITE);
|
||||
set.setHighlightCircleWidth(1.5f);
|
||||
set.setDrawValues(true);
|
||||
bd.addDataSet(set);
|
||||
|
||||
return bd;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.combined, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.viewGithub: {
|
||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||
i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/CombinedChartActivity.java"));
|
||||
startActivity(i);
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleLineValues: {
|
||||
for (IDataSet set : chart.getData().getDataSets()) {
|
||||
if (set instanceof LineDataSet)
|
||||
set.setDrawValues(!set.isDrawValuesEnabled());
|
||||
}
|
||||
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleBarValues: {
|
||||
for (IDataSet set : chart.getData().getDataSets()) {
|
||||
if (set instanceof BarDataSet)
|
||||
set.setDrawValues(!set.isDrawValuesEnabled());
|
||||
}
|
||||
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionRemoveDataSet: {
|
||||
int rnd = (int) getRandom(chart.getData().getDataSetCount(), 0);
|
||||
chart.getData().removeDataSet(chart.getData().getDataSetByIndex(rnd));
|
||||
chart.getData().notifyDataChanged();
|
||||
chart.notifyDataSetChanged();
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveToGallery() { /* Intentionally left empty */ }
|
||||
}
|
|
@ -0,0 +1,320 @@
|
|||
|
||||
package com.xxmassdeveloper.mpchartexample;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.github.mikephil.charting.charts.LineChart;
|
||||
import com.github.mikephil.charting.components.XAxis;
|
||||
import com.github.mikephil.charting.components.YAxis;
|
||||
import com.github.mikephil.charting.data.Entry;
|
||||
import com.github.mikephil.charting.data.LineData;
|
||||
import com.github.mikephil.charting.data.LineDataSet;
|
||||
import com.github.mikephil.charting.formatter.IFillFormatter;
|
||||
import com.github.mikephil.charting.interfaces.dataprovider.LineDataProvider;
|
||||
import com.github.mikephil.charting.interfaces.datasets.IDataSet;
|
||||
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
|
||||
import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CubicLineChartActivity extends DemoBase implements OnSeekBarChangeListener {
|
||||
|
||||
private LineChart chart;
|
||||
private SeekBar seekBarX, seekBarY;
|
||||
private TextView tvX, tvY;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_linechart);
|
||||
|
||||
setTitle("CubicLineChartActivity");
|
||||
|
||||
tvX = findViewById(R.id.tvXMax);
|
||||
tvY = findViewById(R.id.tvYMax);
|
||||
|
||||
seekBarX = findViewById(R.id.seekBar1);
|
||||
seekBarY = findViewById(R.id.seekBar2);
|
||||
|
||||
chart = findViewById(R.id.chart1);
|
||||
chart.setViewPortOffsets(0, 0, 0, 0);
|
||||
chart.setBackgroundColor(Color.rgb(104, 241, 175));
|
||||
|
||||
// no description text
|
||||
chart.getDescription().setEnabled(false);
|
||||
|
||||
// enable touch gestures
|
||||
chart.setTouchEnabled(true);
|
||||
|
||||
// enable scaling and dragging
|
||||
chart.setDragEnabled(true);
|
||||
chart.setScaleEnabled(true);
|
||||
|
||||
// if disabled, scaling can be done on x- and y-axis separately
|
||||
chart.setPinchZoom(false);
|
||||
|
||||
chart.setDrawGridBackground(false);
|
||||
chart.setMaxHighlightDistance(300);
|
||||
|
||||
XAxis x = chart.getXAxis();
|
||||
x.setEnabled(false);
|
||||
|
||||
YAxis y = chart.getAxisLeft();
|
||||
y.setTypeface(tfLight);
|
||||
y.setLabelCount(6, false);
|
||||
y.setTextColor(Color.WHITE);
|
||||
y.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
|
||||
y.setDrawGridLines(false);
|
||||
y.setAxisLineColor(Color.WHITE);
|
||||
|
||||
chart.getAxisRight().setEnabled(false);
|
||||
|
||||
// add data
|
||||
seekBarY.setOnSeekBarChangeListener(this);
|
||||
seekBarX.setOnSeekBarChangeListener(this);
|
||||
|
||||
// lower max, as cubic runs significantly slower than linear
|
||||
seekBarX.setMax(700);
|
||||
|
||||
seekBarX.setProgress(45);
|
||||
seekBarY.setProgress(100);
|
||||
|
||||
chart.getLegend().setEnabled(false);
|
||||
|
||||
chart.animateXY(2000, 2000);
|
||||
|
||||
// don't forget to refresh the drawing
|
||||
chart.invalidate();
|
||||
}
|
||||
|
||||
private void setData(int count, float range) {
|
||||
|
||||
ArrayList<Entry> values = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
float val = (float) (Math.random() * (range + 1)) + 20;
|
||||
values.add(new Entry(i, val));
|
||||
}
|
||||
|
||||
LineDataSet set1;
|
||||
|
||||
if (chart.getData() != null &&
|
||||
chart.getData().getDataSetCount() > 0) {
|
||||
set1 = (LineDataSet) chart.getData().getDataSetByIndex(0);
|
||||
set1.setValues(values);
|
||||
chart.getData().notifyDataChanged();
|
||||
chart.notifyDataSetChanged();
|
||||
} else {
|
||||
// create a dataset and give it a type
|
||||
set1 = new LineDataSet(values, "DataSet 1");
|
||||
|
||||
set1.setMode(LineDataSet.Mode.CUBIC_BEZIER);
|
||||
set1.setCubicIntensity(0.2f);
|
||||
set1.setDrawFilled(true);
|
||||
set1.setDrawCircles(false);
|
||||
set1.setLineWidth(1.8f);
|
||||
set1.setCircleRadius(4f);
|
||||
set1.setCircleColor(Color.WHITE);
|
||||
set1.setHighLightColor(Color.rgb(244, 117, 117));
|
||||
set1.setColor(Color.WHITE);
|
||||
set1.setFillColor(Color.WHITE);
|
||||
set1.setFillAlpha(100);
|
||||
set1.setDrawHorizontalHighlightIndicator(false);
|
||||
set1.setFillFormatter(new IFillFormatter() {
|
||||
@Override
|
||||
public float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider) {
|
||||
return chart.getAxisLeft().getAxisMinimum();
|
||||
}
|
||||
});
|
||||
|
||||
// create a data object with the data sets
|
||||
LineData data = new LineData(set1);
|
||||
data.setValueTypeface(tfLight);
|
||||
data.setValueTextSize(9f);
|
||||
data.setDrawValues(false);
|
||||
|
||||
// set data
|
||||
chart.setData(data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.line, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.viewGithub: {
|
||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||
i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/CubicLineChartActivity.java"));
|
||||
startActivity(i);
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleValues: {
|
||||
for (IDataSet set : chart.getData().getDataSets())
|
||||
set.setDrawValues(!set.isDrawValuesEnabled());
|
||||
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleHighlight: {
|
||||
if(chart.getData() != null) {
|
||||
chart.getData().setHighlightEnabled(!chart.getData().isHighlightEnabled());
|
||||
chart.invalidate();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleFilled: {
|
||||
|
||||
List<ILineDataSet> sets = chart.getData()
|
||||
.getDataSets();
|
||||
|
||||
for (ILineDataSet iSet : sets) {
|
||||
|
||||
LineDataSet set = (LineDataSet) iSet;
|
||||
|
||||
if (set.isDrawFilledEnabled())
|
||||
set.setDrawFilled(false);
|
||||
else
|
||||
set.setDrawFilled(true);
|
||||
}
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleCircles: {
|
||||
List<ILineDataSet> sets = chart.getData()
|
||||
.getDataSets();
|
||||
|
||||
for (ILineDataSet iSet : sets) {
|
||||
|
||||
LineDataSet set = (LineDataSet) iSet;
|
||||
if (set.isDrawCirclesEnabled())
|
||||
set.setDrawCircles(false);
|
||||
else
|
||||
set.setDrawCircles(true);
|
||||
}
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleCubic: {
|
||||
List<ILineDataSet> sets = chart.getData()
|
||||
.getDataSets();
|
||||
|
||||
for (ILineDataSet iSet : sets) {
|
||||
|
||||
LineDataSet set = (LineDataSet) iSet;
|
||||
set.setMode(set.getMode() == LineDataSet.Mode.CUBIC_BEZIER
|
||||
? LineDataSet.Mode.LINEAR
|
||||
: LineDataSet.Mode.CUBIC_BEZIER);
|
||||
}
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleStepped: {
|
||||
List<ILineDataSet> sets = chart.getData()
|
||||
.getDataSets();
|
||||
|
||||
for (ILineDataSet iSet : sets) {
|
||||
|
||||
LineDataSet set = (LineDataSet) iSet;
|
||||
set.setMode(set.getMode() == LineDataSet.Mode.STEPPED
|
||||
? LineDataSet.Mode.LINEAR
|
||||
: LineDataSet.Mode.STEPPED);
|
||||
}
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleHorizontalCubic: {
|
||||
List<ILineDataSet> sets = chart.getData()
|
||||
.getDataSets();
|
||||
|
||||
for (ILineDataSet iSet : sets) {
|
||||
|
||||
LineDataSet set = (LineDataSet) iSet;
|
||||
set.setMode(set.getMode() == LineDataSet.Mode.HORIZONTAL_BEZIER
|
||||
? LineDataSet.Mode.LINEAR
|
||||
: LineDataSet.Mode.HORIZONTAL_BEZIER);
|
||||
}
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionTogglePinch: {
|
||||
if (chart.isPinchZoomEnabled())
|
||||
chart.setPinchZoom(false);
|
||||
else
|
||||
chart.setPinchZoom(true);
|
||||
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleAutoScaleMinMax: {
|
||||
chart.setAutoScaleMinMaxEnabled(!chart.isAutoScaleMinMaxEnabled());
|
||||
chart.notifyDataSetChanged();
|
||||
break;
|
||||
}
|
||||
case R.id.animateX: {
|
||||
chart.animateX(2000);
|
||||
break;
|
||||
}
|
||||
case R.id.animateY: {
|
||||
chart.animateY(2000);
|
||||
break;
|
||||
}
|
||||
case R.id.animateXY: {
|
||||
chart.animateXY(2000, 2000);
|
||||
break;
|
||||
}
|
||||
case R.id.actionSave: {
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
|
||||
saveToGallery();
|
||||
} else {
|
||||
requestStoragePermission(chart);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
|
||||
tvX.setText(String.valueOf(seekBarX.getProgress()));
|
||||
tvY.setText(String.valueOf(seekBarY.getProgress()));
|
||||
|
||||
setData(seekBarX.getProgress(), seekBarY.getProgress());
|
||||
|
||||
// redraw
|
||||
chart.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void saveToGallery() {
|
||||
saveToGallery(chart, "CubicLineChartActivity");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {}
|
||||
}
|
|
@ -0,0 +1,184 @@
|
|||
// TODO: Finish and add to main activity list
|
||||
package com.xxmassdeveloper.mpchartexample;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.github.mikephil.charting.charts.Chart;
|
||||
import com.github.mikephil.charting.charts.LineChart;
|
||||
import com.github.mikephil.charting.components.XAxis;
|
||||
import com.github.mikephil.charting.components.YAxis;
|
||||
import com.github.mikephil.charting.data.DataSet;
|
||||
import com.github.mikephil.charting.data.Entry;
|
||||
import com.github.mikephil.charting.data.LineData;
|
||||
import com.github.mikephil.charting.data.LineDataSet;
|
||||
import com.github.mikephil.charting.highlight.Highlight;
|
||||
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
|
||||
import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
|
||||
import com.github.mikephil.charting.listener.OnDrawListener;
|
||||
import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This Activity demonstrates drawing into the Chart with the finger. Both line,
|
||||
* bar and scatter charts can be used for drawing.
|
||||
*
|
||||
* @author Philipp Jahoda
|
||||
*/
|
||||
public class DrawChartActivity extends DemoBase implements OnChartValueSelectedListener,
|
||||
OnDrawListener {
|
||||
|
||||
private LineChart chart;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_draw_chart);
|
||||
|
||||
setTitle("DrawChartActivity");
|
||||
|
||||
chart = findViewById(R.id.chart1);
|
||||
|
||||
// listener for selecting and drawing
|
||||
chart.setOnChartValueSelectedListener(this);
|
||||
chart.setOnDrawListener(this);
|
||||
|
||||
// if disabled, drawn data sets with the finger will not be automatically
|
||||
// finished
|
||||
// chart.setAutoFinish(true);
|
||||
chart.setDrawGridBackground(false);
|
||||
|
||||
// add dummy-data to the chart
|
||||
initWithDummyData();
|
||||
|
||||
XAxis xl = chart.getXAxis();
|
||||
xl.setTypeface(tfRegular);
|
||||
xl.setAvoidFirstLastClipping(true);
|
||||
|
||||
YAxis yl = chart.getAxisLeft();
|
||||
yl.setTypeface(tfRegular);
|
||||
|
||||
chart.getLegend().setEnabled(false);
|
||||
|
||||
// chart.setYRange(-40f, 40f, true);
|
||||
// call this to reset the changed y-range
|
||||
// chart.resetYRange(true);
|
||||
}
|
||||
|
||||
private void initWithDummyData() {
|
||||
|
||||
ArrayList<Entry> values = new ArrayList<>();
|
||||
|
||||
// create a dataset and give it a type (0)
|
||||
LineDataSet set1 = new LineDataSet(values, "DataSet");
|
||||
set1.setLineWidth(3f);
|
||||
set1.setCircleRadius(5f);
|
||||
|
||||
// create a data object with the data sets
|
||||
LineData data = new LineData(set1);
|
||||
|
||||
chart.setData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.draw, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.actionToggleValues: {
|
||||
List<ILineDataSet> sets = chart.getData()
|
||||
.getDataSets();
|
||||
|
||||
for (ILineDataSet iSet : sets) {
|
||||
|
||||
LineDataSet set = (LineDataSet) iSet;
|
||||
set.setDrawValues(!set.isDrawValuesEnabled());
|
||||
}
|
||||
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleHighlight: {
|
||||
if(chart.getData() != null) {
|
||||
chart.getData().setHighlightEnabled(!chart.getData().isHighlightEnabled());
|
||||
chart.invalidate();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case R.id.actionTogglePinch: {
|
||||
if (chart.isPinchZoomEnabled())
|
||||
chart.setPinchZoom(false);
|
||||
else
|
||||
chart.setPinchZoom(true);
|
||||
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleAutoScaleMinMax: {
|
||||
chart.setAutoScaleMinMaxEnabled(!chart.isAutoScaleMinMaxEnabled());
|
||||
chart.notifyDataSetChanged();
|
||||
break;
|
||||
}
|
||||
case R.id.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, "DrawChartActivity");
|
||||
}
|
||||
|
||||
@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() {
|
||||
}
|
||||
|
||||
/** callback for each new entry drawn with the finger */
|
||||
@Override
|
||||
public void onEntryAdded(Entry entry) {
|
||||
Log.i(Chart.LOG_TAG, entry.toString());
|
||||
}
|
||||
|
||||
/** callback when a DataSet has been drawn (when lifting the finger) */
|
||||
@Override
|
||||
public void onDrawFinished(DataSet<?> dataSet) {
|
||||
Log.i(Chart.LOG_TAG, "DataSet drawn. " + dataSet.toSimpleString());
|
||||
|
||||
// prepare the legend again
|
||||
chart.getLegendRenderer().computeLegend(chart.getData());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntryMoved(Entry entry) {
|
||||
Log.i(Chart.LOG_TAG, "Point moved " + entry.toString());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,242 @@
|
|||
|
||||
package com.xxmassdeveloper.mpchartexample;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.github.mikephil.charting.charts.LineChart;
|
||||
import com.github.mikephil.charting.components.YAxis.AxisDependency;
|
||||
import com.github.mikephil.charting.data.Entry;
|
||||
import com.github.mikephil.charting.data.LineData;
|
||||
import com.github.mikephil.charting.data.LineDataSet;
|
||||
import com.github.mikephil.charting.highlight.Highlight;
|
||||
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
|
||||
import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
|
||||
import com.github.mikephil.charting.utils.ColorTemplate;
|
||||
import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class DynamicalAddingActivity extends DemoBase implements OnChartValueSelectedListener {
|
||||
|
||||
private LineChart chart;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_linechart_noseekbar);
|
||||
|
||||
setTitle("DynamicalAddingActivity");
|
||||
|
||||
chart = findViewById(R.id.chart1);
|
||||
chart.setOnChartValueSelectedListener(this);
|
||||
chart.setDrawGridBackground(false);
|
||||
chart.getDescription().setEnabled(false);
|
||||
chart.setNoDataText("No chart data available. Use the menu to add entries and data sets!");
|
||||
|
||||
// chart.getXAxis().setDrawLabels(false);
|
||||
// chart.getXAxis().setDrawGridLines(false);
|
||||
|
||||
chart.invalidate();
|
||||
}
|
||||
|
||||
private final int[] colors = ColorTemplate.VORDIPLOM_COLORS;
|
||||
|
||||
private void addEntry() {
|
||||
|
||||
LineData data = chart.getData();
|
||||
|
||||
if (data == null) {
|
||||
data = new LineData();
|
||||
chart.setData(data);
|
||||
}
|
||||
|
||||
ILineDataSet set = data.getDataSetByIndex(0);
|
||||
// set.addEntry(...); // can be called as well
|
||||
|
||||
if (set == null) {
|
||||
set = createSet();
|
||||
data.addDataSet(set);
|
||||
}
|
||||
|
||||
// choose a random dataSet
|
||||
int randomDataSetIndex = (int) (Math.random() * data.getDataSetCount());
|
||||
ILineDataSet randomSet = data.getDataSetByIndex(randomDataSetIndex);
|
||||
float value = (float) (Math.random() * 50) + 50f * (randomDataSetIndex + 1);
|
||||
|
||||
data.addEntry(new Entry(randomSet.getEntryCount(), value), randomDataSetIndex);
|
||||
data.notifyDataChanged();
|
||||
|
||||
// let the chart know it's data has changed
|
||||
chart.notifyDataSetChanged();
|
||||
|
||||
chart.setVisibleXRangeMaximum(6);
|
||||
//chart.setVisibleYRangeMaximum(15, AxisDependency.LEFT);
|
||||
//
|
||||
// // this automatically refreshes the chart (calls invalidate())
|
||||
chart.moveViewTo(data.getEntryCount() - 7, 50f, AxisDependency.LEFT);
|
||||
|
||||
}
|
||||
|
||||
private void removeLastEntry() {
|
||||
|
||||
LineData data = chart.getData();
|
||||
|
||||
if (data != null) {
|
||||
|
||||
ILineDataSet set = data.getDataSetByIndex(0);
|
||||
|
||||
if (set != null) {
|
||||
|
||||
Entry e = set.getEntryForXValue(set.getEntryCount() - 1, Float.NaN);
|
||||
|
||||
data.removeEntry(e, 0);
|
||||
// or remove by index
|
||||
// mData.removeEntryByXValue(xIndex, dataSetIndex);
|
||||
data.notifyDataChanged();
|
||||
chart.notifyDataSetChanged();
|
||||
chart.invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addDataSet() {
|
||||
|
||||
LineData data = chart.getData();
|
||||
|
||||
if (data == null) {
|
||||
chart.setData(new LineData());
|
||||
} else {
|
||||
int count = (data.getDataSetCount() + 1);
|
||||
int amount = data.getDataSetByIndex(0).getEntryCount();
|
||||
|
||||
ArrayList<Entry> values = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < amount; i++) {
|
||||
values.add(new Entry(i, (float) (Math.random() * 50f) + 50f * count));
|
||||
}
|
||||
|
||||
LineDataSet set = new LineDataSet(values, "DataSet " + count);
|
||||
set.setLineWidth(2.5f);
|
||||
set.setCircleRadius(4.5f);
|
||||
|
||||
int color = colors[count % colors.length];
|
||||
|
||||
set.setColor(color);
|
||||
set.setCircleColor(color);
|
||||
set.setHighLightColor(color);
|
||||
set.setValueTextSize(10f);
|
||||
set.setValueTextColor(color);
|
||||
|
||||
data.addDataSet(set);
|
||||
data.notifyDataChanged();
|
||||
chart.notifyDataSetChanged();
|
||||
chart.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private void removeDataSet() {
|
||||
|
||||
LineData data = chart.getData();
|
||||
|
||||
if (data != null) {
|
||||
|
||||
data.removeDataSet(data.getDataSetByIndex(data.getDataSetCount() - 1));
|
||||
|
||||
chart.notifyDataSetChanged();
|
||||
chart.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private LineDataSet createSet() {
|
||||
|
||||
LineDataSet set = new LineDataSet(null, "DataSet 1");
|
||||
set.setLineWidth(2.5f);
|
||||
set.setCircleRadius(4.5f);
|
||||
set.setColor(Color.rgb(240, 99, 99));
|
||||
set.setCircleColor(Color.rgb(240, 99, 99));
|
||||
set.setHighLightColor(Color.rgb(190, 190, 190));
|
||||
set.setAxisDependency(AxisDependency.LEFT);
|
||||
set.setValueTextSize(10f);
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueSelected(Entry e, Highlight h) {
|
||||
Toast.makeText(this, e.toString(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected() {}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.dynamical, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.viewGithub: {
|
||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||
i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/DynamicalAddingActivity.java"));
|
||||
startActivity(i);
|
||||
break;
|
||||
}
|
||||
case R.id.actionAddEntry: {
|
||||
addEntry();
|
||||
Toast.makeText(this, "Entry added!", Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
}
|
||||
case R.id.actionRemoveEntry: {
|
||||
removeLastEntry();
|
||||
Toast.makeText(this, "Entry removed!", Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
}
|
||||
case R.id.actionAddDataSet: {
|
||||
addDataSet();
|
||||
Toast.makeText(this, "DataSet added!", Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
}
|
||||
case R.id.actionRemoveDataSet: {
|
||||
removeDataSet();
|
||||
Toast.makeText(this, "DataSet removed!", Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
}
|
||||
case R.id.actionClear: {
|
||||
chart.clear();
|
||||
Toast.makeText(this, "Chart cleared!", Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
}
|
||||
case R.id.actionSave: {
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
|
||||
saveToGallery();
|
||||
} else {
|
||||
requestStoragePermission(chart);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void saveToGallery() {
|
||||
saveToGallery(chart, "DynamicalAddingActivity");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,189 @@
|
|||
|
||||
package com.xxmassdeveloper.mpchartexample;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.github.mikephil.charting.charts.LineChart;
|
||||
import com.github.mikephil.charting.components.Legend;
|
||||
import com.github.mikephil.charting.components.XAxis;
|
||||
import com.github.mikephil.charting.components.YAxis;
|
||||
import com.github.mikephil.charting.data.Entry;
|
||||
import com.github.mikephil.charting.data.LineData;
|
||||
import com.github.mikephil.charting.data.LineDataSet;
|
||||
import com.github.mikephil.charting.formatter.IFillFormatter;
|
||||
import com.github.mikephil.charting.interfaces.dataprovider.LineDataProvider;
|
||||
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
|
||||
import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* This works by inverting the background and desired "fill" color. First, we draw the fill color
|
||||
* that we want between the lines as the actual background of the chart. Then, we fill the area
|
||||
* above the highest line and the area under the lowest line with the desired background color.
|
||||
*
|
||||
* This method makes it look like we filled the area between the lines, but really we are filling
|
||||
* the area OUTSIDE the lines!
|
||||
*/
|
||||
@SuppressWarnings("SameParameterValue")
|
||||
public class FilledLineActivity extends DemoBase {
|
||||
|
||||
private LineChart chart;
|
||||
private final int fillColor = Color.argb(150, 51, 181, 229);
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_linechart_noseekbar);
|
||||
|
||||
setTitle("FilledLineActivity");
|
||||
|
||||
chart = findViewById(R.id.chart1);
|
||||
chart.setBackgroundColor(Color.WHITE);
|
||||
chart.setGridBackgroundColor(fillColor);
|
||||
chart.setDrawGridBackground(true);
|
||||
|
||||
chart.setDrawBorders(true);
|
||||
|
||||
// no description text
|
||||
chart.getDescription().setEnabled(false);
|
||||
|
||||
// if disabled, scaling can be done on x- and y-axis separately
|
||||
chart.setPinchZoom(false);
|
||||
|
||||
Legend l = chart.getLegend();
|
||||
l.setEnabled(false);
|
||||
|
||||
XAxis xAxis = chart.getXAxis();
|
||||
xAxis.setEnabled(false);
|
||||
|
||||
YAxis leftAxis = chart.getAxisLeft();
|
||||
leftAxis.setAxisMaximum(900f);
|
||||
leftAxis.setAxisMinimum(-250f);
|
||||
leftAxis.setDrawAxisLine(false);
|
||||
leftAxis.setDrawZeroLine(false);
|
||||
leftAxis.setDrawGridLines(false);
|
||||
|
||||
chart.getAxisRight().setEnabled(false);
|
||||
|
||||
// add data
|
||||
setData(100, 60);
|
||||
|
||||
chart.invalidate();
|
||||
}
|
||||
|
||||
private void setData(int count, float range) {
|
||||
|
||||
ArrayList<Entry> values1 = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
float val = (float) (Math.random() * range) + 50;
|
||||
values1.add(new Entry(i, val));
|
||||
}
|
||||
|
||||
ArrayList<Entry> values2 = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
float val = (float) (Math.random() * range) + 450;
|
||||
values2.add(new Entry(i, val));
|
||||
}
|
||||
|
||||
LineDataSet set1, set2;
|
||||
|
||||
if (chart.getData() != null &&
|
||||
chart.getData().getDataSetCount() > 0) {
|
||||
set1 = (LineDataSet) chart.getData().getDataSetByIndex(0);
|
||||
set2 = (LineDataSet) chart.getData().getDataSetByIndex(1);
|
||||
set1.setValues(values1);
|
||||
set2.setValues(values2);
|
||||
chart.getData().notifyDataChanged();
|
||||
chart.notifyDataSetChanged();
|
||||
} else {
|
||||
// create a dataset and give it a type
|
||||
set1 = new LineDataSet(values1, "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 IFillFormatter() {
|
||||
@Override
|
||||
public float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider) {
|
||||
// change the return value here to better understand the effect
|
||||
// return 0;
|
||||
return chart.getAxisLeft().getAxisMinimum();
|
||||
}
|
||||
});
|
||||
|
||||
// create a dataset and give it a type
|
||||
set2 = new LineDataSet(values2, "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 IFillFormatter() {
|
||||
@Override
|
||||
public float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider) {
|
||||
// change the return value here to better understand the effect
|
||||
// return 600;
|
||||
return chart.getAxisLeft().getAxisMaximum();
|
||||
}
|
||||
});
|
||||
|
||||
ArrayList<ILineDataSet> dataSets = new ArrayList<>();
|
||||
dataSets.add(set1); // add the data sets
|
||||
dataSets.add(set2);
|
||||
|
||||
// create a data object with the data sets
|
||||
LineData data = new LineData(dataSets);
|
||||
data.setDrawValues(false);
|
||||
|
||||
// set data
|
||||
chart.setData(data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.only_github, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.viewGithub: {
|
||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||
i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/FilledLineActivity.java"));
|
||||
startActivity(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveToGallery() { /* Intentionally left empty */ }
|
||||
}
|
|
@ -0,0 +1,168 @@
|
|||
|
||||
package com.xxmassdeveloper.mpchartexample;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.net.Uri;
|
||||
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.DisplayMetrics;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
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.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.utils.ColorTemplate;
|
||||
import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@SuppressWarnings("SameParameterValue")
|
||||
public class HalfPieChartActivity extends DemoBase {
|
||||
|
||||
private PieChart chart;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_piechart_half);
|
||||
|
||||
setTitle("HalfPieChartActivity");
|
||||
|
||||
chart = findViewById(R.id.chart1);
|
||||
chart.setBackgroundColor(Color.WHITE);
|
||||
|
||||
moveOffScreen();
|
||||
|
||||
chart.setUsePercentValues(true);
|
||||
chart.getDescription().setEnabled(false);
|
||||
|
||||
chart.setCenterTextTypeface(tfLight);
|
||||
chart.setCenterText(generateCenterSpannableText());
|
||||
|
||||
chart.setDrawHoleEnabled(true);
|
||||
chart.setHoleColor(Color.WHITE);
|
||||
|
||||
chart.setTransparentCircleColor(Color.WHITE);
|
||||
chart.setTransparentCircleAlpha(110);
|
||||
|
||||
chart.setHoleRadius(58f);
|
||||
chart.setTransparentCircleRadius(61f);
|
||||
|
||||
chart.setDrawCenterText(true);
|
||||
|
||||
chart.setRotationEnabled(false);
|
||||
chart.setHighlightPerTapEnabled(true);
|
||||
|
||||
chart.setMaxAngle(180f); // HALF CHART
|
||||
chart.setRotationAngle(180f);
|
||||
chart.setCenterTextOffset(0, -20);
|
||||
|
||||
setData(4, 100);
|
||||
|
||||
chart.animateY(1400, Easing.EaseInOutQuad);
|
||||
|
||||
Legend l = chart.getLegend();
|
||||
l.setVerticalAlignment(Legend.LegendVerticalAlignment.TOP);
|
||||
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
|
||||
l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
|
||||
l.setDrawInside(false);
|
||||
l.setXEntrySpace(7f);
|
||||
l.setYEntrySpace(0f);
|
||||
l.setYOffset(0f);
|
||||
|
||||
// entry label styling
|
||||
chart.setEntryLabelColor(Color.WHITE);
|
||||
chart.setEntryLabelTypeface(tfRegular);
|
||||
chart.setEntryLabelTextSize(12f);
|
||||
}
|
||||
|
||||
private void setData(int count, float range) {
|
||||
|
||||
ArrayList<PieEntry> values = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
values.add(new PieEntry((float) ((Math.random() * range) + range / 5), parties[i % parties.length]));
|
||||
}
|
||||
|
||||
PieDataSet dataSet = new PieDataSet(values, "Election Results");
|
||||
dataSet.setSliceSpace(3f);
|
||||
dataSet.setSelectionShift(5f);
|
||||
|
||||
dataSet.setColors(ColorTemplate.MATERIAL_COLORS);
|
||||
//dataSet.setSelectionShift(0f);
|
||||
|
||||
PieData data = new PieData(dataSet);
|
||||
data.setValueFormatter(new PercentFormatter());
|
||||
data.setValueTextSize(11f);
|
||||
data.setValueTextColor(Color.WHITE);
|
||||
data.setValueTypeface(tfLight);
|
||||
chart.setData(data);
|
||||
|
||||
chart.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;
|
||||
}
|
||||
|
||||
private void moveOffScreen() {
|
||||
|
||||
DisplayMetrics displayMetrics = new DisplayMetrics();
|
||||
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
||||
|
||||
int height = displayMetrics.heightPixels;
|
||||
|
||||
int offset = (int)(height * 0.65); /* percent to move */
|
||||
|
||||
RelativeLayout.LayoutParams rlParams =
|
||||
(RelativeLayout.LayoutParams) chart.getLayoutParams();
|
||||
rlParams.setMargins(0, 0, 0, -offset);
|
||||
chart.setLayoutParams(rlParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.only_github, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.viewGithub: {
|
||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||
i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/HalfPieChartActivity.java"));
|
||||
startActivity(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveToGallery() { /* Intentionally left empty */ }
|
||||
}
|
|
@ -0,0 +1,291 @@
|
|||
|
||||
package com.xxmassdeveloper.mpchartexample;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.RectF;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.github.mikephil.charting.charts.HorizontalBarChart;
|
||||
import com.github.mikephil.charting.components.Legend;
|
||||
import com.github.mikephil.charting.components.XAxis;
|
||||
import com.github.mikephil.charting.components.XAxis.XAxisPosition;
|
||||
import com.github.mikephil.charting.components.YAxis;
|
||||
import com.github.mikephil.charting.data.BarData;
|
||||
import com.github.mikephil.charting.data.BarDataSet;
|
||||
import com.github.mikephil.charting.data.BarEntry;
|
||||
import com.github.mikephil.charting.data.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.MPPointF;
|
||||
import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class HorizontalBarChartActivity extends DemoBase implements OnSeekBarChangeListener,
|
||||
OnChartValueSelectedListener {
|
||||
|
||||
private HorizontalBarChart 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_horizontalbarchart);
|
||||
|
||||
setTitle("HorizontalBarChartActivity");
|
||||
|
||||
tvX = findViewById(R.id.tvXMax);
|
||||
tvY = findViewById(R.id.tvYMax);
|
||||
|
||||
seekBarX = findViewById(R.id.seekBar1);
|
||||
seekBarY = findViewById(R.id.seekBar2);
|
||||
|
||||
seekBarY.setOnSeekBarChangeListener(this);
|
||||
seekBarX.setOnSeekBarChangeListener(this);
|
||||
|
||||
chart = findViewById(R.id.chart1);
|
||||
chart.setOnChartValueSelectedListener(this);
|
||||
// chart.setHighlightEnabled(false);
|
||||
|
||||
chart.setDrawBarShadow(false);
|
||||
|
||||
chart.setDrawValueAboveBar(true);
|
||||
|
||||
chart.getDescription().setEnabled(false);
|
||||
|
||||
// if more than 60 entries are displayed in the chart, no values will be
|
||||
// drawn
|
||||
chart.setMaxVisibleValueCount(60);
|
||||
|
||||
// scaling can now only be done on x- and y-axis separately
|
||||
chart.setPinchZoom(false);
|
||||
|
||||
// draw shadows for each bar that show the maximum value
|
||||
// chart.setDrawBarShadow(true);
|
||||
|
||||
chart.setDrawGridBackground(false);
|
||||
|
||||
XAxis xl = chart.getXAxis();
|
||||
xl.setPosition(XAxisPosition.BOTTOM);
|
||||
xl.setTypeface(tfLight);
|
||||
xl.setDrawAxisLine(true);
|
||||
xl.setDrawGridLines(false);
|
||||
xl.setGranularity(10f);
|
||||
|
||||
YAxis yl = chart.getAxisLeft();
|
||||
yl.setTypeface(tfLight);
|
||||
yl.setDrawAxisLine(true);
|
||||
yl.setDrawGridLines(true);
|
||||
yl.setAxisMinimum(0f); // this replaces setStartAtZero(true)
|
||||
// yl.setInverted(true);
|
||||
|
||||
YAxis yr = chart.getAxisRight();
|
||||
yr.setTypeface(tfLight);
|
||||
yr.setDrawAxisLine(true);
|
||||
yr.setDrawGridLines(false);
|
||||
yr.setAxisMinimum(0f); // this replaces setStartAtZero(true)
|
||||
// yr.setInverted(true);
|
||||
|
||||
chart.setFitBars(true);
|
||||
chart.animateY(2500);
|
||||
|
||||
// setting data
|
||||
seekBarY.setProgress(50);
|
||||
seekBarX.setProgress(12);
|
||||
|
||||
Legend l = chart.getLegend();
|
||||
l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
|
||||
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.LEFT);
|
||||
l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
|
||||
l.setDrawInside(false);
|
||||
l.setFormSize(8f);
|
||||
l.setXEntrySpace(4f);
|
||||
}
|
||||
|
||||
private void setData(int count, float range) {
|
||||
|
||||
float barWidth = 9f;
|
||||
float spaceForBar = 10f;
|
||||
ArrayList<BarEntry> values = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
float val = (float) (Math.random() * range);
|
||||
values.add(new BarEntry(i * spaceForBar, val,
|
||||
getResources().getDrawable(R.drawable.star)));
|
||||
}
|
||||
|
||||
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, "DataSet 1");
|
||||
|
||||
set1.setDrawIcons(false);
|
||||
|
||||
ArrayList<IBarDataSet> dataSets = new ArrayList<>();
|
||||
dataSets.add(set1);
|
||||
|
||||
BarData data = new BarData(dataSets);
|
||||
data.setValueTextSize(10f);
|
||||
data.setValueTypeface(tfLight);
|
||||
data.setBarWidth(barWidth);
|
||||
chart.setData(data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.bar, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.viewGithub: {
|
||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||
i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/HorizontalBarChartActivity.java"));
|
||||
startActivity(i);
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleValues: {
|
||||
List<IBarDataSet> sets = chart.getData()
|
||||
.getDataSets();
|
||||
|
||||
for (IBarDataSet iSet : sets) {
|
||||
iSet.setDrawValues(!iSet.isDrawValuesEnabled());
|
||||
}
|
||||
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleIcons: {
|
||||
List<IBarDataSet> sets = chart.getData()
|
||||
.getDataSets();
|
||||
|
||||
for (IBarDataSet iSet : sets) {
|
||||
iSet.setDrawIcons(!iSet.isDrawIconsEnabled());
|
||||
}
|
||||
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleHighlight: {
|
||||
if(chart.getData() != null) {
|
||||
chart.getData().setHighlightEnabled(!chart.getData().isHighlightEnabled());
|
||||
chart.invalidate();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case R.id.actionTogglePinch: {
|
||||
if (chart.isPinchZoomEnabled())
|
||||
chart.setPinchZoom(false);
|
||||
else
|
||||
chart.setPinchZoom(true);
|
||||
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleAutoScaleMinMax: {
|
||||
chart.setAutoScaleMinMaxEnabled(!chart.isAutoScaleMinMaxEnabled());
|
||||
chart.notifyDataSetChanged();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleBarBorders: {
|
||||
for (IBarDataSet set : chart.getData().getDataSets())
|
||||
((BarDataSet)set).setBarBorderWidth(set.getBarBorderWidth() == 1.f ? 0.f : 1.f);
|
||||
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.animateX: {
|
||||
chart.animateX(2000);
|
||||
break;
|
||||
}
|
||||
case R.id.animateY: {
|
||||
chart.animateY(2000);
|
||||
break;
|
||||
}
|
||||
case R.id.animateXY: {
|
||||
chart.animateXY(2000, 2000);
|
||||
break;
|
||||
}
|
||||
case R.id.actionSave: {
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
|
||||
saveToGallery();
|
||||
} else {
|
||||
requestStoragePermission(chart);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
|
||||
tvX.setText(String.valueOf(seekBarX.getProgress()));
|
||||
tvY.setText(String.valueOf(seekBarY.getProgress()));
|
||||
|
||||
setData(seekBarX.getProgress(), seekBarY.getProgress());
|
||||
chart.setFitBars(true);
|
||||
chart.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void saveToGallery() {
|
||||
saveToGallery(chart, "HorizontalBarChartActivity");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {}
|
||||
|
||||
private final RectF mOnValueSelectedRectF = new RectF();
|
||||
|
||||
@Override
|
||||
public void onValueSelected(Entry e, Highlight h) {
|
||||
|
||||
if (e == null)
|
||||
return;
|
||||
|
||||
RectF bounds = mOnValueSelectedRectF;
|
||||
chart.getBarBounds((BarEntry) e, bounds);
|
||||
|
||||
MPPointF position = chart.getPosition(e, chart.getData().getDataSetByIndex(h.getDataSetIndex())
|
||||
.getAxisDependency());
|
||||
|
||||
Log.i("bounds", bounds.toString());
|
||||
Log.i("position", position.toString());
|
||||
|
||||
MPPointF.recycleInstance(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected() {}
|
||||
}
|
|
@ -0,0 +1,292 @@
|
|||
|
||||
package com.xxmassdeveloper.mpchartexample;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.RectF;
|
||||
import android.net.Uri;
|
||||
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 androidx.core.content.ContextCompat;
|
||||
|
||||
import com.github.mikephil.charting.charts.HorizontalBarChart;
|
||||
import com.github.mikephil.charting.components.Legend;
|
||||
import com.github.mikephil.charting.components.XAxis;
|
||||
import com.github.mikephil.charting.components.XAxis.XAxisPosition;
|
||||
import com.github.mikephil.charting.components.YAxis;
|
||||
import com.github.mikephil.charting.data.BarData;
|
||||
import com.github.mikephil.charting.data.BarDataSet;
|
||||
import com.github.mikephil.charting.data.BarEntry;
|
||||
import com.github.mikephil.charting.data.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.MPPointF;
|
||||
import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class HorizontalBarNegativeChartActivity extends DemoBase implements OnSeekBarChangeListener,
|
||||
OnChartValueSelectedListener {
|
||||
|
||||
private HorizontalBarChart 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_horizontalbarchart);
|
||||
|
||||
setTitle("HorizontalBarChartActivity");
|
||||
|
||||
tvX = findViewById(R.id.tvXMax);
|
||||
tvY = findViewById(R.id.tvYMax);
|
||||
|
||||
seekBarX = findViewById(R.id.seekBar1);
|
||||
seekBarY = findViewById(R.id.seekBar2);
|
||||
|
||||
seekBarY.setOnSeekBarChangeListener(this);
|
||||
seekBarX.setOnSeekBarChangeListener(this);
|
||||
|
||||
chart = findViewById(R.id.chart1);
|
||||
chart.setOnChartValueSelectedListener(this);
|
||||
// chart.setHighlightEnabled(false);
|
||||
|
||||
chart.setDrawBarShadow(false);
|
||||
|
||||
chart.setDrawValueAboveBar(true);
|
||||
|
||||
chart.getDescription().setEnabled(false);
|
||||
|
||||
// if more than 60 entries are displayed in the chart, no values will be
|
||||
// drawn
|
||||
chart.setMaxVisibleValueCount(60);
|
||||
|
||||
// scaling can now only be done on x- and y-axis separately
|
||||
chart.setPinchZoom(false);
|
||||
|
||||
// draw shadows for each bar that show the maximum value
|
||||
// chart.setDrawBarShadow(true);
|
||||
|
||||
chart.setDrawGridBackground(false);
|
||||
|
||||
XAxis xl = chart.getXAxis();
|
||||
xl.setPosition(XAxisPosition.BOTTOM);
|
||||
xl.setTypeface(tfLight);
|
||||
xl.setDrawAxisLine(true);
|
||||
xl.setDrawGridLines(false);
|
||||
xl.setGranularity(10f);
|
||||
|
||||
YAxis yl = chart.getAxisLeft();
|
||||
yl.setTypeface(tfLight);
|
||||
yl.setDrawAxisLine(true);
|
||||
yl.setDrawGridLines(true);
|
||||
// yl.setInverted(true);
|
||||
|
||||
YAxis yr = chart.getAxisRight();
|
||||
yr.setTypeface(tfLight);
|
||||
yr.setDrawAxisLine(true);
|
||||
yr.setDrawGridLines(false);
|
||||
// yr.setInverted(true);
|
||||
|
||||
chart.setFitBars(true);
|
||||
chart.animateY(2500);
|
||||
|
||||
// setting data
|
||||
seekBarY.setProgress(50);
|
||||
seekBarX.setProgress(12);
|
||||
|
||||
Legend l = chart.getLegend();
|
||||
l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
|
||||
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.LEFT);
|
||||
l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
|
||||
l.setDrawInside(false);
|
||||
l.setFormSize(8f);
|
||||
l.setXEntrySpace(4f);
|
||||
}
|
||||
|
||||
private void setData(int count, float range) {
|
||||
|
||||
float barWidth = 9f;
|
||||
float spaceForBar = 10f;
|
||||
ArrayList<BarEntry> values = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
float val = (float) (Math.random() * range - range / 2);
|
||||
values.add(new BarEntry(i * spaceForBar, val,
|
||||
getResources().getDrawable(R.drawable.star)));
|
||||
}
|
||||
|
||||
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, "DataSet 1");
|
||||
|
||||
set1.setDrawIcons(false);
|
||||
|
||||
ArrayList<IBarDataSet> dataSets = new ArrayList<>();
|
||||
dataSets.add(set1);
|
||||
|
||||
BarData data = new BarData(dataSets);
|
||||
data.setValueTextSize(10f);
|
||||
data.setValueTypeface(tfLight);
|
||||
data.setBarWidth(barWidth);
|
||||
chart.setData(data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.bar, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.viewGithub: {
|
||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||
i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/HorizontalBarChartActivity.java"));
|
||||
startActivity(i);
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleValues: {
|
||||
List<IBarDataSet> sets = chart.getData()
|
||||
.getDataSets();
|
||||
|
||||
for (IBarDataSet iSet : sets) {
|
||||
iSet.setDrawValues(!iSet.isDrawValuesEnabled());
|
||||
}
|
||||
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleIcons: {
|
||||
List<IBarDataSet> sets = chart.getData()
|
||||
.getDataSets();
|
||||
|
||||
for (IBarDataSet iSet : sets) {
|
||||
iSet.setDrawIcons(!iSet.isDrawIconsEnabled());
|
||||
}
|
||||
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleHighlight: {
|
||||
if(chart.getData() != null) {
|
||||
chart.getData().setHighlightEnabled(!chart.getData().isHighlightEnabled());
|
||||
chart.invalidate();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case R.id.actionTogglePinch: {
|
||||
if (chart.isPinchZoomEnabled())
|
||||
chart.setPinchZoom(false);
|
||||
else
|
||||
chart.setPinchZoom(true);
|
||||
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleAutoScaleMinMax: {
|
||||
chart.setAutoScaleMinMaxEnabled(!chart.isAutoScaleMinMaxEnabled());
|
||||
chart.notifyDataSetChanged();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleBarBorders: {
|
||||
for (IBarDataSet set : chart.getData().getDataSets())
|
||||
((BarDataSet)set).setBarBorderWidth(set.getBarBorderWidth() == 1.f ? 0.f : 1.f);
|
||||
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.animateX: {
|
||||
chart.animateX(2000);
|
||||
break;
|
||||
}
|
||||
case R.id.animateY: {
|
||||
chart.animateY(2000);
|
||||
break;
|
||||
}
|
||||
case R.id.animateXY: {
|
||||
chart.animateXY(2000, 2000);
|
||||
break;
|
||||
}
|
||||
case R.id.actionSave: {
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
|
||||
saveToGallery();
|
||||
} else {
|
||||
requestStoragePermission(chart);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
|
||||
tvX.setText(String.valueOf(seekBarX.getProgress()));
|
||||
tvY.setText(String.valueOf(seekBarY.getProgress()));
|
||||
|
||||
setData(seekBarX.getProgress(), seekBarY.getProgress());
|
||||
chart.setFitBars(true);
|
||||
chart.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void saveToGallery() {
|
||||
saveToGallery(chart, "HorizontalBarChartActivity");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {}
|
||||
|
||||
private final RectF mOnValueSelectedRectF = new RectF();
|
||||
|
||||
@Override
|
||||
public void onValueSelected(Entry e, Highlight h) {
|
||||
|
||||
if (e == null)
|
||||
return;
|
||||
|
||||
RectF bounds = mOnValueSelectedRectF;
|
||||
chart.getBarBounds((BarEntry) e, bounds);
|
||||
|
||||
MPPointF position = chart.getPosition(e, chart.getData().getDataSetByIndex(h.getDataSetIndex())
|
||||
.getAxisDependency());
|
||||
|
||||
Log.i("bounds", bounds.toString());
|
||||
Log.i("position", position.toString());
|
||||
|
||||
MPPointF.recycleInstance(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected() {}
|
||||
}
|
|
@ -0,0 +1,283 @@
|
|||
|
||||
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.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.LegendForm;
|
||||
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.OnChartValueSelectedListener;
|
||||
import com.github.mikephil.charting.utils.EntryXComparator;
|
||||
import com.xxmassdeveloper.mpchartexample.custom.MyMarkerView;
|
||||
import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class InvertedLineChartActivity extends DemoBase implements OnSeekBarChangeListener,
|
||||
OnChartValueSelectedListener {
|
||||
|
||||
private LineChart chart;
|
||||
private SeekBar seekBarX, seekBarY;
|
||||
private TextView tvX, tvY;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_linechart);
|
||||
|
||||
setTitle("InvertedLineChartActivity");
|
||||
|
||||
tvX = findViewById(R.id.tvXMax);
|
||||
tvY = findViewById(R.id.tvYMax);
|
||||
|
||||
seekBarX = findViewById(R.id.seekBar1);
|
||||
seekBarY = findViewById(R.id.seekBar2);
|
||||
|
||||
seekBarY.setOnSeekBarChangeListener(this);
|
||||
seekBarX.setOnSeekBarChangeListener(this);
|
||||
|
||||
chart = findViewById(R.id.chart1);
|
||||
chart.setOnChartValueSelectedListener(this);
|
||||
chart.setDrawGridBackground(false);
|
||||
|
||||
// no description text
|
||||
chart.getDescription().setEnabled(false);
|
||||
|
||||
// enable touch gestures
|
||||
chart.setTouchEnabled(true);
|
||||
|
||||
// enable scaling and dragging
|
||||
chart.setDragEnabled(true);
|
||||
chart.setScaleEnabled(true);
|
||||
|
||||
// if disabled, scaling can be done on x- and y-axis separately
|
||||
chart.setPinchZoom(true);
|
||||
|
||||
// set an alternative background color
|
||||
// chart.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);
|
||||
mv.setChartView(chart); // For bounds control
|
||||
chart.setMarker(mv); // Set the marker to the chart
|
||||
|
||||
XAxis xl = chart.getXAxis();
|
||||
xl.setAvoidFirstLastClipping(true);
|
||||
xl.setAxisMinimum(0f);
|
||||
|
||||
YAxis leftAxis = chart.getAxisLeft();
|
||||
leftAxis.setInverted(true);
|
||||
leftAxis.setAxisMinimum(0f); // this replaces setStartAtZero(true)
|
||||
|
||||
YAxis rightAxis = chart.getAxisRight();
|
||||
rightAxis.setEnabled(false);
|
||||
|
||||
// add data
|
||||
seekBarX.setProgress(25);
|
||||
seekBarY.setProgress(50);
|
||||
|
||||
// // restrain the maximum scale-out factor
|
||||
// chart.setScaleMinima(3f, 3f);
|
||||
//
|
||||
// // center the view to a specific position inside the chart
|
||||
// chart.centerViewPort(10, 50);
|
||||
|
||||
// get the legend (only possible after setting data)
|
||||
Legend l = chart.getLegend();
|
||||
|
||||
// modify the legend ...
|
||||
l.setForm(LegendForm.LINE);
|
||||
|
||||
// don't forget to refresh the drawing
|
||||
chart.invalidate();
|
||||
}
|
||||
|
||||
private void setData(int count, float range) {
|
||||
|
||||
ArrayList<Entry> entries = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
float xVal = (float) (Math.random() * range);
|
||||
float yVal = (float) (Math.random() * range);
|
||||
entries.add(new Entry(xVal, yVal));
|
||||
}
|
||||
|
||||
// sort by x-value
|
||||
Collections.sort(entries, new EntryXComparator());
|
||||
|
||||
// create a dataset and give it a type
|
||||
LineDataSet set1 = new LineDataSet(entries, "DataSet 1");
|
||||
|
||||
set1.setLineWidth(1.5f);
|
||||
set1.setCircleRadius(4f);
|
||||
|
||||
// create a data object with the data sets
|
||||
LineData data = new LineData(set1);
|
||||
|
||||
// set data
|
||||
chart.setData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.line, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.viewGithub: {
|
||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||
i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/InvertedLineChartActivity.java"));
|
||||
startActivity(i);
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleValues: {
|
||||
List<ILineDataSet> sets = chart.getData()
|
||||
.getDataSets();
|
||||
|
||||
for (ILineDataSet iSet : sets) {
|
||||
|
||||
LineDataSet set = (LineDataSet) iSet;
|
||||
set.setDrawValues(!set.isDrawValuesEnabled());
|
||||
}
|
||||
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleHighlight: {
|
||||
if(chart.getData() != null) {
|
||||
chart.getData().setHighlightEnabled(!chart.getData().isHighlightEnabled());
|
||||
chart.invalidate();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleFilled: {
|
||||
|
||||
List<ILineDataSet> sets = chart.getData()
|
||||
.getDataSets();
|
||||
|
||||
for (ILineDataSet iSet : sets) {
|
||||
|
||||
LineDataSet set = (LineDataSet) iSet;
|
||||
if (set.isDrawFilledEnabled())
|
||||
set.setDrawFilled(false);
|
||||
else
|
||||
set.setDrawFilled(true);
|
||||
}
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleCircles: {
|
||||
List<ILineDataSet> sets = chart.getData()
|
||||
.getDataSets();
|
||||
|
||||
for (ILineDataSet iSet : sets) {
|
||||
|
||||
LineDataSet set = (LineDataSet) iSet;
|
||||
if (set.isDrawCirclesEnabled())
|
||||
set.setDrawCircles(false);
|
||||
else
|
||||
set.setDrawCircles(true);
|
||||
}
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.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.actionTogglePinch: {
|
||||
if (chart.isPinchZoomEnabled())
|
||||
chart.setPinchZoom(false);
|
||||
else
|
||||
chart.setPinchZoom(true);
|
||||
|
||||
chart.invalidate();
|
||||
break;
|
||||
}
|
||||
case R.id.actionToggleAutoScaleMinMax: {
|
||||
chart.setAutoScaleMinMaxEnabled(!chart.isAutoScaleMinMaxEnabled());
|
||||
chart.notifyDataSetChanged();
|
||||
break;
|
||||
}
|
||||
case R.id.actionSave: {
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
|
||||
saveToGallery();
|
||||
} else {
|
||||
requestStoragePermission(chart);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
|
||||
tvX.setText(String.valueOf(seekBarX.getProgress()));
|
||||
tvY.setText(String.valueOf(seekBarY.getProgress()));
|
||||
|
||||
setData(seekBarX.getProgress(), seekBarY.getProgress());
|
||||
|
||||
// redraw
|
||||
chart.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void saveToGallery() {
|
||||
saveToGallery(chart, "InvertedLineChartActivity");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueSelected(Entry e, Highlight h) {
|
||||
Log.i("VAL SELECTED",
|
||||
"Value: " + e.getY() + ", xIndex: " + e.getX()
|
||||
+ ", DataSet index: " + h.getDataSetIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected() {}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue