SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and iOS Chart & Android Chart Components

1
0

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

Version
2.2.2.854
  • Sean Young
    Not sure how useful the answer will be to me, but I’m also wondering how to do this in native iOS.
  • You must to post comments
0
0

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,

  • Sean Young
    Boo. I don’t suppose there’s a way to subclass SCIDefaultLegendItemBase without using a xib for UI design?
  • Andriy Shkinder
    Hi, Sean. In current version SCILegendDataSource supports only xib-based cell customization.
  • Lazar Nikolov
    Hi Andriy. Can you please check my response below?
  • Lazar Nikolov
    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!
  • Lazar Nikolov
    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 to post comments
0
0

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

  • Andriy Shkinder
    Hi, Lazar. Using SCILegendModifier isn’t necessary, SCILegend can live without modifier and just be placed on a surface manually.
  • Lazar Nikolov
    Okay, so you say I can leave out the LegendModifier altogether and it should be working as it should, right?
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.

SciChart WPF v6 BETA released! Note pricing/licensing changes are coming. Contact us to beat the rise!Read more
+