0
votes

I have data like this:

var data = [{
    x: Date.UTC(1951, 5, 22),
    name: 'First dogs in space',
    label: 'fds',
    dataLabels: {
        allowOverlap: false,
        format: '<span style="color:{point.color}">● </span><span style="font-weight: bold;" > ' +
            '</span><br/>{point.label}'
    },
}, {
    x: Date.UTC(1957, 9, 4),
    name: 'First artificial satellite',
    label: 'First artificial satellite',
}, {
    x: Date.UTC(1959, 0, 4),
    name: 'First artificial satellite to reach the Moon',
    label: 'First artificial satellite to reach the Moon',
}, {
    x: Date.UTC(1961, 3, 12),
    name: 'First human spaceflight',
    label: 'First human spaceflight',
}, {
    x: Date.UTC(1966, 1, 3),
    name: 'First soft landing on the Moon',
    label: 'First soft landing on the Moon',
}, {
    x: Date.UTC(1969, 6, 20),
    name: 'First human on the Moon',
    label: 'First human on the Moon',
}, {
    x: Date.UTC(1971, 3, 19),
    name: 'First space station',
    label: 'First space station',
}, {
    x: Date.UTC(1971, 11, 2),
    name: 'First soft Mars landing',
    label: 'First soft Mars landing',
}, {
    x: Date.UTC(1976, 3, 17),
    name: 'Closest flyby of the Sun',
    label: 'Closest flyby of the Sun',
}, {
    x: Date.UTC(1978, 11, 4),
    name: 'First orbital exploration of Venus',
    label: 'First orbital exploration of Venus',
}, {
    x: Date.UTC(1986, 1, 19),
    name: 'First inhabited space station',
    label: 'First inhabited space station',
}, {
    x: Date.UTC(1989, 7, 8),
    name: 'First astrometric satellite',
    label: 'First astrometric satellite',
}, {
    x: Date.UTC(1998, 10, 20),
    name: 'First multinational space station',
    label: 'First multinational space station',
}];

Here is the fiddle link for your reference: Fiddle

In which I want some clickable event or others not according to my condition. Ex: If the label name is "First artificial satellite to reach the Moon" and "First soft landing on the Moon" It won't be clickable and others are clickable.

Screenshot for reference: enter image description here

1

1 Answers

1
votes

You could check if it is "not clickable" within the click processing (JSFiddle). First define those labels not clickable:

var unclickable = ["First artificial satellite to reach the Moon", "First soft landing on the Moon"];

Then implement the check in click to prevent processing, as well as showing the default cursor when hovering the points in mouseOver:

series: [{
  point: {
    events: {
      mouseOver: function() {
        if(unclickable.includes(this.label)) {
          this.dataLabel.element.style.setProperty('cursor', 'default');
          this.dataLabel.text.element.style.setProperty('cursor', 'default');
        }
      },
      click: function(data) {
        if(!unclickable.includes(this.label)) {
            // ...
        }
      }
    }
  }
}]

Be aware that your example JSFiddle had some &nbsp; characters in the labels, which meant that regular didn't get a match when checking for includes. Make sure you have only regular spaces, or you have to be very exact when matching the label against another string.