score:17

Accepted answer

as said in the chart.js line chart data structure (pointstyle attribute) :

pointstyle
string, array< string >, image, array< image >
the style of point. options are 'circle', 'triangle', 'rect', 'rectrot', 'cross', 'crossrot', 'star', 'line', and 'dash'. if the option is an image, that image is drawn on the canvas using drawimage.

so you just need to edit your chart and put an image instead of the default circle in the pointstyle attribute of a specific data.


you can do it using chart.js plugins like this :

// variables 'sun' and 'cloud' are created before with `new image()`

chart.pluginservice.register({
    afterupdate: function(chart) {
        chart.config.data.datasets[0]._meta[0].data[7]._model.pointstyle = sun;
        chart.config.data.datasets[1]._meta[0].data[2]._model.pointstyle = cloud;
    }
});

and will give you this result.


Related Query

More Query from same tag