Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/VRGsoftUA/SMDiagramView
Diagram View for iOS
https://github.com/VRGsoftUA/SMDiagramView
diagram ios swift view
Last synced: 3 months ago
JSON representation
Diagram View for iOS
- Host: GitHub
- URL: https://github.com/VRGsoftUA/SMDiagramView
- Owner: VRGsoftUA
- License: apache-2.0
- Created: 2017-12-06T08:52:38.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-05-08T12:48:38.000Z (over 5 years ago)
- Last Synced: 2024-07-26T19:37:06.412Z (3 months ago)
- Topics: diagram, ios, swift, view
- Language: Objective-C
- Homepage: http://vrgsoft.net/
- Size: 1.77 MB
- Stars: 45
- Watchers: 6
- Forks: 12
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-ios - SMDiagramViewSwift - Meet cute and very flexibility library for iOS application for different data view in one circle diagram. (Charts)
- awesome-ios-star - SMDiagramViewSwift - Meet cute and very flexibility library for iOS application for different data view in one circle diagram. (Charts)
- fucking-awesome-ios - SMDiagramViewSwift - Meet cute and very flexibility library for iOS application for different data view in one circle diagram. (Charts)
- fucking-awesome-ios - SMDiagramViewSwift - Meet cute and very flexibility library for iOS application for different data view in one circle diagram. (Charts)
README
# SMDiagramViewSwift
Meet cute and very flexibility library for iOS application for different data view in one circle diagram. The opportunity of transformation of this sample make application interactive, colorful with wow-effect.
### [CocoaControls](https://www.cocoacontrols.com/controls/smdiagramview)
## Images
![](demo.gif)
![](demo.png)## Requirements
- Xcode 9
- iOS 9.x+
- Swift 4## Be sure to read all instructions carefully.
### Installing with [CocoaPods](https://cocoapods.org)
```ruby
use_frameworks!pod 'SMDiagramViewSwift', '~> 1.0'
```### Usage
Add a `UIView` instance in your .storyboard or .xib, set `SMDiagramView` class, connect `IBOutlet` and add `DataSource`
```swift
import SMDiagramViewSwiftclass ViewController: UIViewController, SMDiagramViewDataSource {
let dataSource = [1, 2, 3, 4, 5]
@IBOutlet weak var diagramView: SMDiagramView!
override func viewDidLoad() {
super.viewDidLoad()
diagramView.dataSource = self
}
}
```Setup `SMDiagramView` if need
```swift
override func viewDidLoad() {
super.viewDidLoad()
diagramView.dataSource = self
diagramView.minProportion = 0.1
diagramView.diagramViewMode = .arc // or .segment
diagramView.diagramOffset = .zero
diagramView.radiusOfSegments = 80.0
diagramView.radiusOfViews = 130.0
diagramView.arcWidth = 6.0 //Ignoring for SMDiagramViewMode.segment
diagramView.startAngle = -.pi/2
diagramView.endAngle = 2.0 * .pi - .pi/2.0
diagramView.colorOfSegments = .black
diagramView.viewsOffset = .zero
diagramView.separatorWidh = 1.0
public var separatorColor = .white
}
````DataSource` functions
```swift
//Required
func numberOfSegmentsIn(diagramView: SMDiagramView) -> Int {
return dataSource.count
}
//Optional
func diagramView(_ diagramView: SMDiagramView, proportionForSegmentAtIndex index: NSInteger) -> CGFloat {
return CGFloat(1/dataSource.count)
}
func diagramView(_ diagramView: SMDiagramView, colorForSegmentAtIndex index: NSInteger, angle: CGFloat) -> UIColor? {
return .black
}
func diagramView(_ diagramView: SMDiagramView, viewForSegmentAtIndex index: NSInteger, colorOfSegment color:UIColor?, angle: CGFloat) -> UIView? {
return UIView()
}
func diagramView(_ diagramView: SMDiagramView, offsetForView view: UIView?, atIndex index: NSInteger, angle: CGFloat) -> CGPoint {
return .zero
}
func diagramView(_ diagramView: SMDiagramView, radiusForView view: UIView?, atIndex index: NSInteger, radiusOfSegment radius: CGFloat, angle: CGFloat) -> CGFloat {
return 130.0
}
func diagramView(_ diagramView: SMDiagramView, radiusForSegmentAtIndex index: NSInteger, proportion: CGFloat, angle: CGFloat) -> CGFloat {
return 80.0
}
func diagramView(_ diagramView: SMDiagramView, lineWidthForSegmentAtIndex index: NSInteger, angle: CGFloat) -> CGFloat {
//not called for SMDiagramViewModeSegment
return 6.0
}
```## Compatibility
* IOS 9-11
## Changelog### Version: 1.0
* Initial Build
## Contributors
* Contributors and stars are welcome.
## License
Copyright 2017 VRG Soft
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.