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

Marker view mac #5030

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Marker view mac #5030

wants to merge 3 commits into from

Conversation

RCCoop
Copy link

@RCCoop RCCoop commented Mar 23, 2023

Issue Link πŸ”—

#5023

Goals ⚽

Make MarkerView work in MacOS, and add an example of it into the MacOS sample app.

Implementation Details 🚧

  • Several non-breaking changes in MarkerView
    • Added didSet in chartView property, which calls a new function didAddToChart(_:).
    • didAddToChart(_:) only does anything in OSX. It adds the MarkerView as an off-screen subview of the chartView's containing view. This is necessary because the MarkerView would not render in OSX without it having been added to a view already. See this SO answer for more context.
    • Changed the implementation of viewFromXib(in:) to return Self rather than MarkerView so that subclasses will return as their own type rather than the base class.
    • Also changed the implementation of viewFromXib(in:) to find the first instance of Self in the loaded objects from the xib rather than assuming that the first object in that array was the one we'd be looking for. In MacOS this was a problem because the view was often second in the xib's loaded objects rather than the first.
    • Finally, in the MacOS implementation of viewFromXib(in:), set wantsLayer to true for the resulting view, which was also necessary to render the view during draw(context:point:) as referenced in previous StackOverflow answer.

Testing Details πŸ”

  • Created RadarMarkerViewMac in the MacOS sample app, which is nearly identical to the RadarMarkerView in the iOS sample app.
  • Added the new RadarMarkerViewMac as the marker in the MacOS sample's RadarDemoViewController.
  • Ran the MacOS sample app and made sure the RadarDemoViewController displayed the marker as expected.

@yongfrank
Copy link

Thank you for your commit. It very useful for me to develop with DGCharts on Mac!

It's strange that your PR fixing the bug has not been merged for a long time.

@yongfrank
Copy link

yongfrank commented Nov 24, 2023

@liuxuan30 Hi, I found the same issue with Marker View and xib on Mac when I was developing. #5023

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

Successfully merging this pull request may close these issues.

None yet

2 participants