wangyao5 / achartengine

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

No (vertical) grid for custom xLabels #79

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When setting

renderer.setXLabels(0);

and adding

renderer.addTextLabel(123, "abc"); // or addXTextLabel in r145

the chart does not draw the vertical grid. I can't think of a case where, when 
using custom labels in the currently implemented way, you would NOT want to 
have the vertical grid, if the grid is enabled at all.

So considering this as a bug, you can easily fix this by substituting the code 
in XYChart.java (lines 460ff) with:

if (showLabels) {
      for (Double location : xTextLabelLocations) {
        paint.setColor(mRenderer.getLabelsColor());
        float xLabel = (float) (left + xPixelsPerUnit * (location.doubleValue() - minX));
        canvas.drawLine(xLabel, bottom, xLabel, bottom + 4, paint);
        drawText(canvas, mRenderer.getXTextLabel(location), xLabel, bottom + mRenderer.getLabelsTextSize(), paint, mRenderer
            .getXLabelsAngle());

        if (showGrid) {
          paint.setColor(mRenderer.getGridColor());
          canvas.drawLine(xLabel, bottom, xLabel, top, paint);
        }
      }
    }

I did this locally, but I think someone else asked for it in a discussion 
(sorry, don't have the link anymore).

Best regards and keep up the great work !

Ben

Original issue reported on code.google.com by benfwi...@gmail.com on 29 Apr 2011 at 11:30

GoogleCodeExporter commented 9 years ago
Added a renderer.setShowCustomTextGrid() for enabling this.
Fixed in SVN rev. r176.

Original comment by dandrome...@gmail.com on 14 May 2011 at 10:04