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

Doesn't support multiple AnyChartView instances #7

Open
devpolant opened this issue May 17, 2020 · 2 comments
Open

Doesn't support multiple AnyChartView instances #7

devpolant opened this issue May 17, 2020 · 2 comments

Comments

@devpolant
Copy link

devpolant commented May 17, 2020

Precondition

  • I'm trying to display 2 charts on the same screen. First one on left half of the screen and second one on the right half.
  • But I see that only one of them is displayed on the screen

Problem

  • I looked at the init method inside AnyChartView.swift and I see APIlib.sharedInstance.jsDelegate = self there
    required public init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        initSubviews()
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        initSubviews()
    }
    
    func initSubviews() {
        let bundle = Bundle(for: type(of: self))
        let nib = UINib(nibName: "AnyChartView", bundle: bundle)
        nib.instantiate(withOwner: self, options: nil)
        container.frame = bounds
        addSubview(container)
        
        let webConfiguration = WKWebViewConfiguration()
        let customFrame = CGRect.init(origin: CGPoint.zero, size: CGSize.init(width: 0.0, height: container.frame.size.height))
        webView = WKWebView (frame: customFrame , configuration: webConfiguration)
        webView.translatesAutoresizingMaskIntoConstraints = false
        container.addSubview(webView)
        webView.topAnchor.constraint(equalTo: container.topAnchor).isActive = true
        webView.rightAnchor.constraint(equalTo: container.rightAnchor).isActive = true
        webView.leftAnchor.constraint(equalTo: container.leftAnchor).isActive = true
        webView.bottomAnchor.constraint(equalTo: container.bottomAnchor).isActive = true
        webView.heightAnchor.constraint(equalTo: container.heightAnchor).isActive = true

        APIlib.sharedInstance.jsDelegate = self
    }

So it is impossible to use more than one AnyChartView object instance simultaneously.

Is it possible to make a workaround for that?

@Shestac92
Copy link
Contributor

@AntonPoltoratskyi
Unfortunately, the current version of the library doesn't support multiple Views. We have been asked about that frequently, so we will take into account for future updates.

@devpolant
Copy link
Author

Thanks for your reply!

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