Skip to content

adding functionality to the default legend onClick function #10009

Answered by kurkle
CodeMazeSolver asked this question in Q&A
Discussion options

You must be logged in to vote

Legend onClick, onHover, and onLeave options now receive the legend as the 3rd argument in addition to implicitly via this

https://www.chartjs.org/docs/latest/getting-started/v3-migration.html

  options: {
    plugins: {
      legend: {
        onClick(evt, item) {
          Chart.defaults.plugins.legend.onClick.call(this, evt, item, this);
          // or Chart.defaults.plugins.legend.onClick(evt, item, this);
        }
      }
    }
  }

https://codepen.io/kurkle/pen/xxXrRjy

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@CodeMazeSolver
Comment options

Answer selected by CodeMazeSolver
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #10008 on December 19, 2021 09:24.