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

Highlight does not respect the draw order. #4223

Closed
1 task done
AdrianBinDC opened this issue Nov 20, 2019 · 3 comments
Closed
1 task done

Highlight does not respect the draw order. #4223

AdrianBinDC opened this issue Nov 20, 2019 · 3 comments

Comments

@AdrianBinDC
Copy link

AdrianBinDC commented Nov 20, 2019

What did you do?

I created a CombinedChartView with a CombinedChartData object that has BarChartData and LineChartData with default draw order.
Default draw order places the BarChartData at the back and LineChartData at the front.
I configured LineChartData's highlightEnabled to false and BarChartData's highlightEnabled to true.

What did you expect to happen?

When I highlight a bar chart entry, I would expect the highlight to respect the draw order and remain underneath the line.

What happened instead?

The highlight disregards the draw order and draws in the foreground, obscuring on the line rendering.

Charts Environment

Charts version/Branch/Commit Number: 3.4.0
Xcode version: Version 11.1 (11A1027)
Swift version: 5.0
Platform(s) running Charts: iOS
macOS version running Xcode: Mojave 10.14.6

ℹ Please link to or upload a project we can download that reproduces the issue.

Unable to provide

@liuxuan30
Copy link
Member

liuxuan30 commented Jan 20, 2020

I take a look at open override func drawHighlighted(context: CGContext, indices: [Highlight])

the order is respected, however, it seems that the drawHighlight is drawing new shapes right upon what has been drawn; meaning it's like the highlight bars are covering the normal charts, which leads to what you said. This is likely by design. so...

@AdrianBinDC
Copy link
Author

AdrianBinDC commented Jan 20, 2020

In highlighting an element, I would expect the bar to retain its place in the view hierarchy and change the color of of the selected bar. What you're saying is a new bar is drawn on top of the existing bar.

What would you suggest as the correct way to change the color of a selected bar while respecting the draw order specified when declaring a CombinedChart object?

@danielgindi
Copy link
Collaborator

Highlights are always drawn on top, because the whole point of a highlight is dismissed if you can't see it. We may be able to configure this behavior in the future, but not currently.

If you need to temporarily change the color of a single bar for other reasons than a highlight, in some cases you can change the color in the dataset (when you have as many colors as bars).

Or you can make a PR for setting a color to a bar entry (should be very easy), or for refactoring the highlight code (quite complex).

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

3 participants