Menencia
Menencia

Reputation: 1289

Highstock: Property 'firePointEvent' of object #<Object> is not a function

When fire a click on a serie, I get the next error : Uncaught TypeError: Property 'firePointEvent' of object # is not a function.

In Highstock.js v1.3.1 (2013-04-15) on line 9575 :

// the series click event
fireEvent(hoverPoint.series, 'click', extend(e, {
    point: hoverPoint
}));

Until there, hoverPoint exist and have real values, but don't have yet firePointEvent method.

// the point click event
hoverPoint.firePointEvent('click', e);

On this next line, hoverPoint still exist and do have a firePointEvent method, but all its attributes are null. So it throws the error :/

What's the problem here?

Upvotes: 2

Views: 1266

Answers (1)

Guian
Guian

Reputation: 4689

I could reproduce this problem. You can see it in this fiddle.

  1. click on the chart background (it removes the line)
  2. then click on the series (the line is back and it trigger the error)

I found a workaround for this, you have to set a little timeout so the click event and the update process won't happen in the same call.

I guess the update() makes the hoverPoint object to be altered, causing the firePointEvent property to be null at the end of the process.

Here the workaround : (in JSFiddle here )

plotOptions: {
        series: {
            events: {
                click: function(event) {
                    var that = this;
                    setTimeout( function(){
                        that.update({
                            lineWidth: 1,
                        });
                    }, 20);

                }
            }
        }
},

Upvotes: 2

Related Questions