Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency lines plugin: page becomes unresponsive on zoom change #364

Open
Icebreaker83 opened this issue Jan 31, 2023 · 1 comment
Open

Comments

@Icebreaker83
Copy link

Icebreaker83 commented Jan 31, 2023

Describe the bug
When DependencyLines plugin is used and we have items where grandchild item has time.start > time.end, and zoom iz changed, and then horizontal scroll to the right, page becomes unresponsive.

Same happens on zoom change only, depending if items are currently rendered or not.

When child item has time.start > time.end then this doesn't happen.

No errors in console.

Code
How to reproduce this error?
Codesandbox HERE

import GSTC from 'gantt-schedule-timeline-calendar/dist/gstc.wasm.esm.min.js';
import { Plugin as DependencyLines } from 'gantt-schedule-timeline-calendar/dist/plugins/dependency-lines.esm.min.js';
import 'gantt-schedule-timeline-calendar/dist/style.css';

let gstc, state;

const items = {
  'gstcid-303026010': {
    id: 'gstcid-303026010',
    label: 'Parent',
    dependant: ['gstcid-303026014'],
    rowId: 'gstcid-303026010',
    startFormatted: '2022-01-05',
    finishFormatted: '2022-02-21',
    time: { start: 1641366000000, end: 1645441200000 },
    type: 'project',
  },
  'gstcid-303026014': {
    id: 'gstcid-303026014',
    label: 'Child',
    dependant: [
      'gstcid-3030101723',
    ],
    rowId: 'gstcid-303026014',
    startFormatted: '2022-02-04',
    finishFormatted: '2022-02-21',
    time: { start: 1643972400000, end: 1645441200000 },
    type: 'wbs',
  },
  'gstcid-3030101723': {
    id: 'gstcid-3030101723',
    label: 'Grandchild',
    rowId: 'gstcid-3030101723',
    startFormatted: '2038-02-16',
    finishFormatted: '2022-02-16',
    time: { start: 2149930800000, end: 1645016400000 },
    type: 'activity',
  },
};

const rows = {
  'gstcid-303026010': {
    id: 'gstcid-303026010',
    label: 'Parent',
  },
  'gstcid-303026014': {
    id: 'gstcid-303026014',
    label: 'Child',
  },
  'gstcid-3030101723': {
    id: 'gstcid-3030101723',
    label: 'Grandchild',
  },
};

export default {
  name: 'GSTC',
  mounted() {
    const config = {
      licenseKey:
        '====BEGIN LICENSE KEY====\nXOfH/lnVASM6et4Co473t9jPIvhmQ/l0X3Ewog30VudX6GVkOB0n3oDx42NtADJ8HjYrhfXKSNu5EMRb5KzCLvMt/pu7xugjbvpyI1glE7Ha6E5VZwRpb4AC8T1KBF67FKAgaI7YFeOtPFROSCKrW5la38jbE5fo+q2N6wAfEti8la2ie6/7U2V+SdJPqkm/mLY/JBHdvDHoUduwe4zgqBUYLTNUgX6aKdlhpZPuHfj2SMeB/tcTJfH48rN1mgGkNkAT9ovROwI7ReLrdlHrHmJ1UwZZnAfxAC3ftIjgTEHsd/f+JrjW6t+kL6Ef1tT1eQ2DPFLJlhluTD91AsZMUg==||U2FsdGVkX1/SWWqU9YmxtM0T6Nm5mClKwqTaoF9wgZd9rNw2xs4hnY8Ilv8DZtFyNt92xym3eB6WA605N5llLm0D68EQtU9ci1rTEDopZ1ODzcqtTVSoFEloNPFSfW6LTIC9+2LSVBeeHXoLEQiLYHWihHu10Xll3KsH9iBObDACDm1PT7IV4uWvNpNeuKJc\npY3C5SG+3sHRX1aeMnHlKLhaIsOdw2IexjvMqocVpfRpX4wnsabNA0VJ3k95zUPS3vTtSegeDhwbl6j+/FZcGk9i+gAy6LuetlKuARjPYn2LH5Be3Ah+ggSBPlxf3JW9rtWNdUoFByHTcFlhzlU9HnpnBUrgcVMhCQ7SAjN9h2NMGmCr10Rn4OE0WtelNqYVig7KmENaPvFT+k2I0cYZ4KWwxxsQNKbjEAxJxrzK4HkaczCvyQbzj4Ppxx/0q+Cns44OeyWcwYD/vSaJm4Kptwpr+L4y5BoSO/WeqhSUQQ85nvOhtE0pSH/ZXYo3pqjPdQRfNm6NFeBl2lwTmZUEuw==\n====END LICENSE KEY====',
      plugins: [
        DependencyLines(),
      ],
      list: {
        columns: {
          data: {
            [GSTC.api.GSTCID('id')]: {
              id: GSTC.api.GSTCID('id'),
              width: 60,
              data: ({ row }) => GSTC.api.sourceID(row.id),
              header: {
                content: 'ID',
              },
            },
            [GSTC.api.GSTCID('label')]: {
              id: GSTC.api.GSTCID('label'),
              width: 200,
              data: 'label',
              header: {
                content: 'Label',
              },
            },
          },
        },
        rows: rows,
      },
      chart: {
        items: items,
        time: {
          from: 1638313200000,
          to: 1704063599999,
          zoom: 20,
        },
      },
    };

    state = GSTC.api.stateFromConfig(config);

    gstc = GSTC({
      element: this.$refs.gstc,
      state,
    });
  },

  beforeUnmount() {
    if (gstc) gstc.destroy();
  },

  methods: {
    zoomChange(ev) {
      const period = ev.target.value;
      let zoom = 20;
      switch (period) {
        case 'hours':
          zoom = 16;
          break;
        case 'days':
          zoom = 20;
          break;
        case 'months':
          zoom = 26;
          break;
      }

      state.update('config.chart.time', (time) => {
        time.zoom = zoom;
        return time;
      });
    },
  },
};

gantt-schedule-timeline-calendar version
What version are you using?
3.33.13

Screenshots or movies
When items currently rendered and zoom changed (page immediatelly unresponsive)
gannt_dependency_bug_1

When zoom changed, then horizontal scroll (page unresponsive when item needs to be rendered)
gannt_dependency_bug_2

@Icebreaker83 Icebreaker83 changed the title Dependency lines plugin: page becomes unresponsive on zoom change > horizontal scroll Dependency lines plugin: page becomes unresponsive on zoom change Jan 31, 2023
@neuronetio
Copy link
Owner

When the start time is later than the end time, the calculation is probably going wrong.
You shouldn't have such tasks. The only thing that can be done in this situation is to either swap the start and end of tasks if they are incorrect or display an error. I'll come back to that later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants