Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to align the Legend! #279

Closed
hxdev opened this issue Aug 6, 2015 · 5 comments
Closed

Allow to align the Legend! #279

hxdev opened this issue Aug 6, 2015 · 5 comments

Comments

@hxdev
Copy link

hxdev commented Aug 6, 2015

I've create a BarChart with two BarChartDataSet.
Here is my init for the Legend:

    ChartLegend* legend = barChart.legend;
    [legend setCustomWithColors:@[UIColorFromRGB(0xD3370A),UIColorFromRGB(0xFFFFFF)] labels:@[@"Data1",@"Data2"]];
    legend.position = ChartLegendPositionRightOfChartInside;
    legend.direction = ChartLegendDirectionLeftToRight;
    legend.xEntrySpace = 15.f;
    legend.yEntrySpace = 0.f;
    legend.form = ChartLegendFormSquare;
    legend.formSize = 9.0;
    legend.font = [UIFont systemFontOfSize:11.f];
    legend.textColor = [UIColor whiteColor];
    [legend setYOffset:-15];

The legend will display like this:

[icon] Data1
[icon] Data2

How can I align the Legend to Left to Right? Like this

[icon] Data1    [icon] Data2

Thank!

@liuxuan30
Copy link
Member

I think as long as you set the position to ChartLegendPositionRight, it will render vertically, to save space. You either use bottom position, or customize ChartLegendRenderer to whatever you like.

@hxdev
Copy link
Author

hxdev commented Aug 6, 2015

Thanks for your support :) I'll try with the ChartLegendRenderer

@hxdev hxdev closed this as completed Aug 6, 2015
@nathanmrtns
Copy link

@hxdev Did you find a solution ?

@MarcosiOSdev
Copy link

Today this attribute doesnt exist.
Does anyone know how to do ?

legend.direction = ChartLegendDirectionLeftToRight;

@ABridoux
Copy link

In case of someone ends up here like me. To set the legend position:

chartView.legend.horizontalAlignment = .left
chartView.legend.verticalAlignment = .top

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants