Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

give the value points in a line chart their own color #321

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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.

None yet

3 participants