Skip to content

Unable to define zoom for minute unit #11

@danielleanspace

Description

@danielleanspace

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading '')

export const zoomConfig = {
  level: 3,
  levels: [
    {
      minCellWidth: 100,
      scales: [
        { unit: 'month', step: 1, format: 'MMMM yyy' },
        { unit: 'week', step: 1, format: "'week' w" },
      ],
      maxCellWidth: 0,
    },
    {
      maxCellWidth: 200,
      scales: [
        { unit: 'month', step: 1, format: 'MMMM yyy' },
        { unit: 'day', step: 1, format: 'd', css: dayStyle },
      ],
      minCellWidth: 0,
    },
    {
      minCellWidth: 25,
      maxCellWidth: 100,
      scales: [
        { unit: 'day', step: 1, format: 'MMM d', css: dayStyle },
        { unit: 'hour', step: 6, format: hoursTemplate },
      ],
    },
    {
      maxCellWidth: 120,
      scales: [
        { unit: 'day', step: 1, format: 'MMM d', css: dayStyle },
        { unit: 'hour', step: 1, format: 'HH:mm' },
      ],
      minCellWidth: 0,
    },
    {
      maxCellWidth: 250,
      scales: [
        { unit: 'hour', step: 1, format: 'HH:mm', css: dayStyle },
        { unit: 'minute', step: 1, format: (d) => format(new Date(d), 'HH:mm') },  // Error
      ],
      minCellWidth: 0,
    },
  ],
};

registerScaleUnit('minute', {
  start: (date) => startOfMinute(new Date(date)),
  end: (date) => endOfMinute(new Date(date)),
  isSame: (a, b) => isSameMinute(new Date(a), new Date(b)),
  add: (date, amount) => addMinutes(new Date(date), amount),
});

const Timeline: React.FC = () => {
  const data = useMemo(() => getData(), []);

  return (
    <Stack spacing={3}>
      <MainInfo />
      <WillowDark>
        <Gantt tasks={data.tasks} links={data.links} zoom={zoomConfig} />
      </WillowDark>
    </Stack>
  );
};

export default Timeline;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions