Chartjs-Get a single point programmatically

1👍

You should access to dataset meta data by chart.getDatasetMeta(datasetIndex). You will get an object which represents the dataset. In the meta object, there is an array property, data, which contains all data elements(the points in your case). In each data element there is a object property, options, with the options of the element, where you can set the borderColor.

const pulsePoint = {
  id: 'pulsePoint',
  afterDraw: chart => {
    const meta = chart.getDatasetMeta(0); // first dataset
    const firstPoint = meta.data[0];
    // Pay attention because it could be a loop. a condition should be set
    if (firstPoint.options.borderColor !== '#ffffff') {  
      firstPoint.options.borderColor = '#ffffff';
      chart.draw(); // better than update for this use case.
    } 
  }
};

Leave a comment