From 35d3ddafe3a9281b65ac05b1ea6a5345b91555e3 Mon Sep 17 00:00:00 2001 From: Erich Grunewald Date: Tue, 7 Apr 2015 17:52:04 +0200 Subject: [PATCH 1/7] Add soon-to-be-fleshed-out GKStackedBarGraph. --- GraphKit/GraphKit.xcodeproj/project.pbxproj | 2159 ++++++------------- Source/BarGraph/GKStackedBarGraph.h | 64 + Source/BarGraph/GKStackedBarGraph.m | 263 +++ Source/GraphKit.h | 1 + 4 files changed, 952 insertions(+), 1535 deletions(-) create mode 100644 Source/BarGraph/GKStackedBarGraph.h create mode 100644 Source/BarGraph/GKStackedBarGraph.m diff --git a/GraphKit/GraphKit.xcodeproj/project.pbxproj b/GraphKit/GraphKit.xcodeproj/project.pbxproj index b5daeb0..4669ef8 100644 --- a/GraphKit/GraphKit.xcodeproj/project.pbxproj +++ b/GraphKit/GraphKit.xcodeproj/project.pbxproj @@ -1,1535 +1,624 @@ - - - - - archiveVersion - 1 - classes - - objectVersion - 46 - objects - - 74E12B5B49644056930176BC - - explicitFileType - archive.ar - includeInIndex - 0 - isa - PBXFileReference - path - libPods.a - sourceTree - BUILT_PRODUCTS_DIR - - 83175F7BAC184C238C8A7ED0 - - buildActionMask - 2147483647 - files - - inputPaths - - isa - PBXShellScriptBuildPhase - name - Check Pods Manifest.lock - outputPaths - - runOnlyForDeploymentPostprocessing - 0 - shellPath - /bin/sh - shellScript - diff "${PODS_ROOT}/../Podfile.lock" "${PODS_ROOT}/Manifest.lock" > /dev/null -if [[ $? != 0 ]] ; then - cat << EOM -error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation. -EOM - exit 1 -fi - - showEnvVarsInLog - 0 - - 84654C0718FE8EE200160F11 - - children - - 84654C1918FE8EE300160F11 - 84654C3218FE8EE300160F11 - 84654C1218FE8EE300160F11 - 84654C1118FE8EE300160F11 - D66EB86FC82255B51279B314 - - isa - PBXGroup - sourceTree - <group> - - 84654C0818FE8EE200160F11 - - attributes - - LastUpgradeCheck - 0510 - ORGANIZATIONNAME - Michal Konturek - TargetAttributes - - 84654C2A18FE8EE300160F11 - - TestTargetID - 84654C0F18FE8EE200160F11 - - - - buildConfigurationList - 84654C0B18FE8EE200160F11 - compatibilityVersion - Xcode 3.2 - developmentRegion - English - hasScannedForEncodings - 0 - isa - PBXProject - knownRegions - - en - - mainGroup - 84654C0718FE8EE200160F11 - productRefGroup - 84654C1118FE8EE300160F11 - projectDirPath - - projectReferences - - projectRoot - - targets - - 84654C0F18FE8EE200160F11 - 84654C2A18FE8EE300160F11 - - - 84654C0B18FE8EE200160F11 - - buildConfigurations - - 84654C3A18FE8EE300160F11 - 84654C3B18FE8EE300160F11 - - defaultConfigurationIsVisible - 0 - defaultConfigurationName - Release - isa - XCConfigurationList - - 84654C0C18FE8EE200160F11 - - buildActionMask - 2147483647 - files - - 847259231904ABE200819664 - 8472592F1905D63500819664 - 84654C5518FEDCDF00160F11 - 84654C2418FE8EE300160F11 - 847259291905C1D300819664 - 84654C5918FF4C8300160F11 - 8472591E1904AA4F00819664 - 84654C4C18FE909A00160F11 - 84654C2018FE8EE300160F11 - 84F0E98E1902B30C00FA4810 - 84654C5118FE934800160F11 - - isa - PBXSourcesBuildPhase - runOnlyForDeploymentPostprocessing - 0 - - 84654C0D18FE8EE200160F11 - - buildActionMask - 2147483647 - files - - 84654C1618FE8EE300160F11 - 84654C1818FE8EE300160F11 - 84654C1418FE8EE300160F11 - 973F4746059343C9A462AA2D - - isa - PBXFrameworksBuildPhase - runOnlyForDeploymentPostprocessing - 0 - - 84654C0E18FE8EE200160F11 - - buildActionMask - 2147483647 - files - - 84654C1E18FE8EE300160F11 - 84654C2618FE8EE300160F11 - 84654C5A18FF4C8300160F11 - 84F0E98F1902B30C00FA4810 - 84654C5218FE934800160F11 - 8472591F1904AA4F00819664 - - isa - PBXResourcesBuildPhase - runOnlyForDeploymentPostprocessing - 0 - - 84654C0F18FE8EE200160F11 - - buildConfigurationList - 84654C3C18FE8EE300160F11 - buildPhases - - 83175F7BAC184C238C8A7ED0 - 84654C0C18FE8EE200160F11 - 84654C0D18FE8EE200160F11 - 84654C0E18FE8EE200160F11 - D08870F64023490D9D34D82D - - buildRules - - dependencies - - isa - PBXNativeTarget - name - GraphKit - productName - GraphKit - productReference - 84654C1018FE8EE300160F11 - productType - com.apple.product-type.application - - 84654C1018FE8EE300160F11 - - explicitFileType - wrapper.application - includeInIndex - 0 - isa - PBXFileReference - path - GraphKit.app - sourceTree - BUILT_PRODUCTS_DIR - - 84654C1118FE8EE300160F11 - - children - - 84654C1018FE8EE300160F11 - 84654C2B18FE8EE300160F11 - - isa - PBXGroup - name - Products - sourceTree - <group> - - 84654C1218FE8EE300160F11 - - children - - 84654C1318FE8EE300160F11 - 84654C1518FE8EE300160F11 - 84654C1718FE8EE300160F11 - 84654C2C18FE8EE300160F11 - 74E12B5B49644056930176BC - - isa - PBXGroup - name - Frameworks - sourceTree - <group> - - 84654C1318FE8EE300160F11 - - isa - PBXFileReference - lastKnownFileType - wrapper.framework - name - Foundation.framework - path - System/Library/Frameworks/Foundation.framework - sourceTree - SDKROOT - - 84654C1418FE8EE300160F11 - - fileRef - 84654C1318FE8EE300160F11 - isa - PBXBuildFile - - 84654C1518FE8EE300160F11 - - isa - PBXFileReference - lastKnownFileType - wrapper.framework - name - CoreGraphics.framework - path - System/Library/Frameworks/CoreGraphics.framework - sourceTree - SDKROOT - - 84654C1618FE8EE300160F11 - - fileRef - 84654C1518FE8EE300160F11 - isa - PBXBuildFile - - 84654C1718FE8EE300160F11 - - isa - PBXFileReference - lastKnownFileType - wrapper.framework - name - UIKit.framework - path - System/Library/Frameworks/UIKit.framework - sourceTree - SDKROOT - - 84654C1818FE8EE300160F11 - - fileRef - 84654C1718FE8EE300160F11 - isa - PBXBuildFile - - 84654C1918FE8EE300160F11 - - children - - 84654C4D18FE932A00160F11 - 84654C4218FE8EF300160F11 - 84654C2218FE8EE300160F11 - 84654C2318FE8EE300160F11 - 84654C2518FE8EE300160F11 - 84654C1A18FE8EE300160F11 - - isa - PBXGroup - path - GraphKit - sourceTree - <group> - - 84654C1A18FE8EE300160F11 - - children - - 84654C1B18FE8EE300160F11 - 84654C1C18FE8EE300160F11 - 84654C1F18FE8EE300160F11 - 84654C2118FE8EE300160F11 - - isa - PBXGroup - name - Supporting Files - sourceTree - <group> - - 84654C1B18FE8EE300160F11 - - isa - PBXFileReference - lastKnownFileType - text.plist.xml - path - GraphKit-Info.plist - sourceTree - <group> - - 84654C1C18FE8EE300160F11 - - children - - 84654C1D18FE8EE300160F11 - - isa - PBXVariantGroup - name - InfoPlist.strings - sourceTree - <group> - - 84654C1D18FE8EE300160F11 - - isa - PBXFileReference - lastKnownFileType - text.plist.strings - name - en - path - en.lproj/InfoPlist.strings - sourceTree - <group> - - 84654C1E18FE8EE300160F11 - - fileRef - 84654C1C18FE8EE300160F11 - isa - PBXBuildFile - - 84654C1F18FE8EE300160F11 - - isa - PBXFileReference - lastKnownFileType - sourcecode.c.objc - path - main.m - sourceTree - <group> - - 84654C2018FE8EE300160F11 - - fileRef - 84654C1F18FE8EE300160F11 - isa - PBXBuildFile - - 84654C2118FE8EE300160F11 - - isa - PBXFileReference - lastKnownFileType - sourcecode.c.h - path - GraphKit-Prefix.pch - sourceTree - <group> - - 84654C2218FE8EE300160F11 - - isa - PBXFileReference - lastKnownFileType - sourcecode.c.h - path - AppDelegate.h - sourceTree - <group> - - 84654C2318FE8EE300160F11 - - isa - PBXFileReference - lastKnownFileType - sourcecode.c.objc - path - AppDelegate.m - sourceTree - <group> - - 84654C2418FE8EE300160F11 - - fileRef - 84654C2318FE8EE300160F11 - isa - PBXBuildFile - - 84654C2518FE8EE300160F11 - - isa - PBXFileReference - lastKnownFileType - folder.assetcatalog - path - Images.xcassets - sourceTree - <group> - - 84654C2618FE8EE300160F11 - - fileRef - 84654C2518FE8EE300160F11 - isa - PBXBuildFile - - 84654C2718FE8EE300160F11 - - buildActionMask - 2147483647 - files - - 84654C3918FE8EE300160F11 - - isa - PBXSourcesBuildPhase - runOnlyForDeploymentPostprocessing - 0 - - 84654C2818FE8EE300160F11 - - buildActionMask - 2147483647 - files - - 84654C2D18FE8EE300160F11 - 84654C2F18FE8EE300160F11 - 84654C2E18FE8EE300160F11 - - isa - PBXFrameworksBuildPhase - runOnlyForDeploymentPostprocessing - 0 - - 84654C2918FE8EE300160F11 - - buildActionMask - 2147483647 - files - - 84654C3718FE8EE300160F11 - - isa - PBXResourcesBuildPhase - runOnlyForDeploymentPostprocessing - 0 - - 84654C2A18FE8EE300160F11 - - buildConfigurationList - 84654C3F18FE8EE300160F11 - buildPhases - - 84654C2718FE8EE300160F11 - 84654C2818FE8EE300160F11 - 84654C2918FE8EE300160F11 - - buildRules - - dependencies - - 84654C3118FE8EE300160F11 - - isa - PBXNativeTarget - name - GraphKitTests - productName - GraphKitTests - productReference - 84654C2B18FE8EE300160F11 - productType - com.apple.product-type.bundle.unit-test - - 84654C2B18FE8EE300160F11 - - explicitFileType - wrapper.cfbundle - includeInIndex - 0 - isa - PBXFileReference - path - GraphKitTests.xctest - sourceTree - BUILT_PRODUCTS_DIR - - 84654C2C18FE8EE300160F11 - - isa - PBXFileReference - lastKnownFileType - wrapper.framework - name - XCTest.framework - path - Library/Frameworks/XCTest.framework - sourceTree - DEVELOPER_DIR - - 84654C2D18FE8EE300160F11 - - fileRef - 84654C2C18FE8EE300160F11 - isa - PBXBuildFile - - 84654C2E18FE8EE300160F11 - - fileRef - 84654C1318FE8EE300160F11 - isa - PBXBuildFile - - 84654C2F18FE8EE300160F11 - - fileRef - 84654C1718FE8EE300160F11 - isa - PBXBuildFile - - 84654C3018FE8EE300160F11 - - containerPortal - 84654C0818FE8EE200160F11 - isa - PBXContainerItemProxy - proxyType - 1 - remoteGlobalIDString - 84654C0F18FE8EE200160F11 - remoteInfo - GraphKit - - 84654C3118FE8EE300160F11 - - isa - PBXTargetDependency - target - 84654C0F18FE8EE200160F11 - targetProxy - 84654C3018FE8EE300160F11 - - 84654C3218FE8EE300160F11 - - children - - 84654C3818FE8EE300160F11 - 84654C3318FE8EE300160F11 - - isa - PBXGroup - path - GraphKitTests - sourceTree - <group> - - 84654C3318FE8EE300160F11 - - children - - 84654C3418FE8EE300160F11 - 84654C3518FE8EE300160F11 - - isa - PBXGroup - name - Supporting Files - sourceTree - <group> - - 84654C3418FE8EE300160F11 - - isa - PBXFileReference - lastKnownFileType - text.plist.xml - path - GraphKitTests-Info.plist - sourceTree - <group> - - 84654C3518FE8EE300160F11 - - children - - 84654C3618FE8EE300160F11 - - isa - PBXVariantGroup - name - InfoPlist.strings - sourceTree - <group> - - 84654C3618FE8EE300160F11 - - isa - PBXFileReference - lastKnownFileType - text.plist.strings - name - en - path - en.lproj/InfoPlist.strings - sourceTree - <group> - - 84654C3718FE8EE300160F11 - - fileRef - 84654C3518FE8EE300160F11 - isa - PBXBuildFile - - 84654C3818FE8EE300160F11 - - isa - PBXFileReference - lastKnownFileType - sourcecode.c.objc - path - GraphKitTests.m - sourceTree - <group> - - 84654C3918FE8EE300160F11 - - fileRef - 84654C3818FE8EE300160F11 - isa - PBXBuildFile - - 84654C3A18FE8EE300160F11 - - buildSettings - - ALWAYS_SEARCH_USER_PATHS - YES - CLANG_CXX_LANGUAGE_STANDARD - gnu++0x - CLANG_CXX_LIBRARY - libc++ - CLANG_ENABLE_MODULES - YES - CLANG_ENABLE_OBJC_ARC - YES - CLANG_WARN_BOOL_CONVERSION - YES - CLANG_WARN_CONSTANT_CONVERSION - YES - CLANG_WARN_DIRECT_OBJC_ISA_USAGE - YES_ERROR - CLANG_WARN_EMPTY_BODY - YES - CLANG_WARN_ENUM_CONVERSION - YES - CLANG_WARN_INT_CONVERSION - YES - CLANG_WARN_OBJC_ROOT_CLASS - YES_ERROR - CLANG_WARN__DUPLICATE_METHOD_MATCH - YES - CODE_SIGN_IDENTITY[sdk=iphoneos*] - iPhone Developer - COPY_PHASE_STRIP - NO - GCC_C_LANGUAGE_STANDARD - gnu99 - GCC_DYNAMIC_NO_PIC - NO - GCC_OPTIMIZATION_LEVEL - 0 - GCC_PREPROCESSOR_DEFINITIONS - - DEBUG=1 - $(inherited) - - GCC_SYMBOLS_PRIVATE_EXTERN - NO - GCC_WARN_64_TO_32_BIT_CONVERSION - YES - GCC_WARN_ABOUT_RETURN_TYPE - YES_ERROR - GCC_WARN_UNDECLARED_SELECTOR - YES - GCC_WARN_UNINITIALIZED_AUTOS - YES_AGGRESSIVE - GCC_WARN_UNUSED_FUNCTION - YES - GCC_WARN_UNUSED_VARIABLE - YES - IPHONEOS_DEPLOYMENT_TARGET - 7.1 - ONLY_ACTIVE_ARCH - YES - SDKROOT - iphoneos - USER_HEADER_SEARCH_PATHS - $(SRCROOT)/** - - isa - XCBuildConfiguration - name - Debug - - 84654C3B18FE8EE300160F11 - - buildSettings - - ALWAYS_SEARCH_USER_PATHS - YES - CLANG_CXX_LANGUAGE_STANDARD - gnu++0x - CLANG_CXX_LIBRARY - libc++ - CLANG_ENABLE_MODULES - YES - CLANG_ENABLE_OBJC_ARC - YES - CLANG_WARN_BOOL_CONVERSION - YES - CLANG_WARN_CONSTANT_CONVERSION - YES - CLANG_WARN_DIRECT_OBJC_ISA_USAGE - YES_ERROR - CLANG_WARN_EMPTY_BODY - YES - CLANG_WARN_ENUM_CONVERSION - YES - CLANG_WARN_INT_CONVERSION - YES - CLANG_WARN_OBJC_ROOT_CLASS - YES_ERROR - CLANG_WARN__DUPLICATE_METHOD_MATCH - YES - CODE_SIGN_IDENTITY[sdk=iphoneos*] - iPhone Developer - COPY_PHASE_STRIP - YES - ENABLE_NS_ASSERTIONS - NO - GCC_C_LANGUAGE_STANDARD - gnu99 - GCC_WARN_64_TO_32_BIT_CONVERSION - YES - GCC_WARN_ABOUT_RETURN_TYPE - YES_ERROR - GCC_WARN_UNDECLARED_SELECTOR - YES - GCC_WARN_UNINITIALIZED_AUTOS - YES_AGGRESSIVE - GCC_WARN_UNUSED_FUNCTION - YES - GCC_WARN_UNUSED_VARIABLE - YES - IPHONEOS_DEPLOYMENT_TARGET - 7.1 - SDKROOT - iphoneos - USER_HEADER_SEARCH_PATHS - $(SRCROOT)/** - VALIDATE_PRODUCT - YES - - isa - XCBuildConfiguration - name - Release - - 84654C3C18FE8EE300160F11 - - buildConfigurations - - 84654C3D18FE8EE300160F11 - 84654C3E18FE8EE300160F11 - - defaultConfigurationIsVisible - 0 - defaultConfigurationName - Release - isa - XCConfigurationList - - 84654C3D18FE8EE300160F11 - - baseConfigurationReference - 8AEF73567DD4B30E5A877C5C - buildSettings - - ALWAYS_SEARCH_USER_PATHS - YES - ASSETCATALOG_COMPILER_APPICON_NAME - AppIcon - ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME - LaunchImage - GCC_PRECOMPILE_PREFIX_HEADER - YES - GCC_PREFIX_HEADER - GraphKit/GraphKit-Prefix.pch - INFOPLIST_FILE - GraphKit/GraphKit-Info.plist - PRODUCT_NAME - $(TARGET_NAME) - USER_HEADER_SEARCH_PATHS - $(SRCROOT)/** - WRAPPER_EXTENSION - app - - isa - XCBuildConfiguration - name - Debug - - 84654C3E18FE8EE300160F11 - - baseConfigurationReference - 873AC9F69410844871F60371 - buildSettings - - ALWAYS_SEARCH_USER_PATHS - YES - ASSETCATALOG_COMPILER_APPICON_NAME - AppIcon - ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME - LaunchImage - GCC_PRECOMPILE_PREFIX_HEADER - YES - GCC_PREFIX_HEADER - GraphKit/GraphKit-Prefix.pch - INFOPLIST_FILE - GraphKit/GraphKit-Info.plist - PRODUCT_NAME - $(TARGET_NAME) - USER_HEADER_SEARCH_PATHS - $(SRCROOT)/** - WRAPPER_EXTENSION - app - - isa - XCBuildConfiguration - name - Release - - 84654C3F18FE8EE300160F11 - - buildConfigurations - - 84654C4018FE8EE300160F11 - 84654C4118FE8EE300160F11 - - defaultConfigurationIsVisible - 0 - defaultConfigurationName - Release - isa - XCConfigurationList - - 84654C4018FE8EE300160F11 - - buildSettings - - BUNDLE_LOADER - $(BUILT_PRODUCTS_DIR)/GraphKit.app/GraphKit - FRAMEWORK_SEARCH_PATHS - - $(SDKROOT)/Developer/Library/Frameworks - $(inherited) - $(DEVELOPER_FRAMEWORKS_DIR) - - GCC_PRECOMPILE_PREFIX_HEADER - YES - GCC_PREFIX_HEADER - GraphKit/GraphKit-Prefix.pch - GCC_PREPROCESSOR_DEFINITIONS - - DEBUG=1 - $(inherited) - - INFOPLIST_FILE - GraphKitTests/GraphKitTests-Info.plist - PRODUCT_NAME - $(TARGET_NAME) - TEST_HOST - $(BUNDLE_LOADER) - WRAPPER_EXTENSION - xctest - - isa - XCBuildConfiguration - name - Debug - - 84654C4118FE8EE300160F11 - - buildSettings - - BUNDLE_LOADER - $(BUILT_PRODUCTS_DIR)/GraphKit.app/GraphKit - FRAMEWORK_SEARCH_PATHS - - $(SDKROOT)/Developer/Library/Frameworks - $(inherited) - $(DEVELOPER_FRAMEWORKS_DIR) - - GCC_PRECOMPILE_PREFIX_HEADER - YES - GCC_PREFIX_HEADER - GraphKit/GraphKit-Prefix.pch - INFOPLIST_FILE - GraphKitTests/GraphKitTests-Info.plist - PRODUCT_NAME - $(TARGET_NAME) - TEST_HOST - $(BUNDLE_LOADER) - WRAPPER_EXTENSION - xctest - - isa - XCBuildConfiguration - name - Release - - 84654C4218FE8EF300160F11 - - children - - 84654C4618FE8F0600160F11 - 847259271905C1D300819664 - 847259281905C1D300819664 - 84654C4918FE907500160F11 - 847259201904AB8F00819664 - - isa - PBXGroup - name - Source - path - ../../Source - sourceTree - <group> - - 84654C4618FE8F0600160F11 - - fileEncoding - 4 - isa - PBXFileReference - lastKnownFileType - sourcecode.c.h - path - GraphKit.h - sourceTree - <group> - - 84654C4918FE907500160F11 - - children - - 84654C4A18FE909A00160F11 - 84654C4B18FE909A00160F11 - 84654C5318FEDCDF00160F11 - 84654C5418FEDCDF00160F11 - - isa - PBXGroup - path - BarGraph - sourceTree - <group> - - 84654C4A18FE909A00160F11 - - fileEncoding - 4 - isa - PBXFileReference - lastKnownFileType - sourcecode.c.h - path - GKBar.h - sourceTree - <group> - - 84654C4B18FE909A00160F11 - - fileEncoding - 4 - isa - PBXFileReference - lastKnownFileType - sourcecode.c.objc - path - GKBar.m - sourceTree - <group> - - 84654C4C18FE909A00160F11 - - fileRef - 84654C4B18FE909A00160F11 - isa - PBXBuildFile - - 84654C4D18FE932A00160F11 - - children - - 84F0E98B1902B30C00FA4810 - 84F0E98C1902B30C00FA4810 - 84F0E98D1902B30C00FA4810 - 84654C4E18FE934800160F11 - 84654C4F18FE934800160F11 - 84654C5018FE934800160F11 - 84654C5618FF4C8300160F11 - 84654C5718FF4C8300160F11 - 84654C5818FF4C8300160F11 - 8472591B1904AA4F00819664 - 8472591C1904AA4F00819664 - 8472591D1904AA4F00819664 - 8472592D1905D63500819664 - 8472592E1905D63500819664 - - isa - PBXGroup - path - Example - sourceTree - SOURCE_ROOT - - 84654C4E18FE934800160F11 - - fileEncoding - 4 - isa - PBXFileReference - lastKnownFileType - sourcecode.c.h - path - ExampleBarVC.h - sourceTree - <group> - - 84654C4F18FE934800160F11 - - fileEncoding - 4 - isa - PBXFileReference - lastKnownFileType - sourcecode.c.objc - path - ExampleBarVC.m - sourceTree - <group> - - 84654C5018FE934800160F11 - - fileEncoding - 4 - isa - PBXFileReference - lastKnownFileType - file.xib - path - ExampleBarVC.xib - sourceTree - <group> - - 84654C5118FE934800160F11 - - fileRef - 84654C4F18FE934800160F11 - isa - PBXBuildFile - - 84654C5218FE934800160F11 - - fileRef - 84654C5018FE934800160F11 - isa - PBXBuildFile - - 84654C5318FEDCDF00160F11 - - fileEncoding - 4 - isa - PBXFileReference - lastKnownFileType - sourcecode.c.h - path - GKBarGraph.h - sourceTree - <group> - - 84654C5418FEDCDF00160F11 - - fileEncoding - 4 - isa - PBXFileReference - lastKnownFileType - sourcecode.c.objc - path - GKBarGraph.m - sourceTree - <group> - - 84654C5518FEDCDF00160F11 - - fileRef - 84654C5418FEDCDF00160F11 - isa - PBXBuildFile - - 84654C5618FF4C8300160F11 - - fileEncoding - 4 - isa - PBXFileReference - lastKnownFileType - sourcecode.c.h - path - ExampleBarGraphVC.h - sourceTree - <group> - - 84654C5718FF4C8300160F11 - - fileEncoding - 4 - isa - PBXFileReference - lastKnownFileType - sourcecode.c.objc - path - ExampleBarGraphVC.m - sourceTree - <group> - - 84654C5818FF4C8300160F11 - - fileEncoding - 4 - isa - PBXFileReference - lastKnownFileType - file.xib - path - ExampleBarGraphVC.xib - sourceTree - <group> - - 84654C5918FF4C8300160F11 - - fileRef - 84654C5718FF4C8300160F11 - isa - PBXBuildFile - - 84654C5A18FF4C8300160F11 - - fileRef - 84654C5818FF4C8300160F11 - isa - PBXBuildFile - - 8472591B1904AA4F00819664 - - fileEncoding - 4 - isa - PBXFileReference - lastKnownFileType - sourcecode.c.h - path - ExampleLineGraph.h - sourceTree - <group> - - 8472591C1904AA4F00819664 - - fileEncoding - 4 - isa - PBXFileReference - lastKnownFileType - sourcecode.c.objc - path - ExampleLineGraph.m - sourceTree - <group> - - 8472591D1904AA4F00819664 - - fileEncoding - 4 - isa - PBXFileReference - lastKnownFileType - file.xib - path - ExampleLineGraph.xib - sourceTree - <group> - - 8472591E1904AA4F00819664 - - fileRef - 8472591C1904AA4F00819664 - isa - PBXBuildFile - - 8472591F1904AA4F00819664 - - fileRef - 8472591D1904AA4F00819664 - isa - PBXBuildFile - - 847259201904AB8F00819664 - - children - - 847259211904ABE200819664 - 847259221904ABE200819664 - - isa - PBXGroup - path - LineGraph - sourceTree - <group> - - 847259211904ABE200819664 - - fileEncoding - 4 - isa - PBXFileReference - lastKnownFileType - sourcecode.c.h - path - GKLineGraph.h - sourceTree - <group> - - 847259221904ABE200819664 - - fileEncoding - 4 - isa - PBXFileReference - lastKnownFileType - sourcecode.c.objc - path - GKLineGraph.m - sourceTree - <group> - - 847259231904ABE200819664 - - fileRef - 847259221904ABE200819664 - isa - PBXBuildFile - - 847259271905C1D300819664 - - fileEncoding - 4 - isa - PBXFileReference - lastKnownFileType - sourcecode.c.h - path - UIColor+GraphKit.h - sourceTree - <group> - - 847259281905C1D300819664 - - fileEncoding - 4 - isa - PBXFileReference - lastKnownFileType - sourcecode.c.objc - path - UIColor+GraphKit.m - sourceTree - <group> - - 847259291905C1D300819664 - - fileRef - 847259281905C1D300819664 - isa - PBXBuildFile - - 8472592D1905D63500819664 - - fileEncoding - 4 - isa - PBXFileReference - lastKnownFileType - sourcecode.c.h - path - UIViewController+BButton.h - sourceTree - <group> - - 8472592E1905D63500819664 - - fileEncoding - 4 - isa - PBXFileReference - lastKnownFileType - sourcecode.c.objc - path - UIViewController+BButton.m - sourceTree - <group> - - 8472592F1905D63500819664 - - fileRef - 8472592E1905D63500819664 - isa - PBXBuildFile - - 84F0E98B1902B30C00FA4810 - - fileEncoding - 4 - isa - PBXFileReference - lastKnownFileType - sourcecode.c.h - path - ExampleListVC.h - sourceTree - <group> - - 84F0E98C1902B30C00FA4810 - - fileEncoding - 4 - isa - PBXFileReference - lastKnownFileType - sourcecode.c.objc - path - ExampleListVC.m - sourceTree - <group> - - 84F0E98D1902B30C00FA4810 - - fileEncoding - 4 - isa - PBXFileReference - lastKnownFileType - file.xib - path - ExampleListVC.xib - sourceTree - <group> - - 84F0E98E1902B30C00FA4810 - - fileRef - 84F0E98C1902B30C00FA4810 - isa - PBXBuildFile - - 84F0E98F1902B30C00FA4810 - - fileRef - 84F0E98D1902B30C00FA4810 - isa - PBXBuildFile - - 873AC9F69410844871F60371 - - includeInIndex - 1 - isa - PBXFileReference - lastKnownFileType - text.xcconfig - name - Pods.release.xcconfig - path - Pods/Target Support Files/Pods/Pods.release.xcconfig - sourceTree - <group> - - 8AEF73567DD4B30E5A877C5C - - includeInIndex - 1 - isa - PBXFileReference - lastKnownFileType - text.xcconfig - name - Pods.debug.xcconfig - path - Pods/Target Support Files/Pods/Pods.debug.xcconfig - sourceTree - <group> - - 973F4746059343C9A462AA2D - - fileRef - 74E12B5B49644056930176BC - isa - PBXBuildFile - - D08870F64023490D9D34D82D - - buildActionMask - 2147483647 - files - - inputPaths - - isa - PBXShellScriptBuildPhase - name - Copy Pods Resources - outputPaths - - runOnlyForDeploymentPostprocessing - 0 - shellPath - /bin/sh - shellScript - "${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh" - - showEnvVarsInLog - 0 - - D66EB86FC82255B51279B314 - - children - - 8AEF73567DD4B30E5A877C5C - 873AC9F69410844871F60371 - - isa - PBXGroup - name - Pods - sourceTree - <group> - - - rootObject - 84654C0818FE8EE200160F11 - - +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 84654C1418FE8EE300160F11 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84654C1318FE8EE300160F11 /* Foundation.framework */; }; + 84654C1618FE8EE300160F11 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84654C1518FE8EE300160F11 /* CoreGraphics.framework */; }; + 84654C1818FE8EE300160F11 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84654C1718FE8EE300160F11 /* UIKit.framework */; }; + 84654C1E18FE8EE300160F11 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 84654C1C18FE8EE300160F11 /* InfoPlist.strings */; }; + 84654C2018FE8EE300160F11 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 84654C1F18FE8EE300160F11 /* main.m */; }; + 84654C2418FE8EE300160F11 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 84654C2318FE8EE300160F11 /* AppDelegate.m */; }; + 84654C2618FE8EE300160F11 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 84654C2518FE8EE300160F11 /* Images.xcassets */; }; + 84654C2D18FE8EE300160F11 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84654C2C18FE8EE300160F11 /* XCTest.framework */; }; + 84654C2E18FE8EE300160F11 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84654C1318FE8EE300160F11 /* Foundation.framework */; }; + 84654C2F18FE8EE300160F11 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84654C1718FE8EE300160F11 /* UIKit.framework */; }; + 84654C3718FE8EE300160F11 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 84654C3518FE8EE300160F11 /* InfoPlist.strings */; }; + 84654C3918FE8EE300160F11 /* GraphKitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 84654C3818FE8EE300160F11 /* GraphKitTests.m */; }; + 84654C4C18FE909A00160F11 /* GKBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 84654C4B18FE909A00160F11 /* GKBar.m */; }; + 84654C5118FE934800160F11 /* ExampleBarVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 84654C4F18FE934800160F11 /* ExampleBarVC.m */; }; + 84654C5218FE934800160F11 /* ExampleBarVC.xib in Resources */ = {isa = PBXBuildFile; fileRef = 84654C5018FE934800160F11 /* ExampleBarVC.xib */; }; + 84654C5518FEDCDF00160F11 /* GKBarGraph.m in Sources */ = {isa = PBXBuildFile; fileRef = 84654C5418FEDCDF00160F11 /* GKBarGraph.m */; }; + 84654C5918FF4C8300160F11 /* ExampleBarGraphVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 84654C5718FF4C8300160F11 /* ExampleBarGraphVC.m */; }; + 84654C5A18FF4C8300160F11 /* ExampleBarGraphVC.xib in Resources */ = {isa = PBXBuildFile; fileRef = 84654C5818FF4C8300160F11 /* ExampleBarGraphVC.xib */; }; + 8472591E1904AA4F00819664 /* ExampleLineGraph.m in Sources */ = {isa = PBXBuildFile; fileRef = 8472591C1904AA4F00819664 /* ExampleLineGraph.m */; }; + 8472591F1904AA4F00819664 /* ExampleLineGraph.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8472591D1904AA4F00819664 /* ExampleLineGraph.xib */; }; + 847259231904ABE200819664 /* GKLineGraph.m in Sources */ = {isa = PBXBuildFile; fileRef = 847259221904ABE200819664 /* GKLineGraph.m */; }; + 847259291905C1D300819664 /* UIColor+GraphKit.m in Sources */ = {isa = PBXBuildFile; fileRef = 847259281905C1D300819664 /* UIColor+GraphKit.m */; }; + 8472592F1905D63500819664 /* UIViewController+BButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 8472592E1905D63500819664 /* UIViewController+BButton.m */; }; + 84F0E98E1902B30C00FA4810 /* ExampleListVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 84F0E98C1902B30C00FA4810 /* ExampleListVC.m */; }; + 84F0E98F1902B30C00FA4810 /* ExampleListVC.xib in Resources */ = {isa = PBXBuildFile; fileRef = 84F0E98D1902B30C00FA4810 /* ExampleListVC.xib */; }; + 973F4746059343C9A462AA2D /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 74E12B5B49644056930176BC /* libPods.a */; }; + FC41ADB61AD4341900F7D9C0 /* GKStackedBarGraph.m in Sources */ = {isa = PBXBuildFile; fileRef = FC41ADB51AD4341900F7D9C0 /* GKStackedBarGraph.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 84654C3018FE8EE300160F11 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 84654C0818FE8EE200160F11 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 84654C0F18FE8EE200160F11; + remoteInfo = GraphKit; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 74E12B5B49644056930176BC /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 84654C1018FE8EE300160F11 /* GraphKit.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GraphKit.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 84654C1318FE8EE300160F11 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 84654C1518FE8EE300160F11 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; + 84654C1718FE8EE300160F11 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; + 84654C1B18FE8EE300160F11 /* GraphKit-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "GraphKit-Info.plist"; sourceTree = ""; }; + 84654C1D18FE8EE300160F11 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; + 84654C1F18FE8EE300160F11 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 84654C2118FE8EE300160F11 /* GraphKit-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "GraphKit-Prefix.pch"; sourceTree = ""; }; + 84654C2218FE8EE300160F11 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 84654C2318FE8EE300160F11 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 84654C2518FE8EE300160F11 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; + 84654C2B18FE8EE300160F11 /* GraphKitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GraphKitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 84654C2C18FE8EE300160F11 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; + 84654C3418FE8EE300160F11 /* GraphKitTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "GraphKitTests-Info.plist"; sourceTree = ""; }; + 84654C3618FE8EE300160F11 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; + 84654C3818FE8EE300160F11 /* GraphKitTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GraphKitTests.m; sourceTree = ""; }; + 84654C4618FE8F0600160F11 /* GraphKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphKit.h; sourceTree = ""; }; + 84654C4A18FE909A00160F11 /* GKBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GKBar.h; sourceTree = ""; }; + 84654C4B18FE909A00160F11 /* GKBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GKBar.m; sourceTree = ""; }; + 84654C4E18FE934800160F11 /* ExampleBarVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExampleBarVC.h; sourceTree = ""; }; + 84654C4F18FE934800160F11 /* ExampleBarVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ExampleBarVC.m; sourceTree = ""; }; + 84654C5018FE934800160F11 /* ExampleBarVC.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ExampleBarVC.xib; sourceTree = ""; }; + 84654C5318FEDCDF00160F11 /* GKBarGraph.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GKBarGraph.h; sourceTree = ""; }; + 84654C5418FEDCDF00160F11 /* GKBarGraph.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GKBarGraph.m; sourceTree = ""; }; + 84654C5618FF4C8300160F11 /* ExampleBarGraphVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExampleBarGraphVC.h; sourceTree = ""; }; + 84654C5718FF4C8300160F11 /* ExampleBarGraphVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ExampleBarGraphVC.m; sourceTree = ""; }; + 84654C5818FF4C8300160F11 /* ExampleBarGraphVC.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ExampleBarGraphVC.xib; sourceTree = ""; }; + 8472591B1904AA4F00819664 /* ExampleLineGraph.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExampleLineGraph.h; sourceTree = ""; }; + 8472591C1904AA4F00819664 /* ExampleLineGraph.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ExampleLineGraph.m; sourceTree = ""; }; + 8472591D1904AA4F00819664 /* ExampleLineGraph.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ExampleLineGraph.xib; sourceTree = ""; }; + 847259211904ABE200819664 /* GKLineGraph.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GKLineGraph.h; sourceTree = ""; }; + 847259221904ABE200819664 /* GKLineGraph.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GKLineGraph.m; sourceTree = ""; }; + 847259271905C1D300819664 /* UIColor+GraphKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIColor+GraphKit.h"; sourceTree = ""; }; + 847259281905C1D300819664 /* UIColor+GraphKit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIColor+GraphKit.m"; sourceTree = ""; }; + 8472592D1905D63500819664 /* UIViewController+BButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+BButton.h"; sourceTree = ""; }; + 8472592E1905D63500819664 /* UIViewController+BButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+BButton.m"; sourceTree = ""; }; + 84F0E98B1902B30C00FA4810 /* ExampleListVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExampleListVC.h; sourceTree = ""; }; + 84F0E98C1902B30C00FA4810 /* ExampleListVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ExampleListVC.m; sourceTree = ""; }; + 84F0E98D1902B30C00FA4810 /* ExampleListVC.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ExampleListVC.xib; sourceTree = ""; }; + 873AC9F69410844871F60371 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = ""; }; + 8AEF73567DD4B30E5A877C5C /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = ""; }; + FC41ADB41AD4341900F7D9C0 /* GKStackedBarGraph.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GKStackedBarGraph.h; sourceTree = ""; }; + FC41ADB51AD4341900F7D9C0 /* GKStackedBarGraph.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GKStackedBarGraph.m; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 84654C0D18FE8EE200160F11 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 84654C1618FE8EE300160F11 /* CoreGraphics.framework in Frameworks */, + 84654C1818FE8EE300160F11 /* UIKit.framework in Frameworks */, + 84654C1418FE8EE300160F11 /* Foundation.framework in Frameworks */, + 973F4746059343C9A462AA2D /* libPods.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 84654C2818FE8EE300160F11 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 84654C2D18FE8EE300160F11 /* XCTest.framework in Frameworks */, + 84654C2F18FE8EE300160F11 /* UIKit.framework in Frameworks */, + 84654C2E18FE8EE300160F11 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 84654C0718FE8EE200160F11 = { + isa = PBXGroup; + children = ( + 84654C1918FE8EE300160F11 /* GraphKit */, + 84654C3218FE8EE300160F11 /* GraphKitTests */, + 84654C1218FE8EE300160F11 /* Frameworks */, + 84654C1118FE8EE300160F11 /* Products */, + D66EB86FC82255B51279B314 /* Pods */, + ); + sourceTree = ""; + }; + 84654C1118FE8EE300160F11 /* Products */ = { + isa = PBXGroup; + children = ( + 84654C1018FE8EE300160F11 /* GraphKit.app */, + 84654C2B18FE8EE300160F11 /* GraphKitTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 84654C1218FE8EE300160F11 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 84654C1318FE8EE300160F11 /* Foundation.framework */, + 84654C1518FE8EE300160F11 /* CoreGraphics.framework */, + 84654C1718FE8EE300160F11 /* UIKit.framework */, + 84654C2C18FE8EE300160F11 /* XCTest.framework */, + 74E12B5B49644056930176BC /* libPods.a */, + ); + name = Frameworks; + sourceTree = ""; + }; + 84654C1918FE8EE300160F11 /* GraphKit */ = { + isa = PBXGroup; + children = ( + 84654C4D18FE932A00160F11 /* Example */, + 84654C4218FE8EF300160F11 /* Source */, + 84654C2218FE8EE300160F11 /* AppDelegate.h */, + 84654C2318FE8EE300160F11 /* AppDelegate.m */, + 84654C2518FE8EE300160F11 /* Images.xcassets */, + 84654C1A18FE8EE300160F11 /* Supporting Files */, + ); + path = GraphKit; + sourceTree = ""; + }; + 84654C1A18FE8EE300160F11 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 84654C1B18FE8EE300160F11 /* GraphKit-Info.plist */, + 84654C1C18FE8EE300160F11 /* InfoPlist.strings */, + 84654C1F18FE8EE300160F11 /* main.m */, + 84654C2118FE8EE300160F11 /* GraphKit-Prefix.pch */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 84654C3218FE8EE300160F11 /* GraphKitTests */ = { + isa = PBXGroup; + children = ( + 84654C3818FE8EE300160F11 /* GraphKitTests.m */, + 84654C3318FE8EE300160F11 /* Supporting Files */, + ); + path = GraphKitTests; + sourceTree = ""; + }; + 84654C3318FE8EE300160F11 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 84654C3418FE8EE300160F11 /* GraphKitTests-Info.plist */, + 84654C3518FE8EE300160F11 /* InfoPlist.strings */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 84654C4218FE8EF300160F11 /* Source */ = { + isa = PBXGroup; + children = ( + 84654C4618FE8F0600160F11 /* GraphKit.h */, + 847259271905C1D300819664 /* UIColor+GraphKit.h */, + 847259281905C1D300819664 /* UIColor+GraphKit.m */, + 84654C4918FE907500160F11 /* BarGraph */, + 847259201904AB8F00819664 /* LineGraph */, + ); + name = Source; + path = ../../Source; + sourceTree = ""; + }; + 84654C4918FE907500160F11 /* BarGraph */ = { + isa = PBXGroup; + children = ( + 84654C4A18FE909A00160F11 /* GKBar.h */, + 84654C4B18FE909A00160F11 /* GKBar.m */, + 84654C5318FEDCDF00160F11 /* GKBarGraph.h */, + 84654C5418FEDCDF00160F11 /* GKBarGraph.m */, + FC41ADB41AD4341900F7D9C0 /* GKStackedBarGraph.h */, + FC41ADB51AD4341900F7D9C0 /* GKStackedBarGraph.m */, + ); + path = BarGraph; + sourceTree = ""; + }; + 84654C4D18FE932A00160F11 /* Example */ = { + isa = PBXGroup; + children = ( + 84F0E98B1902B30C00FA4810 /* ExampleListVC.h */, + 84F0E98C1902B30C00FA4810 /* ExampleListVC.m */, + 84F0E98D1902B30C00FA4810 /* ExampleListVC.xib */, + 84654C4E18FE934800160F11 /* ExampleBarVC.h */, + 84654C4F18FE934800160F11 /* ExampleBarVC.m */, + 84654C5018FE934800160F11 /* ExampleBarVC.xib */, + 84654C5618FF4C8300160F11 /* ExampleBarGraphVC.h */, + 84654C5718FF4C8300160F11 /* ExampleBarGraphVC.m */, + 84654C5818FF4C8300160F11 /* ExampleBarGraphVC.xib */, + 8472591B1904AA4F00819664 /* ExampleLineGraph.h */, + 8472591C1904AA4F00819664 /* ExampleLineGraph.m */, + 8472591D1904AA4F00819664 /* ExampleLineGraph.xib */, + 8472592D1905D63500819664 /* UIViewController+BButton.h */, + 8472592E1905D63500819664 /* UIViewController+BButton.m */, + ); + path = Example; + sourceTree = SOURCE_ROOT; + }; + 847259201904AB8F00819664 /* LineGraph */ = { + isa = PBXGroup; + children = ( + 847259211904ABE200819664 /* GKLineGraph.h */, + 847259221904ABE200819664 /* GKLineGraph.m */, + ); + path = LineGraph; + sourceTree = ""; + }; + D66EB86FC82255B51279B314 /* Pods */ = { + isa = PBXGroup; + children = ( + 8AEF73567DD4B30E5A877C5C /* Pods.debug.xcconfig */, + 873AC9F69410844871F60371 /* Pods.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 84654C0F18FE8EE200160F11 /* GraphKit */ = { + isa = PBXNativeTarget; + buildConfigurationList = 84654C3C18FE8EE300160F11 /* Build configuration list for PBXNativeTarget "GraphKit" */; + buildPhases = ( + 83175F7BAC184C238C8A7ED0 /* Check Pods Manifest.lock */, + 84654C0C18FE8EE200160F11 /* Sources */, + 84654C0D18FE8EE200160F11 /* Frameworks */, + 84654C0E18FE8EE200160F11 /* Resources */, + D08870F64023490D9D34D82D /* Copy Pods Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = GraphKit; + productName = GraphKit; + productReference = 84654C1018FE8EE300160F11 /* GraphKit.app */; + productType = "com.apple.product-type.application"; + }; + 84654C2A18FE8EE300160F11 /* GraphKitTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 84654C3F18FE8EE300160F11 /* Build configuration list for PBXNativeTarget "GraphKitTests" */; + buildPhases = ( + 84654C2718FE8EE300160F11 /* Sources */, + 84654C2818FE8EE300160F11 /* Frameworks */, + 84654C2918FE8EE300160F11 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 84654C3118FE8EE300160F11 /* PBXTargetDependency */, + ); + name = GraphKitTests; + productName = GraphKitTests; + productReference = 84654C2B18FE8EE300160F11 /* GraphKitTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 84654C0818FE8EE200160F11 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0510; + ORGANIZATIONNAME = "Michal Konturek"; + TargetAttributes = { + 84654C2A18FE8EE300160F11 = { + TestTargetID = 84654C0F18FE8EE200160F11; + }; + }; + }; + buildConfigurationList = 84654C0B18FE8EE200160F11 /* Build configuration list for PBXProject "GraphKit" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 84654C0718FE8EE200160F11; + productRefGroup = 84654C1118FE8EE300160F11 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 84654C0F18FE8EE200160F11 /* GraphKit */, + 84654C2A18FE8EE300160F11 /* GraphKitTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 84654C0E18FE8EE200160F11 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 84654C1E18FE8EE300160F11 /* InfoPlist.strings in Resources */, + 84654C2618FE8EE300160F11 /* Images.xcassets in Resources */, + 84654C5A18FF4C8300160F11 /* ExampleBarGraphVC.xib in Resources */, + 84F0E98F1902B30C00FA4810 /* ExampleListVC.xib in Resources */, + 84654C5218FE934800160F11 /* ExampleBarVC.xib in Resources */, + 8472591F1904AA4F00819664 /* ExampleLineGraph.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 84654C2918FE8EE300160F11 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 84654C3718FE8EE300160F11 /* InfoPlist.strings in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 83175F7BAC184C238C8A7ED0 /* Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; + D08870F64023490D9D34D82D /* Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 84654C0C18FE8EE200160F11 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 847259231904ABE200819664 /* GKLineGraph.m in Sources */, + 8472592F1905D63500819664 /* UIViewController+BButton.m in Sources */, + 84654C5518FEDCDF00160F11 /* GKBarGraph.m in Sources */, + 84654C2418FE8EE300160F11 /* AppDelegate.m in Sources */, + 847259291905C1D300819664 /* UIColor+GraphKit.m in Sources */, + 84654C5918FF4C8300160F11 /* ExampleBarGraphVC.m in Sources */, + 8472591E1904AA4F00819664 /* ExampleLineGraph.m in Sources */, + 84654C4C18FE909A00160F11 /* GKBar.m in Sources */, + 84654C2018FE8EE300160F11 /* main.m in Sources */, + 84F0E98E1902B30C00FA4810 /* ExampleListVC.m in Sources */, + FC41ADB61AD4341900F7D9C0 /* GKStackedBarGraph.m in Sources */, + 84654C5118FE934800160F11 /* ExampleBarVC.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 84654C2718FE8EE300160F11 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 84654C3918FE8EE300160F11 /* GraphKitTests.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 84654C3118FE8EE300160F11 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 84654C0F18FE8EE200160F11 /* GraphKit */; + targetProxy = 84654C3018FE8EE300160F11 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 84654C1C18FE8EE300160F11 /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 84654C1D18FE8EE300160F11 /* en */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; + 84654C3518FE8EE300160F11 /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 84654C3618FE8EE300160F11 /* en */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 84654C3A18FE8EE300160F11 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 7.1; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/**"; + }; + name = Debug; + }; + 84654C3B18FE8EE300160F11 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = YES; + ENABLE_NS_ASSERTIONS = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 7.1; + SDKROOT = iphoneos; + USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/**"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 84654C3D18FE8EE300160F11 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 8AEF73567DD4B30E5A877C5C /* Pods.debug.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = YES; + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "GraphKit/GraphKit-Prefix.pch"; + INFOPLIST_FILE = "GraphKit/GraphKit-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/**"; + WRAPPER_EXTENSION = app; + }; + name = Debug; + }; + 84654C3E18FE8EE300160F11 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 873AC9F69410844871F60371 /* Pods.release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = YES; + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "GraphKit/GraphKit-Prefix.pch"; + INFOPLIST_FILE = "GraphKit/GraphKit-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/**"; + WRAPPER_EXTENSION = app; + }; + name = Release; + }; + 84654C4018FE8EE300160F11 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/GraphKit.app/GraphKit"; + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(inherited)", + "$(DEVELOPER_FRAMEWORKS_DIR)", + ); + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "GraphKit/GraphKit-Prefix.pch"; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + INFOPLIST_FILE = "GraphKitTests/GraphKitTests-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUNDLE_LOADER)"; + WRAPPER_EXTENSION = xctest; + }; + name = Debug; + }; + 84654C4118FE8EE300160F11 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/GraphKit.app/GraphKit"; + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(inherited)", + "$(DEVELOPER_FRAMEWORKS_DIR)", + ); + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "GraphKit/GraphKit-Prefix.pch"; + INFOPLIST_FILE = "GraphKitTests/GraphKitTests-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUNDLE_LOADER)"; + WRAPPER_EXTENSION = xctest; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 84654C0B18FE8EE200160F11 /* Build configuration list for PBXProject "GraphKit" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 84654C3A18FE8EE300160F11 /* Debug */, + 84654C3B18FE8EE300160F11 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 84654C3C18FE8EE300160F11 /* Build configuration list for PBXNativeTarget "GraphKit" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 84654C3D18FE8EE300160F11 /* Debug */, + 84654C3E18FE8EE300160F11 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 84654C3F18FE8EE300160F11 /* Build configuration list for PBXNativeTarget "GraphKitTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 84654C4018FE8EE300160F11 /* Debug */, + 84654C4118FE8EE300160F11 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 84654C0818FE8EE200160F11 /* Project object */; +} diff --git a/Source/BarGraph/GKStackedBarGraph.h b/Source/BarGraph/GKStackedBarGraph.h new file mode 100644 index 0000000..aedcc9a --- /dev/null +++ b/Source/BarGraph/GKStackedBarGraph.h @@ -0,0 +1,64 @@ +// +// GKStackedBarGraph.h +// GraphKit +// +// Copyright (c) 2014 Michal Konturek +// +// 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: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// 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. +// + + +#import + +@protocol GKStackedBarGraphDataSource; + +@interface GKStackedBarGraph : UIView + +@property (nonatomic, assign) BOOL animated; +@property (nonatomic, assign) CFTimeInterval animationDuration; + +@property (nonatomic, weak) IBOutlet id dataSource; + +@property (nonatomic, strong) NSArray *bars; +@property (nonatomic, strong) NSArray *labels; +@property (nonatomic, strong) UIColor *barColor; + +@property (nonatomic, assign) CGFloat barHeight; +@property (nonatomic, assign) CGFloat barWidth; +@property (nonatomic, assign) CGFloat marginBar; + +- (void)draw; +- (void)reset; + +@end + +@protocol GKStackedBarGraphDataSource + +- (NSInteger)numberOfBars; +- (NSInteger)numberOfStacks; +- (NSNumber *)valueForBarAtIndex:(NSInteger)index stack:(NSInteger)stack; + +@optional +- (UIColor *)colorForBarAtIndex:(NSInteger)index stack:(NSInteger)stack; +- (UIColor *)colorForBarBackgroundAtIndex:(NSInteger)index; +- (CFTimeInterval)animationDurationForBarAtIndex:(NSInteger)index; + +- (NSString *)titleForBarAtIndex:(NSInteger)index; + +@end diff --git a/Source/BarGraph/GKStackedBarGraph.m b/Source/BarGraph/GKStackedBarGraph.m new file mode 100644 index 0000000..f116179 --- /dev/null +++ b/Source/BarGraph/GKStackedBarGraph.m @@ -0,0 +1,263 @@ +// +// GKStackedBarGraph.m +// GraphKit +// +// Copyright (c) 2014 Michal Konturek +// +// 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: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// 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. +// + +#import "GKStackedBarGraph.h" + +#import +#import + +#import "GKBar.h" + +static CGFloat kDefaultBarHeight = 140; +static CGFloat kDefaultBarWidth = 22; +static CGFloat kDefaultBarMargin = 20; +static CGFloat kDefaultLabelWidth = 40; +static CGFloat kDefaultLabelHeight = 15; + +static CGFloat kDefaultAnimationDuration = 2.0; + +@implementation GKStackedBarGraph + +- (id)initWithCoder:(NSCoder *)aDecoder { + self = [super initWithCoder:aDecoder]; + if (self) { + [self _init]; + } + return self; +} + +- (id)initWithFrame:(CGRect)frame { + self = [super initWithFrame:frame]; + if (self) { + [self _init]; + self.backgroundColor = [UIColor clearColor]; + } + return self; +} + +- (void)_init { + self.animationDuration = kDefaultAnimationDuration; + self.barHeight = kDefaultBarHeight; + self.barWidth = kDefaultBarWidth; + self.marginBar = kDefaultBarMargin; +} + +- (void)setAnimated:(BOOL)animated { + _animated = animated; + [self.bars mk_each:^(NSArray *bar) { + [bar mk_each:^(GKBar *item) { + item.animated = animated; + }]; + }]; +} + +- (void)setAnimationDuration:(CFTimeInterval)animationDuration { + _animationDuration = animationDuration; + [self.bars mk_each:^(NSArray *bar) { + [bar mk_each:^(GKBar *item) { + item.animationDuration = animationDuration; + }]; + }]; +} + +- (void)setBarColor:(UIColor *)color { + _barColor = color; + [self.bars mk_each:^(NSArray *bar) { + [bar mk_each:^(GKBar *item) { + item.foregroundColor = color; + }]; + }]; +} + +- (void)draw { + [self _construct]; + [self _drawBars]; +} + +- (void)_construct { + NSAssert(self.dataSource, @"GKStackedBarGraph : No data source is assigned."); + + if ([self _hasBars]) [self _removeBars]; + if ([self _hasLabels]) [self _removeLabels]; + + [self _constructBars]; + [self _constructLabels]; + + [self _positionBars]; + [self _positionLabels]; +} + +- (BOOL)_hasBars { + return ![self.bars mk_isEmpty]; +} + +- (void)_constructBars { + NSInteger barCount = [self.dataSource numberOfBars]; + NSInteger stackCount = [self.dataSource numberOfStacks]; + + id bars = [NSMutableArray arrayWithCapacity:barCount]; + for (NSInteger idx = 0; idx < barCount; idx++) { + + id stacks = [NSMutableArray arrayWithCapacity:stackCount]; + for (NSInteger sIdx = 0; sIdx < stackCount; sIdx++) { + GKBar *item = [GKBar create]; + if ([self barColor]) item.foregroundColor = [self barColor]; + [stacks addObject:item]; + } + [bars addObject:stacks]; + } + self.bars = bars; +} + +- (void)_removeBars { + [self.bars mk_each:^(NSArray *bar) { + [bar mk_each:^(GKBar *item) { + [item removeFromSuperview]; + }]; + }]; +} + +- (void)_positionBars { + __block CGFloat x = [self _barStartX]; + [self.bars mk_each:^(NSArray *bar) { + __block CGFloat y = [self _barStartY]; + + [bar mk_each:^(GKBar *item) { + item.frame = CGRectMake(x, y, _barWidth, _barHeight); + [self addSubview:item]; + y += 10; + }]; + x += [self _barSpace]; + }]; +} + +- (CGFloat)_barStartX { + CGFloat result = self.width; + CGFloat item = [self _barSpace]; + NSInteger count = [self.dataSource numberOfBars]; + + result = result - (item * count) + self.marginBar; + result = (result / 2); + return result; +} + +- (CGFloat)_barSpace { + return (self.barWidth + self.marginBar); +} + +- (CGFloat)_barStartY { + return (self.height - self.barHeight); +} + +- (BOOL)_hasLabels { + return ![self.labels mk_isEmpty]; +} + +- (void)_constructLabels { + + NSInteger count = [self.dataSource numberOfBars]; + id items = [NSMutableArray arrayWithCapacity:count]; + for (NSInteger idx = 0; idx < count; idx++) { + + CGRect frame = CGRectMake(0, 0, kDefaultLabelWidth, kDefaultLabelHeight); + UILabel *item = [[UILabel alloc] initWithFrame:frame]; + item.textAlignment = NSTextAlignmentCenter; + item.font = [UIFont boldSystemFontOfSize:13]; + item.textColor = [UIColor lightGrayColor]; + item.text = [self.dataSource titleForBarAtIndex:idx]; + + [items addObject:item]; + } + self.labels = items; +} + +- (void)_removeLabels { + [self.labels mk_each:^(id item) { + [item removeFromSuperview]; + }]; +} + +- (void)_positionLabels { + + __block NSInteger idx = 0; + [self.bars mk_each:^(GKBar *bar) { + + }]; + [self.bars mk_each:^(NSArray *bar) { + GKBar *firstStack = bar[0]; + CGFloat labelWidth = kDefaultLabelWidth; + CGFloat labelHeight = kDefaultLabelHeight; + CGFloat startX = firstStack.x - ((labelWidth - self.barWidth) / 2); + CGFloat startY = (self.height - labelHeight); + + UILabel *label = [self.labels objectAtIndex:idx]; + label.x = startX; + label.y = startY; + + [self addSubview:label]; + + [bar mk_each:^(GKBar *item) { + item.y -= labelHeight + 5; + }]; + + idx++; + }]; +} + +- (void)_drawBars { + __block NSInteger idx = 0; + id source = self.dataSource; + [self.bars mk_each:^(NSArray *bar) { + __block NSInteger sidx = 0; + [bar mk_each:^(GKBar *item) { + + if ([source respondsToSelector:@selector(animationDurationForBarAtIndex:)]) { + item.animationDuration = [source animationDurationForBarAtIndex:idx]; + } + + if ([source respondsToSelector:@selector(colorForBarAtIndex:stack:)]) { + item.foregroundColor = [source colorForBarAtIndex:idx stack:sidx]; + } + + if ([source respondsToSelector:@selector(colorForBarBackgroundAtIndex:)]) { + item.backgroundColor = [source colorForBarBackgroundAtIndex:idx]; + } + + item.percentage = [[source valueForBarAtIndex:idx stack:sidx] doubleValue]; + sidx++; + }]; + idx++; + }]; +} + +- (void)reset { + [self.bars mk_each:^(NSArray *bar) { + [bar mk_each:^(GKBar *item) { + [item reset]; + }]; + }]; +} + +@end diff --git a/Source/GraphKit.h b/Source/GraphKit.h index 6387f9a..acdbda6 100644 --- a/Source/GraphKit.h +++ b/Source/GraphKit.h @@ -28,6 +28,7 @@ #import "GKBar.h" #import "GKBarGraph.h" +#import "GKStackedBarGraph.h" #import "GKLineGraph.h" #import "UIColor+GraphKit.h" \ No newline at end of file From ae5cce284a15af767e16c8b3ee33331f6b65bf6b Mon Sep 17 00:00:00 2001 From: Erich Grunewald Date: Tue, 7 Apr 2015 18:21:16 +0200 Subject: [PATCH 2/7] Add a soon-to-be-fixed GKStackedBar file. --- GraphKit/GraphKit.xcodeproj/project.pbxproj | 30 ++- Source/GraphKit.h | 1 + Source/StackedBarGraph/GKStackedBar.h | 46 +++++ Source/StackedBarGraph/GKStackedBar.m | 190 ++++++++++++++++++ .../GKStackedBarGraph.h | 0 .../GKStackedBarGraph.m | 24 +-- 6 files changed, 271 insertions(+), 20 deletions(-) create mode 100644 Source/StackedBarGraph/GKStackedBar.h create mode 100644 Source/StackedBarGraph/GKStackedBar.m rename Source/{BarGraph => StackedBarGraph}/GKStackedBarGraph.h (100%) rename Source/{BarGraph => StackedBarGraph}/GKStackedBarGraph.m (92%) diff --git a/GraphKit/GraphKit.xcodeproj/project.pbxproj b/GraphKit/GraphKit.xcodeproj/project.pbxproj index 4669ef8..2855274 100644 --- a/GraphKit/GraphKit.xcodeproj/project.pbxproj +++ b/GraphKit/GraphKit.xcodeproj/project.pbxproj @@ -33,7 +33,8 @@ 84F0E98E1902B30C00FA4810 /* ExampleListVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 84F0E98C1902B30C00FA4810 /* ExampleListVC.m */; }; 84F0E98F1902B30C00FA4810 /* ExampleListVC.xib in Resources */ = {isa = PBXBuildFile; fileRef = 84F0E98D1902B30C00FA4810 /* ExampleListVC.xib */; }; 973F4746059343C9A462AA2D /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 74E12B5B49644056930176BC /* libPods.a */; }; - FC41ADB61AD4341900F7D9C0 /* GKStackedBarGraph.m in Sources */ = {isa = PBXBuildFile; fileRef = FC41ADB51AD4341900F7D9C0 /* GKStackedBarGraph.m */; }; + FC41ADBA1AD436D600F7D9C0 /* GKStackedBarGraph.m in Sources */ = {isa = PBXBuildFile; fileRef = FC41ADB91AD436D600F7D9C0 /* GKStackedBarGraph.m */; }; + FC41ADBD1AD436EE00F7D9C0 /* GKStackedBar.m in Sources */ = {isa = PBXBuildFile; fileRef = FC41ADBC1AD436EE00F7D9C0 /* GKStackedBar.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -89,8 +90,10 @@ 84F0E98D1902B30C00FA4810 /* ExampleListVC.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ExampleListVC.xib; sourceTree = ""; }; 873AC9F69410844871F60371 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = ""; }; 8AEF73567DD4B30E5A877C5C /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = ""; }; - FC41ADB41AD4341900F7D9C0 /* GKStackedBarGraph.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GKStackedBarGraph.h; sourceTree = ""; }; - FC41ADB51AD4341900F7D9C0 /* GKStackedBarGraph.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GKStackedBarGraph.m; sourceTree = ""; }; + FC41ADB81AD436D600F7D9C0 /* GKStackedBarGraph.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GKStackedBarGraph.h; path = StackedBarGraph/GKStackedBarGraph.h; sourceTree = ""; }; + FC41ADB91AD436D600F7D9C0 /* GKStackedBarGraph.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GKStackedBarGraph.m; path = StackedBarGraph/GKStackedBarGraph.m; sourceTree = ""; }; + FC41ADBB1AD436EE00F7D9C0 /* GKStackedBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GKStackedBar.h; path = StackedBarGraph/GKStackedBar.h; sourceTree = ""; }; + FC41ADBC1AD436EE00F7D9C0 /* GKStackedBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GKStackedBar.m; path = StackedBarGraph/GKStackedBar.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -195,11 +198,12 @@ 84654C4218FE8EF300160F11 /* Source */ = { isa = PBXGroup; children = ( + 84654C4918FE907500160F11 /* BarGraph */, 84654C4618FE8F0600160F11 /* GraphKit.h */, + 847259201904AB8F00819664 /* LineGraph */, + FC41ADB71AD436A800F7D9C0 /* StackedBarGraph */, 847259271905C1D300819664 /* UIColor+GraphKit.h */, 847259281905C1D300819664 /* UIColor+GraphKit.m */, - 84654C4918FE907500160F11 /* BarGraph */, - 847259201904AB8F00819664 /* LineGraph */, ); name = Source; path = ../../Source; @@ -212,8 +216,6 @@ 84654C4B18FE909A00160F11 /* GKBar.m */, 84654C5318FEDCDF00160F11 /* GKBarGraph.h */, 84654C5418FEDCDF00160F11 /* GKBarGraph.m */, - FC41ADB41AD4341900F7D9C0 /* GKStackedBarGraph.h */, - FC41ADB51AD4341900F7D9C0 /* GKStackedBarGraph.m */, ); path = BarGraph; sourceTree = ""; @@ -257,6 +259,17 @@ name = Pods; sourceTree = ""; }; + FC41ADB71AD436A800F7D9C0 /* StackedBarGraph */ = { + isa = PBXGroup; + children = ( + FC41ADBB1AD436EE00F7D9C0 /* GKStackedBar.h */, + FC41ADBC1AD436EE00F7D9C0 /* GKStackedBar.m */, + FC41ADB81AD436D600F7D9C0 /* GKStackedBarGraph.h */, + FC41ADB91AD436D600F7D9C0 /* GKStackedBarGraph.m */, + ); + name = StackedBarGraph; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -398,10 +411,11 @@ 847259291905C1D300819664 /* UIColor+GraphKit.m in Sources */, 84654C5918FF4C8300160F11 /* ExampleBarGraphVC.m in Sources */, 8472591E1904AA4F00819664 /* ExampleLineGraph.m in Sources */, + FC41ADBD1AD436EE00F7D9C0 /* GKStackedBar.m in Sources */, 84654C4C18FE909A00160F11 /* GKBar.m in Sources */, 84654C2018FE8EE300160F11 /* main.m in Sources */, 84F0E98E1902B30C00FA4810 /* ExampleListVC.m in Sources */, - FC41ADB61AD4341900F7D9C0 /* GKStackedBarGraph.m in Sources */, + FC41ADBA1AD436D600F7D9C0 /* GKStackedBarGraph.m in Sources */, 84654C5118FE934800160F11 /* ExampleBarVC.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Source/GraphKit.h b/Source/GraphKit.h index acdbda6..fa29d3c 100644 --- a/Source/GraphKit.h +++ b/Source/GraphKit.h @@ -28,6 +28,7 @@ #import "GKBar.h" #import "GKBarGraph.h" +#import "GKStackedBar.h" #import "GKStackedBarGraph.h" #import "GKLineGraph.h" diff --git a/Source/StackedBarGraph/GKStackedBar.h b/Source/StackedBarGraph/GKStackedBar.h new file mode 100644 index 0000000..0daf52a --- /dev/null +++ b/Source/StackedBarGraph/GKStackedBar.h @@ -0,0 +1,46 @@ +// +// GKStackedBar.h +// GraphKit +// +// Copyright (c) 2014 Michal Konturek +// +// 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: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// 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. +// + +#import + +@interface GKStackedBar : UIView + ++ (instancetype)create; ++ (instancetype)createWithFrame:(CGRect)frame; + +@property (nonatomic, assign) BOOL animated; +@property (nonatomic, assign) CFTimeInterval animationDuration; + +@property (nonatomic, strong) NSMutableArray *percentages; + +@property (nonatomic, assign) CGFloat cornerRadius; +@property (nonatomic, strong) NSArray *foregroundColors; + +- (void)setPercentages:(NSArray *)percentages animated:(BOOL)animated; +- (void)setPercentage:(CGFloat)percentage atIndex:(NSInteger)index animated:(BOOL)animated; + +- (void)reset; + +@end diff --git a/Source/StackedBarGraph/GKStackedBar.m b/Source/StackedBarGraph/GKStackedBar.m new file mode 100644 index 0000000..610f23e --- /dev/null +++ b/Source/StackedBarGraph/GKStackedBar.m @@ -0,0 +1,190 @@ +// +// GKStackedBar.m +// GraphKit +// +// Copyright (c) 2014 Michal Konturek +// +// 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: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// 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. +// + +#import "GKStackedBar.h" + +#import + +#import "UIColor+GraphKit.h" + +static CFTimeInterval kDefaultAnimationDuration = 1.0; + +@interface GKStackedBar () + +@property (atomic, assign) BOOL animationInProgress; + +@end + +@implementation GKStackedBar + ++ (instancetype)create { + CGRect defaultRect = CGRectMake(0, 0, 30, 200); + return [self createWithFrame:defaultRect]; +} + ++ (instancetype)createWithFrame:(CGRect)frame { + return [[self alloc] initWithFrame:frame]; +} + +- (id)initWithCoder:(NSCoder *)aDecoder { + self = [super initWithCoder:aDecoder]; + if (self) { + [self _init]; + } + return self; +} + +- (id)initWithFrame:(CGRect)frame { + self = [super initWithFrame:frame]; + if (self) { + [self _init]; + } + return self; +} + +- (void)_init { + self.animated = YES; + self.animationDuration = kDefaultAnimationDuration; + self.clipsToBounds = YES; + self.cornerRadius = 2.0; + self.foregroundColor = [UIColor gk_turquoiseColor]; + self.backgroundColor = [UIColor gk_silverColor]; + _percentages = [NSMutableArray array]; +} + +- (void)setCornerRadius:(CGFloat)cornerRadius { + _cornerRadius = cornerRadius; + self.layer.cornerRadius = cornerRadius; +} + +- (void)setPercentages:(NSArray *)percentages animated:(BOOL)animated { + self.animated = animated; + self.percentages = percentages; + self.animated = YES; +} + +- (void)setPercentage:(CGFloat)percentage atIndex:(NSInteger)index animated:(BOOL)animated { + self.animated = animated; + self.percentages[index] = @(percentage); + self.animated = YES; +} + +- (void)setPercentages:(NSArray *)percentages { + [self.percentages enumerateObjectsUsingBlock:^(NSNumber *item, NSUInteger idx, BOOL *stop) { + CGFloat percentage = [item floatValue]; + if (percentage == [_percentages[idx] floatValue]) return; + if (percentage > 100) percentage = 100; + if (percentage < 0) percentage = 0; + if (self.animationInProgress) return; + + [self _progressBarTo:percentage atIndex:idx]; + }]; + + _percentages = percentages; +} + +- (void)_progressBarTo:(CGFloat)value atIndex:(NSInteger)index { + + CGFloat converted = (value / 100); + UIBezierPath *path = [self _bezierPathWith:converted atIndex:index]; + + CAShapeLayer *layer = [self _layerWithPath:path]; + if ([_percentages[index] floatValue] > value) layer.strokeColor = [self.backgroundColor CGColor]; + + [self.layer addSublayer:layer]; + + if (self.animated) { + id animation = [self _animationWithKeyPath:@"strokeEnd"]; + [layer addAnimation:animation forKey:@"strokeEndAnimation"]; + } +} + +- (UIBezierPath *)_bezierPathWith:(CGFloat)value atIndex:(NSInteger)index { + UIBezierPath *path = [UIBezierPath bezierPath]; + CGFloat startX = (self.frame.size.width / 2); + CGFloat startY = (self.frame.size.height * (1 - ([_percentages[index] floatValue] / 100))); + CGFloat endY = (self.frame.size.height * (1 - value)); + [path moveToPoint:CGPointMake(startX, startY)]; + [path addLineToPoint:CGPointMake(startX, endY)]; + return path; +} + +- (CAShapeLayer *)_layerWithPath:(UIBezierPath *)path atIndex:(NSInteger)index { + CAShapeLayer *item = [CAShapeLayer layer]; + item.fillColor = [[UIColor blackColor] CGColor]; + item.lineCap = kCALineCapButt; + item.lineWidth = self.frame.size.width; + item.path = path.CGPath; + item.strokeColor = [self.foregroundColor CGColor]; + item.strokeEnd = 1.0; + return item; +} + +- (CABasicAnimation *)_animationWithKeyPath:(NSString *)keyPath { + CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:keyPath]; + animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; + animation.duration = self.animationDuration; + animation.fromValue = @(0); + animation.toValue = @(1); + animation.delegate = self; + return animation; +} + +- (void)animationDidStart:(CAAnimation *)anim { + self.animationInProgress = YES; +} + +- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag { + self.animationInProgress = NO; +} + +- (void)setForegroundColors:(NSArray *)foregroundColors { + _foregroundColors = foregroundColors; + + self.layer.sublayers = nil; + for (int i = 0; i < self.percentages.count; i++) { + CGFloat temp = [_percentages[i] floatValue]; + [self setPercentage:0 atIndex:i animated:NO]; + [self setPercentage:temp atIndex:i animated:NO]; + } +} + +- (void)reset { + [UIView animateWithDuration:0.5 + delay:0.0 + options:UIViewAnimationOptionCurveEaseOut + animations:^{ + for (CAShapeLayer *item in self.layer.sublayers) { + item.strokeColor = [[UIColor clearColor] CGColor]; + } + } completion:^(BOOL finished) { + self.layer.sublayers = nil; + }]; + for (int i = 0; i < self.percentages.count; i++) { + self.percentages[i] = @0; + } +} + +@end diff --git a/Source/BarGraph/GKStackedBarGraph.h b/Source/StackedBarGraph/GKStackedBarGraph.h similarity index 100% rename from Source/BarGraph/GKStackedBarGraph.h rename to Source/StackedBarGraph/GKStackedBarGraph.h diff --git a/Source/BarGraph/GKStackedBarGraph.m b/Source/StackedBarGraph/GKStackedBarGraph.m similarity index 92% rename from Source/BarGraph/GKStackedBarGraph.m rename to Source/StackedBarGraph/GKStackedBarGraph.m index f116179..9956dd2 100644 --- a/Source/BarGraph/GKStackedBarGraph.m +++ b/Source/StackedBarGraph/GKStackedBarGraph.m @@ -28,7 +28,7 @@ #import #import -#import "GKBar.h" +#import "GKStackedBar.h" static CGFloat kDefaultBarHeight = 140; static CGFloat kDefaultBarWidth = 22; @@ -67,7 +67,7 @@ - (void)_init { - (void)setAnimated:(BOOL)animated { _animated = animated; [self.bars mk_each:^(NSArray *bar) { - [bar mk_each:^(GKBar *item) { + [bar mk_each:^(GKStackedBar *item) { item.animated = animated; }]; }]; @@ -76,7 +76,7 @@ - (void)setAnimated:(BOOL)animated { - (void)setAnimationDuration:(CFTimeInterval)animationDuration { _animationDuration = animationDuration; [self.bars mk_each:^(NSArray *bar) { - [bar mk_each:^(GKBar *item) { + [bar mk_each:^(GKStackedBar *item) { item.animationDuration = animationDuration; }]; }]; @@ -85,7 +85,7 @@ - (void)setAnimationDuration:(CFTimeInterval)animationDuration { - (void)setBarColor:(UIColor *)color { _barColor = color; [self.bars mk_each:^(NSArray *bar) { - [bar mk_each:^(GKBar *item) { + [bar mk_each:^(GKStackedBar *item) { item.foregroundColor = color; }]; }]; @@ -122,7 +122,7 @@ - (void)_constructBars { id stacks = [NSMutableArray arrayWithCapacity:stackCount]; for (NSInteger sIdx = 0; sIdx < stackCount; sIdx++) { - GKBar *item = [GKBar create]; + GKStackedBar *item = [GKStackedBar create]; if ([self barColor]) item.foregroundColor = [self barColor]; [stacks addObject:item]; } @@ -133,7 +133,7 @@ - (void)_constructBars { - (void)_removeBars { [self.bars mk_each:^(NSArray *bar) { - [bar mk_each:^(GKBar *item) { + [bar mk_each:^(GKStackedBar *item) { [item removeFromSuperview]; }]; }]; @@ -144,7 +144,7 @@ - (void)_positionBars { [self.bars mk_each:^(NSArray *bar) { __block CGFloat y = [self _barStartY]; - [bar mk_each:^(GKBar *item) { + [bar mk_each:^(GKStackedBar *item) { item.frame = CGRectMake(x, y, _barWidth, _barHeight); [self addSubview:item]; y += 10; @@ -202,11 +202,11 @@ - (void)_removeLabels { - (void)_positionLabels { __block NSInteger idx = 0; - [self.bars mk_each:^(GKBar *bar) { + [self.bars mk_each:^(GKStackedBar *bar) { }]; [self.bars mk_each:^(NSArray *bar) { - GKBar *firstStack = bar[0]; + GKStackedBar *firstStack = bar[0]; CGFloat labelWidth = kDefaultLabelWidth; CGFloat labelHeight = kDefaultLabelHeight; CGFloat startX = firstStack.x - ((labelWidth - self.barWidth) / 2); @@ -218,7 +218,7 @@ - (void)_positionLabels { [self addSubview:label]; - [bar mk_each:^(GKBar *item) { + [bar mk_each:^(GKStackedBar *item) { item.y -= labelHeight + 5; }]; @@ -231,7 +231,7 @@ - (void)_drawBars { id source = self.dataSource; [self.bars mk_each:^(NSArray *bar) { __block NSInteger sidx = 0; - [bar mk_each:^(GKBar *item) { + [bar mk_each:^(GKStackedBar *item) { if ([source respondsToSelector:@selector(animationDurationForBarAtIndex:)]) { item.animationDuration = [source animationDurationForBarAtIndex:idx]; @@ -254,7 +254,7 @@ - (void)_drawBars { - (void)reset { [self.bars mk_each:^(NSArray *bar) { - [bar mk_each:^(GKBar *item) { + [bar mk_each:^(GKStackedBar *item) { [item reset]; }]; }]; From 7e71d5814a9ca0deefca96b97f68e6ffc39d75f5 Mon Sep 17 00:00:00 2001 From: Erich Grunewald Date: Tue, 7 Apr 2015 22:23:48 +0200 Subject: [PATCH 3/7] Fix compilation errors and rewrite lots of things. --- Source/StackedBarGraph/GKStackedBar.m | 34 ++++-- Source/StackedBarGraph/GKStackedBarGraph.h | 2 +- Source/StackedBarGraph/GKStackedBarGraph.m | 134 +++++++++------------ 3 files changed, 78 insertions(+), 92 deletions(-) diff --git a/Source/StackedBarGraph/GKStackedBar.m b/Source/StackedBarGraph/GKStackedBar.m index 610f23e..1e5c876 100644 --- a/Source/StackedBarGraph/GKStackedBar.m +++ b/Source/StackedBarGraph/GKStackedBar.m @@ -69,7 +69,7 @@ - (void)_init { self.animationDuration = kDefaultAnimationDuration; self.clipsToBounds = YES; self.cornerRadius = 2.0; - self.foregroundColor = [UIColor gk_turquoiseColor]; + self.foregroundColors = [NSArray array]; self.backgroundColor = [UIColor gk_silverColor]; _percentages = [NSMutableArray array]; } @@ -81,7 +81,7 @@ - (void)setCornerRadius:(CGFloat)cornerRadius { - (void)setPercentages:(NSArray *)percentages animated:(BOOL)animated { self.animated = animated; - self.percentages = percentages; + self.percentages = [percentages mutableCopy]; self.animated = YES; } @@ -92,29 +92,37 @@ - (void)setPercentage:(CGFloat)percentage atIndex:(NSInteger)index animated:(BOO } - (void)setPercentages:(NSArray *)percentages { - [self.percentages enumerateObjectsUsingBlock:^(NSNumber *item, NSUInteger idx, BOOL *stop) { + if (_percentages.count < percentages.count) { + for (int i = 0; i < percentages.count; i++) { + [_percentages addObject:@0]; + } + } + + [percentages enumerateObjectsUsingBlock:^(NSNumber *item, NSUInteger idx, BOOL *stop) { CGFloat percentage = [item floatValue]; if (percentage == [_percentages[idx] floatValue]) return; if (percentage > 100) percentage = 100; if (percentage < 0) percentage = 0; if (self.animationInProgress) return; - + [self _progressBarTo:percentage atIndex:idx]; }]; - - _percentages = percentages; + + _percentages = [percentages mutableCopy]; } - (void)_progressBarTo:(CGFloat)value atIndex:(NSInteger)index { - + + NSLog(@"progress at %lu with nums: %f", index, value); + CGFloat converted = (value / 100); UIBezierPath *path = [self _bezierPathWith:converted atIndex:index]; - - CAShapeLayer *layer = [self _layerWithPath:path]; + + CAShapeLayer *layer = [self _layerWithPath:path atIndex:index]; if ([_percentages[index] floatValue] > value) layer.strokeColor = [self.backgroundColor CGColor]; - + [self.layer addSublayer:layer]; - + if (self.animated) { id animation = [self _animationWithKeyPath:@"strokeEnd"]; [layer addAnimation:animation forKey:@"strokeEndAnimation"]; @@ -137,7 +145,7 @@ - (CAShapeLayer *)_layerWithPath:(UIBezierPath *)path atIndex:(NSInteger)index { item.lineCap = kCALineCapButt; item.lineWidth = self.frame.size.width; item.path = path.CGPath; - item.strokeColor = [self.foregroundColor CGColor]; + item.strokeColor = [self.foregroundColors[index] CGColor]; item.strokeEnd = 1.0; return item; } @@ -162,7 +170,7 @@ - (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag { - (void)setForegroundColors:(NSArray *)foregroundColors { _foregroundColors = foregroundColors; - + self.layer.sublayers = nil; for (int i = 0; i < self.percentages.count; i++) { CGFloat temp = [_percentages[i] floatValue]; diff --git a/Source/StackedBarGraph/GKStackedBarGraph.h b/Source/StackedBarGraph/GKStackedBarGraph.h index aedcc9a..68822c2 100644 --- a/Source/StackedBarGraph/GKStackedBarGraph.h +++ b/Source/StackedBarGraph/GKStackedBarGraph.h @@ -37,7 +37,7 @@ @property (nonatomic, strong) NSArray *bars; @property (nonatomic, strong) NSArray *labels; -@property (nonatomic, strong) UIColor *barColor; +@property (nonatomic, strong) NSArray *barColors; @property (nonatomic, assign) CGFloat barHeight; @property (nonatomic, assign) CGFloat barWidth; diff --git a/Source/StackedBarGraph/GKStackedBarGraph.m b/Source/StackedBarGraph/GKStackedBarGraph.m index 9956dd2..251e59e 100644 --- a/Source/StackedBarGraph/GKStackedBarGraph.m +++ b/Source/StackedBarGraph/GKStackedBarGraph.m @@ -66,28 +66,22 @@ - (void)_init { - (void)setAnimated:(BOOL)animated { _animated = animated; - [self.bars mk_each:^(NSArray *bar) { - [bar mk_each:^(GKStackedBar *item) { - item.animated = animated; - }]; + [self.bars mk_each:^(GKStackedBar *item) { + item.animated = animated; }]; } - (void)setAnimationDuration:(CFTimeInterval)animationDuration { _animationDuration = animationDuration; - [self.bars mk_each:^(NSArray *bar) { - [bar mk_each:^(GKStackedBar *item) { - item.animationDuration = animationDuration; - }]; + [self.bars mk_each:^(GKStackedBar *item) { + item.animationDuration = animationDuration; }]; } -- (void)setBarColor:(UIColor *)color { - _barColor = color; - [self.bars mk_each:^(NSArray *bar) { - [bar mk_each:^(GKStackedBar *item) { - item.foregroundColor = color; - }]; +- (void)setBarColors:(NSArray *)barColors { + _barColors = barColors; + [self.bars mk_each:^(GKStackedBar *item) { + item.foregroundColors = barColors; }]; } @@ -98,13 +92,13 @@ - (void)draw { - (void)_construct { NSAssert(self.dataSource, @"GKStackedBarGraph : No data source is assigned."); - + if ([self _hasBars]) [self _removeBars]; if ([self _hasLabels]) [self _removeLabels]; - + [self _constructBars]; [self _constructLabels]; - + [self _positionBars]; [self _positionLabels]; } @@ -115,40 +109,28 @@ - (BOOL)_hasBars { - (void)_constructBars { NSInteger barCount = [self.dataSource numberOfBars]; - NSInteger stackCount = [self.dataSource numberOfStacks]; - id bars = [NSMutableArray arrayWithCapacity:barCount]; for (NSInteger idx = 0; idx < barCount; idx++) { - - id stacks = [NSMutableArray arrayWithCapacity:stackCount]; - for (NSInteger sIdx = 0; sIdx < stackCount; sIdx++) { - GKStackedBar *item = [GKStackedBar create]; - if ([self barColor]) item.foregroundColor = [self barColor]; - [stacks addObject:item]; - } - [bars addObject:stacks]; + GKStackedBar *item = [GKStackedBar create]; + if ([self barColors]) item.foregroundColors = [self barColors]; + [bars addObject:item]; } self.bars = bars; } - (void)_removeBars { - [self.bars mk_each:^(NSArray *bar) { - [bar mk_each:^(GKStackedBar *item) { - [item removeFromSuperview]; - }]; + [self.bars mk_each:^(GKStackedBar *item) { + [item removeFromSuperview]; }]; } - (void)_positionBars { + CGFloat y = [self _barStartY]; + __block CGFloat x = [self _barStartX]; - [self.bars mk_each:^(NSArray *bar) { - __block CGFloat y = [self _barStartY]; - - [bar mk_each:^(GKStackedBar *item) { - item.frame = CGRectMake(x, y, _barWidth, _barHeight); - [self addSubview:item]; - y += 10; - }]; + [self.bars mk_each:^(GKStackedBar *item) { + item.frame = CGRectMake(x, y, _barWidth, _barHeight); + [self addSubview:item]; x += [self _barSpace]; }]; } @@ -157,7 +139,7 @@ - (CGFloat)_barStartX { CGFloat result = self.width; CGFloat item = [self _barSpace]; NSInteger count = [self.dataSource numberOfBars]; - + result = result - (item * count) + self.marginBar; result = (result / 2); return result; @@ -176,18 +158,18 @@ - (BOOL)_hasLabels { } - (void)_constructLabels { - + NSInteger count = [self.dataSource numberOfBars]; id items = [NSMutableArray arrayWithCapacity:count]; for (NSInteger idx = 0; idx < count; idx++) { - + CGRect frame = CGRectMake(0, 0, kDefaultLabelWidth, kDefaultLabelHeight); UILabel *item = [[UILabel alloc] initWithFrame:frame]; item.textAlignment = NSTextAlignmentCenter; item.font = [UIFont boldSystemFontOfSize:13]; item.textColor = [UIColor lightGrayColor]; item.text = [self.dataSource titleForBarAtIndex:idx]; - + [items addObject:item]; } self.labels = items; @@ -200,28 +182,22 @@ - (void)_removeLabels { } - (void)_positionLabels { - + __block NSInteger idx = 0; [self.bars mk_each:^(GKStackedBar *bar) { - - }]; - [self.bars mk_each:^(NSArray *bar) { - GKStackedBar *firstStack = bar[0]; + CGFloat labelWidth = kDefaultLabelWidth; CGFloat labelHeight = kDefaultLabelHeight; - CGFloat startX = firstStack.x - ((labelWidth - self.barWidth) / 2); + CGFloat startX = bar.x - ((labelWidth - self.barWidth) / 2); CGFloat startY = (self.height - labelHeight); - + UILabel *label = [self.labels objectAtIndex:idx]; label.x = startX; label.y = startY; - + [self addSubview:label]; - - [bar mk_each:^(GKStackedBar *item) { - item.y -= labelHeight + 5; - }]; - + + bar.y -= labelHeight + 5; idx++; }]; } @@ -229,34 +205,36 @@ - (void)_positionLabels { - (void)_drawBars { __block NSInteger idx = 0; id source = self.dataSource; - [self.bars mk_each:^(NSArray *bar) { - __block NSInteger sidx = 0; - [bar mk_each:^(GKStackedBar *item) { - - if ([source respondsToSelector:@selector(animationDurationForBarAtIndex:)]) { - item.animationDuration = [source animationDurationForBarAtIndex:idx]; - } - - if ([source respondsToSelector:@selector(colorForBarAtIndex:stack:)]) { - item.foregroundColor = [source colorForBarAtIndex:idx stack:sidx]; - } - - if ([source respondsToSelector:@selector(colorForBarBackgroundAtIndex:)]) { - item.backgroundColor = [source colorForBarBackgroundAtIndex:idx]; + [self.bars mk_each:^(GKStackedBar *item) { + + if ([source respondsToSelector:@selector(animationDurationForBarAtIndex:)]) { + item.animationDuration = [source animationDurationForBarAtIndex:idx]; + } + + if ([source respondsToSelector:@selector(colorForBarAtIndex:stack:)]) { + NSMutableArray *colors = [NSMutableArray array]; + for (int i = 0; i < [self.dataSource numberOfStacks]; i++) { + [colors addObject:[source colorForBarAtIndex:idx stack:i]]; } - - item.percentage = [[source valueForBarAtIndex:idx stack:sidx] doubleValue]; - sidx++; - }]; + item.foregroundColors = colors; + } + + if ([source respondsToSelector:@selector(colorForBarBackgroundAtIndex:)]) { + item.backgroundColor = [source colorForBarBackgroundAtIndex:idx]; + } + + NSMutableArray *percentages = [NSMutableArray array]; + for (int i = 0; i < [self.dataSource numberOfStacks]; i++) { + [percentages addObject:[source valueForBarAtIndex:idx stack:i]]; + } + item.percentages = percentages; idx++; }]; } - (void)reset { - [self.bars mk_each:^(NSArray *bar) { - [bar mk_each:^(GKStackedBar *item) { - [item reset]; - }]; + [self.bars mk_each:^(GKStackedBar *item) { + [item reset]; }]; } From 857192381d92808cc78b04eee9149da93b762431 Mon Sep 17 00:00:00 2001 From: Erich Grunewald Date: Wed, 8 Apr 2015 09:46:31 +0200 Subject: [PATCH 4/7] Fix GKStackedBar so that it actually works. --- Source/StackedBarGraph/GKStackedBar.m | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Source/StackedBarGraph/GKStackedBar.m b/Source/StackedBarGraph/GKStackedBar.m index 1e5c876..e1f5d88 100644 --- a/Source/StackedBarGraph/GKStackedBar.m +++ b/Source/StackedBarGraph/GKStackedBar.m @@ -98,6 +98,7 @@ - (void)setPercentages:(NSArray *)percentages { } } + __block CGFloat sum = 0; [percentages enumerateObjectsUsingBlock:^(NSNumber *item, NSUInteger idx, BOOL *stop) { CGFloat percentage = [item floatValue]; if (percentage == [_percentages[idx] floatValue]) return; @@ -105,18 +106,17 @@ - (void)setPercentages:(NSArray *)percentages { if (percentage < 0) percentage = 0; if (self.animationInProgress) return; - [self _progressBarTo:percentage atIndex:idx]; + [self _progressBarFrom:sum value:percentage atIndex:idx]; + sum += percentage; }]; _percentages = [percentages mutableCopy]; } -- (void)_progressBarTo:(CGFloat)value atIndex:(NSInteger)index { - - NSLog(@"progress at %lu with nums: %f", index, value); - +- (void)_progressBarFrom:(CGFloat)from value:(CGFloat)value atIndex:(NSInteger)index { + CGFloat fromConverted = (from / 100); CGFloat converted = (value / 100); - UIBezierPath *path = [self _bezierPathWith:converted atIndex:index]; + UIBezierPath *path = [self _bezierPathWithStart:fromConverted value:converted atIndex:index]; CAShapeLayer *layer = [self _layerWithPath:path atIndex:index]; if ([_percentages[index] floatValue] > value) layer.strokeColor = [self.backgroundColor CGColor]; @@ -129,11 +129,12 @@ - (void)_progressBarTo:(CGFloat)value atIndex:(NSInteger)index { } } -- (UIBezierPath *)_bezierPathWith:(CGFloat)value atIndex:(NSInteger)index { +- (UIBezierPath *)_bezierPathWithStart:(CGFloat)start value:(CGFloat)value atIndex:(NSInteger)index { UIBezierPath *path = [UIBezierPath bezierPath]; CGFloat startX = (self.frame.size.width / 2); - CGFloat startY = (self.frame.size.height * (1 - ([_percentages[index] floatValue] / 100))); - CGFloat endY = (self.frame.size.height * (1 - value)); + CGFloat previousStackEndY = self.frame.size.height * start; + CGFloat startY = (self.frame.size.height * (1 - ([_percentages[index] floatValue] / 100)) - previousStackEndY); + CGFloat endY = (self.frame.size.height * (1 - value) - previousStackEndY); [path moveToPoint:CGPointMake(startX, startY)]; [path addLineToPoint:CGPointMake(startX, endY)]; return path; From 061bbfeac0ff8451edac518f9a74639810e3b520 Mon Sep 17 00:00:00 2001 From: Erich Grunewald Date: Wed, 8 Apr 2015 10:10:31 +0200 Subject: [PATCH 5/7] Fix default bar colours. --- Source/StackedBarGraph/GKStackedBar.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/StackedBarGraph/GKStackedBar.m b/Source/StackedBarGraph/GKStackedBar.m index e1f5d88..bb660a0 100644 --- a/Source/StackedBarGraph/GKStackedBar.m +++ b/Source/StackedBarGraph/GKStackedBar.m @@ -69,7 +69,7 @@ - (void)_init { self.animationDuration = kDefaultAnimationDuration; self.clipsToBounds = YES; self.cornerRadius = 2.0; - self.foregroundColors = [NSArray array]; + self.foregroundColors = @[[UIColor gk_alizarinColor], [UIColor gk_emerlandColor], [UIColor gk_peterRiverColor]]; self.backgroundColor = [UIColor gk_silverColor]; _percentages = [NSMutableArray array]; } @@ -146,7 +146,7 @@ - (CAShapeLayer *)_layerWithPath:(UIBezierPath *)path atIndex:(NSInteger)index { item.lineCap = kCALineCapButt; item.lineWidth = self.frame.size.width; item.path = path.CGPath; - item.strokeColor = [self.foregroundColors[index] CGColor]; + item.strokeColor = [self.foregroundColors[index % (self.foregroundColors.count)] CGColor]; item.strokeEnd = 1.0; return item; } From 9c72f5471a418a53112471cbf27380ec599f6dd6 Mon Sep 17 00:00:00 2001 From: Erich Grunewald Date: Mon, 27 Apr 2015 16:24:49 +0200 Subject: [PATCH 6/7] Fix a bug with setting foreground colors. --- Source/StackedBarGraph/GKStackedBar.h | 1 - Source/StackedBarGraph/GKStackedBar.m | 22 ++++++++++------------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/Source/StackedBarGraph/GKStackedBar.h b/Source/StackedBarGraph/GKStackedBar.h index 0daf52a..02c91d0 100644 --- a/Source/StackedBarGraph/GKStackedBar.h +++ b/Source/StackedBarGraph/GKStackedBar.h @@ -39,7 +39,6 @@ @property (nonatomic, strong) NSArray *foregroundColors; - (void)setPercentages:(NSArray *)percentages animated:(BOOL)animated; -- (void)setPercentage:(CGFloat)percentage atIndex:(NSInteger)index animated:(BOOL)animated; - (void)reset; diff --git a/Source/StackedBarGraph/GKStackedBar.m b/Source/StackedBarGraph/GKStackedBar.m index bb660a0..b922cbc 100644 --- a/Source/StackedBarGraph/GKStackedBar.m +++ b/Source/StackedBarGraph/GKStackedBar.m @@ -85,12 +85,6 @@ - (void)setPercentages:(NSArray *)percentages animated:(BOOL)animated { self.animated = YES; } -- (void)setPercentage:(CGFloat)percentage atIndex:(NSInteger)index animated:(BOOL)animated { - self.animated = animated; - self.percentages[index] = @(percentage); - self.animated = YES; -} - - (void)setPercentages:(NSArray *)percentages { if (_percentages.count < percentages.count) { for (int i = 0; i < percentages.count; i++) { @@ -173,11 +167,9 @@ - (void)setForegroundColors:(NSArray *)foregroundColors { _foregroundColors = foregroundColors; self.layer.sublayers = nil; - for (int i = 0; i < self.percentages.count; i++) { - CGFloat temp = [_percentages[i] floatValue]; - [self setPercentage:0 atIndex:i animated:NO]; - [self setPercentage:temp atIndex:i animated:NO]; - } + NSMutableArray *temp = [_percentages copy]; + [self setPercentages:[self zeroes] animated:NO]; + [self setPercentages:temp animated:NO]; } - (void)reset { @@ -191,9 +183,15 @@ - (void)reset { } completion:^(BOOL finished) { self.layer.sublayers = nil; }]; + self.percentages = [self zeroes]; +} + +- (NSMutableArray *)zeroes { + NSMutableArray *zeros = [NSMutableArray array]; for (int i = 0; i < self.percentages.count; i++) { - self.percentages[i] = @0; + [zeros addObject:@0]; } + return zeros; } @end From 0264e63c0a7b5e655e447c350806507993bd72ba Mon Sep 17 00:00:00 2001 From: Erich Grunewald Date: Mon, 27 Apr 2015 16:25:07 +0200 Subject: [PATCH 7/7] Add stacked bar graph example. --- GraphKit/Example/ExampleListVC.m | 6 +- GraphKit/Example/ExampleListVC.xib | 12 ++- GraphKit/Example/ExampleStackedBarGraphVC.h | 26 +++++ GraphKit/Example/ExampleStackedBarGraphVC.m | 102 ++++++++++++++++++ GraphKit/Example/ExampleStackedBarGraphVC.xib | 64 +++++++++++ GraphKit/GraphKit.xcodeproj/project.pbxproj | 16 ++- 6 files changed, 218 insertions(+), 8 deletions(-) create mode 100644 GraphKit/Example/ExampleStackedBarGraphVC.h create mode 100644 GraphKit/Example/ExampleStackedBarGraphVC.m create mode 100644 GraphKit/Example/ExampleStackedBarGraphVC.xib diff --git a/GraphKit/Example/ExampleListVC.m b/GraphKit/Example/ExampleListVC.m index 67d327e..84a8ed3 100644 --- a/GraphKit/Example/ExampleListVC.m +++ b/GraphKit/Example/ExampleListVC.m @@ -10,6 +10,7 @@ #import "ExampleBarVC.h" #import "ExampleBarGraphVC.h" +#import "ExampleStackedBarGraphVC.h" #import "ExampleLineGraph.h" #import "UIColor+GraphKit.h" @@ -26,7 +27,7 @@ - (void)viewDidLoad { self.title = @"GraphKit"; self.view.backgroundColor = [UIColor gk_cloudsColor]; - self.data = @[@"Bar", @"Bar Graph", @"Line Graph"]; + self.data = @[@"Bar", @"Bar Graph", @"Stacked Bar Graph", @"Line Graph"]; [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cellID"]; @@ -53,6 +54,9 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath vc = [[ExampleBarGraphVC alloc] initWithNibName:@"ExampleBarGraphVC" bundle:nil]; break; case 2: + vc = [[ExampleStackedBarGraphVC alloc] initWithNibName:@"ExampleStackedBarGraphVC" bundle:nil]; + break; + case 3: vc = [[ExampleLineGraph alloc] initWithNibName:@"ExampleLineGraph" bundle:nil]; break; default: diff --git a/GraphKit/Example/ExampleListVC.xib b/GraphKit/Example/ExampleListVC.xib index cd1b654..ae2a7d5 100644 --- a/GraphKit/Example/ExampleListVC.xib +++ b/GraphKit/Example/ExampleListVC.xib @@ -1,7 +1,8 @@ - + - + + @@ -26,9 +27,12 @@ - - + + + + + diff --git a/GraphKit/Example/ExampleStackedBarGraphVC.h b/GraphKit/Example/ExampleStackedBarGraphVC.h new file mode 100644 index 0000000..2a3b894 --- /dev/null +++ b/GraphKit/Example/ExampleStackedBarGraphVC.h @@ -0,0 +1,26 @@ +// +// ExampleStackedBarGraphVC.h +// GraphKit +// +// Created by Erich Grunewald on 27/04/15. +// Copyright (c) 2015 Michal Konturek. All rights reserved. +// + +#import + +#import "GraphKit.h" + +@interface ExampleStackedBarGraphVC : UIViewController + +@property (nonatomic, weak) IBOutlet GKStackedBarGraph *graphView; + +@property (nonatomic, strong) NSArray *data; +@property (nonatomic, strong) NSArray *labels; + +- (IBAction)onButtonFill:(id)sender; + +- (IBAction)onButtonChange:(id)sender; + +- (IBAction)onButtonReset:(id)sender; + +@end diff --git a/GraphKit/Example/ExampleStackedBarGraphVC.m b/GraphKit/Example/ExampleStackedBarGraphVC.m new file mode 100644 index 0000000..b3ca648 --- /dev/null +++ b/GraphKit/Example/ExampleStackedBarGraphVC.m @@ -0,0 +1,102 @@ +// +// ExampleStackedBarGraphVC.m +// GraphKit +// +// Created by Erich Grunewald on 27/04/15. +// Copyright (c) 2015 Michal Konturek. All rights reserved. +// + +#import "ExampleStackedBarGraphVC.h" + +#import "UIViewController+BButton.h" + +@interface ExampleStackedBarGraphVC () + +@property (nonatomic, strong) NSArray *colors; +@property (nonatomic, assign) BOOL warmColors; + +@end + +@implementation ExampleStackedBarGraphVC + +- (void)viewDidLoad { + [super viewDidLoad]; + self.edgesForExtendedLayout = UIRectEdgeNone; + + [self setupButtons]; + + self.view.backgroundColor = [UIColor gk_cloudsColor]; + + self.data = @[@[@11, @14, @49, @12], + @[@25, @4, @8, @8], + @[@7, @38, @17, @28], + @[@28, @5, @8, @59]]; + self.labels = @[@"DE", @"PL", @"CN", @"JP"]; + + self.colors = @[@[[UIColor gk_midnightBlueColor], + [UIColor gk_wisteriaColor], + [UIColor gk_peterRiverColor], + [UIColor gk_emerlandColor] + ], + @[[UIColor gk_pomegranateColor], + [UIColor gk_alizarinColor], + [UIColor gk_sunflowerColor], + [UIColor gk_amethystColor] + ]]; + + self.graphView.dataSource = self; + + [self.graphView draw]; + + self.warmColors = NO; +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +- (IBAction)onButtonFill:(id)sender { + [self.graphView draw]; +} + +- (IBAction)onButtonChange:(id)sender { + self.warmColors = !self.warmColors; + self.graphView.barColors = self.colors[self.warmColors]; +} + +- (IBAction)onButtonReset:(id)sender { + [self.graphView reset]; +} + + +#pragma mark - GKStackedBarGraphDataSource + +- (NSInteger)numberOfBars { + return [self.data count]; +} + +- (NSInteger)numberOfStacks { + return [[self.data firstObject] count]; +} + +- (NSNumber *)valueForBarAtIndex:(NSInteger)index stack:(NSInteger)stack { + return self.data[index][stack]; +} + +- (UIColor *)colorForBarAtIndex:(NSInteger)index stack:(NSInteger)stack { + return self.colors[0][stack]; +} + +- (NSString *)titleForBarAtIndex:(NSInteger)index { + return self.labels[index]; +} + +- (CFTimeInterval)animationDurationForBarAtIndex:(NSInteger)index { + id barValues = self.data[index]; + CGFloat percentage = [[barValues valueForKeyPath:@"@sum.self"] doubleValue]; + percentage = (percentage / 100); + return (self.graphView.animationDuration * percentage); +} + +@end diff --git a/GraphKit/Example/ExampleStackedBarGraphVC.xib b/GraphKit/Example/ExampleStackedBarGraphVC.xib new file mode 100644 index 0000000..2a49566 --- /dev/null +++ b/GraphKit/Example/ExampleStackedBarGraphVC.xib @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/GraphKit/GraphKit.xcodeproj/project.pbxproj b/GraphKit/GraphKit.xcodeproj/project.pbxproj index 2855274..0c873ae 100644 --- a/GraphKit/GraphKit.xcodeproj/project.pbxproj +++ b/GraphKit/GraphKit.xcodeproj/project.pbxproj @@ -35,6 +35,8 @@ 973F4746059343C9A462AA2D /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 74E12B5B49644056930176BC /* libPods.a */; }; FC41ADBA1AD436D600F7D9C0 /* GKStackedBarGraph.m in Sources */ = {isa = PBXBuildFile; fileRef = FC41ADB91AD436D600F7D9C0 /* GKStackedBarGraph.m */; }; FC41ADBD1AD436EE00F7D9C0 /* GKStackedBar.m in Sources */ = {isa = PBXBuildFile; fileRef = FC41ADBC1AD436EE00F7D9C0 /* GKStackedBar.m */; }; + FC9B45D51AEE6B2A00688D83 /* ExampleStackedBarGraphVC.m in Sources */ = {isa = PBXBuildFile; fileRef = FC9B45D31AEE6B2A00688D83 /* ExampleStackedBarGraphVC.m */; }; + FC9B45D61AEE6B2A00688D83 /* ExampleStackedBarGraphVC.xib in Resources */ = {isa = PBXBuildFile; fileRef = FC9B45D41AEE6B2A00688D83 /* ExampleStackedBarGraphVC.xib */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -94,6 +96,9 @@ FC41ADB91AD436D600F7D9C0 /* GKStackedBarGraph.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GKStackedBarGraph.m; path = StackedBarGraph/GKStackedBarGraph.m; sourceTree = ""; }; FC41ADBB1AD436EE00F7D9C0 /* GKStackedBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GKStackedBar.h; path = StackedBarGraph/GKStackedBar.h; sourceTree = ""; }; FC41ADBC1AD436EE00F7D9C0 /* GKStackedBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GKStackedBar.m; path = StackedBarGraph/GKStackedBar.m; sourceTree = ""; }; + FC9B45D21AEE6B2A00688D83 /* ExampleStackedBarGraphVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExampleStackedBarGraphVC.h; sourceTree = ""; }; + FC9B45D31AEE6B2A00688D83 /* ExampleStackedBarGraphVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ExampleStackedBarGraphVC.m; sourceTree = ""; }; + FC9B45D41AEE6B2A00688D83 /* ExampleStackedBarGraphVC.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ExampleStackedBarGraphVC.xib; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -223,18 +228,21 @@ 84654C4D18FE932A00160F11 /* Example */ = { isa = PBXGroup; children = ( - 84F0E98B1902B30C00FA4810 /* ExampleListVC.h */, - 84F0E98C1902B30C00FA4810 /* ExampleListVC.m */, - 84F0E98D1902B30C00FA4810 /* ExampleListVC.xib */, 84654C4E18FE934800160F11 /* ExampleBarVC.h */, 84654C4F18FE934800160F11 /* ExampleBarVC.m */, 84654C5018FE934800160F11 /* ExampleBarVC.xib */, 84654C5618FF4C8300160F11 /* ExampleBarGraphVC.h */, 84654C5718FF4C8300160F11 /* ExampleBarGraphVC.m */, 84654C5818FF4C8300160F11 /* ExampleBarGraphVC.xib */, + FC9B45D21AEE6B2A00688D83 /* ExampleStackedBarGraphVC.h */, + FC9B45D31AEE6B2A00688D83 /* ExampleStackedBarGraphVC.m */, + FC9B45D41AEE6B2A00688D83 /* ExampleStackedBarGraphVC.xib */, 8472591B1904AA4F00819664 /* ExampleLineGraph.h */, 8472591C1904AA4F00819664 /* ExampleLineGraph.m */, 8472591D1904AA4F00819664 /* ExampleLineGraph.xib */, + 84F0E98B1902B30C00FA4810 /* ExampleListVC.h */, + 84F0E98C1902B30C00FA4810 /* ExampleListVC.m */, + 84F0E98D1902B30C00FA4810 /* ExampleListVC.xib */, 8472592D1905D63500819664 /* UIViewController+BButton.h */, 8472592E1905D63500819664 /* UIViewController+BButton.m */, ); @@ -351,6 +359,7 @@ 84654C2618FE8EE300160F11 /* Images.xcassets in Resources */, 84654C5A18FF4C8300160F11 /* ExampleBarGraphVC.xib in Resources */, 84F0E98F1902B30C00FA4810 /* ExampleListVC.xib in Resources */, + FC9B45D61AEE6B2A00688D83 /* ExampleStackedBarGraphVC.xib in Resources */, 84654C5218FE934800160F11 /* ExampleBarVC.xib in Resources */, 8472591F1904AA4F00819664 /* ExampleLineGraph.xib in Resources */, ); @@ -412,6 +421,7 @@ 84654C5918FF4C8300160F11 /* ExampleBarGraphVC.m in Sources */, 8472591E1904AA4F00819664 /* ExampleLineGraph.m in Sources */, FC41ADBD1AD436EE00F7D9C0 /* GKStackedBar.m in Sources */, + FC9B45D51AEE6B2A00688D83 /* ExampleStackedBarGraphVC.m in Sources */, 84654C4C18FE909A00160F11 /* GKBar.m in Sources */, 84654C2018FE8EE300160F11 /* main.m in Sources */, 84F0E98E1902B30C00FA4810 /* ExampleListVC.m in Sources */,