Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8097225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:41:21+00:00 2026-06-05T21:41:21+00:00

I am using the GraphView API and ive implemented the chart to be intractable.

  • 0

I am using the GraphView API and ive implemented the chart to be intractable. When the user touches the graph, a vertical line appears extending from the data point to the bottom of the graph.

Ive create the line in the onDraw method like so:

mDrawable = new ShapeDrawable(new RectShape());
mDrawable.getPaint().setColor(0xFF363636);
mDrawable.setBounds((int)markerX,(int) (markerY) , (int)markerX+1,  (int) height);
mDrawable.draw(canvas);

Iam using the following code, along with code to calculate the marker positions, to refresh the line in the onTouch method.

invalidate(mDrawable.getBounds());

My problem occurs when the the drawable is being moved. There tends to be a delay in refresh and the line disappears(for fractions of a second) on graph if the gesture is fast enough. The line keeps with the motion but it disappears. It seems almost like the Item is moving faster then its bounds, if that makes any sense.

I hear invalidating the entire canvas is a no-no, and invalidating the bounds of what you want change is preferred(what i’ve done above). When invalidating the entire canvas, the disappearing line phenomenon does not happen but the app does run sluggish.

I’ve some magical thing’s done with SurfaceView and surface holders but using them seems counter productive in this case. From my understanding, i would essentially be using the invalidate() method but in a different thread. Everything would still be redraw over and over which seems counter productive.

Is there another method to accomplish the effect described within GraphView library?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T21:41:23+00:00Added an answer on June 5, 2026 at 9:41 pm

    I was able to remedy this problem with a simple fix. Whenever the Screen was changed, either moved(portait mode) or touched (landscape mode), the onDraw() method is called. Although the dirty Rect method(landscape mode) was used, it still had a noticeable lag. There was also noticeable lag when scrolling the graph in a scroll view. The solution was saving the canvas to a bitmap(on the first call), storing the bitmap, and then only drawing marker after that atop of the bitmap. Whenever a viewport was changed, or different data set was added, the bitmap was nullified to draw all the data. The code

        protected void onDraw(Canvas sysCanvas) {
             canvas = new Canvas(); 
    
             if (bitmap != null) { 
                    sysCanvas.drawBitmap(bitmap, 0,0, null); 
                    drawMarker(sysCanvas); //draw whatever you want to the system canvas in a different method
                    return; 
             } 
    
    
            bitmap = Bitmap.createBitmap(sysCanvas.getWidth(), sysCanvas.getHeight(), Bitmap.Config.ARGB_8888); 
            canvas.setBitmap(bitmap); 
    
            ///more code, draw whatever you want to canvas.
            sysCanvas.drawBitmap(bitmap,0, 0,null);
        } 
    

    After the first run, the canvas will draw the graph. After the first pass though, the canvas just draws the bitmap and then go to a method to draw objects. These objects have x and y paramters that are set in the onTouch() method.

    This method drastically improves performance. In my case, i had a graph in a scrollView( portrait mode). Whenever the scrollview moved, in either direction, the canvas was redrawn. This constant redrawing really ate resources. The same can be said for drawing the marker i had implemented(a circle that follows your finger). Since the CPU only has to redraw 2 objects, the time it takes is less causing greater performance.

    Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

[UPDATE] To conclude this question, I implemented my graph using the following two methods
I'm trying to show graphs on my App using GraphView library. The code is
I'm using graphviz (dot) to generate the graph you can see below. The node
I've just started developing a small C++ program using GraphViz's graph library and noticed
I have been using the Graphview library, and its working great for my simple
I'm trying to create a graph using Graphviz (complied with neato), and I would
I am trying to draw a graph using Graphviz, but I need to add
I'm creating a graph using Graphviz (compiled with neato). This graph contains many overlapping
I am using PlantUML API to generate Activity Diagram. I have used GraphViz before
I'm using GraphView library (see: https://github.com/jjoe64/GraphView or http://www.jjoe64.com/p/graphview-library.html ) But I would like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.