Chartjs-Cannot find a way to correctly use chartjs annotation plugin with react

0👍

I think plugins property in react-chartjs-2 should be an array, I guess.

 <Chart
          type="scatter"
          data={data}
          options={options}
          plugins={[ChartAnnotation]}
        />

The options config for annotation plugin is not in the right node.
It must be added in options.plugins node.

const options = {
  plugins: { // <-- to add, was missing
  annotation: {
    annotations: [
      {
        type: "line",
        mode: "horizontal",
        scaleID: "x",
        value: 1,
        borderColor: "white",
        borderWidth: 2,
      },
    ],
  },
}

Leave a comment