mirror of
				https://github.com/mermaid-js/mermaid.git
				synced 2025-11-03 20:34:20 +01:00 
			
		
		
		
	Merge pull request #3729 from DarkNami/feature/1598_add_tick_interval
feat(gantt): Add option 'tickInterval' for custom tick interval
This commit is contained in:
		@@ -341,4 +341,130 @@ describe('Gantt diagram', () => {
 | 
			
		||||
      expect(descriptionEl.textContent).to.equal(expectedAccDescription);
 | 
			
		||||
    });
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('should render a gantt diagram with tick is 15 minutes', () => {
 | 
			
		||||
    imgSnapshotTest(
 | 
			
		||||
      `
 | 
			
		||||
      gantt
 | 
			
		||||
        title A Gantt Diagram
 | 
			
		||||
        dateFormat   YYYY-MM-DD
 | 
			
		||||
        axisFormat   %H:%M
 | 
			
		||||
        tickInterval 15minute
 | 
			
		||||
        excludes     weekends
 | 
			
		||||
 | 
			
		||||
        section Section
 | 
			
		||||
        A task           : a1, 2022-10-03, 6h
 | 
			
		||||
        Another task     : after a1, 6h
 | 
			
		||||
        section Another
 | 
			
		||||
        Task in sec      : 2022-10-03, 3h
 | 
			
		||||
        another task     : 3h
 | 
			
		||||
      `,
 | 
			
		||||
      {}
 | 
			
		||||
    );
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('should render a gantt diagram with tick is 6 hours', () => {
 | 
			
		||||
    imgSnapshotTest(
 | 
			
		||||
      `
 | 
			
		||||
      gantt
 | 
			
		||||
        title A Gantt Diagram
 | 
			
		||||
        dateFormat   YYYY-MM-DD
 | 
			
		||||
        axisFormat   %d %H:%M
 | 
			
		||||
        tickInterval 6hour
 | 
			
		||||
        excludes     weekends
 | 
			
		||||
 | 
			
		||||
        section Section
 | 
			
		||||
        A task           : a1, 2022-10-03, 1d
 | 
			
		||||
        Another task     : after a1, 2d
 | 
			
		||||
        section Another
 | 
			
		||||
        Task in sec      : 2022-10-04, 2d
 | 
			
		||||
        another task     : 2d
 | 
			
		||||
      `,
 | 
			
		||||
      {}
 | 
			
		||||
    );
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('should render a gantt diagram with tick is 1 day', () => {
 | 
			
		||||
    imgSnapshotTest(
 | 
			
		||||
      `
 | 
			
		||||
      gantt
 | 
			
		||||
        title A Gantt Diagram
 | 
			
		||||
        dateFormat   YYYY-MM-DD
 | 
			
		||||
        axisFormat   %m-%d
 | 
			
		||||
        tickInterval 1day
 | 
			
		||||
        excludes     weekends
 | 
			
		||||
 | 
			
		||||
        section Section
 | 
			
		||||
        A task           : a1, 2022-10-01, 30d
 | 
			
		||||
        Another task     : after a1, 20d
 | 
			
		||||
        section Another
 | 
			
		||||
        Task in sec      : 2022-10-20, 12d
 | 
			
		||||
        another task     : 24d
 | 
			
		||||
      `,
 | 
			
		||||
      {}
 | 
			
		||||
    );
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('should render a gantt diagram with tick is 1 week', () => {
 | 
			
		||||
    imgSnapshotTest(
 | 
			
		||||
      `
 | 
			
		||||
      gantt
 | 
			
		||||
        title A Gantt Diagram
 | 
			
		||||
        dateFormat   YYYY-MM-DD
 | 
			
		||||
        axisFormat   %m-%d
 | 
			
		||||
        tickInterval 1week
 | 
			
		||||
        excludes     weekends
 | 
			
		||||
 | 
			
		||||
        section Section
 | 
			
		||||
        A task           : a1, 2022-10-01, 30d
 | 
			
		||||
        Another task     : after a1, 20d
 | 
			
		||||
        section Another
 | 
			
		||||
        Task in sec      : 2022-10-20, 12d
 | 
			
		||||
        another task     : 24d
 | 
			
		||||
      `,
 | 
			
		||||
      {}
 | 
			
		||||
    );
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('should render a gantt diagram with tick is 1 month', () => {
 | 
			
		||||
    imgSnapshotTest(
 | 
			
		||||
      `
 | 
			
		||||
      gantt
 | 
			
		||||
        title A Gantt Diagram
 | 
			
		||||
        dateFormat   YYYY-MM-DD
 | 
			
		||||
        axisFormat   %m-%d
 | 
			
		||||
        tickInterval 1month
 | 
			
		||||
        excludes     weekends
 | 
			
		||||
 | 
			
		||||
        section Section
 | 
			
		||||
        A task           : a1, 2022-10-01, 30d
 | 
			
		||||
        Another task     : after a1, 20d
 | 
			
		||||
        section Another
 | 
			
		||||
        Task in sec      : 2022-10-20, 12d
 | 
			
		||||
        another task     : 24d
 | 
			
		||||
      `,
 | 
			
		||||
      {}
 | 
			
		||||
    );
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('should render a gantt diagram with tick is 1 day and topAxis is true', () => {
 | 
			
		||||
    imgSnapshotTest(
 | 
			
		||||
      `
 | 
			
		||||
      gantt
 | 
			
		||||
        title A Gantt Diagram
 | 
			
		||||
        dateFormat   YYYY-MM-DD
 | 
			
		||||
        axisFormat   %m-%d
 | 
			
		||||
        tickInterval 1day
 | 
			
		||||
        excludes     weekends
 | 
			
		||||
 | 
			
		||||
        section Section
 | 
			
		||||
        A task           : a1, 2022-10-01, 30d
 | 
			
		||||
        Another task     : after a1, 20d
 | 
			
		||||
        section Another
 | 
			
		||||
        Task in sec      : 2022-10-20, 12d
 | 
			
		||||
        another task     : 24d
 | 
			
		||||
      `,
 | 
			
		||||
      { gantt: { topAxis: true } }
 | 
			
		||||
    );
 | 
			
		||||
  });
 | 
			
		||||
});
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user