@Override public void drawHorizontalLines(Canvas canvas) { Paint paint = linePaints[LEFT]; paint.setColor(borderColor); canvas.drawLine(0, 0, chartView.getWidth(), 0, linePaints[LEFT]); paint.setColor(lineColor); for (int i = 1; i < HORIZONTAL_LINE_NUMBER; i++) { float yPos = (i / (float) HORIZONTAL_LINE_NUMBER) * chartView.getContentHeight(); canvas.drawLine(0, yPos, chartView.getWidth(), yPos, linePaints[LEFT]); } paint.setColor(borderColor); canvas.drawLine( 0, chartView.getContentHeight(), chartView.getWidth(), chartView.getContentHeight(), paint); }
@Override public void drawVerticalLines(Canvas canvas) { Paint linePaint = linePaints[BOTTOM]; linePaint.setColor(borderColor); canvas.drawLine(0, 0, 0, chartView.getContentHeight(), linePaint); linePaint.setColor(lineColor); for (int i = 1; i < VERTICAL_LINE_NUMBER; i++) { float x = (i / (float) VERTICAL_LINE_NUMBER) * chartView.getWidth(); canvas.drawLine(x, 0, x, chartView.getContentHeight(), linePaint); } linePaint.setColor(borderColor); canvas.drawLine( chartView.getWidth() - 1, 0, chartView.getWidth() - 1, chartView.getContentHeight(), linePaint); }