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

Legend spacing issue with LineChart and colors[] #3780

Closed
jonathaz opened this issue Dec 11, 2018 · 2 comments
Closed

Legend spacing issue with LineChart and colors[] #3780

jonathaz opened this issue Dec 11, 2018 · 2 comments

Comments

@jonathaz
Copy link

What did you do?

Created a LineChart with a LineChartDataSet, set the dataset form property to .none to keep it from displaying in the legend. Used the colors[] array to change the colors.

What did you expect to happen?

The dataset entries to neither appear nor take up space in the legend.

What happened instead?

Every color added to the .colors array used space in the legend, even spilling over to the next line. If the label for the dataset is provided, sometimes it renders it and sometimes not, depending on if it spilled over to the next line.

Charts Environment

Charts version/Branch/Commit Number: 3.1.1
Xcode version: Version 10.1 (10B61)
Swift version: Swift 4.2
Platform(s) running Charts: iOS 10.3 10.13.6 (17G65)
macOS version running Xcode:

Demo Project

I don't have a demo project, but I think the bug is in LegendRenderer.swift, in the renderLegend() at line 398. Even though it doesn't render the form or the label, it increments posX by 3 (stack space) for every value in colors[]. I think it would be sufficient to not increment posX in this case, although I don't know if that would break anything else. I did test a change where I filtered out legend entries that had form of .none and label == nil, but that could break other things.

@liuxuan30
Copy link
Member

can you fix it and file a PR?

@jonathaz
Copy link
Author

good workaround for me was to set custom legend entries, as I wanted to reorder them anyway.

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

2 participants