harisrinivasr / achartengine

Automatically exported from code.google.com/p/achartengine
0 stars 0 forks source link

Major drawing bug when partial invalidation is used #223

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Configure any chart 
2. Add the following code. It is assumed that getView() returns a GraphicalView.

  @Override
    public void onResume()
    {
        super.onResume();
        mTriggerUpdateRunnable.run();
    }

    @Override
    public void onPause()
    {
        super.onPause();
        mHandler.removeCallbacks(mTriggerUpdateRunnable);
    }

    private final Runnable mTriggerUpdateRunnable = new Runnable() {
        @Override
        public void run()
        {
getView().invalidate(new Rect(100, 0, getView().getWidth() - 100,  
getView().getHeight()));
            mHandler.postDelayed(mTriggerUpdateRunnable, UPDATE_RATE);
        }
    };
3. Run the activity

What is the expected output? What do you see instead?
The expected output would be that the right side of the chart is drawn 
accurately. What actually happens is that the drawing is shifted over by 100 
pixels. 

This can be bypassed by calling setInScroll(true) on the 
MultipleSeriesRenderer. 

The problem code is:

 canvas.getClipBounds(mRect);
    int top = mRect.top;
    int left = mRect.left;
    int width = mRect.width();
    int height = mRect.height();

    if (mRenderer.isInScroll()) {
      top = 0;
      left = 0;
      width = getMeasuredWidth();
      height = getMeasuredHeight();
    }

The issue is that the clipBounds is not equal to the size of the view. The 
clipBounds is equal to the area that should be redrawn according to the 
invalidation request. Since, for the foreseeable future, you are always going 
to redraw the entire chart, the correct action would be to always use the code 
inside of "isInScroll" since you should always be using 0,0 for the top,left 
and the view width and height is the desired boundaries for drawing. 

What version of the product binary library are you using?
Latest build from the trunk

Original issue reported on code.google.com by mrsl...@gmail.com on 19 Jun 2012 at 8:28

GoogleCodeExporter commented 9 years ago
Sorry, I should mention the problem code is in GraphicalView.java

Original comment by mrsl...@gmail.com on 20 Jun 2012 at 2:00

GoogleCodeExporter commented 9 years ago
Always using the code under isInScroll() breaks a lot of other stuff, so not 
possible.

Original comment by dandrome...@gmail.com on 11 Jul 2012 at 10:44

GoogleCodeExporter commented 9 years ago
Can you detail what other items are broken by using that flag? From what I have 
seen it has fixed the problem perfectly. 

Original comment by mrsl...@gmail.com on 11 Jul 2012 at 12:03

GoogleCodeExporter commented 9 years ago
Try the demo with setInScroll(true); and you will see plenty issues.

Original comment by dandrome...@gmail.com on 11 Jul 2012 at 12:56

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Was this issue ever fixed? 

Original comment by mrsl...@gmail.com on 21 Jan 2013 at 3:56

GoogleCodeExporter commented 9 years ago
No, it's not fixed still. (library ver. 1.1.0 Feb 7, 2013.
The problem place is GraphicalView#onDraw.
Temporal solution is XYMultipleSeriesRenderer#setInScroll(true)

Original comment by qwertier...@gmail.com on 12 Feb 2013 at 4:57