This is a migrated thread and some comments may be shown as answers.

Customise legend's item's appearance not working

1 Answer 92 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Oleg
Top achievements
Rank 1
Oleg asked on 20 Nov 2014, 12:26 PM
I am also trying to customise the legend's appearance. Not working :(
I want to make the legend items much bigger and change the shape of the indicator icon:

TKChartLegendContainer *legendContainerScrollView = chart.legend.container;
    legendContainerScrollView.stack.itemSpacing = 50;
    TKChartLegendItem *item = [legendContainerScrollView itemAtIndex:0];
    item.style.iconSize = CGSizeMake(50, 50); // Not working

Not working...

I also want to change the shape of the legend's indicator to square:

I see in the debugger that :

TKChartLegendItem *item = [legendContainerScrollView itemAtIndex:0];TKChartLegendItem *item = [legendContainerScrollView itemAtIndex:0];
// item.icon is a TKChartShapeView - would like to change the shape to "Square"

Also I see that TKChartLegendItem.h declares a protocol "TKChartLegendItemDelegate"

But no way to become the delegate without sub classing TKChartSeries:

 @discussion The legend asks all series first about the count of legend items they will provide and then gets this count of items.




But I don't see any implementation or declaration in TKSeries of this protocol.

It also seems like a lot of work for something very trivial

Here is the appearance I want to achieve in the attached file:


1 Answer, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 21 Nov 2014, 01:10 PM
Hi,

You can change the legend item shape by using a custom UIView for the legend icon. Here is a sample code for this (assuming that you are using a pie chart):
for (int i = 0; i<_pieChart.legend.container.itemCount; i++) {
    TKChartLegendItem *item = [_pieChart.legend.container itemAtIndex:i];
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)];
    TKChartPaletteItem *paletteItem = [_pieChart paletteItemForSeries:_pieChart.series[0] atIndex:i];
    TKSolidFill *fill = (TKSolidFill*)paletteItem.fill;
    view.backgroundColor = fill.color;
    item.icon = view;
}

However, currently it is not possible to achieve the same layout like in the attached file. We know about this limitation and we are working on improving how legends can be customized in TKChart.

Regards,
Jack
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Chart
Asked by
Oleg
Top achievements
Rank 1
Answers by
Jack
Telerik team
Share this question
or