score:10

Accepted answer

references:

chartjs docs: tooltip configuration - interaction modes

mode : index - finds item at the same index. if the intersect setting is true, the first intersecting item is used to determine the index in the data. if intersect false the nearest item is used to determine the index.

update the chart options to include the tooltips configurations. set the mode to index

tooltips : {
    mode : 'index'
},

the updated options would look like this.

const chart_options = {
  tooltips : {
    mode : 'index'
  },
  scales:
  {
    xaxes: [{
      ticks: {
        display: false,
      },
    }],
    yaxes: [
      {
        type: 'linear',
        id: 'y-axis-0',
        display: false,
        position: 'left',
      },
      {
        type: 'linear',
        id: 'y-axis-1',
        display: false,
        position: 'right',
      },
    ],
  },
};

check updated sample which include tooltips mode set to index


Related Query

More Query from same tag