GithubHelp home page GithubHelp logo

Comments (7)

owlmafia avatar owlmafia commented on May 12, 2024 1

Yes, it's correct, you only have to add circleView.setNeedsDisplay() after the color changes. In order to clear the selection you can use the same approach from AreasExample, just store the last selection in a variable and reset the colors when you select a new one.

from swiftcharts.

owlmafia avatar owlmafia commented on May 12, 2024

I think you can adjust the circleViewGenerator to handle the touches itself. You can pass a touchHandler block to ChartPointEllipseView. In this handler you would have access to ChartPointEllipseView to change its colors. Then you also don't need the touchViewsGenerator.

I'm not sure if the tap area of ChartPointEllipseView will be sufficient, if not you could return a HandlingView in circleViewGenerator (instead of ChartPointEllipseView) with a slightly bigger area than the circles. You would add then ChartPointEllipseView as a subview of this bigger view.

from swiftcharts.

christinalau avatar christinalau commented on May 12, 2024

Thanks, can you share the snippet of code? I tried to add circleView.touchHandler to the circleViewGenerator, but it does not get call at all. Thanks again...

from swiftcharts.

owlmafia avatar owlmafia commented on May 12, 2024

Did you inspect the view hierarchy? Maybe there's something on top of the views consuming the touch. Maybe it also needs to set userInteractionEnabled. If this doesn't help please post your code to find the problem.

from swiftcharts.

christinalau avatar christinalau commented on May 12, 2024

The userInteractionEnabled seems to solve the original problem, now the touchHandler is called. However, I am unable to change the color:

let circleViewGenerator = {(chartPointModel: ChartPointLayerModel, layer: ChartPointsLayer, chart: Chart) -> UIView? in

        let circleView = ChartPointEllipseView(center: chartPointModel.screenLoc, diameter: 24)

        circleView.touchHandler = {
            print("@@@@ **** touch circle..")
            circleView.fillColor = UIColor.redColor()
            circleView.borderColor = UIColor.greenColor()
            circleView.animDuration = 1.5

        }
        circleView.userInteractionEnabled = true
        circleView.animDuration = 1.5
        circleView.fillColor = UIColor.whiteColor()
        circleView.borderWidth = 5
        circleView.borderColor = UIColor.blueColor()

        return circleView
    }

Is this correct or am I missing something? Thanks... I also need a way to clear the previous selection and is uncertain about the approach...

from swiftcharts.

christinalau avatar christinalau commented on May 12, 2024

Thanks, works perfectly 👍

from swiftcharts.

owlmafia avatar owlmafia commented on May 12, 2024

You're welcome!

from swiftcharts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.