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

Change point size and color on click. #2989

Closed
katsuragi545 opened this issue Jul 18, 2016 · 1 comment
Closed

Change point size and color on click. #2989

katsuragi545 opened this issue Jul 18, 2016 · 1 comment

Comments

@katsuragi545
Copy link

How do you go about changing the a point's color and size when clicked (I'm using a scatter line chart)?

This is the function I've created:

        canvas.onclick = function (evt) {
            var activePoints = scatterChart.getElementsAtEvent(evt);

            if (activePoints.length > 0) {

                activePoints[0]._model.radius = 7;
                activePoints[0]._model.backgroundColor = 'rgba(0,0,255,1)';
                activePoints[0]._model.borderWidth = 5;

                scatterChart.update();
            }
        }

When this function is executed, I notice that the point size does indeed change size and color, but it immediately goes back to the default size and color. How do I make the size/color changes permanent?

@katsuragi545
Copy link
Author

katsuragi545 commented Jul 18, 2016

Slipped my mind - I asked a similar question before back when I was using a Chart.js wrapper (using pure Chart.js now)

var activePoint = scatterChart.getElementAtEvent(evt);
var selectedPoint = activePoint[0];
selectedPoint.custom = this.selectedPoint.custom || {};
selectedPoint.custom.backgroundColor = 'rgba(128,128,128,1)';
selectedPoint.custom.radius = 7;

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

No branches or pull requests

3 participants