Pre loader

Custom legend


I managed to implement a chart legend with a custom datasource (using just a SCIChartLegend object as a subview, not SCILegendModifier). However, I am unable to place the legend at specified position, it always snaps to upper-left corner of the screen. When creating a SCIChartLegend instance using the initializer that takes a Rect as a parameter, but not supplying a custom datasource, it draws correctly according to offsets specified by the supplied rect’s X and Y. It does respond to changes in the legendPosition property, but it still doesn’t allow to draw the view with any margins (which is what I’m actually trying to achieve).

  • You must to post comments

Hello, Radoslaw.
By default legend layout positions legend according to legendPosition property, and resizes to fit all the content.
However when you create a legend, you can use

- (instancetype)initWithLegend:(SCIChartLegend *)legend dataSource:(SCILegendDataSource *)dataSource useAutoPlacement:(BOOL)useAutoPlacement;

constructor, and pass useAutoPlacvement flag NO, to have a full control on the legend position. Also legend is a UICollectionView subclass, so you can use all the UICollectionView features, like custom layout etc.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies