├── JTChartView Example ├── .gitignore ├── JTChartView Example.xcodeproj │ └── project.pbxproj ├── JTChartView Example │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ ├── ViewController.h │ ├── ViewController.m │ └── main.m └── JTChartView ExampleTests │ ├── Info.plist │ └── JTChartView_ExampleTests.m ├── JTChartView.podspec ├── JTChartView ├── JTChartView.h └── JTChartView.m ├── LICENSE.md ├── README.md └── Screens ├── chart1.png ├── chart2.png └── example.PNG /JTChartView Example/.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | .DS_Store 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | *.xcworkspace 13 | !default.xcworkspace 14 | xcuserdata 15 | profile 16 | *.moved-aside 17 | DerivedData 18 | .idea/ 19 | # Pods - for those of you who use CocoaPods 20 | Pods 21 | -------------------------------------------------------------------------------- /JTChartView Example/JTChartView Example.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 3B8110D61B4444D7005C2B7A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B8110D51B4444D7005C2B7A /* main.m */; }; 11 | 3B8110D91B4444D7005C2B7A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B8110D81B4444D7005C2B7A /* AppDelegate.m */; }; 12 | 3B8110DC1B4444D7005C2B7A /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B8110DB1B4444D7005C2B7A /* ViewController.m */; }; 13 | 3B8110DF1B4444D7005C2B7A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3B8110DD1B4444D7005C2B7A /* Main.storyboard */; }; 14 | 3B8110E11B4444D7005C2B7A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3B8110E01B4444D7005C2B7A /* Images.xcassets */; }; 15 | 3B8110E41B4444D7005C2B7A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3B8110E21B4444D7005C2B7A /* LaunchScreen.xib */; }; 16 | 3B8110F01B4444D8005C2B7A /* JTChartView_ExampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B8110EF1B4444D8005C2B7A /* JTChartView_ExampleTests.m */; }; 17 | 3B8111011B444559005C2B7A /* JTChartView.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B8111001B444559005C2B7A /* JTChartView.m */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXContainerItemProxy section */ 21 | 3B8110EA1B4444D8005C2B7A /* PBXContainerItemProxy */ = { 22 | isa = PBXContainerItemProxy; 23 | containerPortal = 3B8110C81B4444D7005C2B7A /* Project object */; 24 | proxyType = 1; 25 | remoteGlobalIDString = 3B8110CF1B4444D7005C2B7A; 26 | remoteInfo = "JTChartView Example"; 27 | }; 28 | /* End PBXContainerItemProxy section */ 29 | 30 | /* Begin PBXFileReference section */ 31 | 3B8110D01B4444D7005C2B7A /* JTChartView Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "JTChartView Example.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 32 | 3B8110D41B4444D7005C2B7A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 33 | 3B8110D51B4444D7005C2B7A /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 34 | 3B8110D71B4444D7005C2B7A /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 35 | 3B8110D81B4444D7005C2B7A /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 36 | 3B8110DA1B4444D7005C2B7A /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 37 | 3B8110DB1B4444D7005C2B7A /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 38 | 3B8110DE1B4444D7005C2B7A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 39 | 3B8110E01B4444D7005C2B7A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 40 | 3B8110E31B4444D7005C2B7A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 41 | 3B8110E91B4444D8005C2B7A /* JTChartView ExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "JTChartView ExampleTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 42 | 3B8110EE1B4444D8005C2B7A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 43 | 3B8110EF1B4444D8005C2B7A /* JTChartView_ExampleTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = JTChartView_ExampleTests.m; sourceTree = ""; }; 44 | 3B8110FF1B444559005C2B7A /* JTChartView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JTChartView.h; sourceTree = ""; }; 45 | 3B8111001B444559005C2B7A /* JTChartView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JTChartView.m; sourceTree = ""; }; 46 | /* End PBXFileReference section */ 47 | 48 | /* Begin PBXFrameworksBuildPhase section */ 49 | 3B8110CD1B4444D7005C2B7A /* Frameworks */ = { 50 | isa = PBXFrameworksBuildPhase; 51 | buildActionMask = 2147483647; 52 | files = ( 53 | ); 54 | runOnlyForDeploymentPostprocessing = 0; 55 | }; 56 | 3B8110E61B4444D8005C2B7A /* Frameworks */ = { 57 | isa = PBXFrameworksBuildPhase; 58 | buildActionMask = 2147483647; 59 | files = ( 60 | ); 61 | runOnlyForDeploymentPostprocessing = 0; 62 | }; 63 | /* End PBXFrameworksBuildPhase section */ 64 | 65 | /* Begin PBXGroup section */ 66 | 3B8110C71B4444D7005C2B7A = { 67 | isa = PBXGroup; 68 | children = ( 69 | 3B8110FE1B444559005C2B7A /* JTChartView */, 70 | 3B8110D21B4444D7005C2B7A /* JTChartView Example */, 71 | 3B8110EC1B4444D8005C2B7A /* JTChartView ExampleTests */, 72 | 3B8110D11B4444D7005C2B7A /* Products */, 73 | ); 74 | sourceTree = ""; 75 | }; 76 | 3B8110D11B4444D7005C2B7A /* Products */ = { 77 | isa = PBXGroup; 78 | children = ( 79 | 3B8110D01B4444D7005C2B7A /* JTChartView Example.app */, 80 | 3B8110E91B4444D8005C2B7A /* JTChartView ExampleTests.xctest */, 81 | ); 82 | name = Products; 83 | sourceTree = ""; 84 | }; 85 | 3B8110D21B4444D7005C2B7A /* JTChartView Example */ = { 86 | isa = PBXGroup; 87 | children = ( 88 | 3B8110D71B4444D7005C2B7A /* AppDelegate.h */, 89 | 3B8110D81B4444D7005C2B7A /* AppDelegate.m */, 90 | 3B8110DA1B4444D7005C2B7A /* ViewController.h */, 91 | 3B8110DB1B4444D7005C2B7A /* ViewController.m */, 92 | 3B8110DD1B4444D7005C2B7A /* Main.storyboard */, 93 | 3B8110E01B4444D7005C2B7A /* Images.xcassets */, 94 | 3B8110E21B4444D7005C2B7A /* LaunchScreen.xib */, 95 | 3B8110D31B4444D7005C2B7A /* Supporting Files */, 96 | ); 97 | path = "JTChartView Example"; 98 | sourceTree = ""; 99 | }; 100 | 3B8110D31B4444D7005C2B7A /* Supporting Files */ = { 101 | isa = PBXGroup; 102 | children = ( 103 | 3B8110D41B4444D7005C2B7A /* Info.plist */, 104 | 3B8110D51B4444D7005C2B7A /* main.m */, 105 | ); 106 | name = "Supporting Files"; 107 | sourceTree = ""; 108 | }; 109 | 3B8110EC1B4444D8005C2B7A /* JTChartView ExampleTests */ = { 110 | isa = PBXGroup; 111 | children = ( 112 | 3B8110EF1B4444D8005C2B7A /* JTChartView_ExampleTests.m */, 113 | 3B8110ED1B4444D8005C2B7A /* Supporting Files */, 114 | ); 115 | path = "JTChartView ExampleTests"; 116 | sourceTree = ""; 117 | }; 118 | 3B8110ED1B4444D8005C2B7A /* Supporting Files */ = { 119 | isa = PBXGroup; 120 | children = ( 121 | 3B8110EE1B4444D8005C2B7A /* Info.plist */, 122 | ); 123 | name = "Supporting Files"; 124 | sourceTree = ""; 125 | }; 126 | 3B8110FE1B444559005C2B7A /* JTChartView */ = { 127 | isa = PBXGroup; 128 | children = ( 129 | 3B8110FF1B444559005C2B7A /* JTChartView.h */, 130 | 3B8111001B444559005C2B7A /* JTChartView.m */, 131 | ); 132 | name = JTChartView; 133 | path = ../JTChartView; 134 | sourceTree = ""; 135 | }; 136 | /* End PBXGroup section */ 137 | 138 | /* Begin PBXNativeTarget section */ 139 | 3B8110CF1B4444D7005C2B7A /* JTChartView Example */ = { 140 | isa = PBXNativeTarget; 141 | buildConfigurationList = 3B8110F31B4444D8005C2B7A /* Build configuration list for PBXNativeTarget "JTChartView Example" */; 142 | buildPhases = ( 143 | 3B8110CC1B4444D7005C2B7A /* Sources */, 144 | 3B8110CD1B4444D7005C2B7A /* Frameworks */, 145 | 3B8110CE1B4444D7005C2B7A /* Resources */, 146 | ); 147 | buildRules = ( 148 | ); 149 | dependencies = ( 150 | ); 151 | name = "JTChartView Example"; 152 | productName = "JTChartView Example"; 153 | productReference = 3B8110D01B4444D7005C2B7A /* JTChartView Example.app */; 154 | productType = "com.apple.product-type.application"; 155 | }; 156 | 3B8110E81B4444D8005C2B7A /* JTChartView ExampleTests */ = { 157 | isa = PBXNativeTarget; 158 | buildConfigurationList = 3B8110F61B4444D8005C2B7A /* Build configuration list for PBXNativeTarget "JTChartView ExampleTests" */; 159 | buildPhases = ( 160 | 3B8110E51B4444D8005C2B7A /* Sources */, 161 | 3B8110E61B4444D8005C2B7A /* Frameworks */, 162 | 3B8110E71B4444D8005C2B7A /* Resources */, 163 | ); 164 | buildRules = ( 165 | ); 166 | dependencies = ( 167 | 3B8110EB1B4444D8005C2B7A /* PBXTargetDependency */, 168 | ); 169 | name = "JTChartView ExampleTests"; 170 | productName = "JTChartView ExampleTests"; 171 | productReference = 3B8110E91B4444D8005C2B7A /* JTChartView ExampleTests.xctest */; 172 | productType = "com.apple.product-type.bundle.unit-test"; 173 | }; 174 | /* End PBXNativeTarget section */ 175 | 176 | /* Begin PBXProject section */ 177 | 3B8110C81B4444D7005C2B7A /* Project object */ = { 178 | isa = PBXProject; 179 | attributes = { 180 | LastUpgradeCheck = 0630; 181 | ORGANIZATIONNAME = "Jakub Truhlar"; 182 | TargetAttributes = { 183 | 3B8110CF1B4444D7005C2B7A = { 184 | CreatedOnToolsVersion = 6.3.2; 185 | }; 186 | 3B8110E81B4444D8005C2B7A = { 187 | CreatedOnToolsVersion = 6.3.2; 188 | TestTargetID = 3B8110CF1B4444D7005C2B7A; 189 | }; 190 | }; 191 | }; 192 | buildConfigurationList = 3B8110CB1B4444D7005C2B7A /* Build configuration list for PBXProject "JTChartView Example" */; 193 | compatibilityVersion = "Xcode 3.2"; 194 | developmentRegion = English; 195 | hasScannedForEncodings = 0; 196 | knownRegions = ( 197 | en, 198 | Base, 199 | ); 200 | mainGroup = 3B8110C71B4444D7005C2B7A; 201 | productRefGroup = 3B8110D11B4444D7005C2B7A /* Products */; 202 | projectDirPath = ""; 203 | projectRoot = ""; 204 | targets = ( 205 | 3B8110CF1B4444D7005C2B7A /* JTChartView Example */, 206 | 3B8110E81B4444D8005C2B7A /* JTChartView ExampleTests */, 207 | ); 208 | }; 209 | /* End PBXProject section */ 210 | 211 | /* Begin PBXResourcesBuildPhase section */ 212 | 3B8110CE1B4444D7005C2B7A /* Resources */ = { 213 | isa = PBXResourcesBuildPhase; 214 | buildActionMask = 2147483647; 215 | files = ( 216 | 3B8110DF1B4444D7005C2B7A /* Main.storyboard in Resources */, 217 | 3B8110E41B4444D7005C2B7A /* LaunchScreen.xib in Resources */, 218 | 3B8110E11B4444D7005C2B7A /* Images.xcassets in Resources */, 219 | ); 220 | runOnlyForDeploymentPostprocessing = 0; 221 | }; 222 | 3B8110E71B4444D8005C2B7A /* Resources */ = { 223 | isa = PBXResourcesBuildPhase; 224 | buildActionMask = 2147483647; 225 | files = ( 226 | ); 227 | runOnlyForDeploymentPostprocessing = 0; 228 | }; 229 | /* End PBXResourcesBuildPhase section */ 230 | 231 | /* Begin PBXSourcesBuildPhase section */ 232 | 3B8110CC1B4444D7005C2B7A /* Sources */ = { 233 | isa = PBXSourcesBuildPhase; 234 | buildActionMask = 2147483647; 235 | files = ( 236 | 3B8110DC1B4444D7005C2B7A /* ViewController.m in Sources */, 237 | 3B8110D91B4444D7005C2B7A /* AppDelegate.m in Sources */, 238 | 3B8110D61B4444D7005C2B7A /* main.m in Sources */, 239 | 3B8111011B444559005C2B7A /* JTChartView.m in Sources */, 240 | ); 241 | runOnlyForDeploymentPostprocessing = 0; 242 | }; 243 | 3B8110E51B4444D8005C2B7A /* Sources */ = { 244 | isa = PBXSourcesBuildPhase; 245 | buildActionMask = 2147483647; 246 | files = ( 247 | 3B8110F01B4444D8005C2B7A /* JTChartView_ExampleTests.m in Sources */, 248 | ); 249 | runOnlyForDeploymentPostprocessing = 0; 250 | }; 251 | /* End PBXSourcesBuildPhase section */ 252 | 253 | /* Begin PBXTargetDependency section */ 254 | 3B8110EB1B4444D8005C2B7A /* PBXTargetDependency */ = { 255 | isa = PBXTargetDependency; 256 | target = 3B8110CF1B4444D7005C2B7A /* JTChartView Example */; 257 | targetProxy = 3B8110EA1B4444D8005C2B7A /* PBXContainerItemProxy */; 258 | }; 259 | /* End PBXTargetDependency section */ 260 | 261 | /* Begin PBXVariantGroup section */ 262 | 3B8110DD1B4444D7005C2B7A /* Main.storyboard */ = { 263 | isa = PBXVariantGroup; 264 | children = ( 265 | 3B8110DE1B4444D7005C2B7A /* Base */, 266 | ); 267 | name = Main.storyboard; 268 | sourceTree = ""; 269 | }; 270 | 3B8110E21B4444D7005C2B7A /* LaunchScreen.xib */ = { 271 | isa = PBXVariantGroup; 272 | children = ( 273 | 3B8110E31B4444D7005C2B7A /* Base */, 274 | ); 275 | name = LaunchScreen.xib; 276 | sourceTree = ""; 277 | }; 278 | /* End PBXVariantGroup section */ 279 | 280 | /* Begin XCBuildConfiguration section */ 281 | 3B8110F11B4444D8005C2B7A /* Debug */ = { 282 | isa = XCBuildConfiguration; 283 | buildSettings = { 284 | ALWAYS_SEARCH_USER_PATHS = NO; 285 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 286 | CLANG_CXX_LIBRARY = "libc++"; 287 | CLANG_ENABLE_MODULES = YES; 288 | CLANG_ENABLE_OBJC_ARC = YES; 289 | CLANG_WARN_BOOL_CONVERSION = YES; 290 | CLANG_WARN_CONSTANT_CONVERSION = YES; 291 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 292 | CLANG_WARN_EMPTY_BODY = YES; 293 | CLANG_WARN_ENUM_CONVERSION = YES; 294 | CLANG_WARN_INT_CONVERSION = YES; 295 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 296 | CLANG_WARN_UNREACHABLE_CODE = YES; 297 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 298 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 299 | COPY_PHASE_STRIP = NO; 300 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 301 | ENABLE_STRICT_OBJC_MSGSEND = YES; 302 | GCC_C_LANGUAGE_STANDARD = gnu99; 303 | GCC_DYNAMIC_NO_PIC = NO; 304 | GCC_NO_COMMON_BLOCKS = YES; 305 | GCC_OPTIMIZATION_LEVEL = 0; 306 | GCC_PREPROCESSOR_DEFINITIONS = ( 307 | "DEBUG=1", 308 | "$(inherited)", 309 | ); 310 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 311 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 312 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 313 | GCC_WARN_UNDECLARED_SELECTOR = YES; 314 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 315 | GCC_WARN_UNUSED_FUNCTION = YES; 316 | GCC_WARN_UNUSED_VARIABLE = YES; 317 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 318 | MTL_ENABLE_DEBUG_INFO = YES; 319 | ONLY_ACTIVE_ARCH = YES; 320 | SDKROOT = iphoneos; 321 | }; 322 | name = Debug; 323 | }; 324 | 3B8110F21B4444D8005C2B7A /* Release */ = { 325 | isa = XCBuildConfiguration; 326 | buildSettings = { 327 | ALWAYS_SEARCH_USER_PATHS = NO; 328 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 329 | CLANG_CXX_LIBRARY = "libc++"; 330 | CLANG_ENABLE_MODULES = YES; 331 | CLANG_ENABLE_OBJC_ARC = YES; 332 | CLANG_WARN_BOOL_CONVERSION = YES; 333 | CLANG_WARN_CONSTANT_CONVERSION = YES; 334 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 335 | CLANG_WARN_EMPTY_BODY = YES; 336 | CLANG_WARN_ENUM_CONVERSION = YES; 337 | CLANG_WARN_INT_CONVERSION = YES; 338 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 339 | CLANG_WARN_UNREACHABLE_CODE = YES; 340 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 341 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 342 | COPY_PHASE_STRIP = NO; 343 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 344 | ENABLE_NS_ASSERTIONS = NO; 345 | ENABLE_STRICT_OBJC_MSGSEND = YES; 346 | GCC_C_LANGUAGE_STANDARD = gnu99; 347 | GCC_NO_COMMON_BLOCKS = YES; 348 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 349 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 350 | GCC_WARN_UNDECLARED_SELECTOR = YES; 351 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 352 | GCC_WARN_UNUSED_FUNCTION = YES; 353 | GCC_WARN_UNUSED_VARIABLE = YES; 354 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 355 | MTL_ENABLE_DEBUG_INFO = NO; 356 | SDKROOT = iphoneos; 357 | VALIDATE_PRODUCT = YES; 358 | }; 359 | name = Release; 360 | }; 361 | 3B8110F41B4444D8005C2B7A /* Debug */ = { 362 | isa = XCBuildConfiguration; 363 | buildSettings = { 364 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 365 | INFOPLIST_FILE = "JTChartView Example/Info.plist"; 366 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 367 | PRODUCT_NAME = "$(TARGET_NAME)"; 368 | }; 369 | name = Debug; 370 | }; 371 | 3B8110F51B4444D8005C2B7A /* Release */ = { 372 | isa = XCBuildConfiguration; 373 | buildSettings = { 374 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 375 | INFOPLIST_FILE = "JTChartView Example/Info.plist"; 376 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 377 | PRODUCT_NAME = "$(TARGET_NAME)"; 378 | }; 379 | name = Release; 380 | }; 381 | 3B8110F71B4444D8005C2B7A /* Debug */ = { 382 | isa = XCBuildConfiguration; 383 | buildSettings = { 384 | BUNDLE_LOADER = "$(TEST_HOST)"; 385 | FRAMEWORK_SEARCH_PATHS = ( 386 | "$(SDKROOT)/Developer/Library/Frameworks", 387 | "$(inherited)", 388 | ); 389 | GCC_PREPROCESSOR_DEFINITIONS = ( 390 | "DEBUG=1", 391 | "$(inherited)", 392 | ); 393 | INFOPLIST_FILE = "JTChartView ExampleTests/Info.plist"; 394 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 395 | PRODUCT_NAME = "$(TARGET_NAME)"; 396 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/JTChartView Example.app/JTChartView Example"; 397 | }; 398 | name = Debug; 399 | }; 400 | 3B8110F81B4444D8005C2B7A /* Release */ = { 401 | isa = XCBuildConfiguration; 402 | buildSettings = { 403 | BUNDLE_LOADER = "$(TEST_HOST)"; 404 | FRAMEWORK_SEARCH_PATHS = ( 405 | "$(SDKROOT)/Developer/Library/Frameworks", 406 | "$(inherited)", 407 | ); 408 | INFOPLIST_FILE = "JTChartView ExampleTests/Info.plist"; 409 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 410 | PRODUCT_NAME = "$(TARGET_NAME)"; 411 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/JTChartView Example.app/JTChartView Example"; 412 | }; 413 | name = Release; 414 | }; 415 | /* End XCBuildConfiguration section */ 416 | 417 | /* Begin XCConfigurationList section */ 418 | 3B8110CB1B4444D7005C2B7A /* Build configuration list for PBXProject "JTChartView Example" */ = { 419 | isa = XCConfigurationList; 420 | buildConfigurations = ( 421 | 3B8110F11B4444D8005C2B7A /* Debug */, 422 | 3B8110F21B4444D8005C2B7A /* Release */, 423 | ); 424 | defaultConfigurationIsVisible = 0; 425 | defaultConfigurationName = Release; 426 | }; 427 | 3B8110F31B4444D8005C2B7A /* Build configuration list for PBXNativeTarget "JTChartView Example" */ = { 428 | isa = XCConfigurationList; 429 | buildConfigurations = ( 430 | 3B8110F41B4444D8005C2B7A /* Debug */, 431 | 3B8110F51B4444D8005C2B7A /* Release */, 432 | ); 433 | defaultConfigurationIsVisible = 0; 434 | defaultConfigurationName = Release; 435 | }; 436 | 3B8110F61B4444D8005C2B7A /* Build configuration list for PBXNativeTarget "JTChartView ExampleTests" */ = { 437 | isa = XCConfigurationList; 438 | buildConfigurations = ( 439 | 3B8110F71B4444D8005C2B7A /* Debug */, 440 | 3B8110F81B4444D8005C2B7A /* Release */, 441 | ); 442 | defaultConfigurationIsVisible = 0; 443 | defaultConfigurationName = Release; 444 | }; 445 | /* End XCConfigurationList section */ 446 | }; 447 | rootObject = 3B8110C81B4444D7005C2B7A /* Project object */; 448 | } 449 | -------------------------------------------------------------------------------- /JTChartView Example/JTChartView Example/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // JTChartView Example 4 | // 5 | // Created by Jakub Truhlar on 01.07.15. 6 | // Copyright (c) 2015 Jakub Truhlar. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /JTChartView Example/JTChartView Example/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // JTChartView Example 4 | // 5 | // Created by Jakub Truhlar on 01.07.15. 6 | // Copyright (c) 2015 Jakub Truhlar. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /JTChartView Example/JTChartView Example/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 22 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /JTChartView Example/JTChartView Example/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 37 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | -------------------------------------------------------------------------------- /JTChartView Example/JTChartView Example/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /JTChartView Example/JTChartView Example/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.jakubtruhlar.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UIStatusBarHidden 34 | 35 | UISupportedInterfaceOrientations 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationLandscapeLeft 39 | UIInterfaceOrientationLandscapeRight 40 | 41 | UIViewControllerBasedStatusBarAppearance 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /JTChartView Example/JTChartView Example/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // JTChartView Example 4 | // 5 | // Created by Jakub Truhlar on 01.07.15. 6 | // Copyright (c) 2015 Jakub Truhlar. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "JTChartView.h" 11 | 12 | @interface ViewController : UIViewController 13 | 14 | @property (strong, nonatomic) IBOutlet UIView *baseView; 15 | 16 | @property (weak, nonatomic) IBOutlet UISlider *value1Slider; 17 | @property (weak, nonatomic) IBOutlet UISlider *value2Slider; 18 | @property (weak, nonatomic) IBOutlet UISlider *value3Slider; 19 | @property (weak, nonatomic) IBOutlet UISlider *originYSlider; 20 | @property (weak, nonatomic) IBOutlet UISlider *topPaddingSlider; 21 | 22 | - (IBAction)value1SliderAction:(id)sender; 23 | - (IBAction)value2SliderAction:(id)sender; 24 | - (IBAction)value3SliderAction:(id)sender; 25 | - (IBAction)originYSliderAction:(id)sender; 26 | - (IBAction)topPaddingSliderAction:(id)sender; 27 | 28 | @end 29 | 30 | -------------------------------------------------------------------------------- /JTChartView Example/JTChartView Example/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // JTChartView Example 4 | // 5 | // Created by Jakub Truhlar on 01.07.15. 6 | // Copyright (c) 2015 Jakub Truhlar. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | @interface ViewController () 12 | 13 | @property (nonatomic, strong) JTChartView *chartView; 14 | 15 | @property (nonatomic, strong) UIColor *curveColor; 16 | @property (nonatomic, strong) UIColor *gradientColorOne; 17 | @property (nonatomic, strong) UIColor *gradientColorTwo; 18 | 19 | @end 20 | 21 | @implementation ViewController 22 | 23 | - (void)viewDidLoad { 24 | [super viewDidLoad]; 25 | 26 | // Example colors 27 | self.curveColor = [UIColor colorWithRed:0.204 green:0.286 blue:0.369 alpha:1]; 28 | self.gradientColorOne = [UIColor colorWithRed:0.102 green:0.737 blue:0.612 alpha:1]; 29 | self.gradientColorTwo = [UIColor colorWithRed:0.18 green:0.8 blue:0.443 alpha:1]; 30 | } 31 | 32 | - (void)viewWillAppear:(BOOL)animated { 33 | [super viewWillAppear:animated]; 34 | [self drawGraph]; 35 | } 36 | 37 | - (void)didReceiveMemoryWarning { 38 | [super didReceiveMemoryWarning]; 39 | } 40 | 41 | #pragma mark - Example 42 | - (void)drawGraph { 43 | 44 | [self.chartView removeFromSuperview]; 45 | 46 | // Create baseView for JTChartView 47 | self.baseView.layer.masksToBounds = true; 48 | self.baseView.layer.cornerRadius = 3.0; 49 | self.baseView.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.15]; 50 | 51 | // Array of all values 52 | NSArray *values = [[NSArray alloc] initWithObjects:@(_value1Slider.value), @(_value2Slider.value), @(_value3Slider.value), nil]; 53 | 54 | // Base method 55 | self.chartView = [[JTChartView alloc] initWithFrame:self.baseView.bounds values:values curveColor:self.curveColor curveWidth:7.0 topGradientColor:self.gradientColorOne bottomGradientColor:self.gradientColorTwo minY:_originYSlider.value / 100 maxY:1.0 topPadding:_topPaddingSlider.value]; 56 | [self.baseView addSubview:self.chartView]; 57 | } 58 | 59 | - (IBAction)value1SliderAction:(id)sender { 60 | [self drawGraph]; 61 | } 62 | 63 | - (IBAction)value2SliderAction:(id)sender { 64 | [self drawGraph]; 65 | } 66 | 67 | - (IBAction)value3SliderAction:(id)sender { 68 | [self drawGraph]; 69 | } 70 | 71 | - (IBAction)originYSliderAction:(id)sender { 72 | [self drawGraph]; 73 | } 74 | 75 | - (IBAction)topPaddingSliderAction:(id)sender { 76 | [self drawGraph]; 77 | } 78 | 79 | @end 80 | -------------------------------------------------------------------------------- /JTChartView Example/JTChartView Example/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // JTChartView Example 4 | // 5 | // Created by Jakub Truhlar on 01.07.15. 6 | // Copyright (c) 2015 Jakub Truhlar. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /JTChartView Example/JTChartView ExampleTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.jakubtruhlar.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /JTChartView Example/JTChartView ExampleTests/JTChartView_ExampleTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // JTChartView_ExampleTests.m 3 | // JTChartView ExampleTests 4 | // 5 | // Created by Jakub Truhlar on 01.07.15. 6 | // Copyright (c) 2015 Jakub Truhlar. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface JTChartView_ExampleTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation JTChartView_ExampleTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /JTChartView.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "JTChartView" 3 | s.version = "1.0.1" 4 | s.summary = "**JTChartView** is the new **lightweight and fully customizable solution** to **draw a chart**." 5 | 6 | s.description = <<-DESC 7 | **JTChartView** is the new **lightweight and fully customizable solution** to **draw a curve** and fill the space underneath it with a **gradient**. 8 | DESC 9 | 10 | s.homepage = "https://github.com/kubatruhlar/JTChartView" 11 | s.screenshots = "https://raw.githubusercontent.com/kubatruhlar/JTChartView/master/Screens/example.PNG" 12 | 13 | s.license = { :type => "MIT", :file => "LICENSE.md" } 14 | s.author = "Jakub Truhlar" 15 | s.social_media_url = "http://kubatruhlar.cz" 16 | s.platform = :ios, "7.0" 17 | s.source = { :git => "https://github.com/kubatruhlar/JTChartView.git", :tag => "1.0.1" } 18 | s.source_files = "JTChartView/*" 19 | s.framework = "UIKit" 20 | s.requires_arc = true 21 | end 22 | -------------------------------------------------------------------------------- /JTChartView/JTChartView.h: -------------------------------------------------------------------------------- 1 | // 2 | // JTChartView.h 3 | // JTChartView 4 | // 5 | // Created by Jakub Truhlar on 01.07.15. 6 | // Copyright (c) 2015 Jakub Truhlar. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface JTChartView : UIView 12 | 13 | - (instancetype)initWithFrame:(CGRect)frame values:(NSArray *)values curveColor:(UIColor *)curveColor curveWidth:(CGFloat)curveWidth topGradientColor:(UIColor *)topGradientColor bottomGradientColor:(UIColor *)bottomGradientColor minY:(CGFloat)minY maxY:(CGFloat)maxY topPadding:(CGFloat)topPadding; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /JTChartView/JTChartView.m: -------------------------------------------------------------------------------- 1 | // 2 | // JTChartView.m 3 | // JTChartView 4 | // 5 | // Created by Jakub Truhlar on 01.07.15. 6 | // Copyright (c) 2015 Jakub Truhlar. All rights reserved. 7 | // 8 | 9 | #import "JTChartView.h" 10 | 11 | @interface JTChartView() 12 | 13 | @property (nonatomic, strong) NSArray *values; 14 | @property (nonatomic, strong) UIColor *curveColor; 15 | @property (nonatomic, assign) CGFloat curveWidth; 16 | @property (nonatomic, strong) UIColor *topGradientColor; 17 | @property (nonatomic, strong) UIColor *bottomGradientColor; 18 | @property (nonatomic, assign) CGFloat minY; 19 | @property (nonatomic, assign) CGFloat maxY; 20 | @property (nonatomic, assign) CGFloat topPadding; 21 | 22 | @end 23 | 24 | @implementation JTChartView 25 | 26 | #pragma mark - Initialize 27 | - (instancetype)initWithFrame:(CGRect)frame values:(NSArray *)values curveColor:(UIColor *)curveColor curveWidth:(CGFloat)curveWidth topGradientColor:(UIColor *)topGradientColor bottomGradientColor:(UIColor *)bottomGradientColor minY:(CGFloat)minY maxY:(CGFloat)maxY topPadding:(CGFloat)topPadding { 28 | 29 | self = [super initWithFrame:frame]; 30 | 31 | // NOTIFICATIONS 32 | [self createObservers]; 33 | 34 | if (values.count < 1) { 35 | return self; 36 | } 37 | 38 | // DEFAULTS 39 | UIColor *curveColorDefault = curveColor ? curveColor : [UIColor blackColor]; 40 | CGFloat curveWidthDefault = curveWidth ? curveWidth : 2.0; 41 | UIColor *topGradientColorDefault = topGradientColor ? topGradientColor : [UIColor grayColor]; 42 | UIColor *bottomGradientColorDefault = bottomGradientColor ? bottomGradientColor : [UIColor lightGrayColor]; 43 | CGFloat minYDefault = minY ? minY : 0.5; 44 | CGFloat maxYDefault = maxY ? maxY : 1.0; 45 | CGFloat topPaddingDefault = topPadding ? topPadding : 30.0; 46 | 47 | // STORE 48 | _values = values; 49 | _curveColor = curveColorDefault; 50 | _curveWidth = curveWidthDefault; 51 | _topGradientColor = topGradientColorDefault; 52 | _bottomGradientColor = bottomGradientColorDefault; 53 | _minY = minYDefault; 54 | _maxY = maxYDefault; 55 | _topPadding = topPaddingDefault; 56 | 57 | [self drawGraphWithValues:values inView:self minY:minYDefault maxY:maxYDefault topPadding:topPaddingDefault curveColor:curveColorDefault curveWidth:curveWidthDefault topGradientColor:topGradientColorDefault bottomGradientColor:bottomGradientColorDefault]; 58 | 59 | return self; 60 | } 61 | 62 | #pragma mark - Base method 63 | - (void)drawGraphWithValues:(NSArray *)values inView:(UIView *)superview minY:(CGFloat)minY maxY:(CGFloat)maxY topPadding:(CGFloat)topPadding curveColor:(UIColor *)curveColor curveWidth:(CGFloat)curveWidth topGradientColor:(UIColor *)topGradientColor bottomGradientColor:(UIColor *)bottomGradientColor { 64 | 65 | // CREATE CGPOINTS 66 | NSArray *points = [self pointsFromValues:values withinView:superview minY:minY maxY:maxY topPadding:topPadding]; 67 | 68 | // CREATE THE CURVE 69 | UIBezierPath *curve = [self quadCurvedPathWithPoints:points]; 70 | 71 | // CREATE LAYER WITH CURVE 72 | CAShapeLayer *curveLayer = [self createLayerWithCurve:curve color:curveColor width:curveWidth]; 73 | 74 | // CREATE GRADIENT LAYER 75 | CAGradientLayer *gradientLayer = [self createGradientWithTopColor:topGradientColor bottomColor:bottomGradientColor inView:superview]; 76 | 77 | // CREATE MASK 78 | CAShapeLayer *maskLayer = [self createMaskWithCurve:curve withinView:superview]; 79 | 80 | // APPLY IT 81 | gradientLayer.mask = maskLayer; 82 | [superview.layer addSublayer:gradientLayer]; 83 | [superview.layer addSublayer:curveLayer]; 84 | } 85 | 86 | #pragma mark - Extremes 87 | - (CGFloat)maxValueInArray:(NSArray *)values { 88 | 89 | CGFloat max = CGFLOAT_MIN; 90 | 91 | for (int i = 0; i < values.count; i++) { 92 | CGFloat value = [[values objectAtIndex:i] floatValue]; 93 | if (value > max) { 94 | max = value; 95 | } 96 | } 97 | return max; 98 | } 99 | 100 | - (CGFloat)minValueInArray:(NSArray *)values { 101 | 102 | CGFloat min = CGFLOAT_MAX; 103 | 104 | for (int i = 0; i < values.count; i++) { 105 | CGFloat value = [[values objectAtIndex:i] floatValue]; 106 | if (value < min) { 107 | min = value; 108 | } 109 | } 110 | return min; 111 | } 112 | 113 | #pragma mark - Array calculating 114 | - (NSMutableArray *)pointsFromValues:(NSArray *)values withinView:(UIView *)superview minY:(CGFloat)minY maxY:(CGFloat)maxY topPadding:(CGFloat)topPadding { 115 | 116 | NSMutableArray *points = [NSMutableArray new]; 117 | 118 | for (int i = 0; i < values.count; i++) { 119 | CGFloat gap = fabs(superview.frame.size.width / MAX(values.count - 1, 0)); 120 | CGFloat pX = i * gap; 121 | CGFloat verticalMin = superview.frame.size.height * minY; 122 | CGFloat verticalMax = superview.frame.size.height * maxY; 123 | // Curve also needs a floor 124 | CGFloat pY = (superview.frame.size.height + topPadding) - (((([[values objectAtIndex:i] floatValue] / verticalMax) * verticalMin)) + verticalMin); 125 | pY = isnan(pY) ? 0.0 : pY; 126 | 127 | CGPoint p = CGPointMake(pX, pY); 128 | [points addObject:[NSValue valueWithCGPoint:p]]; 129 | } 130 | 131 | return points; 132 | } 133 | 134 | 135 | 136 | #pragma mark - Bezier curve handle 137 | - (UIBezierPath *)quadCurvedPathWithPoints:(NSArray *)points { 138 | 139 | UIBezierPath *path = [UIBezierPath bezierPath]; 140 | NSValue *value = points[0]; 141 | CGPoint p1 = [value CGPointValue]; 142 | [path moveToPoint:p1]; 143 | 144 | if (points.count == 2) { 145 | value = points[1]; 146 | CGPoint p2 = [value CGPointValue]; 147 | [path addLineToPoint:p2]; 148 | return path; 149 | } 150 | 151 | for (NSUInteger i = 1; i < points.count; i++) { 152 | value = points[i]; 153 | CGPoint p2 = [value CGPointValue]; 154 | 155 | CGPoint midPoint = [self midPointForPointOne:p1 pointTwo:p2]; 156 | [path addQuadCurveToPoint:midPoint controlPoint:[self controlPointForPointOne:midPoint pointTwo:p1]]; 157 | [path addQuadCurveToPoint:p2 controlPoint:[self controlPointForPointOne:midPoint pointTwo:p2]]; 158 | p1 = p2; 159 | } 160 | 161 | return path; 162 | } 163 | 164 | - (CGPoint)midPointForPointOne:(CGPoint)p1 pointTwo:(CGPoint)p2 { 165 | 166 | return CGPointMake((p1.x + p2.x) / 2, (p1.y + p2.y) / 2); 167 | } 168 | 169 | - (CGPoint)controlPointForPointOne:(CGPoint)p1 pointTwo:(CGPoint)p2 { 170 | 171 | CGPoint controlPoint = [self midPointForPointOne:p1 pointTwo:p2]; 172 | CGFloat diffY = fabs(p2.y - controlPoint.y); 173 | 174 | if (p1.y < p2.y) { 175 | controlPoint.y += diffY; 176 | 177 | } else if (p1.y > p2.y) { 178 | controlPoint.y -= diffY; 179 | } 180 | 181 | return controlPoint; 182 | } 183 | 184 | #pragma mark - Layers 185 | - (CAShapeLayer *)createMaskWithCurve:(UIBezierPath *)curve withinView:(UIView *)superview { 186 | 187 | CAShapeLayer *mask = [CAShapeLayer new]; 188 | mask.frame = superview.bounds; 189 | [curve addLineToPoint:CGPointMake(superview.frame.size.width, superview.frame.size.height)]; 190 | [curve addLineToPoint:CGPointMake(0, superview.frame.size.height)]; 191 | [curve closePath]; 192 | mask.path = curve.CGPath; 193 | 194 | return mask; 195 | } 196 | 197 | - (CAShapeLayer *)createLayerWithCurve:(UIBezierPath *)curve color:(UIColor *)color width:(CGFloat)width { 198 | 199 | CAShapeLayer *shapeLayer = [CAShapeLayer new]; 200 | shapeLayer.path = [curve CGPath]; 201 | 202 | shapeLayer.strokeColor = color.CGColor; 203 | shapeLayer.fillColor = [UIColor clearColor].CGColor; 204 | shapeLayer.lineWidth = width; 205 | shapeLayer.fillRule = kCAFillRuleEvenOdd; 206 | [shapeLayer setLineCap:kCALineCapRound]; 207 | 208 | return shapeLayer; 209 | } 210 | 211 | - (CAGradientLayer *)createGradientWithTopColor:(UIColor *)topColor bottomColor:(UIColor *)bottomColor inView:(UIView *)superview { 212 | 213 | CAGradientLayer *gradientLayer = [CAGradientLayer new]; 214 | gradientLayer.frame = superview.bounds; 215 | gradientLayer.colors = @[(id)topColor.CGColor, 216 | (id)bottomColor.CGColor]; 217 | return gradientLayer; 218 | } 219 | 220 | #pragma mark - Orientation handle 221 | - (void)createObservers { 222 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationDidChange) name:UIDeviceOrientationDidChangeNotification object:nil]; 223 | } 224 | 225 | - (void)dealloc { 226 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 227 | } 228 | 229 | - (void)orientationDidChange { 230 | if (_values.count < 1) { 231 | return; 232 | } 233 | 234 | [self.layer.sublayers makeObjectsPerformSelector:@selector(removeFromSuperlayer)]; 235 | CGRect f = self.superview.bounds; 236 | 237 | if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft || [[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight) { 238 | f.size = CGSizeMake(f.size.height, f.size.width); 239 | } else { 240 | f.size = CGSizeMake(f.size.width, f.size.height); 241 | } 242 | self.frame = f; 243 | 244 | [self drawGraphWithValues:_values inView:self minY:_minY maxY:_maxY topPadding:_topPadding curveColor:_curveColor curveWidth:_curveWidth topGradientColor:_topGradientColor bottomGradientColor:_bottomGradientColor]; 245 | } 246 | 247 | @end 248 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright © 2015 Jakub Truhlar 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Version](https://img.shields.io/cocoapods/v/JTChartView.svg)](http://cocoapods.org/pods/JTChartView) 2 | [![License](https://img.shields.io/cocoapods/l/JTChartView.svg)](http://cocoapods.org/pods/JTChartView) 3 | [![Platform](https://img.shields.io/cocoapods/p/JTChartView.svg)](http://cocoapods.org/pods/JTChartView) 4 | 5 | # JTChartView 6 | 7 | **JTChartView** is the new **lightweight and fully customizable solution** to **draw a curve** and fill the space underneath it with a **gradient**. The result is a **beautiful chart**. 8 | 9 |

10 | Example Chart 1 11 | Example Chart 2 12 |

13 | 14 | 15 | ## Installation 16 | There are two ways to add the **JTProgressHUD** library to your project. Add it as a regular library or install it through **CocoaPods**. 17 | 18 | `pod 'JTChartView'` 19 | 20 | You may also quick try the example project with 21 | 22 | `pod try JTChartView` 23 | 24 | **Library requires target iOS 7.0 and above** 25 | 26 | > **Works in both - Portrait and Landscape modes** 27 | 28 | 29 | ## Usage and Customization 30 | 31 | **JTChartView** is designed to be created in one initialization line of code. Core logic creates all layers and draws them into final **JTChartView**. You **MUST** create a **parent view** for that **JTChartView** to keep it working correctly. 32 | 33 | ### Simple example: 34 | ```objective-c 35 | // Parent view (Whatever you need) 36 | UIView *baseChartView = [[UIView alloc] initWithFrame:CGRectMake(30.0, 30.0, self.view.frame.size.width - 60.0, self.view.frame.size.width - 60.0)]; 37 | baseChartView.layer.masksToBounds = true; 38 | baseChartView.backgroundColor = [UIColor whiteColor]; 39 | 40 | // JTChartView 41 | JTChartView *chartView = [[JTChartView alloc] initWithFrame:baseChartView.bounds 42 | values:@[@15, @5, @10] 43 | curveColor:[UIColor grayColor] 44 | curveWidth:5.0 45 | topGradientColor:[UIColor redColor] 46 | bottomGradientColor:[UIColor orangeColor] 47 | minY:0.5 48 | maxY:1.0 49 | topPadding:10.0]; 50 | [baseChartView addSubview:chartView]; 51 | ``` 52 | 53 | ## Author 54 | This library is open-sourced by [Jakub Truhlar](http://kubatruhlar.cz). 55 | 56 | ## License 57 | The MIT License (MIT) 58 | Copyright © 2015 Jakub Truhlar 59 | -------------------------------------------------------------------------------- /Screens/chart1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kubatruhlar/JTChartView/720feb03a564adda0625a591debc83e143c9f3ac/Screens/chart1.png -------------------------------------------------------------------------------- /Screens/chart2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kubatruhlar/JTChartView/720feb03a564adda0625a591debc83e143c9f3ac/Screens/chart2.png -------------------------------------------------------------------------------- /Screens/example.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kubatruhlar/JTChartView/720feb03a564adda0625a591debc83e143c9f3ac/Screens/example.PNG --------------------------------------------------------------------------------