Skip to content

Conversation

@mlabouardy
Copy link

No description provided.

@saiimons
Copy link

saiimons commented May 4, 2017

IMHO, would be nice to have a method to override in the LineChartRenderer in order to define a point's color when drawing it :

    private final Paint pointPaintBase = new Paint() {{
        setAntiAlias(true);
        setStyle(Paint.Style.FILL);
    }};

    protected Paint getPointPaint(Line line, PointValue pointValue) {
        final Paint paint = new Paint(pointPaintBase);
        paint.setColor(line.getColor());
        return paint;
    }

    private void drawPoint(Canvas canvas, Line line, PointValue pointValue, float rawX, float rawY,
                           float pointRadius) {
        if (ValueShape.SQUARE.equals(line.getShape())) {
            canvas.drawRect(rawX - pointRadius, rawY - pointRadius, rawX + pointRadius, rawY + pointRadius,
                    getPointPaint(line, pointValue));
        } else if (ValueShape.CIRCLE.equals(line.getShape())) {
            canvas.drawCircle(rawX, rawY, pointRadius, getPointPaint(line, pointValue));
        } else if (ValueShape.DIAMOND.equals(line.getShape())) {
            canvas.save();
            canvas.rotate(45, rawX, rawY);
            canvas.drawRect(rawX - pointRadius, rawY - pointRadius, rawX + pointRadius, rawY + pointRadius,
                    getPointPaint(line, pointValue));
            canvas.restore();
        } else {
            throw new IllegalArgumentException("Invalid point shape: " + line.getShape());
        }
    }

Maybe @lecho has an idea about it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants