Adding Horizontal Line to Line Chart

Hi,

Can someone advise how I can insert a horizontal line in the line graph I have. The line needs to be at value 15 as pictured below. I’m new to amCharts and tried looking it up to no avail.

s1
s2

Line Chart.OL-template (8.4 KB) test.OL-datamapper (11.2 KB)

Regards,
S

Was able to solve this using “guides”. Right click the chart object in the main editor and choose Chart… Click the Source tab and add the following snippet to the JSON data:

"guides": [
{
  "value": 15,
  "lineColor": "#CC0000",
  "lineAlpha": 1,
  "fillAlpha": 0
}],

See the screendump below.

Hope this helps.

Erik

Line Chart.OL-template (9.4 KB)

1 Like

Thanks Erik. I was so focused on javascript that I did not even look at the json source.

Would something like this work in a print template? (without animations) I like the “Target” text above the line.

Is there some documentation you can point me too regarding AMCharts and Connect. I found some mentions of documentation here but the links no longer work. I really need to sharpen up my chart knowledge as I don’t want to be on the back foot should another request be made.

Regards,
S

Our implementation is current relying on amCharts v3.
https://www.amcharts.com/docs/v3/

Our UI exposes a subset of the features but many can be added via the Source tab of the Chart Properties dialog. These settings are stored in the data-amchart attribute of the chart element. This you could retrieve in a standard User Script and modify if needed. The snippet below adds your horizontal guide via a script (use #line as the selector for your script). This would also allow you to use a data field for the value and lineColor.

let chartConfig =  JSON.parse( results.attr('data-amchart') );

chartConfig.guides = [
    {
      "value": 10,
      "lineColor": "#CC0000",
      "lineAlpha": 1,
      "fillAlpha": 0
    }
  ]

results.attr('data-amchart', JSON.stringify( chartConfig ) )

Hope this helps,

Erik