In a UIViewController
(think of an iPad
landscape layout) I'm displaying 3 charts (one beside the other) with a donut series each and their legend displayed on bottom middle, outside the plot area, the views containing the charts are of the same size.
Each chart shows up to 5 values, so when they have the same number of values all the donuts and legends appear perfectly aligned with each other.
The problem is that when one of the charts has fewer values, the legend takes a smaller vertical space therefore making the donut appear lower than the others.
Is there a way to fix the plot area at a certain size? My goal would be making all the donuts and legends appear aligned regardless of the number of values for each series.
Thanks!
Starting from MrAPolk answer, I managed to implement a solution to my problem.
These are the steps I followed:
UIView
with the adequate size to contain only the donut; then I drew another UIView
as legend container, placed below the chart container.chart.legend.hidden = YES;
).I implemented the SChartDelegate
method sChartRenderFinished:
to do something like this:
- (void)sChartRenderFinished:(ShinobiChart *)chart {
SChartLegend *legend = chart.legend;
[legend removeFromSuperview];
legend.hidden = NO;
legend.frame = legendContainer.bounds; //legendContainer is the UIView defined in IB
[legendContainer addSubview:legend];
[legend setNeedsDisplay];
}
MrAPolk's answer didn't actually solve my problem, but it sparkled this solution, so I would give him +1 if I could.