darko.studiopresent
Posts: 1
Joined: Fri Sep 06, 2024 7:12 am

Point visibility really slow when using menuItems onclick() function

Hello, what I am trying to achieve here is that I have created my own custom menuItems which has the data for all of the users from the Gantt chart that I am rendering. However, it is horribly slow and I cannot find a way to make it work faster, I can provide my code snippet here but not more than that for now:

This is the way that I load data to the "userFilterData" array.

Code: Select all

    let userFilterData = [
      'printChart',
      'downloadPNG',
      'downloadJPEG',
      'downloadPDF',
      'downloadSVG',
      'separator', // Separator između standardnih opcija i prilagođenih opcija.
    ];
    
    data.users.forEach(function (user) {
      colors[user.login] = getRandomHexColor();

      userFilterData.push({
        text: user.fullName,
        onclick: function (ctx) {
          this.series[0].data.forEach(point => {
            // Check if the point matches to button innerHTML target value.
            if (point?.owner !== ctx.target.innerHTML) {
              point.update({
                visible: false
              })
            } else {
              point.update({
                visible: true
              })
            }
          })
        }
      });
    });
I have also set the click method for point events as seen in some of the tutorials I have stumbled upon

Code: Select all

          point: {
            events: {
              click: function (e) {
                e.point.update({
                  visible: false
                }, true, false)
              }
            }
          }
This is actually the demo that was my reference: https://jsfiddle.net/BlackLabel/6pmuscLw/
User avatar
dawid.d
Site Moderator
Posts: 1162
Joined: Thu Oct 06, 2022 11:31 am

Re: Point visibility really slow when using menuItems onclick() function

Hi,

Welcome to the forum and thank you for reaching out.

I've tried to reproduce this issue, but it seems to work fine for me, with no lag. Could you send a demo where I can directly experience these performance issues?

I see you're updating the points in a loop one by one, without the render-disable flag. There may be a problem here, but I can't figure it out without more context.

Thanks in advance!

Best regards
Dawid Draguła
Highcharts Developer

Return to “Highcharts Gantt”