artakserkses
Posts: 51
Joined: Tue Feb 23, 2021 11:23 am

How to prevent point being selected?

Hey once again :)

I have an issue, cause on select event i would like to check some things, and in some cases prevent from selecting point. For now i have something like this:

Code: Select all

select: data => {
              if (!data.target.dragDrop.draggableY) {
                setTimeout(() => this.unselectAllPoints(), 10);
                return;
              }
and this.unselectAllPoints()

Code: Select all

  
  public unselectAllPoints() {
    this.chartRef.getSelectedPoints().forEach(point => {
      point.select(false, false);
    });
    this.chartRef.redraw();
  }
And it gives me interesting effect of selecting and unselecting point :) But how can i make this point to not select at all?
dominik.c
Posts: 2081
Joined: Fri Aug 07, 2020 7:07 am

Re: How to prevent point being selected?

Hello artakserkses!

We appreciate you reaching out to us!

Unfortunately, it is hard to tell you what is not working and what could be done without taking look at your demo. Could you reproduce the issue in an online editor that I could work on? In the link below you can find a basic template. :)

Demo: https://jsfiddle.net/BlackLabel/jwyds26n/

Best regards!
Dominik Chudy
Highcharts Developer
artakserkses
Posts: 51
Joined: Tue Feb 23, 2021 11:23 am

Re: How to prevent point being selected?

Dear dominic.c here you have example: https://jsfiddle.net/ujyfb603/

I just would like for some points not to be able to be selected.
At this moment I have something like this: https://jsfiddle.net/2j0vrmun/1/ and it works, kind of :) Cause you can select the point, but it unselects instantly :) But I would like to prevent selecting, not select and unselect after 10ms :)
dominik.c
Posts: 2081
Joined: Fri Aug 07, 2020 7:07 am

Re: How to prevent point being selected?

Hi again!

Thanks a lot for the demos and for explaining your issue! :)

I suggest disabling selected status on a series and splitting your data into two series. One for points that can be selected, and the second one for points that can't be selected.

API references:
https://api.highcharts.com/gantt/series ... ct.enabled

Demo:
https://jsfiddle.net/BlackLabel/ot401rj9/

Best regards!
Dominik Chudy
Highcharts Developer
artakserkses
Posts: 51
Joined: Tue Feb 23, 2021 11:23 am

Re: How to prevent point being selected?

dominik.c wrote: Mon Aug 02, 2021 7:54 am Hi again!

Thanks a lot for the demos and for explaining your issue! :)
No problem :)
dominik.c wrote: Mon Aug 02, 2021 7:54 am
I suggest disabling selected status on a series and splitting your data into two series. One for points that can be selected, and the second one for points that can't be selected.
In my case this isn't good option, cause I have about 70 series with c.a. 20-30 points in each serie (with categories, and so on), that's why i'm looking for an option for point :)
dominik.c
Posts: 2081
Joined: Fri Aug 07, 2020 7:07 am

Re: How to prevent point being selected?

Hi again!

Unfortunately, there's no API option that could do that. But we can do something similar to what you were trying to do.

We can check the name of the point in the select function and depend on the name we can activate the select functionality (return true) or not (return false).

Demo: https://jsfiddle.net/BlackLabel/89h1j370/

Best regards!
Dominik Chudy
Highcharts Developer
artakserkses
Posts: 51
Joined: Tue Feb 23, 2021 11:23 am

Re: How to prevent point being selected?

dominik.c wrote: Tue Aug 03, 2021 10:02 am Hi again!

Unfortunately, there's no API option that could do that. But we can do something similar to what you were trying to do.

We can check the name of the point in the select function and depend on the name we can activate the select functionality (return true) or not (return false).

Demo: https://jsfiddle.net/BlackLabel/89h1j370/

Best regards!
O, and this is what i was looking for :D
Thx :)
dominik.c
Posts: 2081
Joined: Fri Aug 07, 2020 7:07 am

Re: How to prevent point being selected?

You're welcome!

In case of any further questions, feel free to contact us again.
Dominik Chudy
Highcharts Developer

Return to “Highcharts Gantt”