Suggestion for a change of a grid background of graph using an android plot library

1.3k views Asked by At

I want to make look like grid background as a full screen, [look like this image.

...by using android plot library. Can anyone suggest a good implementation of that.

I'm going to change bitmapshader by creating bitmap, to pass
RectF rect = plot.getGraph().getGridRect(); BitmapShader myShader = new BitmapShader( Bitmap.createScaledBitmap( BitmapFactory.decodeResource( getResources(), R.drawable.graph_background), 1, (int) rect.height(), false), Shader.TileMode.REPEAT, Shader.TileMode.REPEAT); Matrix m = new Matrix(); m.setTranslate(rect.left, rect.top); myShader.setLocalMatrix(m);
plot.getGraph().getGridBackgroundPaint().setShader(myShader);

this give error for (int) rect.height(), null pointer exception for this

1

There are 1 answers

0
Nick On BEST ANSWER

Without a more precise description of what you're trying to do the best I can do is to provide a general answer to how you accomplish your goal. Here's how you would display a grid of 25x25 px boxes:

plot.setDomainStep(StepMode.INCREMENT_BY_PIXELS, 25);
plot.setRangeStep(StepMode.INCREMENT_BY_PIXELS, 25);
plot.getGraph().getDomainGridLinePaint().setColor(Color.BLUE);
plot.getGraph().getRangeGridLinePaint().setColor(Color.BLUE);

You said in your comments that you wanted to make the boxes as small as possible, so if you really want to do that, you could specify a size of 1 by 1 instead.