pzych
Posts: 4
Joined: Mon Mar 21, 2016 11:12 am

Events not working on highstock Chart

Hello,
I have already set up working Highstock chart that is presenting some data.
Now I was asked by user if it is possible to select points with mouse drag. I started reading API and googling and found couple of solutions. Like those for example:

http://jsfiddle.net/Lqcmf7ao/
http://jsfiddle.net/gh/get/jquery/1.7.2 ... on-points/

First move was to implement Event 'selection' into chart. I added it with this code:

Code: Select all

            
            $scope.chart = new Highcharts.Chart(Config);
            $scope.chart.events = {

                selection: function (event) {
                    console.log("test");
                },
                click: function (event) {
                    console.log("test1");
                }
            };

            $scope.chart.zoomType = 'xy';
After website loaded I have those events attached (below is screenshot from console.log($scope.chart);)
Image

And the events does not work at all. I was expecting that it will zoom my chart and return test/test1 to console. It doesn't.

And additionaly. I implemented single-click selection with this code:

Code: Select all

                        $scope.chart.addSeries({
                        allowPointSelect: true,
                        point: {
                            events: {
                                select: function(event){
                                    console.log(event);
                                }
                            },
                        }
And it is working.
So events are working at all. They just don't work on chart in general, only in series.
Izothep
Posts: 1246
Joined: Wed Oct 07, 2015 11:50 am

Re: Events not working on highstock Chart

Hi Pzych,

I am not able to recreate your issue. Could you post live example of your chart?

I have changed the examples you gave me so I have Highstock charts and this examples are working with them as well:
http://jsfiddle.net/Lqcmf7ao/1/
http://jsfiddle.net/yj70gubv/

Kind regards
Grzegorz Blachliński
Highcharts Developer
pzych
Posts: 4
Joined: Mon Mar 21, 2016 11:12 am

Re: Events not working on highstock Chart

Grzegorz,

Unfortunately I am not able to post living example. It is intranet and pasting it here would be very difficult. I just pasted some settings code here and i thought that it will be enough to check if I am doing everything right.

Can you advise me how can I debug this to find out why it is not working?

Thanks for your assistance / dziekuje za pomoc
Izothep
Posts: 1246
Joined: Wed Oct 07, 2015 11:50 am

Re: Events not working on highstock Chart

Hi,

You' re welcome / cieszę się że mogę pomóc :)

Are you adding your events inside your chart options, or you are trying to add them after your chart is made?

I think you should add your events inside your chart options.

Kind regards.
Grzegorz Blachliński
Highcharts Developer
amtenga
Posts: 2
Joined: Fri Jul 22, 2022 1:23 pm

Re: Events not working on highstock Chart

Event in chart doesn't work on react.
kamil.m
Posts: 892
Joined: Thu May 19, 2022 1:33 pm

Re: Events not working on highstock Chart

Hello amtenga,

Thank you for contacting us with your issue. Unfortunately, we are not able to help you without knowing more about the issue. Could you please reproduce your problem in an online code editor with React i.e Stackblitz or codesandbox, tell us more about what you tried to do, what didn't work, and what would be your end goal to achieve with that event?

Since you've posted your reply in a Highstock thread, I'm guessing you're also using it. So to recreate the issue, feel free to work this demo: https://codesandbox.io/s/highcharts-rea ... =/demo.jsx

Waiting for your reply,
Best regards!
Kamil Musiałowski
Highcharts Developer

Return to “Highcharts Stock”