- Use
Carthage
cd
to your project, and create a file named Cartfile
, and fill follow contents:
github "yutingLei/EasyRadian" "master"
then:
$ carthage update
Init with ERView
, and constructure DrawsInfo
.
let frame = CGRect(x: 0, y: 64, width: view.frame.width, height: view.frame.height - 128)
let drawsInfo = [["type": "华为", "percent": "35%"],
["type": "OPPO", "percent": "20%"],
["type": "vivo", "percent": "25%"],
["type": "小米", "percent": "5%"],
["type": "苹果", "percent": "5%"],
["type": "三星", "percent": "5%"],
["type": "金立", "percent": "5%"]]
let erView = ERView(frame: frame, drawsInfo: drawsInfo)
and then, add erView
to the contentView that you want to show in.
if let erView = erView {
view.addSubview(erView)
}
there is nothing at present, you should config some properties.
property | type | description |
---|---|---|
drawRule |
enum | padding , fill , see below. |
showShadow |
bool | Graphic radian view with shadow. default true |
showPercentInRadian |
bool | Show the percent string in the erView , default true |
titleText |
string | The view's title. optional |
titleLabel |
UILabel | The view's title label, get only |
showDigest |
bool | Show the digest |
digestKey |
string | The key that get the digest's value |
digestLoc |
enum | Where the digest should to graphic |
percentKey |
string | The key that get the percent's value |
drawsInfo |
array.of(object/number) | The infos that will be graphic |
colors |
array.of(UIColor) | Every radian's color. optional |
show3DEffect |
bool | 3D effect |
allowHistogram |
bool | Support chart, default true |
isHistogramFirst |
bool | Show chart view first. |
if you set colors
with nil
. graphic with random color.
for example:
// erView.drawRule = .fill // default is fill, so you needn't set it.
erView.drawRule = .padding
erView.titleText = "2017年8月中国手机市场份额"
erView.digestLoc = .top
erView.digestKey = "type"
erView.percentKey = "percent"
erView.showShadow = false
you must invoke startDraw()
method.
erView.startDraw()
showShadow
: true
or false
drawRule
: .padding
, .fill
digestLoc
: top
left
right
bottom
show3DEffect
(ignore drawRule
)
The result of charts: