Chart.JS - Polar area - Legend hover style and margin

前端 未结 3 2096
遇见更好的自我
遇见更好的自我 2021-01-15 15:38

Hi all,

Hopefully this is an easy one. I\'ve set up a legend with an onclick event but would like the mouse cursor to change to \"pointer\" when I hover ove

3条回答
  •  南笙
    南笙 (楼主)
    2021-01-15 16:05

    I found a different way to make this work. This lines up more literally in my mind. Perhaps the framework was updated in the interim since this was initially answered.

     // This event fires anytime you mouse over the chart canvas.
    onHover: function (event) {
        event.target.style.cursor = 'default';
    },
    responsive: true,
    maintainAspectRatio: false,
    legend: {
        display: true,
        position: 'bottom',
        onHover: function (event, legendItem) {
            // There is only a legendItem when your mouse is positioned over one
            if (legendItem) {
                event.srcElement.style.cursor = 'pointer';
            }
        }
    }
    

    In case anyone wants to know more, here are the docs for events and the legend.

提交回复
热议问题