Swift : Set content inside legend in Shinobi Donut


I want to know how to set (everything) inside the legend. For example i want to set width between text legend and it symbol in order to make them one line :

I try this but its not work :

func sChart(_ chart: ShinobiChart, seriesAt index: Int) -> SChartSeries {
    let chartSeries = SChartDonutSeries()
    let legend = SChartLegendSymbolDonutSeries()
    legend.layoutMargins = UIEdgeInsets(top: 1, left: 1, bottom: 1, right: 1)
//        let legend = SChartLegend()

//        legend.style.marginWidth = 1
//        legend.style.horizontalPadding = 1
//        legend.style.symbolAlignment = .alignSymbolsLeft
//        legend.style.borderColor = UIColor.blue

I have read this too. Any suggest will help for me. Thanks in Advance


Hi MrX,

Try something like this:

chart.legend.position = .bottomMiddle
chart.legend.placement = .outsidePlotArea
chart.legend.maxSeriesPerLine = data.count

(where data.count is the number of data points)

Setting the legend placement to be outside the plot area gives it more space to lay everything out horizontally, and maxSeriesPerLine tells the legend how many items it can fit on a single line.

Once you’ve got everything on one line you can change the properties of legend.style to adjust the padding/positioning etc inside the legend.


Hi aclarke,

Thanks, its work with chart.legend.style.horizontalPadding = 0

Regards MrX.