Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Open
mlabouardy wants to merge 2 commits intolecho:masterlecho/hellocharts-android:masterfrom
mlabouardy:mastermlabouardy/hellocharts-android:masterCopy head branch name to clipboard
Open

give the value points in a line chart their own color#321
mlabouardy wants to merge 2 commits intolecho:masterlecho/hellocharts-android:masterfrom
mlabouardy:mastermlabouardy/hellocharts-android:masterCopy head branch name to clipboard

Conversation

@mlabouardy
Copy link
Copy Markdown

No description provided.

@saiimons
Copy link
Copy Markdown

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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.