amcharts4

Is it possible to display specific hours per day in AMChart4 DateAxis


I am displaying a Gantt chart based on the AMCharts4 Gantt example which does pretty much what i want. But i need the date axis to always display specific hours of the day. e.g. Every day from 8 a.m. to 5 p.m. (or 8 to 17). Even if there is no data or even if there is more data.

I already played around with the interval settings (https://www.amcharts.com/docs/v4/concepts/axes/date-axis/) but i do not quite get the result i want.


Solution

  • Ok, i eventually made it. I am now using axis breaks.

    var axisBreak = dateAxis.axisBreaks.create();
    axisBreak.startDate = new Date( day + " 00:00" );
    axisBreak.endDate = new Date( day + " 07:30" );
    
    axisBreak = dateAxis.axisBreaks.create();
    axisBreak.startDate = new Date( day + " 17:30" );
    axisBreak.endDate = new Date( day + " 23:59:59.999" );
    

    Works for the things i want to achieve, yet ;)