How to customize SChartLegend


I want to customize SChartLegend. 

  • Add horizontal space between legend items.

  • Change corner radius of legend symbols.

I thought SChartLegendStyle.symbolCornerRadius would do for the first one, and SChartLegendStyle.horizontalPadding would make the second.

However, SChartLegendStyle.symbolCornerRadius does not take any effect.

SChartLegendStyle.horizontalPadding makes space inside legend item between symbol and text, but NOT space BETWEEN legend items.

Is there any way to achieve what I want?



Like you say - there’s currently no builtin way to customise those specifics parts of the legend layout, however this should be possible by creating your own subclass of the legend, assigning it to the chart.legend property, and subclassing the -drawLegend method. After invoking the superclass implementation, you can iterate through self.symbols and self.labels which will allow you to lay them out however you’d like.

Instead of using symbolCornerRadius, i’d trying setting the cornerRadius property instead - these relate to whether the legend draws the “old” or “new” symbols.

Hope this helps!