Compare commits

...

154 Commits

Author SHA1 Message Date
Terry Worona e3c8fb2794 Fixes #118 - access to bar and dot views 2015-03-30 19:03:44 -07:00
Terry Worona 93bea88b47 updated readme and header comments for #99 2015-03-30 16:03:45 -07:00
Terry Worona fe7f8bbae7 Fixes issue #99 - radius is now a true dot radius (not diameter) 2015-03-30 15:59:34 -07:00
Terry Worona 394bb70599 Cleaned up pr 143 2015-03-30 15:19:48 -07:00
terryworona 4e1411c302 Merge pull request #143 from ADVSENSOR/empty_data
Fix crash and warnings that can occur when a chart line has no data
2015-03-30 15:15:48 -07:00
Terry Worona 21bc7d3a3e List updates 2015-03-30 15:09:31 -07:00
terryworona 21dc1d004a Merge pull request #144 from ADVSENSOR/tooltip_zorder
Keep tooltip subviews above line subviews
2015-03-30 14:21:25 -07:00
Terry Worona 40e4434e18 Readme update 2015-03-30 14:13:04 -07:00
Terry Worona ac3c379af4 Code cleanup 2015-03-30 14:12:07 -07:00
Terry Worona 2c803e87dd cleaned up strings 2015-03-30 14:09:58 -07:00
Terry Worona 7efeaa1ef1 updated line chart docs 2015-03-30 14:04:35 -07:00
Terry Worona a454e221a6 Updated readme 2015-03-30 14:02:52 -07:00
terryworona 7046cf7045 Merge pull request #116 from sebastianreloaded/missing_values
Add ability to have the line start or end at any given point
2015-03-30 13:56:08 -07:00
terryworona e4b0fddd16 Merge pull request #142 from skywinder/add-change-log-file
Add automatically generated change log file.
2015-03-30 13:46:29 -07:00
Sebastian Opel b1c632f5a3 added docu in readme 2015-03-25 11:56:51 +01:00
Sebastian Opel 162619b825 coding style fixes 2015-03-17 10:45:37 +01:00
Sebastian Opel 32cbb39d0b if all points are NAN no need to continue the path 2015-03-17 10:43:46 +01:00
Trevor Harmon 3a0fac18c5 Keep tooltip subviews above line subviews 2015-03-07 16:43:51 -08:00
Trevor Harmon 4c0a22d962 Fix crash and warnings that can occur when a chart line has no data 2015-03-07 14:27:24 -08:00
Petr Korolev 76c1c41886 Added automatically generated change log file 2015-03-05 15:29:07 +02:00
Terry Worona e3b8ccd704 Fixed #140 2015-03-04 22:34:39 -08:00
terryworona b179f20ef9 Merge pull request #127 from paal123/patch-1
Update README.md
2014-11-25 08:56:52 -08:00
paal123 d89472dea5 Update README.md
Removed a small typo resulting in errors during execution.
2014-11-25 16:12:02 +01:00
Sebastian Opel 907a4f25ae added missing points to new example fake data 2014-10-23 17:08:03 +02:00
Sebastian Opel 51454fe3f6 added a copy of linechart example as a new example for missing points 2014-10-23 17:06:09 +02:00
Sebastian Opel 131f251df8 added handling of missing values within a linechart
JBLineChartView uses numberOfVerticalValuesAtLineIndex to define the number
of points, but subsequently requires that all chartPoints have a value anyway.
This commit allows you to use NAN within the charts data.
2014-10-23 16:44:44 +02:00
Terry Worona 64451dd5ac pod spec and read me updates 2014-09-22 19:05:18 -07:00
Terry Worona 36d72ce510 change log and comments 2014-09-22 19:03:25 -07:00
Terry Worona efd8f97335 Removed changes for setFrame 2014-09-22 19:00:10 -07:00
Terry Worona 243c28cffb update to change log, read me, pod spec, etc 2014-09-22 11:18:11 -07:00
Terry Worona 66bf3b14e8 Fixed #111 2014-09-22 11:16:48 -07:00
Terry Worona 7287712da3 More cleanup of compiler warnings on iOS 8 2014-09-22 11:11:32 -07:00
Terry Worona e71db56a76 updated read me, change log, etc 2014-09-19 19:41:52 -07:00
Terry Worona 4be903eda7 fixed some compiler warnings 2014-09-19 19:35:37 -07:00
Terry Worona d5210eff99 Updated read me, change log and pod spec 2014-09-08 22:35:27 -07:00
Terry Worona 956386c7db Cleanup 2014-09-08 22:17:52 -07:00
terryworona c6dfb48047 Merge pull request #106 from eventualbuddha/reduce-numberOfLinesInLineChartView-calls
Only call `numberOfLinesInLineChartView:` once per loop.
2014-09-08 22:17:06 -07:00
terryworona fff2bd22d6 Merge pull request #107 from thefirstnikhil/master
iOS Framework Support
2014-09-08 22:08:46 -07:00
Nikhil Kalra 23e8e3084a iOS Framework Support
Added a UIKit import statement for use when JBChartView is added to a
Xcode project as a framework (iOS 8).
2014-09-05 21:48:15 -07:00
Brian Donovan d04eaa2622 Only call numberOfLinesInLineChartView: once per loop. 2014-09-05 11:18:21 -07:00
Terry Worona e24d2487f1 updated pod spec 2014-08-29 15:23:25 -07:00
Terry Worona d3a92dd70f updated read me and change log fixed issue #100 2014-08-29 15:22:56 -07:00
Terry Worona c73f494034 added custom dot view hide functionality on selection events 2014-08-29 15:19:49 -07:00
Terry Worona 80708acda1 Updated pod spec 2014-08-28 14:52:58 -07:00
Terry Worona 6308ee1b19 Updated read me and change log 2014-08-28 14:50:42 -07:00
Terry Worona 62965bbd9f Finished line chart padding extension properties 2014-08-28 13:51:33 -07:00
Terry Worona 06bf8b5033 Finished bar chart padding extension properties 2014-08-28 13:37:39 -07:00
Terry Worona c2a16d0fbb added optional protocol for footer/header padding extensions 2014-08-28 13:24:13 -07:00
Terry Worona 9548b2ab32 Don't extend selection views into padding 2014-08-28 13:14:58 -07:00
Terry Worona 295fb40a0b Fixed up bar charts to utilize padding properly 2014-08-28 13:01:57 -07:00
Terry Worona e29ebd39ab Updated line chart view for footer padding 2014-08-28 12:10:35 -07:00
Terry Worona 27b0493b9b Added footer padding property and updated bar chart to use it 2014-08-28 12:00:04 -07:00
Terry Worona 04f40aac1a Updated read me 2014-08-27 11:35:42 -07:00
Terry Worona 833f6e9080 Fixed issue #97 2014-08-27 11:27:58 -07:00
Terry Worona eb48db2e73 Updated comment 2014-08-27 11:21:45 -07:00
Terry Worona 55b6dae956 Cleaned up bar pop animations 2014-08-27 11:19:45 -07:00
Terry Worona c44b276ae1 fixed vertical selection adjustment 2014-08-26 19:14:15 -07:00
Terry Worona 93f3d1862e simplified bar chart animations and added invert flag 2014-08-26 19:02:06 -07:00
Terry Worona 19a4a0bf5c Updated pod spec 2014-08-26 15:49:59 -07:00
Terry Worona 9d43c6dd23 updated read me and pod spec 2014-08-26 15:49:21 -07:00
Terry Worona 8598ff1488 Fixed issue #93 2014-08-26 15:46:03 -07:00
Terry Worona b9d28bfd59 Updated pod spec 2014-08-26 15:40:00 -07:00
Terry Worona dd1dce758e updated read me and change log 2014-08-26 15:39:25 -07:00
Terry Worona 9fce2fc1c0 Fixed #95 2014-08-26 15:35:40 -07:00
Terry Worona ab1cf713e6 Fixed bar chart selection view for non-homogenous bar widths 2014-08-26 15:29:05 -07:00
Terry Worona 4363147303 updated read me 2014-08-22 18:19:34 -07:00
Terry Worona 8a1770c6df Updated pod spec 2014-08-22 18:13:52 -07:00
Terry Worona f84f322598 updated read me 2014-08-22 18:13:20 -07:00
Terry Worona 04e1aa5b98 Hide custom dots on selector for now 2014-08-22 18:10:30 -07:00
Terry Worona ab07aa2399 Fixed padding issues 2014-08-22 15:36:08 -07:00
Terry Worona f01e11a0e2 Added custom dot views to line chart 2014-08-22 14:21:06 -07:00
Terry Worona 76984c7c7c added protocols for custom dots 2014-08-22 12:07:09 -07:00
Terry Worona d38a04a70d Added dot radius on a per horizontal index basis 2014-08-22 11:52:53 -07:00
Terry Worona 385d5b3589 Updated pod spec 2014-08-14 19:26:18 -07:00
Terry Worona 90100c7277 updated read me and change log 2014-08-14 19:25:39 -07:00
Terry Worona eca1c0507e Cleaned up PR #90 2014-08-14 19:23:19 -07:00
terryworona ac870e45ce Merge pull request #90 from mszaro/master
Add per-line vertical selection color support.
2014-08-14 19:17:19 -07:00
mszaro 74f588b7e6 Update comment. 2014-08-14 18:51:48 -07:00
mszaro 406b64ae0c Implement per-line vertical selection colors 2014-08-14 18:50:55 -07:00
Terry Worona 92e56d78c5 updates specs and read me 2014-08-14 18:01:04 -07:00
Terry Worona 36ec328346 Fixed issue #89 2014-08-14 17:57:39 -07:00
Terry Worona b763ae540c updated version 2014-08-07 13:33:46 -07:00
Terry Worona 7ffdf6d9da Fixed issue #83 2014-08-07 13:30:48 -07:00
Terry Worona 6531c68574 version update 2014-08-04 13:37:33 -07:00
Terry Worona ebae36bd2f Pushed base datasource and delegate protocols up to JBChartView (for extensibility) 2014-08-04 13:17:04 -07:00
Terry Worona 8cdff2891c Updated version 2014-08-04 10:15:05 -07:00
Terry Worona 333200d041 Fixed issue #77 2014-08-04 10:13:05 -07:00
Terry Worona 6ad3bd7692 Readme update 2014-08-02 12:20:25 -07:00
Terry Worona 3531e593da update change log, read me, pod spec 2014-08-02 12:13:12 -07:00
Terry Worona eeb9ca604c More refactors 2014-08-02 12:02:01 -07:00
Terry Worona b884108dbb More line chart refactors 2014-08-02 11:46:25 -07:00
Terry Worona 00dd74f733 Started JBLineChartView refactor 2014-08-02 11:22:58 -07:00
Terry Worona c1938147d8 Cleaned up warning 2014-08-02 11:17:09 -07:00
Terry Worona e17c5419f4 Refactor JBBarChartView datasource and delegate 2014-08-02 11:14:36 -07:00
Terry Worona d0cb8b0307 Updated pod spec 2014-07-31 13:30:53 -07:00
Terry Worona fe81df094e Updated change log and read me 2014-07-31 13:29:58 -07:00
Terry Worona 0dae570cc6 Fixed line width bug for JBLineChartView 2014-07-31 13:28:07 -07:00
Terry Worona c5c93cb660 update version, read me, pod spec 2014-07-25 16:43:34 -07:00
Terry Worona 3df69b0a9c more demo chart cleanup 2014-07-25 16:19:28 -07:00
Terry Worona 30305cdde9 String cleanup 2014-07-25 16:12:00 -07:00
Terry Worona 8e1cbba06f Fixed chart coloring 2014-07-25 16:00:07 -07:00
Terry Worona 97e5acdb1a added area controller and assets 2014-07-25 15:55:48 -07:00
Terry Worona 47f1f0ba8d Reverted base to iOS 6 2014-07-25 15:22:08 -07:00
Terry Worona 0be9465049 Fixed OS checks 2014-07-25 15:18:47 -07:00
Terry Worona 7bed3dd5d0 updated pod spec, change log and read me 2014-07-25 14:18:23 -07:00
Luo Sheng 4f1f6760d5 Update the Podspec. 2014-07-25 12:28:33 +08:00
Luo Sheng 8103a1aea4 Make the demo run in iOS 6 too. 2014-07-25 12:27:51 +08:00
Luo Sheng dc6dc647ad Use sizeWithFont: method for iOS 6. 2014-07-25 12:23:26 +08:00
Terry Worona b6ea1a502a Updated pod spec 2014-07-24 16:20:10 -07:00
Terry Worona afcf328158 Fixed readme 2014-07-24 15:43:47 -07:00
Terry Worona 49cf12c568 updated read me and change log of fill functions 2014-07-24 15:39:37 -07:00
Terry Worona 0d4b942b74 Merge branch 'master' of https://github.com/Jawbone/JBChartView 2014-07-24 15:25:22 -07:00
Terry Worona 30a369796f Minor cleanup of PR #71 2014-07-24 15:25:15 -07:00
Terry Worona f2f35312e4 Updated read me 2014-07-24 14:32:22 -07:00
terryworona d32f09a584 Merge pull request #67 from jonparker/master
Added documentation for usage in a Swift project
2014-07-18 11:15:44 -07:00
Damien Legrand 80e179df1d Fill Color
Fill color for line chart :
* Default color is clearColor
* The user can define a color and a selection color for each line with
two new methods in JBLineChartViewDataSource protocol
2014-07-17 17:38:24 +02:00
Terry Worona 48da335f09 added spark friends link 2014-06-30 19:24:06 -07:00
Terry Worona 70c1fb897c added more demos section 2014-06-24 13:05:52 -07:00
Terry Worona 30df02f804 screen update 2014-06-24 12:58:50 -07:00
Terry Worona 9ba20e9e14 updated screenshot 2014-06-24 12:52:37 -07:00
Terry Worona d6d1dd8461 Updated screenshot 2014-06-24 12:21:21 -07:00
Jonathan Parker b0de620503 Added link to iOS documentation. 2014-06-23 15:49:26 +10:00
Jonathan Parker 8e81fb20cd Added instructions for use in a Swift project. 2014-06-23 15:46:37 +10:00
Terry Worona a303422d8e updated read me, pod spec, etc 2014-05-13 19:44:52 -07:00
Terry Worona 1aff68557f Cleaned up demo code and add min value to bar charts 2014-05-13 19:42:14 -07:00
terryworona ac3744c0c9 Merge pull request #57 from pala/master
Fixed barView's frame.
2014-05-13 19:33:55 -07:00
Tao Zhang a6ea0c30f8 Update JBBarChartView.m 2014-05-13 21:56:02 -04:00
pala ea531e3cb1 Fixed barView's frame. 2014-05-13 19:42:06 -04:00
terryworona b1a3ebd4ed Merge pull request #55 from pala/patch-1
Update sample code in readme
2014-05-13 10:39:24 -07:00
Tao Zhang 554f93f3d3 Update sample code 2014-05-12 23:41:25 -04:00
Terry Worona 2ddd38fc9d updated change log 2014-05-07 09:55:10 -07:00
Terry Worona 6691f7a8c3 Updated comment, read me, pod spec, etc 2014-05-07 09:47:32 -07:00
terryworona c015531c85 Merge pull request #53 from skywinder/bar-color-delegate
Add delegate method barChartView:colorForBarViewAtIndex: to JBBarChartViewDataSource
2014-05-07 09:40:43 -07:00
terryworona 3d036edc96 Merge pull request #52 from skywinder/compiling-warrnings-and-typos
Compiling warrnings and typos
2014-05-07 09:36:48 -07:00
Petr Korolev 85c30351fe Add new delegate method to JBBarChartView
Implement logic to set specifed color before set the default kJBBarChartViewDefaultBarColor
Add call of this code to Example project
2014-05-07 15:33:50 +03:00
Petr Korolev d37383a352 fix typo 2014-05-07 14:59:34 +03:00
Petr Korolev 3c6cf24cf7 Cast to correct return type (NSUInteger) 2014-05-07 14:37:28 +03:00
Terry Worona 8dbb2679ee Updated log, spec and read me 2014-05-06 14:05:24 -07:00
Terry Worona 867466d1d1 More more compile error 2014-05-06 14:04:17 -07:00
Terry Worona 2046131143 Updated read me, pod spec, etc. 2014-05-06 13:40:21 -07:00
Terry Worona 208a727d88 Fixed compiler warnings 2014-05-06 13:38:24 -07:00
Terry Worona 43c6e9486f Updated version, pod spec, etc 2014-05-05 12:33:39 -07:00
Terry Worona 49206a01ed Fixed issue #48 2014-05-05 12:31:12 -07:00
Terry Worona e2b17820bf readme updates 2014-05-04 14:47:21 -07:00
Terry Worona b59904e5b9 updated for new version 2014-05-04 14:45:27 -07:00
Terry Worona 1d8f78d751 Fixed issue #48 2014-05-04 14:07:27 -07:00
Terry Worona 3cc39124b8 updated version 2014-05-04 09:48:10 -07:00
terryworona bedd7e2c71 Merge pull request #49 from simonnickel/master
fixed typo, renamed mininum -> minimum
2014-05-04 09:44:03 -07:00
Simon Nickel 786af91666 fixed typo, renamed mininum -> minimum 2014-05-03 22:18:42 +02:00
Terry Worona b7927cddb7 Fixes issue #46 2014-04-30 22:58:47 -07:00
Terry Worona 0f2d4d766c updated change log, pod spec, etc 2014-04-30 10:04:01 -07:00
terryworona 64de3e6e23 Merge pull request #45 from ktran03/smoothCurveFix
Smooth curve fix
2014-04-30 09:59:22 -07:00
ktran03 87fb8ee7b8 missing variable in condition 2014-04-29 22:03:40 -04:00
ktran03 7c0dfe3eb5 smooth curve fix for more straight line cases 2014-04-29 21:55:47 -04:00
32 changed files with 2517 additions and 756 deletions
+589 -84
View File
@@ -1,106 +1,611 @@
# Changelog
# Change Log
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.4.0">2.4.0</a>
#### 04/28/14
- Fixes issue <a href="https://github.com/Jawbone/JBChartView/pull/23">#23</a>.
## [Unreleased](https://github.com/Jawbone/JBChartView/tree/HEAD)
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.3.0">2.3.0</a>
#### 04/17/14
- Fixes issue <a href="https://github.com/Jawbone/JBChartView/pull/34">#34</a>.
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.2.0">2.2.0</a>
#### 04/14/14
- Fixes issue <a href="https://github.com/Jawbone/JBChartView/pull/37">#37</a>.
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.8.10...HEAD)
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.1.6">2.1.6</a>
#### 04/11/14
- Fixes issue <a href="https://github.com/Jawbone/JBChartView/pull/33">#33</a>.
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.1.5">2.1.5</a>
#### 04/10/14
- Fixes issue <a href="https://github.com/Jawbone/JBChartView/pull/30">#30</a>.
**Closed issues:**
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.1.4">2.1.4</a>
#### 04/10/14
- Added ability to specify a radius for dotted lines.
- hi is it possible to have x,y value because in example there is no y value and only 2 x value [\#141](https://github.com/Jawbone/JBChartView/issues/141)
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.1.3">2.1.3</a>
#### 04/03/14
- Added the ability to force a chart's state.
- imports without pods [\#140](https://github.com/Jawbone/JBChartView/issues/140)
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.1.2">2.1.2</a>
#### 04/02/14
- Added dynamic padding to JBLineChartView (based on max line width).
- How can I group Bars? [\#139](https://github.com/Jawbone/JBChartView/issues/139)
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.1.1">2.1.1</a>
#### 04/02/14
- Fixed minimumValue and maximumValue getter functions.
- request: AreaChart - fillColorForLineAtLineIndex - add custom color for a specific X axis range [\#137](https://github.com/Jawbone/JBChartView/issues/137)
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.1.0">2.1.0</a>
#### 03/30/14
- Added minimumValue and maximumValue properties.
- Changed default min value implementation from 0 to chart's actual minimum value.
- smallest value is shown as a blank bar [\#136](https://github.com/Jawbone/JBChartView/issues/136)
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.0.2">2.0.2</a>
#### 03/27/14
- Added the ability to add point dots for lines in JBLineChartView.
- Streamlined line styling.
- Is there any way I can use JBBarChartView as horizontal bars? [\#135](https://github.com/Jawbone/JBChartView/issues/135)
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.0.1">2.0.1</a>
#### 03/19/14
- Fixes issue <a href="https://github.com/Jawbone/JBChartView/pull/22">#22</a>.
- Multiple colors to a line graph [\#134](https://github.com/Jawbone/JBChartView/issues/134)
## <a href="https://github.com/Jawbone/JBChartView/tree/v2.0.0">2.0.0</a>
#### 03/18/14
- Fixes issue <a href="https://github.com/Jawbone/JBChartView/pull/21">#21</a>.
- Added multi-line support for JBLineChartView.
- Added position delegation on touch events.
- Added tooltip views (demo-only).
- Overriding - \(void\)barChartView:\(JBBarChartView \*\)barChartView didSelectBarAtIndex:\(NSUInteger\)index is not showing selection view? [\#133](https://github.com/Jawbone/JBChartView/issues/133)
## <a href="https://github.com/Jawbone/JBChartView/tree/v1.1.6">1.1.6</a>
#### 03/02/14
- Fixes issue <a href="https://github.com/Jawbone/JBChartView/pull/15">#15</a>.
- Fixes issue <a href="https://github.com/Jawbone/JBChartView/pull/14">#14</a>.
- Exception thrown on setState: [\#132](https://github.com/Jawbone/JBChartView/issues/132)
## <a href="https://github.com/Jawbone/JBChartView/tree/v1.1.5">1.1.5</a>
#### 02/11/14
- Chart selection improvements.
- Animation performance improvements.
- X and Y scale and reference values [\#131](https://github.com/Jawbone/JBChartView/issues/131)
## <a href="https://github.com/Jawbone/JBChartView/tree/v1.1.4">1.1.4</a>
#### 02/06/14
- Fixed compilation warnings.
- Determine x-value of a certain point by a number instead of it's index in the input array? [\#130](https://github.com/Jawbone/JBChartView/issues/130)
## <a href="https://github.com/Jawbone/JBChartView/tree/v1.1.3">1.1.3</a>
#### 01/06/14
- Fixes issue <a href="https://github.com/Jawbone/JBChartView/pull/11">#11</a>.
- How to accomplish similar didUnselectBarChartView [\#129](https://github.com/Jawbone/JBChartView/issues/129)
## <a href="https://github.com/Jawbone/JBChartView/tree/v1.1.2">1.1.2</a>
#### 01/03/14
- Added CGFloat support for chart heights intead of integers.
- Is posible - scroll chart [\#126](https://github.com/Jawbone/JBChartView/issues/126)
## <a href="https://github.com/Jawbone/JBChartView/tree/v1.1.1">1.1.1</a>
#### 01/02/14
- Fixes issue <a href="https://github.com/Jawbone/JBChartView/pull/7">#7</a>.
- Crash when vertical value for horizontal at index x less than zero [\#125](https://github.com/Jawbone/JBChartView/issues/125)
## <a href="https://github.com/Jawbone/JBChartView/tree/v1.1.0">1.1.0</a>
#### 12/26/13
- Updated JBBarChartView datasource to request UIView subclasses for bars.
- JBBarChartView does not display all the bars [\#124](https://github.com/Jawbone/JBChartView/issues/124)
## <a href="https://github.com/Jawbone/JBChartView/tree/v1.0.3">1.0.3</a>
#### 12/23/13
- Fixes issue <a href="https://github.com/Jawbone/JBChartView/pull/4">#4</a>.
- "automatically normalized across the entire chart" [\#123](https://github.com/Jawbone/JBChartView/issues/123)
## <a href="https://github.com/Jawbone/JBChartView/tree/v1.0.2">1.0.2</a>
#### 12/17/13
- Additional fixes for issue <a href="https://github.com/Jawbone/JBChartView/pull/2">#2</a>.
- reloadData in viewDidLayoutSubviews does not trigger didDeselectLineInLineChartView on first selection [\#122](https://github.com/Jawbone/JBChartView/issues/122)
## <a href="https://github.com/Jawbone/JBChartView/tree/v1.0.1">1.0.1</a>
#### (12/14/13)
- Fixes issue <a href="https://github.com/Jawbone/JBChartView/pull/2">#2</a>.
- Question [\#121](https://github.com/Jawbone/JBChartView/issues/121)
## <a href="https://github.com/Jawbone/JBChartView/tree/v1.0">1.0</a>
#### 12/10/13
- Initial public release.
- Base line and bar charts.
- Basic customization; color, positioning, selections.
- Sublayers not properly resized [\#120](https://github.com/Jawbone/JBChartView/issues/120)
- It will be really cool if "while on tap on line charts dots I can get the dot object do some scale animation" or something? [\#119](https://github.com/Jawbone/JBChartView/issues/119)
- Is there any way I can pass new bar view while user selects particular bar? [\#117](https://github.com/Jawbone/JBChartView/issues/117)
- Typo error in README [\#114](https://github.com/Jawbone/JBChartView/issues/114)
- Dynamic/append values [\#113](https://github.com/Jawbone/JBChartView/issues/113)
- It needs better documentation [\#112](https://github.com/Jawbone/JBChartView/issues/112)
**Merged pull requests:**
- Add optional gradient fill to line chart [\#138](https://github.com/Jawbone/JBChartView/pull/138) ([mbachrach](https://github.com/mbachrach))
- fix for updating graphs on view resize [\#128](https://github.com/Jawbone/JBChartView/pull/128) ([sobakasu](https://github.com/sobakasu))
- Update README.md [\#127](https://github.com/Jawbone/JBChartView/pull/127) ([paal123](https://github.com/paal123))
## [v2.8.10](https://github.com/Jawbone/JBChartView/tree/v2.8.10) (2014-09-23)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.8.9...v2.8.10)
## [v2.8.9](https://github.com/Jawbone/JBChartView/tree/v2.8.9) (2014-09-22)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.8.8...v2.8.9)
**Closed issues:**
- JBLineChartView doesn't resize its subviews [\#111](https://github.com/Jawbone/JBChartView/issues/111)
## [v2.8.8](https://github.com/Jawbone/JBChartView/tree/v2.8.8) (2014-09-20)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.8.7...v2.8.8)
**Fixed bugs:**
- iOS 8 warnings [\#110](https://github.com/Jawbone/JBChartView/issues/110)
**Closed issues:**
- Noob level tutorial [\#109](https://github.com/Jawbone/JBChartView/issues/109)
- Data points with uneavenly distributed x-values? [\#108](https://github.com/Jawbone/JBChartView/issues/108)
## [v2.8.7](https://github.com/Jawbone/JBChartView/tree/v2.8.7) (2014-09-09)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.8.6...v2.8.7)
**Implemented enhancements:**
- Add hide custom dot functionality [\#100](https://github.com/Jawbone/JBChartView/issues/100)
- Add footer padding [\#98](https://github.com/Jawbone/JBChartView/issues/98)
- DotView is hidden when inside selected table view cell [\#82](https://github.com/Jawbone/JBChartView/issues/82)
**Closed issues:**
- There should be flexibility to change to touch point to nearest data point so vertical selection view just jumps from one data point to another in JBLineChartView. [\#105](https://github.com/Jawbone/JBChartView/issues/105)
- barWidth Method and barPadding property should be in JBBarChartView header file. [\#104](https://github.com/Jawbone/JBChartView/issues/104)
- Why minimum and maximum should be positive? [\#102](https://github.com/Jawbone/JBChartView/issues/102)
**Merged pull requests:**
- iOS Framework Support [\#107](https://github.com/Jawbone/JBChartView/pull/107) ([thefirstnikhil](https://github.com/thefirstnikhil))
- Only call `numberOfLinesInLineChartView:` once per loop. [\#106](https://github.com/Jawbone/JBChartView/pull/106) ([eventualbuddha](https://github.com/eventualbuddha))
- Allowed to use negative values [\#103](https://github.com/Jawbone/JBChartView/pull/103) ([ReDetection](https://github.com/ReDetection))
- Multitouch support [\#84](https://github.com/Jawbone/JBChartView/pull/84) ([nopshusang](https://github.com/nopshusang))
- Added block chart [\#81](https://github.com/Jawbone/JBChartView/pull/81) ([jhogervorst](https://github.com/jhogervorst))
## [v2.8.6](https://github.com/Jawbone/JBChartView/tree/v2.8.6) (2014-08-29)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.8.5...v2.8.6)
## [v2.8.5](https://github.com/Jawbone/JBChartView/tree/v2.8.5) (2014-08-28)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.8.4...v2.8.5)
**Implemented enhancements:**
- Invert option for bar charts [\#97](https://github.com/Jawbone/JBChartView/issues/97)
## [v2.8.4](https://github.com/Jawbone/JBChartView/tree/v2.8.4) (2014-08-27)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.8.3...v2.8.4)
## [v2.8.3](https://github.com/Jawbone/JBChartView/tree/v2.8.3) (2014-08-26)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.8.2...v2.8.3)
**Implemented enhancements:**
- return type of barPaddingForBarChartView: [\#93](https://github.com/Jawbone/JBChartView/issues/93)
- Custom dot functionality [\#92](https://github.com/Jawbone/JBChartView/issues/92)
## [v2.8.2](https://github.com/Jawbone/JBChartView/tree/v2.8.2) (2014-08-26)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.8.1...v2.8.2)
**Fixed bugs:**
- Selection view width should equal bar width [\#96](https://github.com/Jawbone/JBChartView/issues/96)
**Closed issues:**
- Changing dot radius in dotRadiusForLineAtLineIndex has no effect [\#95](https://github.com/Jawbone/JBChartView/issues/95)
## [v2.8.1](https://github.com/Jawbone/JBChartView/tree/v2.8.1) (2014-08-23)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.8.0...v2.8.1)
## [v2.8.0](https://github.com/Jawbone/JBChartView/tree/v2.8.0) (2014-08-15)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.7.4...v2.8.0)
**Closed issues:**
- Don't bring selection view to front with line view [\#89](https://github.com/Jawbone/JBChartView/issues/89)
**Merged pull requests:**
- Add per-line vertical selection color support. [\#90](https://github.com/Jawbone/JBChartView/pull/90) ([mszaro](https://github.com/mszaro))
## [v2.7.4](https://github.com/Jawbone/JBChartView/tree/v2.7.4) (2014-08-15)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.7.3...v2.7.4)
**Implemented enhancements:**
- Not able to create Y-Axis labels or background grid [\#20](https://github.com/Jawbone/JBChartView/issues/20)
**Closed issues:**
- \[Enhancement\] Provide an option to disable Y-axis normalization for line graphs [\#88](https://github.com/Jawbone/JBChartView/issues/88)
- Add left padding to the graph for y-axis labels [\#87](https://github.com/Jawbone/JBChartView/issues/87)
- Error Protocol not implemented [\#86](https://github.com/Jawbone/JBChartView/issues/86)
- What if I want to animate the LineChartView progression? [\#85](https://github.com/Jawbone/JBChartView/issues/85)
- Enabling smooth lines in line chart view results in line graph clipping \(Out of bounds\)? [\#83](https://github.com/Jawbone/JBChartView/issues/83)
## [v2.7.3](https://github.com/Jawbone/JBChartView/tree/v2.7.3) (2014-08-07)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.7.2...v2.7.3)
**Closed issues:**
- Can I animate bar charts? [\#79](https://github.com/Jawbone/JBChartView/issues/79)
- Create generic dataSource and delegate for extensibility. [\#78](https://github.com/Jawbone/JBChartView/issues/78)
## [v2.7.2](https://github.com/Jawbone/JBChartView/tree/v2.7.2) (2014-08-04)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.7.1...v2.7.2)
## [v2.7.1](https://github.com/Jawbone/JBChartView/tree/v2.7.1) (2014-08-04)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.7.0...v2.7.1)
**Closed issues:**
- Typo in JBBarChartView.h [\#77](https://github.com/Jawbone/JBChartView/issues/77)
- Refactor datasource and delegate functions [\#76](https://github.com/Jawbone/JBChartView/issues/76)
## [v2.7.0](https://github.com/Jawbone/JBChartView/tree/v2.7.0) (2014-08-02)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.6.3...v2.7.0)
**Closed issues:**
- Incorrect padding on line widths [\#75](https://github.com/Jawbone/JBChartView/issues/75)
## [v2.6.3](https://github.com/Jawbone/JBChartView/tree/v2.6.3) (2014-07-31)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.6.2...v2.6.3)
## [v2.6.2](https://github.com/Jawbone/JBChartView/tree/v2.6.2) (2014-07-25)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.6.1...v2.6.2)
## [v2.6.1](https://github.com/Jawbone/JBChartView/tree/v2.6.1) (2014-07-25)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.6.0...v2.6.1)
**Merged pull requests:**
- iOS 6 support [\#74](https://github.com/Jawbone/JBChartView/pull/74) ([luosheng](https://github.com/luosheng))
## [v2.6.0](https://github.com/Jawbone/JBChartView/tree/v2.6.0) (2014-07-24)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.5.5...v2.6.0)
**Closed issues:**
- Allow setting views for lines as well as bars [\#73](https://github.com/Jawbone/JBChartView/issues/73)
- Requires iOS 7 or later [\#72](https://github.com/Jawbone/JBChartView/issues/72)
- How to Know the x,width of each bar [\#70](https://github.com/Jawbone/JBChartView/issues/70)
- Multiple y-axis [\#69](https://github.com/Jawbone/JBChartView/issues/69)
- NSInternalInconsistencyException - JBLineChartView // dataSource must implement [\#68](https://github.com/Jawbone/JBChartView/issues/68)
- Zoom and scrolling? \(Question\) [\#65](https://github.com/Jawbone/JBChartView/issues/65)
- Support for missing data points rather than going to 0? [\#63](https://github.com/Jawbone/JBChartView/issues/63)
- Interesting behavior 'barViewAtIndex' and 'colorForBarViewAtIndex'. [\#62](https://github.com/Jawbone/JBChartView/issues/62)
- In LineChart x-axis, splits into more numbers and not able view x-axis last point [\#60](https://github.com/Jawbone/JBChartView/issues/60)
- Overlay more than 1 chart? [\#59](https://github.com/Jawbone/JBChartView/issues/59)
- Footer Views - Can they be perpendicular to the x-axis [\#58](https://github.com/Jawbone/JBChartView/issues/58)
**Merged pull requests:**
- Fill Color on Line Chart [\#71](https://github.com/Jawbone/JBChartView/pull/71) ([legranddamien](https://github.com/legranddamien))
- Added documentation for usage in a Swift project [\#67](https://github.com/Jawbone/JBChartView/pull/67) ([jonparker](https://github.com/jonparker))
- barChartView corner radius support [\#66](https://github.com/Jawbone/JBChartView/pull/66) ([gabybarsky](https://github.com/gabybarsky))
- barWidth selector and better height normalization [\#64](https://github.com/Jawbone/JBChartView/pull/64) ([gabybarsky](https://github.com/gabybarsky))
- Added area diagram functionality [\#42](https://github.com/Jawbone/JBChartView/pull/42) ([hackingotter](https://github.com/hackingotter))
## [v2.5.5](https://github.com/Jawbone/JBChartView/tree/v2.5.5) (2014-05-14)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.5.4...v2.5.5)
**Implemented enhancements:**
- Ability to draw lines with negative values [\#51](https://github.com/Jawbone/JBChartView/issues/51)
**Closed issues:**
- How to adjust selected bar height for LineChart in demo project [\#56](https://github.com/Jawbone/JBChartView/issues/56)
- Line Chart Collapse Animation Changed? [\#54](https://github.com/Jawbone/JBChartView/issues/54)
**Merged pull requests:**
- Fixed barView's frame. [\#57](https://github.com/Jawbone/JBChartView/pull/57) ([pala](https://github.com/pala))
- Update sample code in readme [\#55](https://github.com/Jawbone/JBChartView/pull/55) ([pala](https://github.com/pala))
## [v2.5.4](https://github.com/Jawbone/JBChartView/tree/v2.5.4) (2014-05-07)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.5.3...v2.5.4)
**Merged pull requests:**
- Add delegate method barChartView:colorForBarViewAtIndex: to JBBarChartViewDataSource [\#53](https://github.com/Jawbone/JBChartView/pull/53) ([skywinder](https://github.com/skywinder))
- Compiling warrnings and typos [\#52](https://github.com/Jawbone/JBChartView/pull/52) ([skywinder](https://github.com/skywinder))
## [v2.5.3](https://github.com/Jawbone/JBChartView/tree/v2.5.3) (2014-05-06)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.5.2...v2.5.3)
## [v2.5.2](https://github.com/Jawbone/JBChartView/tree/v2.5.2) (2014-05-06)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.5.1...v2.5.2)
## [v2.5.1](https://github.com/Jawbone/JBChartView/tree/v2.5.1) (2014-05-05)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.5.0...v2.5.1)
**Closed issues:**
- non-evenly distributed plots [\#50](https://github.com/Jawbone/JBChartView/issues/50)
- Using minimum of 0 as default [\#48](https://github.com/Jawbone/JBChartView/issues/48)
## [v2.5.0](https://github.com/Jawbone/JBChartView/tree/v2.5.0) (2014-05-04)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.4.3...v2.5.0)
## [v2.4.3](https://github.com/Jawbone/JBChartView/tree/v2.4.3) (2014-05-04)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.4.2...v2.4.3)
**Closed issues:**
- Bars not drawn when all have the same height [\#47](https://github.com/Jawbone/JBChartView/issues/47)
- Moving podspec to root [\#46](https://github.com/Jawbone/JBChartView/issues/46)
**Merged pull requests:**
- fixed typo, renamed mininum -\> minimum [\#49](https://github.com/Jawbone/JBChartView/pull/49) ([simonnickel](https://github.com/simonnickel))
## [v2.4.2](https://github.com/Jawbone/JBChartView/tree/v2.4.2) (2014-05-01)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.4.1...v2.4.2)
## [v2.4.1](https://github.com/Jawbone/JBChartView/tree/v2.4.1) (2014-04-30)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.4.0...v2.4.1)
**Implemented enhancements:**
- Curved line charts [\#23](https://github.com/Jawbone/JBChartView/issues/23)
**Closed issues:**
- JBChartView demo footerview problem [\#44](https://github.com/Jawbone/JBChartView/issues/44)
**Merged pull requests:**
- Smooth curve fix [\#45](https://github.com/Jawbone/JBChartView/pull/45) ([ktran03](https://github.com/ktran03))
## [v2.4.0](https://github.com/Jawbone/JBChartView/tree/v2.4.0) (2014-04-28)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.3.0...v2.4.0)
**Closed issues:**
- Aligning X-axis, padding? [\#43](https://github.com/Jawbone/JBChartView/issues/43)
- `JBLineChartFooterView` Value Marks are Inaccurate [\#41](https://github.com/Jawbone/JBChartView/issues/41)
**Merged pull requests:**
- Allowing custom views for dots [\#40](https://github.com/Jawbone/JBChartView/pull/40) ([simonbromberg](https://github.com/simonbromberg))
- smooth curve using bezierpath [\#39](https://github.com/Jawbone/JBChartView/pull/39) ([ktran03](https://github.com/ktran03))
## [v2.3.0](https://github.com/Jawbone/JBChartView/tree/v2.3.0) (2014-04-18)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.2.0...v2.3.0)
**Closed issues:**
- Crash, lineChartView "must implement numberOfPointsInLineChartView" ? [\#38](https://github.com/Jawbone/JBChartView/issues/38)
## [v2.2.0](https://github.com/Jawbone/JBChartView/tree/v2.2.0) (2014-04-14)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.1.6...v2.2.0)
**Closed issues:**
- Typo in readme? [\#36](https://github.com/Jawbone/JBChartView/issues/36)
- Nav bar background remains black [\#35](https://github.com/Jawbone/JBChartView/issues/35)
**Merged pull requests:**
- Added delegate method to configure the width of the vertical selection bar in a line chart. [\#37](https://github.com/Jawbone/JBChartView/pull/37) ([veducm](https://github.com/veducm))
- Add variable dot colors [\#34](https://github.com/Jawbone/JBChartView/pull/34) ([alexdunn](https://github.com/alexdunn))
## [v2.1.6](https://github.com/Jawbone/JBChartView/tree/v2.1.6) (2014-04-11)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.1.5...v2.1.6)
**Closed issues:**
- `showsLineSelection` Does Nothing [\#33](https://github.com/Jawbone/JBChartView/issues/33)
- cocoapods [\#31](https://github.com/Jawbone/JBChartView/issues/31)
**Merged pull requests:**
- Add variable dot colors [\#32](https://github.com/Jawbone/JBChartView/pull/32) ([alexdunn](https://github.com/alexdunn))
## [v2.1.5](https://github.com/Jawbone/JBChartView/tree/v2.1.5) (2014-04-10)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.1.4...v2.1.5)
**Merged pull requests:**
- JBChartView: needs initWithCoder initializer for inflation from a xib [\#30](https://github.com/Jawbone/JBChartView/pull/30) ([gumbypp](https://github.com/gumbypp))
## [v2.1.4](https://github.com/Jawbone/JBChartView/tree/v2.1.4) (2014-04-10)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.1.3...v2.1.4)
**Closed issues:**
- Stach bars? [\#29](https://github.com/Jawbone/JBChartView/issues/29)
- Problem with Bar Height [\#28](https://github.com/Jawbone/JBChartView/issues/28)
- Selection does not work without Auto Layout in iPhone 3.5" [\#27](https://github.com/Jawbone/JBChartView/issues/27)
## [v2.1.3](https://github.com/Jawbone/JBChartView/tree/v2.1.3) (2014-04-03)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.1.2...v2.1.3)
## [v2.1.2](https://github.com/Jawbone/JBChartView/tree/v2.1.2) (2014-04-02)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.1.1...v2.1.2)
## [v2.1.1](https://github.com/Jawbone/JBChartView/tree/v2.1.1) (2014-04-02)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.1.0...v2.1.1)
**Closed issues:**
- representing negative values [\#26](https://github.com/Jawbone/JBChartView/issues/26)
- Real time [\#25](https://github.com/Jawbone/JBChartView/issues/25)
## [v2.1.0](https://github.com/Jawbone/JBChartView/tree/v2.1.0) (2014-03-31)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.0.2...v2.1.0)
## [v2.0.2](https://github.com/Jawbone/JBChartView/tree/v2.0.2) (2014-03-27)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.0.1...v2.0.2)
**Closed issues:**
- Negative Bars? [\#24](https://github.com/Jawbone/JBChartView/issues/24)
## [v2.0.1](https://github.com/Jawbone/JBChartView/tree/v2.0.1) (2014-03-19)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v2.0.0...v2.0.1)
**Closed issues:**
- NSAssert on bar height in JBBarChartView, \> 0 when it should be \>= [\#22](https://github.com/Jawbone/JBChartView/issues/22)
## [v2.0.0](https://github.com/Jawbone/JBChartView/tree/v2.0.0) (2014-03-19)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v1.1.6...v2.0.0)
**Implemented enhancements:**
- Multiple Lines on chart [\#6](https://github.com/Jawbone/JBChartView/issues/6)
**Closed issues:**
- JBBarChartView Bar Height Problem With Storyboard/Autolayout [\#19](https://github.com/Jawbone/JBChartView/issues/19)
- blank result [\#18](https://github.com/Jawbone/JBChartView/issues/18)
- Bar Highlight Offset Issue [\#17](https://github.com/Jawbone/JBChartView/issues/17)
- Following the tutorial creates an empty/blank view [\#16](https://github.com/Jawbone/JBChartView/issues/16)
**Merged pull requests:**
- Multiple Line Support & Tooltips [\#21](https://github.com/Jawbone/JBChartView/pull/21) ([terryworona](https://github.com/terryworona))
## [v1.1.6](https://github.com/Jawbone/JBChartView/tree/v1.1.6) (2014-03-03)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v1.1.5...v1.1.6)
**Merged pull requests:**
- Added customization for line width [\#15](https://github.com/Jawbone/JBChartView/pull/15) ([kmcbride](https://github.com/kmcbride))
- fix spelling mistake [\#14](https://github.com/Jawbone/JBChartView/pull/14) ([Undo1](https://github.com/Undo1))
## [v1.1.5](https://github.com/Jawbone/JBChartView/tree/v1.1.5) (2014-02-12)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v1.1.4...v1.1.5)
## [v1.1.4](https://github.com/Jawbone/JBChartView/tree/v1.1.4) (2014-02-06)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v1.1.3...v1.1.4)
**Closed issues:**
- What about ios6 [\#13](https://github.com/Jawbone/JBChartView/issues/13)
- Could the Bar Chart data be nil ? [\#12](https://github.com/Jawbone/JBChartView/issues/12)
**Merged pull requests:**
- Added minimum height and touch point on delegate method [\#10](https://github.com/Jawbone/JBChartView/pull/10) ([didats](https://github.com/didats))
## [v1.1.3](https://github.com/Jawbone/JBChartView/tree/v1.1.3) (2014-01-06)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v1.1.2...v1.1.3)
**Closed issues:**
- heightForIndex should return CGFloat instead of NSInteger [\#9](https://github.com/Jawbone/JBChartView/issues/9)
**Merged pull requests:**
- Fixes small typos in README [\#11](https://github.com/Jawbone/JBChartView/pull/11) ([sampage](https://github.com/sampage))
## [v1.1.2](https://github.com/Jawbone/JBChartView/tree/v1.1.2) (2014-01-03)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v1.1.1...v1.1.2)
## [v1.1.1](https://github.com/Jawbone/JBChartView/tree/v1.1.1) (2014-01-02)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v1.1.0...v1.1.1)
**Closed issues:**
- reloadData is not reducing height of other bars [\#7](https://github.com/Jawbone/JBChartView/issues/7)
- Add barViewAtIndex: to datasource [\#5](https://github.com/Jawbone/JBChartView/issues/5)
**Merged pull requests:**
- Reset cached max height on data reload Fixes \#7 [\#8](https://github.com/Jawbone/JBChartView/pull/8) ([l4u](https://github.com/l4u))
## [v1.1.0](https://github.com/Jawbone/JBChartView/tree/v1.1.0) (2013-12-26)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v1.0.3...v1.1.0)
## [v1.0.3](https://github.com/Jawbone/JBChartView/tree/v1.0.3) (2013-12-23)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v1.0.2...v1.0.3)
**Closed issues:**
- Single press on bar [\#3](https://github.com/Jawbone/JBChartView/issues/3)
**Merged pull requests:**
- Added barShadowEnabled property and improved performance of the shadow [\#4](https://github.com/Jawbone/JBChartView/pull/4) ([wtsnz](https://github.com/wtsnz))
## [v1.0.2](https://github.com/Jawbone/JBChartView/tree/v1.0.2) (2013-12-17)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v1.0.1...v1.0.2)
## [v1.0.1](https://github.com/Jawbone/JBChartView/tree/v1.0.1) (2013-12-15)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/v1.0...v1.0.1)
**Merged pull requests:**
- If there is no footer view, bars won't be added to the chart. [\#2](https://github.com/Jawbone/JBChartView/pull/2) ([joelkraut](https://github.com/joelkraut))
## [v1.0](https://github.com/Jawbone/JBChartView/tree/v1.0) (2013-12-11)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/0.2.0...v1.0)
**Merged pull requests:**
- JBChartViewDemo and JBChartView [\#1](https://github.com/Jawbone/JBChartView/pull/1) ([terryworona](https://github.com/terryworona))
## [0.2.0](https://github.com/Jawbone/JBChartView/tree/0.2.0) (2013-08-20)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/1.0...0.2.0)
## [1.0](https://github.com/Jawbone/JBChartView/tree/1.0) (2012-04-23)
[Full Changelog](https://github.com/Jawbone/JBChartView/compare/1.0.0...1.0)
## [1.0.0](https://github.com/Jawbone/JBChartView/tree/1.0.0) (2012-04-23)
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
+87 -55
View File
@@ -9,29 +9,43 @@
// Views
#import "JBChartView.h"
@protocol JBBarChartViewDelegate;
@protocol JBBarChartViewDataSource;
@class JBBarChartView;
@interface JBBarChartView : JBChartView
@property (nonatomic, weak) id<JBBarChartViewDelegate> delegate;
@property (nonatomic, weak) id<JBBarChartViewDataSource> dataSource;
/**
* Vertical highlight overlayed on bar during touch events.
*
* Default: YES.
*/
@property (nonatomic, assign) BOOL showsVerticalSelection;
@end
@protocol JBBarChartViewDelegate <NSObject>
@protocol JBBarChartViewDataSource <JBChartViewDataSource>
@required
/**
* Height for a bar at a given index (left to right). There is no ceiling on the the height;
* The number of bars in a given bar chart is the number of vertical views shown along the x-axis.
*
* @param barChartView The bar chart object requesting this information.
*
* @return Number of bars in the given chart, displayed horizontally along the chart's x-axis.
*/
- (NSUInteger)numberOfBarsInBarChartView:(JBBarChartView *)barChartView;
@optional
/**
* A UIView subclass representing the bar at a particular index.
*
* Default: solid black UIView.
*
* @param barChartView The bar chart object requesting this information.
* @param index The 0-based index of a given bar (left to right, x-axis).
*
* @return A UIView subclass. The view will automatically be resized by the chart during creation (ie. no need to set the frame).
*/
- (UIView *)barChartView:(JBBarChartView *)barChartView barViewAtIndex:(NSUInteger)index;
@end
@protocol JBBarChartViewDelegate <JBChartViewDelegate>
@required
/**
* Height for a bar at a given index (left to right). There is no ceiling on the the height;
* the chart will automatically normalize all values between the overal min and max heights.
*
* @param barChartView The bar chart object requesting this information.
@@ -39,7 +53,7 @@
*
* @return The y-axis height of the supplied bar index (x-axis)
*/
- (CGFloat)barChartView:(JBBarChartView *)barChartView heightForBarViewAtAtIndex:(NSUInteger)index;
- (CGFloat)barChartView:(JBBarChartView *)barChartView heightForBarViewAtIndex:(NSUInteger)index;
@optional
@@ -58,53 +72,26 @@
* Occurs when selection ends by either ending a touch event or selecting an area that is outside the view's bounds.
* For selection start events, see: didSelectBarAtIndex...
*
* @param barChartView A bar chart object informing the delegate about the unselection.
* @param barChartView A bar chart object informing the delegate about the deselection.
*/
- (void)didUnselectBarChartView:(JBBarChartView *)barChartView;
@end
@protocol JBBarChartViewDataSource <NSObject>
@required
- (void)didDeselectBarChartView:(JBBarChartView *)barChartView;
/**
* The number of bars in a given bar chart is the number of vertical views shown along the x-axis.
* If you already implement barChartView:barViewAtIndex: delegate - this method has no effect.
* If a custom UIView isn't supplied, a flat bar will be made automatically (default color black).
*
* @param barChartView The bar chart object requesting this information.
*
* @return Number of bars in the given chart, displayed horizontally along the chart's x-axis.
*/
- (NSUInteger)numberOfBarsInBarChartView:(JBBarChartView *)barChartView;
@optional
/**
* Horizontal padding between bars.
*
* Default: 'best-guess' algorithm based on the the total number of bars and width of the chart.
*
* @param barChartView The bar chart object requesting this information.
*
* @return Horizontal width (in pixels) between each bar.
*/
- (NSUInteger)barPaddingForBarChartView:(JBBarChartView *)barChartView;
/**
* A UIView subclass representing the bar at a particular index.
*
* Default: solid black UIView.
* Default: if none specified - calls barChartView:barViewAtIndex:.
*
* @param barChartView The bar chart object requesting this information.
* @param index The 0-based index of a given bar (left to right, x-axis).
*
* @return A UIView subclass. The view will automatically be resized by the chart during creation (ie. no need to set the frame).
* @return The color to be used to color a bar in the chart.
*/
- (UIView *)barChartView:(JBBarChartView *)barChartView barViewAtIndex:(NSUInteger)index;
- (UIColor *)barChartView:(JBBarChartView *)barChartView colorForBarViewAtIndex:(NSUInteger)index;
/**
* The selection color to be overlayed on a bar during touch events.
* The color is automically faded to transparent (vertically). The property showsVerticalSelection
* The selection color to be overlayed on a bar during touch events.
* The color is automatically faded to transparent (vertically). The property showsVerticalSelection
* must be YES for the color to apply.
*
* Default: white color (faded to transparent).
@@ -115,4 +102,49 @@
*/
- (UIColor *)barSelectionColorForBarChartView:(JBBarChartView *)barChartView;
/**
* Horizontal padding between bars.
*
* Default: 'best-guess' algorithm based on the the total number of bars and width of the chart.
*
* @param barChartView The bar chart object requesting this information.
*
* @return Horizontal width (in pixels) between each bar.
*/
- (CGFloat)barPaddingForBarChartView:(JBBarChartView *)barChartView;
@end
@interface JBBarChartView : JBChartView
@property (nonatomic, weak) id<JBBarChartViewDataSource> dataSource;
@property (nonatomic, weak) id<JBBarChartViewDelegate> delegate;
/**
* Vertical highlight overlayed on bar during touch events.
*
* Default: YES.
*/
@property (nonatomic, assign) BOOL showsVerticalSelection;
/*
* Bars can be (vertically) positoned top to bottom instead of bottom up.
* If this property is set to YES, both the bar and the selection view will be inverted.
* For the inverted orientation to take effect, reloadData must be called.
*
* Default: NO.
*/
@property (nonatomic, assign, getter=isInverted) BOOL inverted;
/**
* The bar view at a particular index.
*
* Default: nil.
*
* @param index The 0-based index of a given bar (left to right, x-axis).
*
* @return The UIView representing the bar view at a given index or nil if the index is out of range.
*/
- (UIView *)barViewAtIndex:(NSUInteger)index;
@end
+194 -107
View File
@@ -12,16 +12,24 @@
CGFloat static const kJBBarChartViewBarBasePaddingMutliplier = 50.0f;
CGFloat static const kJBBarChartViewUndefinedCachedHeight = -1.0f;
CGFloat static const kJBBarChartViewStateAnimationDuration = 0.05f;
CGFloat static const kJBBarChartViewPopOffset = 10.0f; // used to offset bars for 'pop' animations
CGFloat static const kJBBarChartViewStatePopOffset = 10.0f;
NSInteger static const kJBBarChartViewUndefinedBarIndex = -1;
// Colors (JBChartView)
static UIColor *kJBBarChartViewDefaultBarColor = nil;
@interface JBChartView (Private)
- (BOOL)hasMaximumValue;
- (BOOL)hasMinimumValue;
@end
@interface JBBarChartView ()
@property (nonatomic, strong) NSDictionary *chartDataDictionary; // key = column, value = height
@property (nonatomic, strong) NSArray *barViews;
@property (nonatomic, strong) NSArray *cachedBarViewHeights;
@property (nonatomic, assign) CGFloat barPadding;
@property (nonatomic, assign) CGFloat cachedMaxHeight;
@property (nonatomic, assign) CGFloat cachedMinHeight;
@@ -34,10 +42,7 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
// View quick accessors
- (CGFloat)availableHeight;
- (CGFloat)normalizedHeightForRawHeight:(NSNumber*)rawHeight;
- (CGFloat)minHeight;
- (CGFloat)maxHeight;
- (CGFloat)barWidth;
- (CGFloat)popOffset;
// Touch helpers
- (NSInteger)barViewIndexForPoint:(CGPoint)point;
@@ -125,12 +130,12 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
NSUInteger dataCount = [self.dataSource numberOfBarsInBarChartView:self];
// Build up the data collection
NSAssert([self.delegate respondsToSelector:@selector(barChartView:heightForBarViewAtAtIndex:)], @"JBBarChartView // delegate must implement - (CGFloat)barChartView:(JBBarChartView *)barChartView heightForBarViewAtAtIndex:(NSUInteger)index");
NSAssert([self.delegate respondsToSelector:@selector(barChartView:heightForBarViewAtIndex:)], @"JBBarChartView // delegate must implement - (CGFloat)barChartView:(JBBarChartView *)barChartView heightForBarViewAtIndex:(NSUInteger)index");
NSMutableDictionary *dataDictionary = [NSMutableDictionary dictionary];
for (NSUInteger index=0; index<dataCount; index++)
{
CGFloat height = [self.delegate barChartView:self heightForBarViewAtAtIndex:index];
NSAssert(height >= 0, @"JBBarChartView // datasource function - (CGFloat)barChartView:(JBBarChartView *)barChartView heightForBarViewAtAtIndex:(NSUInteger)index must return a CGFloat >= 0");
CGFloat height = [self.delegate barChartView:self heightForBarViewAtIndex:index];
NSAssert(height >= 0, @"JBBarChartView // datasource function - (CGFloat)barChartView:(JBBarChartView *)barChartView heightForBarViewAtIndex:(NSUInteger)index must return a CGFloat >= 0");
[dataDictionary setObject:[NSNumber numberWithFloat:height] forKey:[NSNumber numberWithInt:(int)index]];
}
self.chartDataDictionary = [NSDictionary dictionaryWithDictionary:dataDictionary];
@@ -140,9 +145,9 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
* Determines the padding between bars as a function of # of bars
*/
dispatch_block_t createBarPadding = ^{
if ([self.dataSource respondsToSelector:@selector(barPaddingForBarChartView:)])
if ([self.delegate respondsToSelector:@selector(barPaddingForBarChartView:)])
{
self.barPadding = [self.dataSource barPaddingForBarChartView:self];
self.barPadding = [self.delegate barPaddingForBarChartView:self];
}
else
{
@@ -162,9 +167,12 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
[barView removeFromSuperview];
}
self.cachedBarViewHeights = nil;
CGFloat xOffset = 0;
NSUInteger index = 0;
NSMutableArray *mutableBarViews = [NSMutableArray array];
NSMutableArray *mutableCachedBarViewHeights = [NSMutableArray array];
for (NSNumber *key in [[self.chartDataDictionary allKeys] sortedArrayUsingSelector:@selector(compare:)])
{
UIView *barView = nil; // since all bars are visible at once, no need to cache this view
@@ -176,12 +184,27 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
else
{
barView = [[UIView alloc] init];
barView.backgroundColor = kJBBarChartViewDefaultBarColor;
UIColor *backgroundColor = nil;
if ([self.delegate respondsToSelector:@selector(barChartView:colorForBarViewAtIndex:)])
{
backgroundColor = [self.delegate barChartView:self colorForBarViewAtIndex:index];
NSAssert(backgroundColor != nil, @"JBBarChartView // delegate function - (UIColor *)barChartView:(JBBarChartView *)barChartView colorForBarViewAtIndex:(NSUInteger)index must return a non-nil UIColor");
}
else
{
backgroundColor = kJBBarChartViewDefaultBarColor;
}
barView.backgroundColor = backgroundColor;
}
barView.tag = index;
CGFloat height = [self normalizedHeightForRawHeight:[self.chartDataDictionary objectForKey:key]];
CGFloat extensionHeight = height > 0.0 ? kJBBarChartViewPopOffset : 0.0;
barView.frame = CGRectMake(xOffset, self.bounds.size.height - height - self.footerView.frame.size.height + self.headerPadding, [self barWidth], height + extensionHeight - self.headerPadding);
barView.frame = CGRectMake(xOffset, self.bounds.size.height - height - self.footerView.frame.size.height, [self barWidth], height);
[mutableBarViews addObject:barView];
[mutableCachedBarViewHeights addObject:[NSNumber numberWithFloat:height]];
// Add new bar
if (self.footerView)
@@ -197,6 +220,7 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
index++;
}
self.barViews = [NSArray arrayWithArray:mutableBarViews];
self.cachedBarViewHeights = [NSArray arrayWithArray:mutableCachedBarViewHeights];
};
/*
@@ -211,12 +235,32 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
self.verticalSelectionView = nil;
}
self.verticalSelectionView = [[JBChartVerticalSelectionView alloc] initWithFrame:CGRectMake(0, 0, [self barWidth], self.bounds.size.height - self.footerView.frame.size.height)];
CGFloat verticalSelectionViewHeight = self.bounds.size.height - self.headerView.frame.size.height - self.footerView.frame.size.height - self.headerPadding - self.footerPadding;
if ([self.dataSource respondsToSelector:@selector(shouldExtendSelectionViewIntoHeaderPaddingForChartView:)])
{
if ([self.dataSource shouldExtendSelectionViewIntoHeaderPaddingForChartView:self])
{
verticalSelectionViewHeight += self.headerPadding;
}
}
if ([self.dataSource respondsToSelector:@selector(shouldExtendSelectionViewIntoFooterPaddingForChartView:)])
{
if ([self.dataSource shouldExtendSelectionViewIntoFooterPaddingForChartView:self])
{
verticalSelectionViewHeight += self.footerPadding;
}
}
self.verticalSelectionView = [[JBChartVerticalSelectionView alloc] initWithFrame:CGRectMake(0, 0, [self barWidth], verticalSelectionViewHeight)];
self.verticalSelectionView.alpha = 0.0;
self.verticalSelectionView.hidden = !self.showsVerticalSelection;
if ([self.dataSource respondsToSelector:@selector(barSelectionColorForBarChartView:)])
if ([self.delegate respondsToSelector:@selector(barSelectionColorForBarChartView:)])
{
self.verticalSelectionView.bgColor = [self.dataSource barSelectionColorForBarChartView:self];
UIColor *selectionViewBackgroundColor = [self.delegate barSelectionColorForBarChartView:self];
NSAssert(selectionViewBackgroundColor != nil, @"JBBarChartView // delegate function - (UIColor *)barSelectionColorForBarChartView:(JBBarChartView *)barChartView must return a non-nil UIColor");
self.verticalSelectionView.bgColor = selectionViewBackgroundColor;
}
// Add new selection bar
@@ -228,6 +272,8 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
{
[self addSubview:self.verticalSelectionView];
}
self.verticalSelectionView.transform = self.inverted ? CGAffineTransformMakeScale(1.0, -1.0) : CGAffineTransformIdentity;
};
createDataDictionaries();
@@ -240,20 +286,20 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
self.footerView.frame = CGRectMake(self.bounds.origin.x, self.bounds.size.height - self.footerView.frame.size.height, self.bounds.size.width, self.footerView.frame.size.height);
// Refresh state
[self setState:self.state animated:NO callback:nil force:YES];
[self setState:self.state animated:NO force:YES callback:nil];
}
#pragma mark - View Quick Accessors
- (CGFloat)availableHeight
{
return self.bounds.size.height - self.headerView.frame.size.height - self.footerView.frame.size.height - self.headerPadding;
return self.bounds.size.height - self.headerView.frame.size.height - self.footerView.frame.size.height - self.headerPadding - self.footerPadding;
}
- (CGFloat)normalizedHeightForRawHeight:(NSNumber*)rawHeight
{
CGFloat minHeight = [self minHeight];
CGFloat maxHeight = [self maxHeight];
CGFloat minHeight = [self minimumValue];
CGFloat maxHeight = [self maximumValue];
CGFloat value = [rawHeight floatValue];
if ((maxHeight - minHeight) <= 0)
@@ -264,24 +310,6 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
return ((value - minHeight) / (maxHeight - minHeight)) * [self availableHeight];
}
- (CGFloat)minHeight
{
if (self.mininumValue != kJBChartViewUndefinedMinimumValue)
{
return MIN(self.mininumValue, self.cachedMinHeight);
}
return self.cachedMinHeight;
}
- (CGFloat)maxHeight
{
if (self.maximumValue != kJBChartViewUndefinedMaximumValue)
{
return MAX(self.maximumValue, self.cachedMaxHeight);
}
return self.cachedMaxHeight;
}
- (CGFloat)barWidth
{
NSUInteger barCount = [[self.chartDataDictionary allKeys] count];
@@ -294,16 +322,68 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
return 0;
}
- (CGFloat)popOffset
{
return self.bounds.size.height - self.footerView.frame.size.height;
}
#pragma mark - Setters
- (void)setState:(JBChartViewState)state animated:(BOOL)animated callback:(void (^)())callback force:(BOOL)force
- (void)setState:(JBChartViewState)state animated:(BOOL)animated force:(BOOL)force callback:(void (^)())callback
{
[super setState:state animated:animated callback:callback force:force];
[super setState:state animated:animated force:force callback:callback];
__weak JBBarChartView* weakSelf = self;
void (^updateBarView)(UIView *barView, BOOL popBar);
updateBarView = ^(UIView *barView, BOOL popBar) {
if (weakSelf.inverted)
{
if (weakSelf.state == JBChartViewStateExpanded)
{
if (popBar)
{
barView.frame = CGRectMake(barView.frame.origin.x, weakSelf.headerView.frame.size.height + weakSelf.headerPadding, barView.frame.size.width, [[weakSelf.cachedBarViewHeights objectAtIndex:barView.tag] floatValue] + kJBBarChartViewStatePopOffset);
}
else
{
barView.frame = CGRectMake(barView.frame.origin.x, weakSelf.headerView.frame.size.height + weakSelf.headerPadding, barView.frame.size.width, [[weakSelf.cachedBarViewHeights objectAtIndex:barView.tag] floatValue]);
}
}
else if (weakSelf.state == JBChartViewStateCollapsed)
{
if (popBar)
{
barView.frame = CGRectMake(barView.frame.origin.x, weakSelf.headerView.frame.size.height + weakSelf.headerPadding, barView.frame.size.width, [[weakSelf.cachedBarViewHeights objectAtIndex:barView.tag] floatValue] + kJBBarChartViewStatePopOffset);
}
else
{
barView.frame = CGRectMake(barView.frame.origin.x, weakSelf.headerView.frame.size.height + weakSelf.headerPadding, barView.frame.size.width, 0.0f);
}
}
}
else
{
if (weakSelf.state == JBChartViewStateExpanded)
{
if (popBar)
{
barView.frame = CGRectMake(barView.frame.origin.x, weakSelf.bounds.size.height - weakSelf.footerView.frame.size.height - weakSelf.footerPadding - [[weakSelf.cachedBarViewHeights objectAtIndex:barView.tag] floatValue] - kJBBarChartViewStatePopOffset, barView.frame.size.width, [[weakSelf.cachedBarViewHeights objectAtIndex:barView.tag] floatValue] + kJBBarChartViewStatePopOffset);
}
else
{
barView.frame = CGRectMake(barView.frame.origin.x, weakSelf.bounds.size.height - weakSelf.footerView.frame.size.height - weakSelf.footerPadding - [[weakSelf.cachedBarViewHeights objectAtIndex:barView.tag] floatValue], barView.frame.size.width, [[weakSelf.cachedBarViewHeights objectAtIndex:barView.tag] floatValue]);
}
}
else if (weakSelf.state == JBChartViewStateCollapsed)
{
if (popBar)
{
barView.frame = CGRectMake(barView.frame.origin.x, weakSelf.bounds.size.height - weakSelf.footerView.frame.size.height - weakSelf.footerPadding - [[weakSelf.cachedBarViewHeights objectAtIndex:barView.tag] floatValue] - kJBBarChartViewStatePopOffset, barView.frame.size.width, [[weakSelf.cachedBarViewHeights objectAtIndex:barView.tag] floatValue] + kJBBarChartViewStatePopOffset);
}
else
{
barView.frame = CGRectMake(barView.frame.origin.x, weakSelf.bounds.size.height, barView.frame.size.width, 0.0f);
}
}
}
};
dispatch_block_t callbackCopy = [callback copy];
@@ -311,25 +391,16 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
{
if (animated)
{
CGFloat popOffset = [self popOffset];
NSUInteger index = 0;
for (UIView *barView in self.barViews)
{
[UIView animateWithDuration:kJBBarChartViewStateAnimationDuration delay:(kJBBarChartViewStateAnimationDuration * 0.5) * index options:UIViewAnimationOptionBeginFromCurrentState animations:^{
barView.frame = CGRectMake(barView.frame.origin.x, popOffset - barView.frame.size.height, barView.frame.size.width, barView.frame.size.height);
updateBarView(barView, YES);
} completion:^(BOOL finished) {
[UIView animateWithDuration:kJBBarChartViewStateAnimationDuration delay:0.0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
if (state == JBChartViewStateExpanded)
{
barView.frame = CGRectMake(barView.frame.origin.x, popOffset - barView.frame.size.height + kJBBarChartViewPopOffset, barView.frame.size.width, barView.frame.size.height);
}
else if (state == JBChartViewStateCollapsed)
{
barView.frame = CGRectMake(barView.frame.origin.x, self.bounds.size.height, barView.frame.size.width, barView.frame.size.height);
}
updateBarView(barView, NO);
} completion:^(BOOL lastBarFinished) {
if (index == [self.barViews count] - 1)
if ((NSUInteger)barView.tag == [self.barViews count] - 1)
{
if (callbackCopy)
{
@@ -345,14 +416,7 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
{
for (UIView *barView in self.barViews)
{
if (state == JBChartViewStateExpanded)
{
barView.frame = CGRectMake(barView.frame.origin.x, (self.bounds.size.height + kJBBarChartViewPopOffset) - (barView.frame.size.height + self.footerView.frame.size.height), barView.frame.size.width, barView.frame.size.height);
}
else if (state == JBChartViewStateCollapsed)
{
barView.frame = CGRectMake(barView.frame.origin.x, self.bounds.size.height, barView.frame.size.width, barView.frame.size.height);
}
updateBarView(barView, NO);
}
if (callbackCopy)
{
@@ -371,7 +435,34 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
- (void)setState:(JBChartViewState)state animated:(BOOL)animated callback:(void (^)())callback
{
[self setState:state animated:animated callback:callback force:NO];
[self setState:state animated:animated force:NO callback:callback];
}
- (void)setVerticalSelectionViewVisible:(BOOL)verticalSelectionViewVisible animated:(BOOL)animated
{
_verticalSelectionViewVisible = verticalSelectionViewVisible;
if (animated)
{
[UIView animateWithDuration:kJBChartViewDefaultAnimationDuration delay:0.0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
self.verticalSelectionView.alpha = self.verticalSelectionViewVisible ? 1.0 : 0.0;
} completion:nil];
}
else
{
self.verticalSelectionView.alpha = _verticalSelectionViewVisible ? 1.0 : 0.0;
}
}
- (void)setVerticalSelectionViewVisible:(BOOL)verticalSelectionViewVisible
{
[self setVerticalSelectionViewVisible:verticalSelectionViewVisible animated:NO];
}
- (void)setShowsVerticalSelection:(BOOL)showsVerticalSelection
{
_showsVerticalSelection = showsVerticalSelection;
self.verticalSelectionView.hidden = _showsVerticalSelection ? NO : YES;
}
#pragma mark - Getters
@@ -380,8 +471,7 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
{
if(_cachedMinHeight == kJBBarChartViewUndefinedCachedHeight)
{
// min height is min value across all goals and values
NSArray *chartValues = [[[self.chartDataDictionary allValues] arrayByAddingObjectsFromArray:[self.chartDataDictionary allValues]] sortedArrayUsingSelector:@selector(compare:)];
NSArray *chartValues = [[NSMutableArray arrayWithArray:[self.chartDataDictionary allValues]] sortedArrayUsingSelector:@selector(compare:)];
_cachedMinHeight = [[chartValues firstObject] floatValue];
}
return _cachedMinHeight;
@@ -391,29 +481,37 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
{
if (_cachedMaxHeight == kJBBarChartViewUndefinedCachedHeight)
{
// max height is max value across all goals and values
NSArray *chartValues = [[[self.chartDataDictionary allValues] arrayByAddingObjectsFromArray:[self.chartDataDictionary allValues]] sortedArrayUsingSelector:@selector(compare:)];
NSArray *chartValues = [[NSMutableArray arrayWithArray:[self.chartDataDictionary allValues]] sortedArrayUsingSelector:@selector(compare:)];
_cachedMaxHeight = [[chartValues lastObject] floatValue];
}
return _cachedMaxHeight;
}
- (CGFloat)mininumValue
- (CGFloat)minimumValue
{
if ([super mininumValue] == kJBChartViewUndefinedMinimumValue)
if ([self hasMinimumValue])
{
return self.cachedMinHeight;
return fminf(self.cachedMinHeight, [super minimumValue]);
}
return [super mininumValue];
return self.cachedMinHeight;
}
- (CGFloat)maximumValue
{
if ([super maximumValue] == kJBChartViewUndefinedMaximumValue)
if ([self hasMaximumValue])
{
return self.cachedMaxHeight;
return fmaxf(self.cachedMaxHeight, [super maximumValue]);
}
return [super maximumValue];
return self.cachedMaxHeight;
}
- (UIView *)barViewAtIndex:(NSUInteger)index
{
if (index < [self.barViews count])
{
return [self.barViews objectAtIndex:index];
}
return nil;
}
#pragma mark - Touch Helpers
@@ -472,6 +570,24 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
CGRect barViewFrame = barView.frame;
CGRect selectionViewFrame = self.verticalSelectionView.frame;
selectionViewFrame.origin.x = barViewFrame.origin.x;
selectionViewFrame.size.width = barViewFrame.size.width;
if ([self.dataSource respondsToSelector:@selector(shouldExtendSelectionViewIntoHeaderPaddingForChartView:)])
{
if ([self.dataSource shouldExtendSelectionViewIntoHeaderPaddingForChartView:self])
{
selectionViewFrame.origin.y = self.headerView.frame.size.height;
}
else
{
selectionViewFrame.origin.y = self.headerView.frame.size.height + self.headerPadding;
}
}
else
{
selectionViewFrame.origin.y = self.headerView.frame.size.height + self.headerPadding;
}
self.verticalSelectionView.frame = selectionViewFrame;
[self setVerticalSelectionViewVisible:YES animated:YES];
@@ -495,41 +611,12 @@ static UIColor *kJBBarChartViewDefaultBarColor = nil;
[self setVerticalSelectionViewVisible:NO animated:YES];
if ([self.delegate respondsToSelector:@selector(didUnselectBarChartView:)])
if ([self.delegate respondsToSelector:@selector(didDeselectBarChartView:)])
{
[self.delegate didUnselectBarChartView:self];
[self.delegate didDeselectBarChartView:self];
}
}
#pragma mark - Setters
- (void)setVerticalSelectionViewVisible:(BOOL)verticalSelectionViewVisible animated:(BOOL)animated
{
_verticalSelectionViewVisible = verticalSelectionViewVisible;
if (animated)
{
[UIView animateWithDuration:kJBChartViewDefaultAnimationDuration delay:0.0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
self.verticalSelectionView.alpha = self.verticalSelectionViewVisible ? 1.0 : 0.0;
} completion:nil];
}
else
{
self.verticalSelectionView.alpha = _verticalSelectionViewVisible ? 1.0 : 0.0;
}
}
- (void)setVerticalSelectionViewVisible:(BOOL)verticalSelectionViewVisible
{
[self setVerticalSelectionViewVisible:verticalSelectionViewVisible animated:NO];
}
- (void)setShowsVerticalSelection:(BOOL)showsVerticalSelection
{
_showsVerticalSelection = showsVerticalSelection;
self.verticalSelectionView.hidden = _showsVerticalSelection ? NO : YES;
}
#pragma mark - Touches
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
+64 -6
View File
@@ -7,10 +7,11 @@
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
extern CGFloat const kJBChartViewDefaultAnimationDuration;
extern CGFloat const kJBChartViewUndefinedMinimumValue; // helper for undefined min/max values
extern CGFloat const kJBChartViewUndefinedMaximumValue;
@class JBChartView;
/**
* At a minimum, a chart can support two states, along with animations to-and-from.
@@ -26,8 +27,48 @@ typedef NS_ENUM(NSInteger, JBChartViewState){
JBChartViewStateCollapsed
};
@protocol JBChartViewDataSource <NSObject>
@optional
/**
* Returns whether or not the chart's selection view should extend into the header padding.
*
* Default: NO
*
* @param chartView The chart object requesting this information.
*
* @return Whether or not a chart's selection view should extend into the header padding.
*/
- (BOOL)shouldExtendSelectionViewIntoHeaderPaddingForChartView:(JBChartView *)chartView;
/**
* Returns whether or not the chart's selection view should extend into the footer padding.
*
* Default: NO
*
* @param chartView The chart object requesting this information.
*
* @return Whether or not a chart's selection view should extend into the footer padding.
*/
- (BOOL)shouldExtendSelectionViewIntoFooterPaddingForChartView:(JBChartView *)chartView;
@end
@protocol JBChartViewDelegate <NSObject>
// Extend (via subclass) to add custom functionality
@end
@interface JBChartView : UIView
/*
* Base dataSource and delegate protocols.
*/
@property (nonatomic, weak) id<JBChartViewDataSource> dataSource;
@property (nonatomic, weak) id<JBChartViewDelegate> delegate;
/**
* Header and footer views are shown above and below the chart respectively.
* Each view will be stretched horizontally to fill width of chart.
@@ -38,12 +79,24 @@ typedef NS_ENUM(NSInteger, JBChartViewState){
/**
* The vertical padding between the header and highest chart point (bar, line, etc).
* By default, the selection view will extend into the header padding area. To modify this behaviour,
* implement the dataSource protocol - (BOOL)shouldExtendSelectionViewIntoHeaderPaddingForChartView:(JBChartView *)chartView.
*/
@property (nonatomic, assign) CGFloat headerPadding;
/**
* The vertical padding between the footer and lowest chart point (bar, line, etc).
* By default, the selection view will extend into the footer padding area. To modify this behaviour,
* implement the dataSource protocol - (BOOL)shouldExtendSelectionViewIntoFooterPaddingForChartView:(JBChartView *)chartView.
*/
@property (nonatomic, assign) CGFloat footerPadding;
/**
* The minimum and maxmimum values of the chart.
* If no value(s) are supplied, the min and max values of the chart's data source are used.
* If no value(s) are supplied:
*
* minimumValue = chart's data source min value.
* maxmimumValue = chart's data source max value.
*
* If value(s) are supplied, they must be >= 0, otherwise an assertion will be thrown.
* The min/max values are clamped to the ceiling and floor of the actual min/max values of the chart's data source;
@@ -51,9 +104,13 @@ typedef NS_ENUM(NSInteger, JBChartViewState){
*
* For min/max modifications to take effect, reloadData must be called.
*/
@property (nonatomic, assign) CGFloat mininumValue;
@property (nonatomic, assign) CGFloat minimumValue;
@property (nonatomic, assign) CGFloat maximumValue;
// reset to default (chart's data source min & max value)
- (void)resetMinimumValue;
- (void)resetMaximumValue;
/**
* Charts can either be expanded or contracted.
* By default, a chart should be expanded on initialization.
@@ -63,6 +120,7 @@ typedef NS_ENUM(NSInteger, JBChartViewState){
/**
* Acts similiar to a UITableView's reloadData function.
* The entire chart will be torn down and re-constructed via datasource and delegate protocls.
* If a chart's frame changes, reloadData must be called directly afterwards for the changes to take effect.
*/
- (void)reloadData;
@@ -71,10 +129,10 @@ typedef NS_ENUM(NSInteger, JBChartViewState){
*
* @param state Either collapse or expanded.
* @param animated Whether or not the state should be animated or not.
* @param callback Called once the animation is completed. If animated == NO, then callback is immediate.
* @param force If current state == new state, then setting force to YES will re-configure the chart (default NO).
* @param callback Called once the animation is completed. If animated == NO, then callback is immediate.
*/
- (void)setState:(JBChartViewState)state animated:(BOOL)animated callback:(void (^)())callback force:(BOOL)force;
- (void)setState:(JBChartViewState)state animated:(BOOL)animated force:(BOOL)force callback:(void (^)())callback;
/**
* State setter.
+21 -9
View File
@@ -8,15 +8,17 @@
#import "JBChartView.h"
// Numerics
CGFloat const kJBChartViewDefaultAnimationDuration = 0.25f;
CGFloat const kJBChartViewUndefinedMinimumValue = -1.0f;
CGFloat const kJBChartViewUndefinedMaximumValue = -1.0f;
// Color (JBChartSelectionView)
static UIColor *kJBChartVerticalSelectionViewDefaultBgColor = nil;
@interface JBChartView ()
@property (nonatomic, assign) BOOL hasMaximumValue;
@property (nonatomic, assign) BOOL hasMinimumValue;
// Construction
- (void)constructChartView;
@@ -59,8 +61,6 @@ static UIColor *kJBChartVerticalSelectionViewDefaultBgColor = nil;
- (void)constructChartView
{
self.clipsToBounds = YES;
_mininumValue = kJBChartViewUndefinedMinimumValue;
_maximumValue = kJBChartViewUndefinedMaximumValue;
}
#pragma mark - Public
@@ -111,7 +111,7 @@ static UIColor *kJBChartVerticalSelectionViewDefaultBgColor = nil;
[self reloadData];
}
- (void)setState:(JBChartViewState)state animated:(BOOL)animated callback:(void (^)())callback force:(BOOL)force
- (void)setState:(JBChartViewState)state animated:(BOOL)animated force:(BOOL)force callback:(void (^)())callback
{
if ((_state == state) && !force)
{
@@ -125,7 +125,7 @@ static UIColor *kJBChartVerticalSelectionViewDefaultBgColor = nil;
- (void)setState:(JBChartViewState)state animated:(BOOL)animated callback:(void (^)())callback
{
[self setState:state animated:animated callback:callback force:NO];
[self setState:state animated:animated force:NO callback:callback];
}
- (void)setState:(JBChartViewState)state animated:(BOOL)animated
@@ -138,16 +138,28 @@ static UIColor *kJBChartVerticalSelectionViewDefaultBgColor = nil;
[self setState:state animated:NO];
}
- (void)setMininumValue:(CGFloat)mininumValue
- (void)setMinimumValue:(CGFloat)minimumValue
{
NSAssert(mininumValue >= 0, @"JBChartView // the minimumValue must be >= 0.");
_mininumValue = mininumValue;
NSAssert(minimumValue >= 0, @"JBChartView // the minimumValue must be >= 0.");
_minimumValue = minimumValue;
_hasMinimumValue = YES;
}
- (void)setMaximumValue:(CGFloat)maximumValue
{
NSAssert(maximumValue >= 0, @"JBChartView // the maximumValue must be >= 0.");
_maximumValue = maximumValue;
_hasMaximumValue = YES;
}
- (void)resetMinimumValue
{
_hasMinimumValue = NO; // clears min
}
- (void)resetMaximumValue
{
_hasMaximumValue = NO; // clears max
}
@end
+168 -99
View File
@@ -8,6 +8,8 @@
#import "JBChartView.h"
@class JBLineChartView;
/**
* Current support for two line styles: solid (default) and dashed.
*/
@@ -22,75 +24,7 @@ typedef NS_ENUM(NSInteger, JBLineChartViewLineStyle){
JBLineChartViewLineStyleDashed
};
@protocol JBLineChartViewDelegate;
@protocol JBLineChartViewDataSource;
@interface JBLineChartView : JBChartView
@property (nonatomic, weak) id<JBLineChartViewDelegate> delegate;
@property (nonatomic, weak) id<JBLineChartViewDataSource> dataSource;
/**
* Vertical highlight overlayed on a line graph during touch events.
*
* Default: YES.
*/
@property (nonatomic, assign) BOOL showsVerticalSelection;
/**
* A highlight shown on a line within the graph during touch events. The highlighted line
* is the closest line to the touch point and corresponds to the lineIndex delegatd back via
* didSelectChartAtHorizontalIndex:atLineIndex: and didUnSlectChartAtHorizontalIndex:atLineIndex:
*
* Default: YES.
*/
@property (nonatomic, assign) BOOL showsLineSelection;
@end
@protocol JBLineChartViewDelegate <NSObject>
@required
/**
* Vertical value for a line point at a given index (left to right). There is no ceiling on the the height;
* the chart will automatically normalize all values between the overal min and max heights.
*
* @param lineChartView The line chart object requesting this information.
* @param horizontalIndex The 0-based horizontal index of a selection point (left to right, x-axis).
* @param lineIndex An index number identifying the closest line in the chart to the current touch point.
*
* @return The y-axis value of the supplied line index (x-axis)
*/
- (CGFloat)lineChartView:(JBLineChartView *)lineChartView verticalValueForHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex;
@optional
/**
* Occurs whenever there is a touch gesture on the chart (chart must be expanded).
* The horizontal index is the closest index to the touch point & is clamped to it's max/min value if it moves outside of the view's bounds.
* The lineIndex remains constant until the line is unselected and will be highlighted using the (optional) selectionColorForLineAtLineIndex: protocol.
* Futhermore, all other lines that aren't selected will be dimmed to 20%% opacity throughout the duration of the touch/move. Any dotted line that isn't the
* primary selection will have it's dots dimmed to hidden (to avoid transparency issues).
*
* @param lineChartView A line chart object informing the delegate about the new selection.
* @param lineIndex An index number identifying the closest line in the chart to the current touch
* @param horizontalIndex The 0-based horizontal index of a selection point (left to right, x-axis).point.
* @param touchPoint The touch point in relation to the chart's bounds (excludes footer and header).
*/
- (void)lineChartView:(JBLineChartView *)lineChartView didSelectLineAtIndex:(NSUInteger)lineIndex horizontalIndex:(NSUInteger)horizontalIndex touchPoint:(CGPoint)touchPoint;
- (void)lineChartView:(JBLineChartView *)lineChartView didSelectLineAtIndex:(NSUInteger)lineIndex horizontalIndex:(NSUInteger)horizontalIndex;
/**
* Occurs when selection ends by ending a touch event. For selection start events, see: didSelectChartAtIndex:
*
* @param lineChartView A line chart object informing the delegate about the unselection.
*/
- (void)didUnselectLineInLineChartView:(JBLineChartView *)lineChartView;
@end
@protocol JBLineChartViewDataSource <NSObject>
@protocol JBLineChartViewDataSource <JBChartViewDataSource>
@required
@@ -115,6 +49,107 @@ typedef NS_ENUM(NSInteger, JBLineChartViewLineStyle){
@optional
/**
* Returns whether or not a line should show a dot for each point.
* Dot size is relative to the line width and not adjustable.
* Dot color is equal to the line color and not adjustable.
*
* Default: NO.
*
* @param lineChartView The line chart object requesting this information.
* @param lineIndex An index number identifying a line in the chart.
*
* @return Whether or not a line should show a dot for each chart point.
*/
- (BOOL)lineChartView:(JBLineChartView *)lineChartView showsDotsForLineAtLineIndex:(NSUInteger)lineIndex;
/**
* Returns whether or not a line should be rendered with curved connections and rounded end caps.
*
* Default: NO.
*
* @param lineChartView The line chart object requesting this information.
* @param lineIndex An index number identifying a line in the chart.
*
* @return Whether or not a line should smooth it's connections and end caps.
*/
- (BOOL)lineChartView:(JBLineChartView *)lineChartView smoothLineAtLineIndex:(NSUInteger)lineIndex;
/**
* Returns a (custom) UIView instance representing a dot (x,y point) within the chart.
* For this value to apply, showsDotsForLineAtLineIndex: must return YES for the line at lineIndex.
* This protocol supercedes colorForDotAtHorizontalIndex: and dotRadiusForDotAtHorizontalIndex:.
* If nil is returned. the original dot protocols will take precedence. During selection events, a custom
* dot view will not be hidden unless lineChartView:shouldHideDotViewOnSelectionAtHorizontalIndex:atLineIndex:
* is implemented.
*
* Default: nil.
*
* @param lineChartView The line chart object requesting this information.
* @param horizontalIndex The 0-based horizontal index of a selection point (left to right, x-axis).
* @param lineIndex An index number identifying a line in the chart.
*
* @return A custom UIView instance representing a dot at a particular horizontal index within a dotted line.
*/
- (UIView *)lineChartView:(JBLineChartView *)lineChartView dotViewAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex;
/**
* Returns whether or not a (custom) dot view should be hidden on selection events.
*
* Default: NO.
*
* @param lineChartView The line chart object requesting this information.
* @param horizontalIndex The 0-based horizontal index of a selection point (left to right, x-axis).
* @param lineIndex An index number identifying a line in the chart.
*
* @return Whether or not a (custom) dot view should be hidden on selection events.
*/
- (BOOL)lineChartView:(JBLineChartView *)lineChartView shouldHideDotViewOnSelectionAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex;
@end
@protocol JBLineChartViewDelegate <JBChartViewDelegate>
@required
/**
* Vertical value for a line point at a given index (left to right). There is no ceiling on the the height;
* the chart will automatically normalize all values between the overal min and max heights.
* NAN may able be retuend to indicate missing values. The chart's line will begin at the first non-NAN value and end at the last non-NAN value.
* Furthermore, the line will interopolate any NAN values in between (ie. the line will not be interrupted).
*
* @param lineChartView The line chart object requesting this information.
* @param horizontalIndex The 0-based horizontal index of a selection point (left to right, x-axis).
* @param lineIndex An index number identifying the closest line in the chart to the current touch point.
*
* @return The y-axis value of the supplied line index (x-axis)
*/
- (CGFloat)lineChartView:(JBLineChartView *)lineChartView verticalValueForHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex;
@optional
/**
* Occurs whenever there is a touch gesture on the chart (chart must be expanded).
* The horizontal index is the closest index to the touch point & is clamped to it's max/min value if it moves outside of the view's bounds.
* The lineIndex remains constant until the line is deselected and will be highlighted using the (optional) selectionColorForLineAtLineIndex: protocol.
* Futhermore, all other lines that aren't selected will be dimmed to 20%% opacity throughout the duration of the touch/move. Any dotted line that isn't the
* primary selection will have it's dots dimmed to hidden (to avoid transparency issues).
*
* @param lineChartView A line chart object informing the delegate about the new selection.
* @param lineIndex An index number identifying the closest line in the chart to the current touch
* @param horizontalIndex The 0-based horizontal index of a selection point (left to right, x-axis).
* @param touchPoint The touch point in relation to the chart's bounds (excludes footer and header).
*/
- (void)lineChartView:(JBLineChartView *)lineChartView didSelectLineAtIndex:(NSUInteger)lineIndex horizontalIndex:(NSUInteger)horizontalIndex touchPoint:(CGPoint)touchPoint;
- (void)lineChartView:(JBLineChartView *)lineChartView didSelectLineAtIndex:(NSUInteger)lineIndex horizontalIndex:(NSUInteger)horizontalIndex;
/**
* Occurs when selection ends by ending a touch event. For selection start events, see: didSelectChartAtIndex:
*
* @param lineChartView A line chart object informing the delegate about the deselection.
*/
- (void)didDeselectLineInLineChartView:(JBLineChartView *)lineChartView;
/**
* Returns the color of particular line at lineIndex within the chart.
*
@@ -127,6 +162,18 @@ typedef NS_ENUM(NSInteger, JBLineChartViewLineStyle){
*/
- (UIColor *)lineChartView:(JBLineChartView *)lineChartView colorForLineAtLineIndex:(NSUInteger)lineIndex;
/**
* Returns the fill color of particular line at lineIndex within the chart.
*
* Default: clear color.
*
* @param lineChartView The line chart object requesting this information.
* @param lineIndex An index number identifying a line in the chart.
*
* @return The fill color to show under a line in the chart.
*/
- (UIColor *)lineChartView:(JBLineChartView *)lineChartView fillColorForLineAtLineIndex:(NSUInteger)lineIndex;
/**
* Returns the color of a particular dot in a line at lineIndex within the chart.
* For this value to apply, showsDotsForLineAtLineIndex: must return YES for the line at lineIndex.
@@ -135,7 +182,7 @@ typedef NS_ENUM(NSInteger, JBLineChartViewLineStyle){
* Default: black color.
*
* @param lineChartView The line chart object requesting this information.
* @param horizontalIndex The 0-based horizontal index of a selection point (left to right, x-axis).point.
* @param horizontalIndex The 0-based horizontal index of a selection point (left to right, x-axis)
* @param lineIndex An index number identifying a line in the chart.
*
* @return The color to be used to color a dot within a dotted line in the chart.
@@ -157,20 +204,21 @@ typedef NS_ENUM(NSInteger, JBLineChartViewLineStyle){
/**
* Returns the radius of all dots in a particular line at lineIndex within the chart.
* For this value to apply, showsDotsForLineAtLineIndex: must return YES for the line at lineIndex.
* Any value can be returned for lineIndex's that don't support dots, as it will never be called.
* Any value can be returned for lineIndex's that don't support dots, as it will never be called.
*
* Default: line width x 3.
* Default: line width x 6.
*
* @param lineChartView The line chart object requesting this information.
* @param horizontalIndex The 0-based horizontal index of a selection point (left to right, x-axis).
* @param lineIndex An index number identifying a line in the chart.
*
* @return The radius of the dots within a dotted line in the chart.
*/
- (CGFloat)lineChartView:(JBLineChartView *)lineChartView dotRadiusForLineAtLineIndex:(NSUInteger)lineIndex;
- (CGFloat)lineChartView:(JBLineChartView *)lineChartView dotRadiusForDotAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex;
/**
* Returns the width of the (vertical) selection view to be overlayed on the chart during touch events.
* The property showsVerticalSelection must be YES for the width to apply. The width is clamped to the
* The property showsVerticalSelection must be YES for the width to apply. The width is clamped to the
* maxmimum width of the chart's bounds.
*
* Default: 20px.
@@ -182,17 +230,16 @@ typedef NS_ENUM(NSInteger, JBLineChartViewLineStyle){
- (CGFloat)verticalSelectionWidthForLineChartView:(JBLineChartView *)lineChartView;
/**
* Returns the (vertical) selection color to be overlayed on the chart during touch events.
* Returns the (vertical) selection color to be overlayed on the chart during touch events on a given line.
* The color is automically faded to transparent (vertically). The property showsVerticalSelection
* must be YES for the color to apply.
*
* Default: white color (faded to transparent).
*
* @param lineChartView The line chart object requesting this information.
* @param lineIndex An index number identifying a line in the chart.
*
* @return The color of the selection view used during chart selections.
* @return The color of the selection view used during chart selections of the given line.
*/
- (UIColor *)verticalSelectionColorForLineChartView:(JBLineChartView *)lineChartView;
- (UIColor *)lineChartView:(JBLineChartView *)lineChartView verticalSelectionColorForLineAtLineIndex:(NSUInteger)lineIndex;
/**
* Returns the selection color to be overlayed on a line within the chart during touch events.
@@ -207,6 +254,19 @@ typedef NS_ENUM(NSInteger, JBLineChartViewLineStyle){
*/
- (UIColor *)lineChartView:(JBLineChartView *)lineChartView selectionColorForLineAtLineIndex:(NSUInteger)lineIndex;
/**
* Returns the selection fill color to be overlayed under a line within the chart during touch events.
* The property showsLineSelection must be YES for the color to apply.
*
* Default: clear color.
*
* @param lineChartView The line chart object requesting this information.
* @param lineIndex An index number identifying a line in the chart.
*
* @return The color to be used to highlight under a line during chart selections.
*/
- (UIColor *)lineChartView:(JBLineChartView *)lineChartView selectionFillColorForLineAtLineIndex:(NSUInteger)lineIndex;
/**
* Returns the selection color to be overlayed on a line within the chart during touch events.
* The property showsLineSelection must be YES for the color to apply.
@@ -214,7 +274,7 @@ typedef NS_ENUM(NSInteger, JBLineChartViewLineStyle){
* Default: white color.
*
* @param lineChartView The line chart object requesting this information.
* @param horizontalIndex The 0-based horizontal index of a selection point (left to right, x-axis).point.
* @param horizontalIndex The 0-based horizontal index of a selection point (left to right, x-axis).
* @param lineIndex An index number identifying a line in the chart.
*
* @return The color to be used to highlight a dot within a dotted line during chart selections.
@@ -225,7 +285,7 @@ typedef NS_ENUM(NSInteger, JBLineChartViewLineStyle){
* Returns the line style of a particular line at lineIndex within the chart.
* See JBLineChartViewLineStyle for line style descriptions.
*
* Default: JBLineChartViewLineStyleSolid
* Default: JBLineChartViewLineStyleSolid.
*
* @param lineChartView The line chart object requesting this information.
* @param lineIndex An index number identifying a line in the chart.
@@ -234,30 +294,39 @@ typedef NS_ENUM(NSInteger, JBLineChartViewLineStyle){
*/
- (JBLineChartViewLineStyle)lineChartView:(JBLineChartView *)lineChartView lineStyleForLineAtLineIndex:(NSUInteger)lineIndex;
/**
* Returns whether or not a line should show a dot for each point.
* Dot size is relative to the line width and not adjustable.
* Dot color is equal to the line color and not adjustable.
*
* Default: NO
*
* @param lineChartView The line chart object requesting this information.
* @param lineIndex An index number identifying a line in the chart.
*
* @return Whether or not a line should show a dot for each chart point.
*/
- (BOOL)lineChartView:(JBLineChartView *)lineChartView showsDotsForLineAtLineIndex:(NSUInteger)lineIndex;
@end
@interface JBLineChartView : JBChartView
@property (nonatomic, weak) id<JBLineChartViewDataSource> dataSource;
@property (nonatomic, weak) id<JBLineChartViewDelegate> delegate;
/**
* Returns whether or not a line should be rendered with curved connections and rounded end caps.
* Vertical highlight overlayed on a line graph during touch events.
*
* Default: NO
* Default: YES.
*/
@property (nonatomic, assign) BOOL showsVerticalSelection;
/**
* A highlight shown on a line within the graph during touch events. The highlighted line
* is the closest line to the touch point and corresponds to the lineIndex delegatd back via
* didSelectChartAtHorizontalIndex:atLineIndex: and didUnSlectChartAtHorizontalIndex:atLineIndex:
*
* @param lineChartView The line chart object requesting this information.
* Default: YES.
*/
@property (nonatomic, assign) BOOL showsLineSelection;
/**
* The dot view within a particular line at a horizontalIndex.
*
* Default: nil.
*
* @param horizontalIndex The 0-based horizontal index of a selection point (left to right, x-axis)
* @param lineIndex An index number identifying a line in the chart.
*
* @return Whether or not a line should smooth it's connections and end caps.
* @return The UIView representing the dot view at a given horizontalIndex within a line or nil if any index is out of range.
*/
- (BOOL)lineChartView:(JBLineChartView *)lineChartView smoothLineAtLineIndex:(NSUInteger)lineIndex;
- (UIView *)dotViewAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex;
@end
+453 -192
View File
File diff suppressed because it is too large Load Diff
@@ -1,19 +1,19 @@
Pod::Spec.new do |s|
s.name = "JBChartView"
s.version = "2.4.0"
s.version = "2.8.10"
s.summary = "Jawbone's iOS-based charting library for both line and bar graphs."
s.homepage = "https://github.com/Jawbone/JBChartView"
s.screenshot = "https://raw.github.com/Jawbone/JBChartView/master/Screenshots/main.png"
s.screenshot = "https://raw.github.com/Jawbone/JBChartView/master/Screenshots/main.jpg"
s.license = { :type => 'Apache', :file => 'LICENSE' }
s.author = { "Terry Worona" => "tworona@jawbone.com" }
s.source = {
:git => "https://github.com/Jawbone/JBChartView.git",
:tag => "v2.4.0"
:tag => "v2.8.10"
}
s.platform = :ios, '7.0'
s.source_files = 'Classes', 'Classes/**/*.{h,m}'
s.platform = :ios, '6.0'
s.source_files = 'Classes/**/*.{h,m}'
s.requires_arc = true
end
@@ -7,6 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
94BDFC3419F933B2007492F6 /* JBLineChartMissingPointsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 94BDFC3319F933B2007492F6 /* JBLineChartMissingPointsViewController.m */; };
9B0725211829822A0052109B /* JBChartListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B0725201829822A0052109B /* JBChartListViewController.m */; };
9B2E530518218CF20079B9D2 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9B2E530418218CF20079B9D2 /* Foundation.framework */; };
9B2E530718218CF20079B9D2 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9B2E530618218CF20079B9D2 /* CoreGraphics.framework */; };
@@ -33,6 +34,9 @@
9B6A68DB1829ADE1006DB3BF /* JBBarChartView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B6A68DA1829ADE1006DB3BF /* JBBarChartView.m */; };
9B6A68DE1829BE63006DB3BF /* JBBarChartViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B6A68DD1829BE63006DB3BF /* JBBarChartViewController.m */; };
9B6A68E11829BED5006DB3BF /* JBLineChartViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B6A68E01829BED5006DB3BF /* JBLineChartViewController.m */; };
9B7967EC198313E30003A2B0 /* JBAreaChartViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B7967EB198313E30003A2B0 /* JBAreaChartViewController.m */; };
9B7967EF198317540003A2B0 /* icon-area-chart.png in Resources */ = {isa = PBXBuildFile; fileRef = 9B7967ED198317540003A2B0 /* icon-area-chart.png */; };
9B7967F0198317540003A2B0 /* icon-area-chart@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 9B7967EE198317540003A2B0 /* icon-area-chart@2x.png */; };
9BD57BBC18D13D1A00ACFA52 /* JBChartTooltipView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BD57BBB18D13D1A00ACFA52 /* JBChartTooltipView.m */; };
9BE0B0AD182AD26400232023 /* JBLineChartView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BE0B0AC182AD26400232023 /* JBLineChartView.m */; };
9BE0B0C7182B161000232023 /* JBChartHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BE0B0C6182B161000232023 /* JBChartHeaderView.m */; };
@@ -42,6 +46,8 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
94BDFC3219F933B2007492F6 /* JBLineChartMissingPointsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JBLineChartMissingPointsViewController.h; sourceTree = "<group>"; };
94BDFC3319F933B2007492F6 /* JBLineChartMissingPointsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JBLineChartMissingPointsViewController.m; sourceTree = "<group>"; };
9B07251F1829822A0052109B /* JBChartListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JBChartListViewController.h; sourceTree = "<group>"; };
9B0725201829822A0052109B /* JBChartListViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JBChartListViewController.m; sourceTree = "<group>"; };
9B2E530118218CF20079B9D2 /* JBChartViewDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = JBChartViewDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -86,6 +92,10 @@
9B6A68DD1829BE63006DB3BF /* JBBarChartViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JBBarChartViewController.m; sourceTree = "<group>"; };
9B6A68DF1829BED5006DB3BF /* JBLineChartViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JBLineChartViewController.h; sourceTree = "<group>"; };
9B6A68E01829BED5006DB3BF /* JBLineChartViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JBLineChartViewController.m; sourceTree = "<group>"; };
9B7967EA198313E30003A2B0 /* JBAreaChartViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JBAreaChartViewController.h; sourceTree = "<group>"; };
9B7967EB198313E30003A2B0 /* JBAreaChartViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JBAreaChartViewController.m; sourceTree = "<group>"; };
9B7967ED198317540003A2B0 /* icon-area-chart.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon-area-chart.png"; sourceTree = "<group>"; };
9B7967EE198317540003A2B0 /* icon-area-chart@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon-area-chart@2x.png"; sourceTree = "<group>"; };
9BD57BBA18D13D1A00ACFA52 /* JBChartTooltipView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JBChartTooltipView.h; sourceTree = "<group>"; };
9BD57BBB18D13D1A00ACFA52 /* JBChartTooltipView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JBChartTooltipView.m; sourceTree = "<group>"; };
9BE0B0AB182AD26400232023 /* JBLineChartView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JBLineChartView.h; path = ../../Classes/JBLineChartView.h; sourceTree = "<group>"; };
@@ -183,10 +193,14 @@
isa = PBXGroup;
children = (
9B603D3B182C6E79000A76D0 /* Base */,
9B7967EA198313E30003A2B0 /* JBAreaChartViewController.h */,
9B7967EB198313E30003A2B0 /* JBAreaChartViewController.m */,
9B6A68DC1829BE63006DB3BF /* JBBarChartViewController.h */,
9B6A68DD1829BE63006DB3BF /* JBBarChartViewController.m */,
9B07251F1829822A0052109B /* JBChartListViewController.h */,
9B0725201829822A0052109B /* JBChartListViewController.m */,
94BDFC3219F933B2007492F6 /* JBLineChartMissingPointsViewController.h */,
94BDFC3319F933B2007492F6 /* JBLineChartMissingPointsViewController.m */,
9B6A68DF1829BED5006DB3BF /* JBLineChartViewController.h */,
9B6A68E01829BED5006DB3BF /* JBLineChartViewController.m */,
);
@@ -219,6 +233,8 @@
9B603D44182C7002000A76D0 /* Images */ = {
isa = PBXGroup;
children = (
9B7967ED198317540003A2B0 /* icon-area-chart.png */,
9B7967EE198317540003A2B0 /* icon-area-chart@2x.png */,
9B698F07182D720E003C135F /* icon-arrow.png */,
9B698F08182D720E003C135F /* icon-arrow@2x.png */,
9B698F12182D7DAE003C135F /* icon-bar-chart.png */,
@@ -368,8 +384,10 @@
9B698F18182D7DAE003C135F /* icon-line-chart.png in Resources */,
9B2E530F18218CF20079B9D2 /* InfoPlist.strings in Resources */,
9B698F17182D7DAE003C135F /* icon-bar-chart@2x.png in Resources */,
9B7967EF198317540003A2B0 /* icon-area-chart.png in Resources */,
9B603D47182C7002000A76D0 /* icon-jawbone-logo.png in Resources */,
9B603D48182C7002000A76D0 /* icon-jawbone-logo@2x.png in Resources */,
9B7967F0198317540003A2B0 /* icon-area-chart@2x.png in Resources */,
9B698F19182D7DAE003C135F /* icon-line-chart@2x.png in Resources */,
9B698F0A182D720E003C135F /* icon-arrow@2x.png in Resources */,
);
@@ -394,10 +412,12 @@
9B603D4E182C7163000A76D0 /* JBBaseTableViewController.m in Sources */,
9B6A68DE1829BE63006DB3BF /* JBBarChartViewController.m in Sources */,
9B4437AD18D7686800682EF0 /* JBChartTooltipTipView.m in Sources */,
94BDFC3419F933B2007492F6 /* JBLineChartMissingPointsViewController.m in Sources */,
9BE0B0AD182AD26400232023 /* JBLineChartView.m in Sources */,
9BEE694618D2789E005D9BA7 /* JBBaseChartViewController.m in Sources */,
9B6A68E11829BED5006DB3BF /* JBLineChartViewController.m in Sources */,
9B2E533F18218D310079B9D2 /* AppDelegate.m in Sources */,
9B7967EC198313E30003A2B0 /* JBAreaChartViewController.m in Sources */,
9BD57BBC18D13D1A00ACFA52 /* JBChartTooltipView.m in Sources */,
9B603D4B182C7117000A76D0 /* JBBaseViewController.m in Sources */,
9B0725211829822A0052109B /* JBChartListViewController.m in Sources */,
@@ -498,7 +518,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "JBChartViewDemo/JBChartViewDemo-Prefix.pch";
INFOPLIST_FILE = "JBChartViewDemo/JBChartViewDemo-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
@@ -512,7 +532,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "JBChartViewDemo/JBChartViewDemo-Prefix.pch";
INFOPLIST_FILE = "JBChartViewDemo/JBChartViewDemo-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
@@ -10,7 +10,8 @@
typedef NS_ENUM(NSInteger, JBChartTableCellType){
JBChartTableCellTypeLineChart,
JBChartTableCellTypeBarChart
JBChartTableCellTypeBarChart,
JBChartTableCellTypeAreaChart
};
@interface JBChartTableCell : UITableViewCell
@@ -22,7 +22,21 @@
- (void)setType:(JBChartTableCellType)type
{
_type = type;
self.accessoryView = [[UIImageView alloc] initWithImage:_type == JBChartTableCellTypeBarChart ? [UIImage imageNamed:kJBImageIconBarChart] : [UIImage imageNamed:kJBImageIconLineChart]];
UIImage *image = nil;
switch (type) {
case JBChartTableCellTypeBarChart:
image = [UIImage imageNamed:kJBImageIconBarChart];
break;
case JBChartTableCellTypeLineChart:
image = [UIImage imageNamed:kJBImageIconLineChart];
break;
case JBChartTableCellTypeAreaChart:
image = [UIImage imageNamed:kJBImageIconAreaChart];
break;
default:
break;
}
self.accessoryView = [[UIImageView alloc] initWithImage:image];
}
@end
@@ -32,6 +32,21 @@
#define kJBColorLineChartDefaultDashedLineColor [UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:1.0]
#define kJBColorLineChartDefaultDashedSelectedLineColor [UIColor colorWithWhite:1.0 alpha:1.0]
#define mark - Area Chart
#define kJBColorAreaChartControllerBackground UIColorFromHex(0xb7e3e4)
#define kJBColorAreaChartBackground UIColorFromHex(0xb7e3e4)
#define kJBColorAreaChartHeader UIColorFromHex(0x1c474e)
#define kJBColorAreaChartHeaderSeparatorColor UIColorFromHex(0x8eb6b7)
#define kJBColorAreaChartDefaultSunLineColor [UIColor clearColor]
#define kJBColorAreaChartDefaultSunAreaColor [UIColorFromHex(0xfcfb3a) colorWithAlphaComponent:0.5]
#define kJBColorAreaChartDefaultSunSelectedLineColor [UIColor clearColor]
#define kJBColorAreaChartDefaultSunSelectedAreaColor UIColorFromHex(0xfcfb3a)
#define kJBColorAreaChartDefaultMoonLineColor [UIColor clearColor]
#define kJBColorAreaChartDefaultMoonAreaColor [[UIColor blackColor] colorWithAlphaComponent:0.5]
#define kJBColorAreaChartDefaultMoonSelectedLineColor [UIColor clearColor]
#define kJBColorAreaChartDefaultMoonSelectedAreaColor [UIColor blackColor]
#pragma mark - Tooltips
#define kJBColorTooltipColor [UIColor colorWithWhite:1.0 alpha:0.9]
@@ -15,6 +15,7 @@
#define kJBStringLabel2012 localize(@"label.2012", @"2012")
#define kJBStringLabelAverageMonthlyTemperature localize(@"label.average.monthly.temperature", @"Average Monthly Temperature")
#define kJBStringLabelWorldwide2012 localize(@"label.worldwide.2013", @"Worldwide - 2012")
#define kJBStringLabelWorldwide2011 localize(@"label.worldwide.2013", @"Worldwide - 2011")
#define kJBStringLabelWorldwideAverage localize(@"label.worldwide.average", @"Worldwide Average")
#define kJBStringLabelDegreesFahrenheit localize(@"label.degrees.fahrenheit", @"%d%@F")
#define kJBStringLabelDegreeSymbol localize(@"label.degree.symbol", @"\u00B0")
@@ -27,3 +28,22 @@
#define kJBStringLabelMm localize(@"label.mm", @"mm")
#define kJBStringLabelMetropolitanAverage localize(@"label.metropolitan.average", @"Metropolitan Average")
#define kJBStringLabelNationalAverage localize(@"label.national.average", @"National Average")
#pragma mark - Labels (Area Chart)
#define kJBStringLabel2011 localize(@"label.2011", @"2011")
#define kJBStringLabelSeattle2014 localize(@"label.seattle.2014", @"Seattle - 2014")
#define kJBStringLabelAverageShineHoursOfSunMoon localize(@"label.average.shine.hours.of.sun.moon", @"Average Shine Hours of Sun/Moon")
#define kJBStringLabelAverageShineHours localize(@"label.average.shine.hours", @"Average Shine Hours")
#define kJBStringLabelHours localize(@"label.hours", @"h")
#define kJBStringLabelMoon localize(@"label.moon", @"Moon")
#define kJBStringLabelSun localize(@"label.sun", @"Sun")
#pragma mark - Labels (Missing Points Line Chart)
#define kJBStringLabel2014 localize(@"label.2014", @"2014")
#define kJBStringLabelCyclingDistances localize(@"label.cycling.distances", @"Cycling Distances")
#define kJBStringLabelCyclingCurrentLastWeek2014 localize(@"label.cycling.current.last.week.2014", @"Current/Last Week - 2014")
#define kJBStringLabelKm2014 localize(@"label.km", @"Km")
#define kJBStringLabelLastWeek localize(@"label.last.week", @"Last Week")
#define kJBStringLabelCurrentWeek localize(@"label.current.week", @"Current Week")
@@ -12,3 +12,4 @@
#define kJBImageIconArrow @"icon-arrow.png"
#define kJBImageIconLineChart @"icon-line-chart.png"
#define kJBImageIconBarChart @"icon-bar-chart.png"
#define kJBImageIconAreaChart @"icon-area-chart.png"
@@ -43,6 +43,8 @@ CGFloat const kJBBaseChartViewControllerAnimationDuration = 0.25f;
[self.view addSubview:self.tooltipView];
}
[self.view bringSubviewToFront:self.tooltipView];
if (!self.tooltipTipView)
{
self.tooltipTipView = [[JBChartTooltipTipView alloc] init];
@@ -50,6 +52,8 @@ CGFloat const kJBBaseChartViewControllerAnimationDuration = 0.25f;
[self.view addSubview:self.tooltipTipView];
}
[self.view bringSubviewToFront:self.tooltipTipView];
dispatch_block_t adjustTooltipPosition = ^{
CGPoint originalTouchPoint = [self.view convertPoint:touchPoint fromView:chartView];
CGPoint convertedTouchPoint = originalTouchPoint; // modified
@@ -8,6 +8,10 @@
#import "JBBaseNavigationController.h"
// Numerics
NSInteger const kJBBaseNavigationControllerBarTintColorMinSystemVersion = 7;
NSInteger const kJBBaseNavigationControllerTintColorMinSystemVersion = 7;
@implementation JBBaseNavigationController
#pragma mark - Alloc/Init
@@ -18,9 +22,23 @@
if (self)
{
self.navigationBar.translucent = NO;
[[UINavigationBar appearance] setBarTintColor:kJBColorNavigationTint];
[[UINavigationBar appearance] setTintColor:kJBColorNavigationBarTint];
self.interactivePopGestureRecognizer.enabled = NO;
// Bar tint (iOS 7)
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= kJBBaseNavigationControllerBarTintColorMinSystemVersion)
{
[[UINavigationBar appearance] setBarTintColor:kJBColorNavigationTint];
}
// Tint (iOS 7)
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= kJBBaseNavigationControllerTintColorMinSystemVersion)
{
[[UINavigationBar appearance] setTintColor:kJBColorNavigationBarTint];
}
if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)])
{
self.interactivePopGestureRecognizer.enabled = NO;
}
}
return self;
}
@@ -19,7 +19,9 @@
- (void)loadView
{
[super loadView];
self.edgesForExtendedLayout = UIRectEdgeTop;
if ([self respondsToSelector:@selector(setEdgesForExtendedLayout:)]) {
self.edgesForExtendedLayout = UIRectEdgeTop;
}
self.view.backgroundColor = [UIColor whiteColor];
self.navigationItem.titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:kJBImageIconJawboneLogo]];
}
@@ -0,0 +1,13 @@
//
// JBAreaChartViewController.h
// JBChartViewDemo
//
// Created by Lars Ott on 21.04.14.
// Copyright (c) 2014 Jawbone. All rights reserved.
//
#import "JBBaseChartViewController.h"
@interface JBAreaChartViewController : JBBaseChartViewController
@end
@@ -0,0 +1,285 @@
//
// JBAreaChartViewController.m
// JBChartViewDemo
//
// Created by Lars Ott on 21.04.14.
// Copyright (c) 2014 Jawbone. All rights reserved.
//
#import "JBAreaChartViewController.h"
// Views
#import "JBLineChartView.h"
#import "JBChartHeaderView.h"
#import "JBLineChartFooterView.h"
#import "JBChartInformationView.h"
#define ARC4RANDOM_MAX 0x100000000
typedef NS_ENUM(NSInteger, JBLineChartLine){
JBLineChartLineSun,
JBLineChartLineMoon,
JBLineChartLineCount
};
// Numerics
CGFloat const kJBAreaChartViewControllerChartHeight = 250.0f;
CGFloat const kJBAreaChartViewControllerChartPadding = 10.0f;
CGFloat const kJBAreaChartViewControllerChartHeaderHeight = 75.0f;
CGFloat const kJBAreaChartViewControllerChartHeaderPadding = 20.0f;
CGFloat const kJBAreaChartViewControllerChartFooterHeight = 20.0f;
CGFloat const kJBAreaChartViewControllerChartLineWidth = 2.0f;
NSInteger const kJBAreaChartViewControllerMaxNumChartPoints = 12;
// Strings
NSString * const kJBAreaChartViewControllerNavButtonViewKey = @"view";
@interface JBAreaChartViewController () <JBLineChartViewDelegate, JBLineChartViewDataSource>
@property (nonatomic, strong) JBLineChartView *lineChartView;
@property (nonatomic, strong) JBChartInformationView *informationView;
@property (nonatomic, strong) NSArray *chartData;
@property (nonatomic, strong) NSArray *monthlySymbols;
// Buttons
- (void)chartToggleButtonPressed:(id)sender;
// Helpers
- (void)initFakeData;
- (NSArray *)largestLineData; // largest collection of fake line data
@end
@implementation JBAreaChartViewController
#pragma mark - Alloc/Init
- (id)init
{
self = [super init];
if (self)
{
[self initFakeData];
}
return self;
}
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self)
{
[self initFakeData];
}
return self;
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self)
{
[self initFakeData];
}
return self;
}
#pragma mark - Data
- (void)initFakeData
{
NSMutableArray *mutableLineCharts = [NSMutableArray array];
for (int lineIndex=0; lineIndex<JBLineChartLineCount; lineIndex++)
{
NSMutableArray *mutableChartData = [NSMutableArray array];
for (int i=0; i<kJBAreaChartViewControllerMaxNumChartPoints; i++)
{
[mutableChartData addObject:[NSNumber numberWithFloat:((double)arc4random() / ARC4RANDOM_MAX) * 12]]; // random number between 0 and 12
}
[mutableLineCharts addObject:mutableChartData];
}
_chartData = [NSArray arrayWithArray:mutableLineCharts];
_monthlySymbols = [[[NSDateFormatter alloc] init] shortMonthSymbols];
}
- (NSArray *)largestLineData
{
NSArray *largestLineData = nil;
for (NSArray *lineData in self.chartData)
{
if ([lineData count] > [largestLineData count])
{
largestLineData = lineData;
}
}
return largestLineData;
}
#pragma mark - View Lifecycle
- (void)loadView
{
[super loadView];
self.view.backgroundColor = kJBColorLineChartControllerBackground;
self.navigationItem.rightBarButtonItem = [self chartToggleButtonWithTarget:self action:@selector(chartToggleButtonPressed:)];
self.lineChartView = [[JBLineChartView alloc] init];
self.lineChartView.frame = CGRectMake(kJBAreaChartViewControllerChartPadding, kJBAreaChartViewControllerChartPadding, self.view.bounds.size.width - (kJBAreaChartViewControllerChartPadding * 2), kJBAreaChartViewControllerChartHeight);
self.lineChartView.delegate = self;
self.lineChartView.dataSource = self;
self.lineChartView.headerPadding =kJBAreaChartViewControllerChartHeaderPadding;
self.lineChartView.backgroundColor = kJBColorLineChartBackground;
JBChartHeaderView *headerView = [[JBChartHeaderView alloc] initWithFrame:CGRectMake(kJBAreaChartViewControllerChartPadding, ceil(self.view.bounds.size.height * 0.5) - ceil(kJBAreaChartViewControllerChartHeaderHeight * 0.5), self.view.bounds.size.width - (kJBAreaChartViewControllerChartPadding * 2), kJBAreaChartViewControllerChartHeaderHeight)];
headerView.titleLabel.text = [kJBStringLabelAverageShineHoursOfSunMoon uppercaseString];
headerView.titleLabel.textColor = kJBColorLineChartHeader;
headerView.titleLabel.shadowColor = [UIColor colorWithWhite:1.0 alpha:0.25];
headerView.titleLabel.shadowOffset = CGSizeMake(0, 1);
headerView.subtitleLabel.text = kJBStringLabel2011;
headerView.subtitleLabel.textColor = kJBColorLineChartHeader;
headerView.subtitleLabel.shadowColor = [UIColor colorWithWhite:1.0 alpha:0.25];
headerView.subtitleLabel.shadowOffset = CGSizeMake(0, 1);
headerView.separatorColor = kJBColorLineChartHeaderSeparatorColor;
self.lineChartView.headerView = headerView;
JBLineChartFooterView *footerView = [[JBLineChartFooterView alloc] initWithFrame:CGRectMake(kJBAreaChartViewControllerChartPadding, ceil(self.view.bounds.size.height * 0.5) - ceil(kJBAreaChartViewControllerChartFooterHeight * 0.5), self.view.bounds.size.width - (kJBAreaChartViewControllerChartPadding * 2), kJBAreaChartViewControllerChartFooterHeight)];
footerView.backgroundColor = [UIColor clearColor];
footerView.leftLabel.text = [[self.monthlySymbols firstObject] uppercaseString];
footerView.leftLabel.textColor = [UIColor whiteColor];
footerView.rightLabel.text = [[self.monthlySymbols lastObject] uppercaseString];;
footerView.rightLabel.textColor = [UIColor whiteColor];
footerView.sectionCount = [[self chartData] count];
self.lineChartView.footerView = footerView;
[self.view addSubview:self.lineChartView];
self.informationView = [[JBChartInformationView alloc] initWithFrame:CGRectMake(self.view.bounds.origin.x, CGRectGetMaxY(self.lineChartView.frame), self.view.bounds.size.width, self.view.bounds.size.height - CGRectGetMaxY(self.lineChartView.frame) - CGRectGetMaxY(self.navigationController.navigationBar.frame))];
[self.informationView setValueAndUnitTextColor:[UIColor colorWithWhite:1.0 alpha:0.75]];
[self.informationView setTitleTextColor:kJBColorLineChartHeader];
[self.informationView setTextShadowColor:nil];
[self.informationView setSeparatorColor:kJBColorLineChartHeaderSeparatorColor];
[self.view addSubview:self.informationView];
[self.lineChartView reloadData];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.lineChartView setState:JBChartViewStateExpanded];
}
#pragma mark - JBLineChartViewDataSource
- (NSUInteger)numberOfLinesInLineChartView:(JBLineChartView *)lineChartView
{
return [self.chartData count];
}
- (NSUInteger)lineChartView:(JBLineChartView *)lineChartView numberOfVerticalValuesAtLineIndex:(NSUInteger)lineIndex
{
return [[self.chartData objectAtIndex:lineIndex] count];
}
- (BOOL)lineChartView:(JBLineChartView *)lineChartView showsDotsForLineAtLineIndex:(NSUInteger)lineIndex
{
return NO;
}
- (BOOL)lineChartView:(JBLineChartView *)lineChartView smoothLineAtLineIndex:(NSUInteger)lineIndex
{
return YES;
}
#pragma mark - JBLineChartViewDelegate
- (CGFloat)lineChartView:(JBLineChartView *)lineChartView verticalValueForHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex
{
return [[[self.chartData objectAtIndex:lineIndex] objectAtIndex:horizontalIndex] floatValue];
}
- (void)lineChartView:(JBLineChartView *)lineChartView didSelectLineAtIndex:(NSUInteger)lineIndex horizontalIndex:(NSUInteger)horizontalIndex touchPoint:(CGPoint)touchPoint
{
NSNumber *valueNumber = [[self.chartData objectAtIndex:lineIndex] objectAtIndex:horizontalIndex];
[self.informationView setValueText:[NSString stringWithFormat:@"%.1f", [valueNumber floatValue]] unitText:kJBStringLabelHours];
[self.informationView setTitleText:lineIndex == JBLineChartLineSun ? kJBStringLabelSun : kJBStringLabelMoon];
[self.informationView setHidden:NO animated:YES];
[self setTooltipVisible:YES animated:YES atTouchPoint:touchPoint];
[self.tooltipView setText:[[self.monthlySymbols objectAtIndex:horizontalIndex] uppercaseString]];
}
- (void)didDeselectLineInLineChartView:(JBLineChartView *)lineChartView
{
[self.informationView setHidden:YES animated:YES];
[self setTooltipVisible:NO animated:YES];
}
- (UIColor *)lineChartView:(JBLineChartView *)lineChartView colorForLineAtLineIndex:(NSUInteger)lineIndex
{
return (lineIndex == JBLineChartLineSun) ? kJBColorAreaChartDefaultSunLineColor: kJBColorAreaChartDefaultMoonLineColor;
}
- (UIColor *)lineChartView:(JBLineChartView *)lineChartView fillColorForLineAtLineIndex:(NSUInteger)lineIndex
{
return (lineIndex == JBLineChartLineSun) ? kJBColorAreaChartDefaultSunAreaColor : kJBColorAreaChartDefaultMoonAreaColor;
}
- (UIColor *)lineChartView:(JBLineChartView *)lineChartView colorForDotAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex
{
return (lineIndex == JBLineChartLineSun) ? kJBColorAreaChartDefaultSunLineColor: kJBColorAreaChartDefaultMoonLineColor;
}
- (CGFloat)lineChartView:(JBLineChartView *)lineChartView widthForLineAtLineIndex:(NSUInteger)lineIndex
{
return kJBAreaChartViewControllerChartLineWidth;
}
- (UIColor *)lineChartView:(JBLineChartView *)lineChartView verticalSelectionColorForLineAtLineIndex:(NSUInteger)lineIndex
{
return [UIColor whiteColor];
}
- (UIColor *)lineChartView:(JBLineChartView *)lineChartView selectionColorForLineAtLineIndex:(NSUInteger)lineIndex
{
return (lineIndex == JBLineChartLineSun) ? kJBColorAreaChartDefaultSunSelectedLineColor: kJBColorAreaChartDefaultMoonSelectedLineColor;
}
- (UIColor *)lineChartView:(JBLineChartView *)lineChartView selectionFillColorForLineAtLineIndex:(NSUInteger)lineIndex
{
return (lineIndex == JBLineChartLineSun) ? kJBColorAreaChartDefaultSunSelectedAreaColor : kJBColorAreaChartDefaultMoonSelectedAreaColor;
}
- (UIColor *)lineChartView:(JBLineChartView *)lineChartView selectionColorForDotAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex
{
return (lineIndex == JBLineChartLineSun) ? kJBColorAreaChartDefaultSunSelectedLineColor: kJBColorAreaChartDefaultMoonSelectedLineColor;
}
- (JBLineChartViewLineStyle)lineChartView:(JBLineChartView *)lineChartView lineStyleForLineAtLineIndex:(NSUInteger)lineIndex
{
return JBLineChartViewLineStyleSolid;
}
#pragma mark - Buttons
- (void)chartToggleButtonPressed:(id)sender
{
UIView *buttonImageView = [self.navigationItem.rightBarButtonItem valueForKey:kJBAreaChartViewControllerNavButtonViewKey];
buttonImageView.userInteractionEnabled = NO;
CGAffineTransform transform = self.lineChartView.state == JBChartViewStateExpanded ? CGAffineTransformMakeRotation(M_PI) : CGAffineTransformMakeRotation(0);
buttonImageView.transform = transform;
[self.lineChartView setState:self.lineChartView.state == JBChartViewStateExpanded ? JBChartViewStateCollapsed : JBChartViewStateExpanded animated:YES callback:^{
buttonImageView.userInteractionEnabled = YES;
}];
}
#pragma mark - Overrides
- (JBChartView *)chartView
{
return self.lineChartView;
}
@end
@@ -18,10 +18,10 @@
CGFloat const kJBBarChartViewControllerChartHeight = 250.0f;
CGFloat const kJBBarChartViewControllerChartPadding = 10.0f;
CGFloat const kJBBarChartViewControllerChartHeaderHeight = 80.0f;
CGFloat const kJBBarChartViewControllerChartHeaderPadding = 10.0f;
CGFloat const kJBBarChartViewControllerChartHeaderPadding = 20.0f;
CGFloat const kJBBarChartViewControllerChartFooterHeight = 25.0f;
CGFloat const kJBBarChartViewControllerChartFooterPadding = 5.0f;
CGFloat const kJBBarChartViewControllerBarPadding = 1;
CGFloat const kJBBarChartViewControllerBarPadding = 1.0f;
NSInteger const kJBBarChartViewControllerNumBars = 12;
NSInteger const kJBBarChartViewControllerMaxBarHeight = 10;
NSInteger const kJBBarChartViewControllerMinBarHeight = 5;
@@ -107,6 +107,8 @@ NSString * const kJBBarChartViewControllerNavButtonViewKey = @"view";
self.barChartView.delegate = self;
self.barChartView.dataSource = self;
self.barChartView.headerPadding = kJBBarChartViewControllerChartHeaderPadding;
self.barChartView.minimumValue = 0.0f;
self.barChartView.inverted = NO;
self.barChartView.backgroundColor = kJBColorBarChartBackground;
JBChartHeaderView *headerView = [[JBChartHeaderView alloc] initWithFrame:CGRectMake(kJBBarChartViewControllerChartPadding, ceil(self.view.bounds.size.height * 0.5) - ceil(kJBBarChartViewControllerChartHeaderHeight * 0.5), self.view.bounds.size.width - (kJBBarChartViewControllerChartPadding * 2), kJBBarChartViewControllerChartHeaderHeight)];
@@ -136,11 +138,16 @@ NSString * const kJBBarChartViewControllerNavButtonViewKey = @"view";
[self.barChartView setState:JBChartViewStateExpanded];
}
#pragma mark - JBBarChartViewDelegate
#pragma mark - JBChartViewDataSource
- (CGFloat)barChartView:(JBBarChartView *)barChartView heightForBarViewAtAtIndex:(NSUInteger)index
- (BOOL)shouldExtendSelectionViewIntoHeaderPaddingForChartView:(JBChartView *)chartView
{
return [[self.chartData objectAtIndex:index] floatValue];
return YES;
}
- (BOOL)shouldExtendSelectionViewIntoFooterPaddingForChartView:(JBChartView *)chartView
{
return NO;
}
#pragma mark - JBBarChartViewDataSource
@@ -150,23 +157,6 @@ NSString * const kJBBarChartViewControllerNavButtonViewKey = @"view";
return kJBBarChartViewControllerNumBars;
}
- (NSUInteger)barPaddingForBarChartView:(JBBarChartView *)barChartView
{
return kJBBarChartViewControllerBarPadding;
}
- (UIView *)barChartView:(JBBarChartView *)barChartView barViewAtIndex:(NSUInteger)index
{
UIView *barView = [[UIView alloc] init];
barView.backgroundColor = (index % 2 == 0) ? kJBColorBarChartBarBlue : kJBColorBarChartBarGreen;
return barView;
}
- (UIColor *)barSelectionColorForBarChartView:(JBBarChartView *)barChartView
{
return [UIColor whiteColor];
}
- (void)barChartView:(JBBarChartView *)barChartView didSelectBarAtIndex:(NSUInteger)index touchPoint:(CGPoint)touchPoint
{
NSNumber *valueNumber = [self.chartData objectAtIndex:index];
@@ -177,12 +167,34 @@ NSString * const kJBBarChartViewControllerNavButtonViewKey = @"view";
[self.tooltipView setText:[[self.monthlySymbols objectAtIndex:index] uppercaseString]];
}
- (void)didUnselectBarChartView:(JBBarChartView *)barChartView
- (void)didDeselectBarChartView:(JBBarChartView *)barChartView
{
[self.informationView setHidden:YES animated:YES];
[self setTooltipVisible:NO animated:YES];
}
#pragma mark - JBBarChartViewDelegate
- (CGFloat)barChartView:(JBBarChartView *)barChartView heightForBarViewAtIndex:(NSUInteger)index
{
return [[self.chartData objectAtIndex:index] floatValue];
}
- (UIColor *)barChartView:(JBBarChartView *)barChartView colorForBarViewAtIndex:(NSUInteger)index
{
return (index % 2 == 0) ? kJBColorBarChartBarBlue : kJBColorBarChartBarGreen;
}
- (UIColor *)barSelectionColorForBarChartView:(JBBarChartView *)barChartView
{
return [UIColor whiteColor];
}
- (CGFloat)barPaddingForBarChartView:(JBBarChartView *)barChartView
{
return kJBBarChartViewControllerBarPadding;
}
#pragma mark - Buttons
- (void)chartToggleButtonPressed:(id)sender
@@ -11,13 +11,17 @@
// Controllers
#import "JBBarChartViewController.h"
#import "JBLineChartViewController.h"
#import "JBAreaChartViewController.h"
#import "JBLineChartMissingPointsViewController.h"
// Views
#import "JBChartTableCell.h"
typedef NS_ENUM(NSInteger, JBChartListViewControllerRow){
JBChartListViewControllerRowLineChart,
JBChartListViewControllerRowBarChart,
JBChartListViewControllerRowLineChartMissingPoints,
JBChartListViewControllerRowBarChart,
JBChartListViewControllerRowAreaChart,
JBChartListViewControllerRowCount
};
@@ -50,10 +54,39 @@ NSInteger const kJBChartListViewControllerCellHeight = 100;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
JBChartTableCell *cell = [tableView dequeueReusableCellWithIdentifier:kJBChartListViewControllerCellIdentifier forIndexPath:indexPath];
cell.textLabel.text = indexPath.row == JBChartListViewControllerRowLineChart ? kJBStringLabelAverageDailyRainfall : kJBStringLabelAverageMonthlyTemperature;
cell.detailTextLabel.text = indexPath.row == JBChartListViewControllerRowLineChart ? kJBStringLabelSanFrancisco2013 : kJBStringLabelWorldwide2012;
cell.type = indexPath.row == JBChartListViewControllerRowLineChart ? JBChartTableCellTypeLineChart : JBChartTableCellTypeBarChart;
JBChartTableCell *cell = [tableView dequeueReusableCellWithIdentifier:kJBChartListViewControllerCellIdentifier forIndexPath:indexPath];
NSString *text = nil;
NSString *detailText = nil;
JBChartTableCellType type = -1;
switch (indexPath.row) {
case JBChartListViewControllerRowLineChart:
text = kJBStringLabelAverageDailyRainfall;
detailText = kJBStringLabelSanFrancisco2013;
type = JBChartTableCellTypeLineChart;
break;
case JBChartListViewControllerRowLineChartMissingPoints:
text = kJBStringLabelCyclingDistances;
detailText = kJBStringLabelCyclingCurrentLastWeek2014;
type = JBChartTableCellTypeLineChart;
break;
case JBChartListViewControllerRowBarChart:
text = kJBStringLabelAverageMonthlyTemperature;
detailText = kJBStringLabelWorldwide2012;
type = JBChartTableCellTypeBarChart;
break;
case JBChartListViewControllerRowAreaChart:
text = kJBStringLabelAverageShineHours;
detailText = kJBStringLabelWorldwide2011;
type = JBChartTableCellTypeAreaChart;
break;
default:
break;
}
cell.textLabel.text = text;
cell.detailTextLabel.text = detailText;
cell.type = type;
return cell;
}
@@ -73,11 +106,21 @@ NSInteger const kJBChartListViewControllerCellHeight = 100;
JBLineChartViewController *lineChartController = [[JBLineChartViewController alloc] init];
[self.navigationController pushViewController:lineChartController animated:YES];
}
else if (indexPath.row == JBChartListViewControllerRowLineChartMissingPoints)
{
JBLineChartMissingPointsViewController *lineChartController = [[JBLineChartMissingPointsViewController alloc] init];
[self.navigationController pushViewController:lineChartController animated:YES];
}
else if (indexPath.row == JBChartListViewControllerRowBarChart)
{
JBBarChartViewController *barChartController = [[JBBarChartViewController alloc] init];
[self.navigationController pushViewController:barChartController animated:YES];
}
else if (indexPath.row == JBChartListViewControllerRowAreaChart)
{
JBAreaChartViewController *areaChartController = [[JBAreaChartViewController alloc] init];
[self.navigationController pushViewController:areaChartController animated:YES];
}
}
@end
@@ -0,0 +1,13 @@
//
// JBLineChartMissingPointsViewController.h
// JBChartViewDemo
//
// Created by Sebastian Opel on 23.10.14.
// Copyright (c) 2014 Jawbone. All rights reserved.
//
#import "JBBaseChartViewController.h"
@interface JBLineChartMissingPointsViewController : JBBaseChartViewController
@end
@@ -0,0 +1,302 @@
//
// JBLineChartMissingPointsViewController.m
// JBChartViewDemo
//
// Created by Sebastian Opel on 23.10.14.
// Copyright (c) 2014 Jawbone. All rights reserved.
//
#import "JBLineChartMissingPointsViewController.h"
// Views
#import "JBLineChartView.h"
#import "JBChartHeaderView.h"
#import "JBLineChartFooterView.h"
#import "JBChartInformationView.h"
#define ARC4RANDOM_MAX 0x010000000
typedef NS_ENUM(NSInteger, JBLineChartLine){
JBLineChartLineSolid,
JBLineChartLineDashed,
JBLineChartLineCount
};
// Numerics
CGFloat const kJBLineChartMissingPointsViewControllerChartHeight = 250.0f;
CGFloat const kJBLineChartMissingPointsViewControllerChartPadding = 10.0f;
CGFloat const kJBLineChartMissingPointsViewControllerChartHeaderHeight = 75.0f;
CGFloat const kJBLineChartMissingPointsViewControllerChartHeaderPadding = 20.0f;
CGFloat const kJBLineChartMissingPointsViewControllerChartFooterHeight = 20.0f;
CGFloat const kJBLineChartMissingPointsViewControllerChartSolidLineWidth = 6.0f;
CGFloat const kJBLineChartMissingPointsViewControllerChartDashedLineWidth = 2.0f;
NSInteger const kJBLineChartMissingPointsViewControllerMaxNumChartPoints = 7;
// Strings
NSString * const kJBLineChartMissingPointsViewControllerNavButtonViewKey = @"view";
@interface JBLineChartMissingPointsViewController () <JBLineChartViewDelegate, JBLineChartViewDataSource>
@property (nonatomic, strong) JBLineChartView *lineChartView;
@property (nonatomic, strong) JBChartInformationView *informationView;
@property (nonatomic, strong) NSArray *chartData;
@property (nonatomic, strong) NSArray *daysOfWeek;
// Buttons
- (void)chartToggleButtonPressed:(id)sender;
// Helpers
- (void)initFakeData;
- (NSArray *)largestLineData; // largest collection of fake line data
@end
@implementation JBLineChartMissingPointsViewController
#pragma mark - Alloc/Init
- (id)init
{
self = [super init];
if (self)
{
[self initFakeData];
}
return self;
}
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self)
{
[self initFakeData];
}
return self;
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self)
{
[self initFakeData];
}
return self;
}
#pragma mark - Data
- (void)initFakeData
{
NSMutableArray *mutableLineCharts = [NSMutableArray array];
for (int lineIndex=0; lineIndex<JBLineChartLineCount; lineIndex++)
{
NSMutableArray *mutableChartData = [NSMutableArray array];
for (int i=0; i<kJBLineChartMissingPointsViewControllerMaxNumChartPoints; i++)
{
if(i < 2 || i > 5 || i == 3)
{
[mutableChartData addObject:[NSNumber numberWithFloat:NAN]];
} else {
[mutableChartData addObject:[NSNumber numberWithFloat:((double)arc4random() / ARC4RANDOM_MAX)]]; // random number between 0 and 1
}
}
[mutableLineCharts addObject:mutableChartData];
}
_chartData = [NSArray arrayWithArray:mutableLineCharts];
_daysOfWeek = [[[NSDateFormatter alloc] init] shortWeekdaySymbols];
}
- (NSArray *)largestLineData
{
NSArray *largestLineData = nil;
for (NSArray *lineData in self.chartData)
{
if ([lineData count] > [largestLineData count])
{
largestLineData = lineData;
}
}
return largestLineData;
}
#pragma mark - View Lifecycle
- (void)loadView
{
[super loadView];
self.view.backgroundColor = kJBColorLineChartControllerBackground;
self.navigationItem.rightBarButtonItem = [self chartToggleButtonWithTarget:self action:@selector(chartToggleButtonPressed:)];
self.lineChartView = [[JBLineChartView alloc] init];
self.lineChartView.frame = CGRectMake(kJBLineChartMissingPointsViewControllerChartPadding, kJBLineChartMissingPointsViewControllerChartPadding, self.view.bounds.size.width - (kJBLineChartMissingPointsViewControllerChartPadding * 2), kJBLineChartMissingPointsViewControllerChartHeight);
self.lineChartView.delegate = self;
self.lineChartView.dataSource = self;
self.lineChartView.headerPadding = kJBLineChartMissingPointsViewControllerChartHeaderPadding;
self.lineChartView.backgroundColor = kJBColorLineChartBackground;
JBChartHeaderView *headerView = [[JBChartHeaderView alloc] initWithFrame:CGRectMake(kJBLineChartMissingPointsViewControllerChartPadding, ceil(self.view.bounds.size.height * 0.5) - ceil(kJBLineChartMissingPointsViewControllerChartHeaderHeight * 0.5), self.view.bounds.size.width - (kJBLineChartMissingPointsViewControllerChartPadding * 2), kJBLineChartMissingPointsViewControllerChartHeaderHeight)];
headerView.titleLabel.text = [kJBStringLabelCyclingDistances uppercaseString];
headerView.titleLabel.textColor = kJBColorLineChartHeader;
headerView.titleLabel.shadowColor = [UIColor colorWithWhite:1.0 alpha:0.25];
headerView.titleLabel.shadowOffset = CGSizeMake(0, 1);
headerView.subtitleLabel.text = kJBStringLabel2014;
headerView.subtitleLabel.textColor = kJBColorLineChartHeader;
headerView.subtitleLabel.shadowColor = [UIColor colorWithWhite:1.0 alpha:0.25];
headerView.subtitleLabel.shadowOffset = CGSizeMake(0, 1);
headerView.separatorColor = kJBColorLineChartHeaderSeparatorColor;
self.lineChartView.headerView = headerView;
JBLineChartFooterView *footerView = [[JBLineChartFooterView alloc] initWithFrame:CGRectMake(kJBLineChartMissingPointsViewControllerChartPadding, ceil(self.view.bounds.size.height * 0.5) - ceil(kJBLineChartMissingPointsViewControllerChartFooterHeight * 0.5), self.view.bounds.size.width - (kJBLineChartMissingPointsViewControllerChartPadding * 2), kJBLineChartMissingPointsViewControllerChartFooterHeight)];
footerView.backgroundColor = [UIColor clearColor];
footerView.leftLabel.text = [[self.daysOfWeek firstObject] uppercaseString];
footerView.leftLabel.textColor = [UIColor whiteColor];
footerView.rightLabel.text = [[self.daysOfWeek lastObject] uppercaseString];;
footerView.rightLabel.textColor = [UIColor whiteColor];
footerView.sectionCount = [[self largestLineData] count];
self.lineChartView.footerView = footerView;
[self.view addSubview:self.lineChartView];
self.informationView = [[JBChartInformationView alloc] initWithFrame:CGRectMake(self.view.bounds.origin.x, CGRectGetMaxY(self.lineChartView.frame), self.view.bounds.size.width, self.view.bounds.size.height - CGRectGetMaxY(self.lineChartView.frame) - CGRectGetMaxY(self.navigationController.navigationBar.frame))];
[self.informationView setValueAndUnitTextColor:[UIColor colorWithWhite:1.0 alpha:0.75]];
[self.informationView setTitleTextColor:kJBColorLineChartHeader];
[self.informationView setTextShadowColor:nil];
[self.informationView setSeparatorColor:kJBColorLineChartHeaderSeparatorColor];
[self.view addSubview:self.informationView];
[self.lineChartView reloadData];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.lineChartView setState:JBChartViewStateExpanded];
}
#pragma mark - JBChartViewDataSource
- (BOOL)shouldExtendSelectionViewIntoHeaderPaddingForChartView:(JBChartView *)chartView
{
return YES;
}
- (BOOL)shouldExtendSelectionViewIntoFooterPaddingForChartView:(JBChartView *)chartView
{
return NO;
}
#pragma mark - JBLineChartViewDataSource
- (NSUInteger)numberOfLinesInLineChartView:(JBLineChartView *)lineChartView
{
return [self.chartData count];
}
- (NSUInteger)lineChartView:(JBLineChartView *)lineChartView numberOfVerticalValuesAtLineIndex:(NSUInteger)lineIndex
{
return [[self.chartData objectAtIndex:lineIndex] count];
}
- (BOOL)lineChartView:(JBLineChartView *)lineChartView showsDotsForLineAtLineIndex:(NSUInteger)lineIndex
{
return lineIndex == JBLineChartViewLineStyleDashed;
}
- (BOOL)lineChartView:(JBLineChartView *)lineChartView smoothLineAtLineIndex:(NSUInteger)lineIndex
{
return lineIndex == JBLineChartViewLineStyleSolid;
}
#pragma mark - JBLineChartViewDelegate
- (CGFloat)lineChartView:(JBLineChartView *)lineChartView verticalValueForHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex
{
return [[[self.chartData objectAtIndex:lineIndex] objectAtIndex:horizontalIndex] floatValue];
}
- (void)lineChartView:(JBLineChartView *)lineChartView didSelectLineAtIndex:(NSUInteger)lineIndex horizontalIndex:(NSUInteger)horizontalIndex touchPoint:(CGPoint)touchPoint
{
NSNumber *valueNumber = [[self.chartData objectAtIndex:lineIndex] objectAtIndex:horizontalIndex];
if(isnan([valueNumber floatValue])) {
[self.informationView setHidden:YES animated:YES];
} else {
[self.informationView setValueText:[NSString stringWithFormat:@"%.2f", [valueNumber floatValue]] unitText:kJBStringLabelKm2014];
[self.informationView setTitleText:lineIndex == JBLineChartLineSolid ? kJBStringLabelLastWeek : kJBStringLabelCurrentWeek];
[self.informationView setHidden:NO animated:YES];
}
[self setTooltipVisible:YES animated:YES atTouchPoint:touchPoint];
[self.tooltipView setText:[[self.daysOfWeek objectAtIndex:horizontalIndex] uppercaseString]];
}
- (void)didDeselectLineInLineChartView:(JBLineChartView *)lineChartView
{
[self.informationView setHidden:YES animated:YES];
[self setTooltipVisible:NO animated:YES];
}
- (UIColor *)lineChartView:(JBLineChartView *)lineChartView colorForLineAtLineIndex:(NSUInteger)lineIndex
{
return (lineIndex == JBLineChartLineSolid) ? kJBColorLineChartDefaultSolidLineColor: kJBColorLineChartDefaultDashedLineColor;
}
- (UIColor *)lineChartView:(JBLineChartView *)lineChartView colorForDotAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex
{
return (lineIndex == JBLineChartLineSolid) ? kJBColorLineChartDefaultSolidLineColor: kJBColorLineChartDefaultDashedLineColor;
}
- (CGFloat)lineChartView:(JBLineChartView *)lineChartView widthForLineAtLineIndex:(NSUInteger)lineIndex
{
return (lineIndex == JBLineChartLineSolid) ? kJBLineChartMissingPointsViewControllerChartSolidLineWidth: kJBLineChartMissingPointsViewControllerChartDashedLineWidth;
}
- (CGFloat)lineChartView:(JBLineChartView *)lineChartView dotRadiusForDotAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex
{
return (lineIndex == JBLineChartLineSolid) ? 0.0: (kJBLineChartMissingPointsViewControllerChartDashedLineWidth * 4);
}
- (UIColor *)lineChartView:(JBLineChartView *)lineChartView verticalSelectionColorForLineAtLineIndex:(NSUInteger)lineIndex
{
return [UIColor whiteColor];
}
- (UIColor *)lineChartView:(JBLineChartView *)lineChartView selectionColorForLineAtLineIndex:(NSUInteger)lineIndex
{
return (lineIndex == JBLineChartLineSolid) ? kJBColorLineChartDefaultSolidSelectedLineColor: kJBColorLineChartDefaultDashedSelectedLineColor;
}
- (UIColor *)lineChartView:(JBLineChartView *)lineChartView selectionColorForDotAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex
{
return (lineIndex == JBLineChartLineSolid) ? kJBColorLineChartDefaultSolidSelectedLineColor: kJBColorLineChartDefaultDashedSelectedLineColor;
}
- (JBLineChartViewLineStyle)lineChartView:(JBLineChartView *)lineChartView lineStyleForLineAtLineIndex:(NSUInteger)lineIndex
{
return (lineIndex == JBLineChartLineSolid) ? JBLineChartViewLineStyleSolid : JBLineChartViewLineStyleDashed;
}
#pragma mark - Buttons
- (void)chartToggleButtonPressed:(id)sender
{
UIView *buttonImageView = [self.navigationItem.rightBarButtonItem valueForKey:kJBLineChartMissingPointsViewControllerNavButtonViewKey];
buttonImageView.userInteractionEnabled = NO;
CGAffineTransform transform = self.lineChartView.state == JBChartViewStateExpanded ? CGAffineTransformMakeRotation(M_PI) : CGAffineTransformMakeRotation(0);
buttonImageView.transform = transform;
[self.lineChartView setState:self.lineChartView.state == JBChartViewStateExpanded ? JBChartViewStateCollapsed : JBChartViewStateExpanded animated:YES callback:^{
buttonImageView.userInteractionEnabled = YES;
}];
}
#pragma mark - Overrides
- (JBChartView *)chartView
{
return self.lineChartView;
}
@end
@@ -171,6 +171,40 @@ NSString * const kJBLineChartViewControllerNavButtonViewKey = @"view";
[self.lineChartView setState:JBChartViewStateExpanded];
}
#pragma mark - JBChartViewDataSource
- (BOOL)shouldExtendSelectionViewIntoHeaderPaddingForChartView:(JBChartView *)chartView
{
return YES;
}
- (BOOL)shouldExtendSelectionViewIntoFooterPaddingForChartView:(JBChartView *)chartView
{
return NO;
}
#pragma mark - JBLineChartViewDataSource
- (NSUInteger)numberOfLinesInLineChartView:(JBLineChartView *)lineChartView
{
return [self.chartData count];
}
- (NSUInteger)lineChartView:(JBLineChartView *)lineChartView numberOfVerticalValuesAtLineIndex:(NSUInteger)lineIndex
{
return [[self.chartData objectAtIndex:lineIndex] count];
}
- (BOOL)lineChartView:(JBLineChartView *)lineChartView showsDotsForLineAtLineIndex:(NSUInteger)lineIndex
{
return lineIndex == JBLineChartViewLineStyleDashed;
}
- (BOOL)lineChartView:(JBLineChartView *)lineChartView smoothLineAtLineIndex:(NSUInteger)lineIndex
{
return lineIndex == JBLineChartViewLineStyleSolid;
}
#pragma mark - JBLineChartViewDelegate
- (CGFloat)lineChartView:(JBLineChartView *)lineChartView verticalValueForHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex
@@ -188,24 +222,12 @@ NSString * const kJBLineChartViewControllerNavButtonViewKey = @"view";
[self.tooltipView setText:[[self.daysOfWeek objectAtIndex:horizontalIndex] uppercaseString]];
}
- (void)didUnselectLineInLineChartView:(JBLineChartView *)lineChartView
- (void)didDeselectLineInLineChartView:(JBLineChartView *)lineChartView
{
[self.informationView setHidden:YES animated:YES];
[self setTooltipVisible:NO animated:YES];
}
#pragma mark - JBLineChartViewDataSource
- (NSUInteger)numberOfLinesInLineChartView:(JBLineChartView *)lineChartView
{
return [self.chartData count];
}
- (NSUInteger)lineChartView:(JBLineChartView *)lineChartView numberOfVerticalValuesAtLineIndex:(NSUInteger)lineIndex
{
return [[self.chartData objectAtIndex:lineIndex] count];
}
- (UIColor *)lineChartView:(JBLineChartView *)lineChartView colorForLineAtLineIndex:(NSUInteger)lineIndex
{
return (lineIndex == JBLineChartLineSolid) ? kJBColorLineChartDefaultSolidLineColor: kJBColorLineChartDefaultDashedLineColor;
@@ -221,12 +243,12 @@ NSString * const kJBLineChartViewControllerNavButtonViewKey = @"view";
return (lineIndex == JBLineChartLineSolid) ? kJBLineChartViewControllerChartSolidLineWidth: kJBLineChartViewControllerChartDashedLineWidth;
}
- (CGFloat)lineChartView:(JBLineChartView *)lineChartView dotRadiusForLineAtLineIndex:(NSUInteger)lineIndex
- (CGFloat)lineChartView:(JBLineChartView *)lineChartView dotRadiusForDotAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex
{
return (lineIndex == JBLineChartLineSolid) ? 0.0: (kJBLineChartViewControllerChartDashedLineWidth * 4);
}
- (UIColor *)verticalSelectionColorForLineChartView:(JBLineChartView *)lineChartView
- (UIColor *)lineChartView:(JBLineChartView *)lineChartView verticalSelectionColorForLineAtLineIndex:(NSUInteger)lineIndex
{
return [UIColor whiteColor];
}
@@ -246,16 +268,6 @@ NSString * const kJBLineChartViewControllerNavButtonViewKey = @"view";
return (lineIndex == JBLineChartLineSolid) ? JBLineChartViewLineStyleSolid : JBLineChartViewLineStyleDashed;
}
- (BOOL)lineChartView:(JBLineChartView *)lineChartView showsDotsForLineAtLineIndex:(NSUInteger)lineIndex
{
return lineIndex == JBLineChartViewLineStyleDashed;
}
- (BOOL)lineChartView:(JBLineChartView *)lineChartView smoothLineAtLineIndex:(NSUInteger)lineIndex
{
return lineIndex == JBLineChartViewLineStyleSolid;
}
#pragma mark - Buttons
- (void)chartToggleButtonPressed:(id)sender
@@ -10,7 +10,6 @@
@interface JBBarChartFooterView : UIView
@property (nonatomic, strong) UIColor *footerBackgroundColor; // footer background (default = black)
@property (nonatomic, assign) CGFloat padding; // label left & right padding (default = 4.0)
@property (nonatomic, readonly) UILabel *leftLabel;
@property (nonatomic, readonly) UILabel *rightLabel;
@@ -10,30 +10,12 @@
// Numerics
CGFloat const kJBBarChartFooterPolygonViewDefaultPadding = 4.0f;
CGFloat const kJBBarChartFooterPolygonViewArrowHeight = 8.0f;
CGFloat const kJBBarChartFooterPolygonViewArrowWidth = 16.0f;
// Colors
static UIColor *kJBBarChartFooterPolygonViewDefaultBackgroundColor = nil;
static UIColor *kJBBarChartFooterViewDefaultBackgroundColor = nil;
@protocol JBBarChartFooterPolygonViewDelegate;
@interface JBBarChartFooterView ()
@interface JBBarChartFooterPolygonView : UIView
@property (nonatomic, weak) id<JBBarChartFooterPolygonViewDelegate> delegate;
@end
@protocol JBBarChartFooterPolygonViewDelegate <NSObject>
- (UIColor *)backgroundColorForChartFooterPolygonView:(JBBarChartFooterPolygonView *)chartFooterPolygonView;
- (CGFloat)paddingForChartFooterPolygonView:(JBBarChartFooterPolygonView *)chartFooterPolygonView;
@end
@interface JBBarChartFooterView () <JBBarChartFooterPolygonViewDelegate>
@property (nonatomic, strong) JBBarChartFooterPolygonView *polygonView;
@property (nonatomic, strong) UILabel *leftLabel;
@property (nonatomic, strong) UILabel *rightLabel;
@@ -47,7 +29,7 @@ static UIColor *kJBBarChartFooterPolygonViewDefaultBackgroundColor = nil;
{
if (self == [JBBarChartFooterView class])
{
kJBBarChartFooterPolygonViewDefaultBackgroundColor = kJBColorBarChartControllerBackground;
kJBBarChartFooterViewDefaultBackgroundColor = kJBColorBarChartControllerBackground;
}
}
@@ -56,15 +38,10 @@ static UIColor *kJBBarChartFooterPolygonViewDefaultBackgroundColor = nil;
self = [super initWithFrame:frame];
if (self)
{
self.backgroundColor = kJBBarChartFooterPolygonViewDefaultBackgroundColor;
self.backgroundColor = kJBBarChartFooterViewDefaultBackgroundColor;
_footerBackgroundColor = kJBBarChartFooterPolygonViewDefaultBackgroundColor;
_padding = kJBBarChartFooterPolygonViewDefaultPadding;
_polygonView = [[JBBarChartFooterPolygonView alloc] initWithFrame:CGRectMake(self.bounds.origin.x, self.bounds.origin.y - kJBBarChartFooterPolygonViewArrowHeight, self.bounds.size.width, self.bounds.size.height + kJBBarChartFooterPolygonViewArrowHeight)];
_polygonView.delegate = self;
[self addSubview:_polygonView];
_leftLabel = [[UILabel alloc] init];
_leftLabel.adjustsFontSizeToFitWidth = YES;
_leftLabel.font = kJBFontFooterLabel;
@@ -100,95 +77,4 @@ static UIColor *kJBBarChartFooterPolygonViewDefaultBackgroundColor = nil;
self.rightLabel.frame = CGRectMake(CGRectGetMaxX(_leftLabel.frame), yOffset, width, self.bounds.size.height);
}
#pragma mark - JBBarChartFooterPolygonViewDelegate
- (UIColor *)backgroundColorForChartFooterPolygonView:(JBBarChartFooterPolygonView *)chartFooterPolygonView
{
return self.footerBackgroundColor;
}
- (CGFloat)paddingForChartFooterPolygonView:(JBBarChartFooterPolygonView *)chartFooterPolygonView
{
return self.padding;
}
@end
@implementation JBBarChartFooterPolygonView
#pragma mark - Alloc/Init
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
self.backgroundColor = [UIColor clearColor];
}
return self;
}
#pragma mark - Drawing
- (void)drawRect:(CGRect)rect
{
[super drawRect:rect];
CGContextRef context = UIGraphicsGetCurrentContext();
// Background gradient
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGFloat locations[] = { 0.0, 1.0 };
NSAssert([self.delegate respondsToSelector:@selector(backgroundColorForChartFooterPolygonView:)], @"JBChartFooterPolygonView // delegate must implement - (UIColor *)backgroundColorForChartFooterPolygonView");
NSAssert([self.delegate respondsToSelector:@selector(paddingForChartFooterPolygonView:)], @"JBChartFooterPolygonView // delegate must implement - (CGFloat)paddingForChartFooterPolygonView");
UIColor *bgColor = [self.delegate backgroundColorForChartFooterPolygonView:self];
NSArray *colors = @[(__bridge id)bgColor.CGColor, (__bridge id)bgColor.CGColor];
CGGradientRef gradient = CGGradientCreateWithColors(colorSpace, (__bridge CFArrayRef) colors, locations);
// Polygon shape
CGFloat xOffset = self.bounds.origin.x;
CGFloat width = self.bounds.size.width;
CGFloat height = self.bounds.size.height;
CGFloat padding = [self.delegate paddingForChartFooterPolygonView:self];
NSArray *polygonPoints = @[[NSValue valueWithCGPoint:CGPointMake(xOffset, height)],
[NSValue valueWithCGPoint:CGPointMake(xOffset, kJBBarChartFooterPolygonViewArrowHeight)],
[NSValue valueWithCGPoint:CGPointMake(xOffset + padding, kJBBarChartFooterPolygonViewArrowHeight)],
[NSValue valueWithCGPoint:CGPointMake(xOffset + padding + ceil(kJBBarChartFooterPolygonViewArrowWidth * 0.5), 0)],
[NSValue valueWithCGPoint:CGPointMake(xOffset + padding + kJBBarChartFooterPolygonViewArrowWidth, kJBBarChartFooterPolygonViewArrowHeight)],
[NSValue valueWithCGPoint:CGPointMake(width - padding - kJBBarChartFooterPolygonViewArrowWidth, kJBBarChartFooterPolygonViewArrowHeight)],
[NSValue valueWithCGPoint:CGPointMake(width - padding - ceil(kJBBarChartFooterPolygonViewArrowWidth * 0.5), 0.0)],
[NSValue valueWithCGPoint:CGPointMake(width - padding, kJBBarChartFooterPolygonViewArrowHeight)],
[NSValue valueWithCGPoint:CGPointMake(width, kJBBarChartFooterPolygonViewArrowHeight)],
[NSValue valueWithCGPoint:CGPointMake(width, height)],
[NSValue valueWithCGPoint:CGPointMake(xOffset, height)]];
// Draw polygon
NSValue *pointValue = polygonPoints[0];
CGContextSaveGState(context);
{
NSInteger index = 0;
for (pointValue in polygonPoints)
{
CGPoint point = [pointValue CGPointValue];
if (index == 0)
{
CGContextMoveToPoint(context, point.x, point.y);
}
else
{
CGContextAddLineToPoint(context, point.x, point.y);
}
index++;
}
CGContextClip(context);
CGContextDrawLinearGradient(context, gradient, CGPointMake(CGRectGetMidX(rect), CGRectGetMinY(rect)), CGPointMake(CGRectGetMidX(rect), CGRectGetMaxY(rect)), 0);
}
CGContextRestoreGState(context);
CGGradientRelease(gradient);
CGColorSpaceRelease(colorSpace);
}
@end
@@ -261,8 +261,25 @@ static UIColor *kJBChartInformationViewShadowColor = nil;
- (void)layoutSubviews
{
CGSize valueLabelSize = [self.valueLabel.text sizeWithAttributes:@{NSFontAttributeName:self.valueLabel.font}];
CGSize unitLabelSize = [self.unitLabel.text sizeWithAttributes:@{NSFontAttributeName:self.unitLabel.font}];
CGSize valueLabelSize = CGSizeZero;
if ([self.valueLabel.text respondsToSelector:@selector(sizeWithAttributes:)])
{
valueLabelSize = [self.valueLabel.text sizeWithAttributes:@{NSFontAttributeName:self.valueLabel.font}];
}
else
{
valueLabelSize = [self.valueLabel.text sizeWithFont:self.valueLabel.font];
}
CGSize unitLabelSize = CGSizeZero;
if ([self.unitLabel.text respondsToSelector:@selector(sizeWithAttributes:)])
{
unitLabelSize = [self.unitLabel.text sizeWithAttributes:@{NSFontAttributeName:self.unitLabel.font}];
}
else
{
unitLabelSize = [self.unitLabel.text sizeWithFont:self.unitLabel.font];
}
CGFloat xOffset = ceil((self.bounds.size.width - (valueLabelSize.width + unitLabelSize.width)) * 0.5);
Binary file not shown.

After

Width:  |  Height:  |  Size: 650 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

+77 -17
View File
@@ -1,7 +1,7 @@
# JBChartView
<br/>
<p align="center">
<img src="https://raw.github.com/Jawbone/JBChartView/master/Screenshots/main.png">
<img src="https://raw.github.com/Jawbone/JBChartView/master/Screenshots/main.jpg">
</p>
Introducing <b>JBChartView - </b> Jawbone's iOS-based charting library for both line and bar graphs. It is easy to set-up, and highly customizable.
@@ -18,13 +18,18 @@ Refer to the <a href="https://github.com/Jawbone/JBChartView/blob/master/CHANGEL
## Requirements
- Requires iOS 7 or later
- Requires iOS 6 or later
- Requires Automatic Reference Counting (ARC)
## Demo
## Demo Project
Build and run the <i>JBChartViewDemo</i> project in Xcode. The demo demonstrates the use of both the line and bar charts. It also outlines how a chart's appearance can be customized.
## More Demos
- <a href="https://github.com/Jawbone/anscombe-quartet-ios">Amsombe's Quartet</a>: project showcasing the use of JBChartView in the classic data visualization example known as Anscombe's Quartet.
- <a href="https://github.com/Jawbone/spark-friends-ios">Spark Friends</a>: project showcasing the use of JBChartView in the context of sparklines and (fake) user step data.
## Installation
<a href="http://cocoapods.org/" target="_blank">CocoaPods</a> is the recommended method of installing JBChartView.
@@ -33,13 +38,9 @@ Build and run the <i>JBChartViewDemo</i> project in Xcode. The demo demonstrates
Simply add the following line to your <code>Podfile</code>:
platform :ios, '6.0'
pod 'JBChartView'
Your Podfile should look something like:
platform :ios, '7.0'
pod 'JBChartView', '~> 2.4.0'
### The Old School Way
The simpliest way to use JBChartView with your application is to drag and drop the <i>/Classes</i> folder into you're Xcode 5 project. It's also recommended you rename the <i>/Classes</i> folder to something more descriptive (ie. "<i>Jawbone - JBChartView</i>").
@@ -52,25 +53,36 @@ The simpliest way to use JBChartView with your application is to drag and drop t
All JBChartView implementations have a similiar data source and delgate pattern to <i>UITableView</i>. If you're familiar with using a <i>UITableView</i> or <i>UITableViewController</i>, using a JBChartView subclass should be a breeze!
#### Swift Projects
To use JBCartView in a Swift project add the following to your bridging header (JBChartView-Bridging-Header.h):
#import <UIKit/UIKit.h>
#import "JBChartView.h"
#import "JBBarChartView.h"
#import "JBLineChartView.h"
For more information about adding bridging headers see <a href="https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html" target="_blank">Swift and Objective-C in the Same Project</a>.
#### JBBarChartView
To initialize a <i>JBBarChartView</i>, you only need a few lines of code (see below). Bar charts can also be initialized via a <b>nib</b> or with a <b>frame</b>.
JBBarChartView *barChartView = [[JBBarChartView alloc] init];
barChartView.delegate = self;
barChartView.dataSource = self;
barChartView.delegate = self;
[self addSubview:barChartView];
At a minimum, you need to inform the data source how many bars are in the chart:
- (NSInteger)numberOfBarsInBarChartView:(JBBarChartView *)barChartView
- (NSUInteger)numberOfBarsInBarChartView:(JBBarChartView *)barChartView
{
return ...; // number of bars in chart
}
Secondly, you need to inform the delegate the height of each bar (automatically normalized across the entire chart):
- (CGFloat)barChartView:(JBBarChartView *)barChartView heightForBarViewAtAtIndex:(NSInteger)index
- (CGFloat)barChartView:(JBBarChartView *)barChartView heightForBarViewAtIndex:(NSUInteger)index
{
return ...; // height of bar at index
}
@@ -79,14 +91,16 @@ Lastly, ensure you have set the *frame* of your barChartView & call *reloadData*
barChartView.frame = CGRectMake( ... );
[barChartView reloadData];
**Note**: subsequent changes to the chart's frame will not invoke *reloadData*; it must be called directly afterwards for any changes to take effect.
#### JBLineChartView
Similiarily, to initialize a JBLineChartView, you only need a few lines of code (see below). Line charts can also be initialized via a <b>nib</b> or with a <b>frame</b>.
JBLineChartView *lineChartView = [[JBLineChartView alloc] init];
lineChartView.delegate = self;
lineChartView.dataSource = self;
lineChartView.delegate = self;
[self addSubview:lineChartView];
At a minimum, you need to inform the data source how many lines and vertical data points (for each line) are in the chart:
@@ -108,11 +122,16 @@ Secondly, you need to inform the delegate of the y-position of each point (autom
return ...; // y-position (y-axis) of point at horizontalIndex (x-axis)
}
**Note**: You can return NAN instead of CGFloat to indicate missing values. The chart's line will begin at the first non-NAN value and end at the last non-NAN value. The line will interopolate any NAN values in between (ie. the line will not be interrupted).
return [NSNumber numberWithFloat:NAN]
Lastly, ensure you have set the *frame* of your lineChartView & call *reloadData* at least once:
lineChartView.frame = CGRectMake( ... );
[lineChartView reloadData];
**Note**: subsequent changes to the chart's frame will not invoke *reloadData*; it must be called directly afterwards for any changes to take effect.
## Customization
@@ -134,12 +153,20 @@ Lastly, any JBChartView subclass can be collapsed or expanded programmatically v
#### JBBarChartView
A bar chart can be inverted such that it's orientation is top->down (including the selection view) by setting the following property:
@property (nonatomic, assign, getter=isInverted) BOOL inverted;
By default, a chart's bars will be black and flat. They can be customized by supplying a UIView subclass through the <i>optional</i> protocol:
- (UIView *)barChartView:(JBBarChartView *)barChartView barViewAtIndex:(NSUInteger)index
{
return ...; // color of line in chart
}
If you don't require a custom UIView, simply supply a color for the bar instead:
- (UIColor *)barChartView:(JBBarChartView *)barChartView colorForBarViewAtIndex:(NSUInteger)index;
Furthermore, the color of the selection bar (on touch events) can be customized via the <i>optional</i> protocol:
@@ -155,7 +182,7 @@ Lastly, a bar chart's selection events are delegated back via:
// Update view
}
- (void)didUnselectBarChartView:(JBBarChartView *)barChartView
- (void)didDeselectBarChartView:(JBBarChartView *)barChartView
{
// Update view
}
@@ -171,6 +198,11 @@ The color, width and style of each line in the chart can be customized via the <
return ...; // color of line in chart
}
- (UIColor *)lineChartView:(JBLineChartView *)lineChartView fillColorForLineAtLineIndex:(NSUInteger)lineIndex
{
return ...; // color of area under line in chart
}
- (CGFloat)lineChartView:(JBLineChartView *)lineChartView widthForLineAtLineIndex:(NSUInteger)lineIndex
{
return ...; // width of line in chart
@@ -183,7 +215,7 @@ The color, width and style of each line in the chart can be customized via the <
Furthermore, the color and width of the selection view along with the color of the selected line can be customized via the <i>optional</i> protocols:
- (UIColor *)verticalSelectionColorForLineChartView:(JBLineChartView *)lineChartView
- (UIColor *)lineChartView:(JBLineChartView *)lineChartView verticalSelectionColorForLineAtLineIndex:(NSUInteger)lineIndex
{
return ...; // color of selection view
}
@@ -198,13 +230,18 @@ Furthermore, the color and width of the selection view along with the color of t
return ...; // color of selected line
}
- (UIColor *)lineChartView:(JBLineChartView *)lineChartView selectionFillColorForLineAtLineIndex:(NSUInteger)lineIndex
{
return ...; // color of area under selected line
}
By default, each line will not show dots for each point. To enable this on a per-line basis:
- (BOOL)lineChartView:(JBLineChartView *)lineChartView showsDotsForLineAtLineIndex:(NSUInteger)lineIndex;
To customize the size of each dot (default 3x the line width), implement:
To the radius of each dot (default is 6x the line width, or 3x the diameter), implement:
- (CGFloat)lineChartView:(JBLineChartView *)lineChartView dotRadiusForLineAtLineIndex:(NSUInteger)lineIndex;
- (CGFloat)lineChartView:(JBLineChartView *)lineChartView dotRadiusForDotAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex;
To customize the color of each dot during selection and non-selection events (default is white and black respectively), implement:
@@ -212,6 +249,14 @@ To customize the color of each dot during selection and non-selection events (de
- (UIColor *)lineChartView:(JBLineChartView *)lineChartView selectionColorForDotAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex;
Alternatively, you can supply your own UIView instead of using the default impelmentation:
- (UIView *)lineChartView:(JBLineChartView *)lineChartView dotViewAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex;
Custom dot views are automatically shown when selected unless the following is implemented:
- (BOOL)lineChartView:(JBLineChartView *)lineChartView shouldHideDotViewOnSelectionAtHorizontalIndex:(NSUInteger)horizontalIndex atLineIndex:(NSUInteger)lineIndex;
As well, by default, each line will have squared off end caps and connection points. To enable rounded connections and end caps:
- (BOOL)lineChartView:(JBLineChartView *)lineChartView smoothLineAtLineIndex:(NSUInteger)lineIndex;
@@ -223,12 +268,27 @@ Lastly, a line chart's selection events are delegated back via:
// Update view
}
- (void)didUnselectLineInLineChartView:(JBLineChartView *)lineChartView
- (void)didDeselectLineInLineChartView:(JBLineChartView *)lineChartView
{
// Update view
}
The <b>touchPoint</b> is especially important as it allows you to add custom elements to your chart during selection events. Refer to the demo project (<b>JBLineChartViewController</b>) to see how a tooltip can be used to display additional information during selection events.
## Minimum & Maximum Values
By default, a chart's minimum and maximum values are equal to the min and max supplied by the dataSource. You can override either value via:
- (void)setMinimumValue:(CGFloat)minimumValue;
- (void)setMaximumValue:(CGFloat)maximumValue;
If value(s) are supplied, they must be >= 0, otherwise an assertion will be thrown. To reset the values back to their original defaults:
- (void)resetMinimumValue;
- (void)resetMaximumValue;
The min/max values are clamped to the ceiling and floor of the actual min/max values of the chart's data source; for example, if a maximumValue of 20 is supplied & the chart's actual max is 100, then 100 will be used. For min/max modifications to take effect, reloadData must be called.
## License
Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 157 KiB