Hi,
I am using IGLegend to add legends to the charts in my iPhone App. I have set the orientation to IGOrientationHorizontal. Here, is there a way to wrap the legend items as the items out of bounds of the legend view are not visible?
Hello Laxman,
The IGLegend uses a scroll viewer to display it's legend items. So in horizontal mode it would scroll left and right. So by default, no, you cannot get the items to wrap.
However, the .legend property of the chartview takes a IGLegendBase object, so we can make our own legend to modify the display. I mocked up a sample showing what I believe you are looking for.
Attached is a sample that creates a custom legend and the view controller sample which shows it being used.
Can you guys update the solution code to work with Autolayout and iOS 8?
Thanks.
Hi Darrell,
Thanks for posting a work around.
However, why the conceptual/"breaking" change to the code base?
"Once upon a time" the following would nicely display a "wrapped" legend for my 2 series stacked bar chart. Not so since upgrading. (Had to upgrade because of that unfortunate iOS 7.1 monochromatic chart issue...) fyi I need to display multiple charts on an iPhone form factor and use swipe to navigate between charts.
@property (strong, nonatomic) IGLegend *chartLegend;
@property (strong, nonatomic) IGChartView *stackedBarChart;
...
self.chartLegend = [[IGLegend alloc] initWithLegendType:IGChartLegendTypeSeries];
[self.chartLegend setFrame:CGRectMake(self.containerView.frame.size.width - 134 - 5 ,5, 120, 40)];
self.stackedBarChart.legend = self.chartLegend;
<birds sing, sun shines>