在amcharts甘特图中画一条代表当前日期的垂直线?

Draw a vertical line representing the current date in amcharts gantt chart?

*在当月画一条垂直线。这里是示例代码 * https://codepen.io/anon/pen/PgELdM * 这就是我想要实现的目标 * https://ibb.co/XjVn4WC

console.log("thank you");

您可以使用 axis guides to draw single lines beneath the chart。例如

var range = dateAxis.axisRanges.create();
range.date = new Date("2016-03-14");
range.grid.stroke = am4core.color("red");
range.grid.strokeWidth = 2;
range.grid.strokeOpacity = 1;

演示:

https://codepen.io/team/amcharts/pen/bb11ebefe894ad526d4bd959fccccf08

如果你需要在各种系列之上加一条线,你可以做一个全高 line (y1, y2 at 0, not sure how to get the top of the chart value... says it only takes numbers meaning pixels, but maybe it can work with am4core.percent(100)?), for its x you'll have to convert date to a coordinate on the chart (the dateAxis will probably have methods),然后把它放在 chart.plotContainer.