Pre loader

iOS - Placing Legend Outside Chart

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

Answered
1
0

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?

Version
2.2.2.2291
  • You must to post comments
Best Answer
2
0

Hello, Sean.
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.

Best Regards,
Andriy.
iOS SciChart developer.

  • 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