ios - Swift set image to center of pie chart -


now use pie chart charts

i want add image center of chart instead of pie chart.

image

what should do?

code

func updatepiechart(){     let track = ["", ""]     let money = [65, 45]     var entries = [piechartdataentry]()     (index, value) in money.enumerated() {         let entry = piechartdataentry()         entry.y = double(value)         entry.label = track[index]         entries.append( entry)     }     let set = piechartdataset( values: entries, label: "pie chart")     var colors: [uicolor] = []      _ in 0..<money.count {         let red = double(arc4random_uniform(256))         let green = double(arc4random_uniform(256))         let blue = double(arc4random_uniform(256))         let color = uicolor(red: cgfloat(red/255), green: cgfloat(green/255), blue: cgfloat(blue/255), alpha: 1)         colors.append(color)     }     set.colors = colors     let data = piechartdata(dataset: set)     pieview.data = data     pieview.nodatatext = "no data available"     // user interaction     pieview.isuserinteractionenabled = true      let d = description()     d.text = "ioscharts.io"     pieview.chartdescription = d     pieview.centertext = "pie chart"     pieview.holeradiuspercent = 0.9     pieview.transparentcirclecolor = uicolor.clear     pieview.holeradiuspercent = 0.65     pieview.transparentcircleradiuspercent = 0     pieview.legend.enabled = false     pieview.chartdescription?.enabled = false 

please try :

let attachment = nstextattachment() attachment.image = uiimage(named: "your image") let attachmentstring = nsattributedstring(attachment: attachment) let labelimg = nsmutableattributedstring(string: "") labelimg.append(attachmentstring)  piechartview.centerattributedtext = labelimg 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -