Search code examples
javascriptamcharts4

Add horizontal line to AmCharts4 Dumbbell plot


I would like to add an horizontal line to an AmCharts4 Dumbbell plot. Since the x-axis is categorical, is it possible? The line must have different settings than the lines of the grid (e.g. larger, dashed, colored).


Solution

  • Found the way here.

    var range = valueAxis.axisRanges.create();
    range.value = 1000;
    range.grid.stroke = am4core.color("#396478");
    range.grid.strokeWidth = 2;
    range.grid.strokeOpacity = 1;
    range.grid.strokeDasharray = "6,3";
    

    This works for other kinds of charts, of course.