harisrinivasr / achartengine

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

Stretched text in horizontal bar chart (Orientation.VERTICAL) #305

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. view an horizontal bar chart (Orientation.VERTICAL) in the demo app 
2. see that the texts are stretched

What is the expected output? What do you see instead?
Texts shouldn't be stretched

Please provide a source code snippet that we can use to replicate the issue.

What version of the product binary library are you using?
1.0.0

Please provide any additional information below.
To correct the problem, I modified drawText(...) in XYChart.java :

protected void drawText(Canvas canvas, String text, float x, float y, Paint 
paint, float extraAngle) {

      Orientation or = mRenderer.getOrientation();
      if (or == Orientation.VERTICAL)
      {     
          float angleOrientation = -mRenderer.getOrientation().getAngle();
          canvas.scale(1 / mScale, mScale);
          canvas.rotate(angleOrientation, 0, 0);
          float xPos=-y/mScale;
          float yPos=x*mScale;
          if (extraAngle != 0) {
              canvas.rotate(extraAngle,  xPos, yPos);
          }
          drawString(canvas, text, xPos, yPos, paint);
          if (extraAngle != 0) {
              canvas.rotate(-extraAngle, xPos, yPos);
          }
          canvas.rotate(-angleOrientation, 0, 0);
          canvas.scale(mScale, 1 / mScale);
      }
      else
      {   
          if (extraAngle != 0) {
              canvas.rotate(extraAngle, x, y);
          }
          drawString(canvas, text, x, y, paint);
          if (extraAngle != 0) {
              canvas.rotate(-extraAngle, x, y);
          }
      }
  }

Original issue reported on code.google.com by reetr...@gmail.com on 20 May 2013 at 8:13

GoogleCodeExporter commented 9 years ago

Original comment by dandrome...@gmail.com on 20 May 2013 at 8:15