1

I am using javascript amcharts v3 to generate trend like interface element. I use trendline class to create trend lines that mark certain events. I would like to handle trendline click event but there seems to be no way of doing it.

Has anyone come across this type of problem or do you have any idea how to work around this?

For trend line example I use this page. There is jsfiddle link in it.

Thank you for the time you spend reading my question.

Edit: JSfiddle example - > here

melanholly
  • 762
  • 1
  • 9
  • 20

1 Answers1

1

Not the most elegant solution (i.e. it uses the generated content rather than hooking neatly into the framework), but I have done the following to catch a click event.

$('#chartdiv').on('click', 'svg path[fill="#00CC00"]', function(){alert('hello');})

Which will bind a click to the chartdiv and then filter on all svg path objects that are the colour of the trendline, triggering the code if it matches.

tonycoupland
  • 4,127
  • 1
  • 28
  • 27
  • This does not semm to work for me. I use chrome 36.0.1985.125 m (WOW havn't checked chrome version lately). Can you provide working jsfiddle example? – melanholly Jul 24 '14 at 14:24
  • I injected that line into Chrome debug window and got the alert... I'll try and update the jsFiddle to do it as well, give me 5 – tonycoupland Jul 24 '14 at 14:31
  • Using jQuery 'on' version of the above, as in http://jsfiddle.net/YVk4a/1/ seems ok. I'll update my answer... you need to click just to the left of the line... like I say, not the most elegant. Sorry :( – tonycoupland Jul 24 '14 at 14:34
  • Well it is some kind of solution. Thank you! Here take my vote! – melanholly Jul 24 '14 at 16:42