I’m having difficulty determining the easiest method of placing the legend outside of the chart surface in iOS. I’ve done a ton of trial and error and have run into several issues. I understand that the SCIChartLegend class is just a subclass of UICollectionView. The problem seems to be these two things:
— When adding a legend via SCILegendModifier it only allows for custom placement if using SCILegendModifier’s initializer which also requires you assign an SCILegendDataSource. Or at least that’s required for the initializer with the useAutoPlacement parameter that I can then set to false (not even sure if that would work once I got that far).
— Placing the SCIChartLegend view manually without first initializing an SCILegendModifier with it results in none of the legend cells being loaded. I would imagine this is due to a missing SCILegendDataSource.
It seems like these could be overcome if I could somehow construct a default instance of SCILegendDataSource. Unfortunately, SCILegendDataSource only exposes one initializer which requires I pass it a xib name for the legend items. But I do not want to customize the legend items- I simply want to be able to construct the default SCILegendDataSource because that is apparently required to get the SCIChartLegend working.
Am I making this more complicated than it needs to be? What’s the simplest path to placing the chart legend where I want in iOS?
The issue should be fixed now.
And using the latest nightly build its possible to place a legend outside the chart.
To achieve this, you need:
1) Create legend using default constructor [SCIChartLegend new];
2) Create modifier using -initWithLegend: constructor (It will create a default datasource and auto placement will be disabled)
3) Place, the legend wherever you want
4) Handle the place where layout is happening and update legend size according to content size)
I’m attaching you an example, it was created using objective-c, but the idea is similar for all the languages. If you still need a Swift or Xamarin example, just let me know.
Please, let me know if you still facing any issues.
iOS SciChart developer.
Please login first to submit.