Lucas Saraiva
Lucas Saraiva

Reputation: 11

AmCharts 5 add a current date in a gantt chart

I want to draw a vertical line representing the current date on my gantt chart. Please help me.

I found this answer

https://stackoverflow.com/questions/55719235/draw-a-vertical-line-representing-the-current-date-in-amcharts-gantt-chart

but it works only in amcharts 4.

Upvotes: 0

Views: 248

Answers (1)

Lucas Saraiva
Lucas Saraiva

Reputation: 11

I found an answer to my own question:

inside the ready function we put:

function createRange(value) {
  var rangeDataItem = xAxis.makeDataItem({
    value: new Date('2023-02-04').getTime(),
    above: true
  });
  
  var range = xAxis.createAxisRange(rangeDataItem);
  
  rangeDataItem.get("grid").set("visible", true);
  range.get("grid").setAll({
    stroke: 'red',
    strokeOpacity: 1,
    width: 32,
    location: 1
  });
  
  range.get("label").setAll({
      fill: am5.color(0xffffff),
      text: '05/02',
      background: am5.RoundedRectangle.new(root, {
        fill: '#aaa'
      })
    });
  
  
}

createRange();

it might solvemy own question hahahaha. 🤦‍♂️

Upvotes: 1

Related Questions