SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components
Hi guys,
I have some troubles with piecharts in swift. I want to provide custom labels outside of the piecharts segments. I found a screenshot of a nested piechart attached to an issue in your issue tracker. Thats what I want to do in swift, but I couldn’t find out a way to do so. Could you please provide an example code?
Thanks a lot in advance!
Alex
Hi, Alexander.
The easiest way to achieve this without overriding the drawing engine is to add second donut series with clear color and the same segments as your pieSeries has.
let pieSeries = SCIPieRenderableSeries()
pieSeries.segmentsCollection.add(segmentWithValue(segmentValue: 40, title: "Green", centerColor: 0xff84BC3D, edgeColor: 0xff5B8829))
let donutSeries = SCIDonutRenderableSeries()
donutSeries.segmentsCollection.add(segmentWithValue(segmentValue: 40, title: "Green", centerColor: 0x00000000, edgeColor: 0x00000000))
surface.renderableSeries.add(pieSeries)
surface.renderableSeries.add(donutSeries)
surface.seriesSpacing = 0
pieSeries.drawLabels = false
func segmentWithValue(segmentValue: Double, title: String, centerColor: UInt32, edgeColor: UInt32) -> SCIPieSegment {
let segment = SCIPieSegment()
segment.value = segmentValue
segment.title = title
segment.fillStyle = SCIRadialGradientBrushStyle(centerColorCode: centerColor, edgeColorCode: edgeColor)
segment.titleStyle = SCIFontStyle(textColor: .white)
segment.strokeStyle = SCISolidPenStyle(color: .clear, thickness: 0)
return segment
}
I hope, that helped.
Cool post. I would like to share some equally useful information. There is a service auto essay writer where only professional writers work. They all have degrees and are always ready to help you with your studies.
Please login first to submit.