Position of the spokes in pie


#1

Hi,

I would like to position spokes in pie to be put “outside” of the pie.
My problem is that on top and bottom, spokes need to go out of the “box” of the chart view.
This lead to spokes be inverted and placed in wrong direction.

I placed

self.clipsToBounds = false self.canvas.clipsToBounds = false

My question is how to persuade chart to dray outside the bounds, or how to put padding around the chart.

Marko


#2

Hi Marko,

You can adjust the radius of the donut chart by setting donutSeries.outerRadius, and the length of the spokes by setting donutSeries.style().spokeStyle.length. Decreasing the outer radius and possibly also increasing the spoke length should give you the effect you’re looking for.

Alison


#3

Alison,

Thank you, this works. But in this scenario I need to pass the specific pixel radius. How to achieve that I only pass the padding and auto sizing is still working?


#4

You could achieve that by using the delegate’s sChartRenderStarted method to calculate the desired radius before the chart is drawn, e.g.

func sChartRenderStarted(_ chart: ShinobiChart, withFullRedraw fullRedraw: Bool) {
    donutSeries.outerRadius = 0.3 * min(chart.plotAreaFrame.size.width, chart.plotAreaFrame.size.height)
}

Alison