(this is just a screenshot from another app)
I’m trying to achieve this using http://www.jjoe64.com/p/graphview-library.html
I want to have a crosshair appear when the user touches the graph and to have show the value of the X axis of that point.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You will need a method to translate X-position on the screen to X-position on the graph, and display the Y value that corresponds with the looked up X position in the graph.
Most simplistic way I can think of would be to get the pixel width of the screen (assuming your graph fits the entire width), and register for touch events by overriding this method below in the view:
Inside that method you can get hold of the x-coordinate tapped (from the MotionEvent object), and then translate to the graph’s position.
For example, you may work out what percentage of the way along the screen is tapped (say the screen width is 400px and the user taps 300px along, thats 75% of the length) then move this percentage through the graph’s data points (so 75% through the ordered dataset)
You can then display a popup or add something to your
onDrawmethod that adds the data point as a small overlay.Note: You would need the raw data points to perform the lookup, unless you are going to try and guess what the graph’s points correspond to on the y-axis…