user2723490
user2723490

Reputation: 2100

Highcharts: click events for heatmaps

I have a problem with click events on heatmaps: it works only if you click on a tooltip, but not on the chart itself. See the demo http://jsfiddle.net/3UWaA/1/

    chart: {
        type: 'heatmap',
        events: {
            click: function(event) {
                alert("clicked!");
            }
        }
    }

Any suggestions how to fix this?

Thanks

Upvotes: 5

Views: 3833

Answers (3)

Harry S
Harry S

Reputation: 73

Try inserting the EVENTS: under series block and disable the tooltip as below:

series: 
    [
    {   name: 'Passed',
        borderWidth: '1',
        borderColor: '#000000', 
        cursor: 'pointer',          
        events:
        {
        click: function ()
        {
        alert('wow');
        }
        },          
        color:'green',          
        data: [[0, 1, ''],[0, 2, ''],[0, 3, '']],
        dataLabels: 
        {
            enabled: 'true',                
            color: '#000000'
        }
    }
   ]

So when you click the chart itself,click event will work fine.

Upvotes: 1

Sebastian Bochan
Sebastian Bochan

Reputation: 37588

Because click event on chart, works in the plotArea, not on the serie. Heatmap serie overlap plotArea, so click event doesnt work. You need to catch plotOptions event on serie / point.

Upvotes: 4

Rob Schmuecker
Rob Schmuecker

Reputation: 8954

Add the events into a plotOptions object.

Like this:

plotOptions: {
        series: {
            events: {
                click: function (event) {
                    alert('event!');
                }
            }
        }
    },

Demo: http://jsfiddle.net/robschmuecker/3UWaA/3/

Upvotes: 6

Related Questions