We’d like to customize the look of our legends. We have 4 legends displaying different data, but right now the only thing we can change is the Theme. Is there any way to customize the legend items, like add some icons, change the point marker shape and size, change the check box icon etc…
P.S.: I’m not a trial user. We have an iOS, Android and WPF licenses purchased.
Project info:
Xamarin.iOS
SciChart.iOS 2.2.2.854
- Lazar Nikolov asked 5 years ago
- Not sure how useful the answer will be to me, but I’m also wondering how to do this in native iOS.
- You must login to post comments
Hello, Lazar and Sean.
SCIChartLegend is a UICollectionView subclass and SCIChartDefaultLegendItem is a UICollectionViewCell subclass.
So to customize legend items you need:
Subclass SCIDefaultLegendItem (create your own xib customize according to your design assign outlets, just take into account properties and methods you have to override).
Create your legend object:
var legend = new SCIChartLegend();
Then create a legend datasource object (pass your xib name into constructor):
var legendDataSource = new SCILegendDataSource(legend, “YourLegendItem.xib”);
then create SCILegendModifier like this:
var legendModifier = new SCILegendModifier(legend, legendDataSource, true);
Thats it.
Let me know if any of these steps isn’t clear enough.
Regards,
Andriy,
- Andriy Shkinder answered 5 years ago
- Boo. I don’t suppose there’s a way to subclass SCIDefaultLegendItemBase without using a xib for UI design?
- Hi, Sean. In current version SCILegendDataSource supports only xib-based cell customization.
- Hi Andriy. Can you please check my response below?
- Hi Andriy. I’ve tried creating a XIB and hooking up the stuff, but when I’m adding the legend it turns out that it has 0 Width and Height. I guess I’m missing something. About the overriding the properties and methods, I’m only overriding the CheckBoxButton, MarkerView, SeriesNameLabel from the Properties, and SetCheckBoxVisibility and SetSeriesMarkerVisibility from the Methods. Am I missing something? Thanks!
- I’ve also tried using LegendModifier, but ended up with empty legend views without any data, even though before assigning the DataSources they’re full.
- You must login to post comments
Hi Andriy,
The thing is that we have 4 separate legends with different data sources, and when we tried creating them with SCILegendModifier the data source was the same for all of the legends. Later we tried just using SCIChartLegend and hooking up the data source and we succeeded displaying 4 different legends with 4 different data sources. I’m not sure what was the problem, but if that problem still persists, using the SCILegendModifier won’t be the solution for our problem. However, I’ll try again with the SCILegendModifier and I’ll let you know what’s up.
Thanks a lot,
Lazar
- Lazar Nikolov answered 5 years ago
- Hi, Lazar. Using SCILegendModifier isn’t necessary, SCILegend can live without modifier and just be placed on a surface manually.
- Okay, so you say I can leave out the LegendModifier altogether and it should be working as it should, right?
- You must login to post comments
Please login first to submit.