Chart.js: how to custom points

Created on 19 Mar 2016  路  7Comments  路  Source: chartjs/Chart.js

Hello everyone,

I have a problem with CHARTJS, I want to change the shape of the points in LINE CHART, I have researched and have not managed to find the solution.

Thank you very much in advance...

support

Most helpful comment

@JuLiAnChz this is possible in version 2.

You can set point style for all points like so:

config = {
    elements: {
        points: {
            pointStyle: 'triangle'
        }
    }
}

Set the pointStyle attribute on each dataset to change the style for only that dataset.

Possible values are 'triangle', 'rect', 'rectRot', 'cross', 'crossRot', 'star', 'line', and 'dash'. If you set pointStyle to a canvas image object, that will be drawn instead.

V2 docs are available at http://nnnick.github.io/Chart.js/docs-v2/

All 7 comments

@JuLiAnChz this is possible in version 2.

You can set point style for all points like so:

config = {
    elements: {
        points: {
            pointStyle: 'triangle'
        }
    }
}

Set the pointStyle attribute on each dataset to change the style for only that dataset.

Possible values are 'triangle', 'rect', 'rectRot', 'cross', 'crossRot', 'star', 'line', and 'dash'. If you set pointStyle to a canvas image object, that will be drawn instead.

V2 docs are available at http://nnnick.github.io/Chart.js/docs-v2/

@etimberg
wow! Thx, but no way to do it in version 1

@JuLiAnChz in v1 it's more complicated you'll have to replace the draw method on Chart.Point.prototype.draw and do the custom drawing in there.

@etimberg Thx, i have new question :D! I change the figure to achieve the points, now I want to know how I can add a new option to dataset.

EDIT: I modified Chart.js v1

Is it possible to remove the points on the line? Or display the points as transparent until hover?

I figured this out. I was using one of the samples, and it was resetting my point options and I did not notice that is was doing so.

@JayBerlin you could set the regular color to transparent and set a highlight color that is not transparent.

Was this page helpful?
0 / 5 - 0 ratings