MaazAli / Meteor-HighCharts

HighCharts for Meteor, with an easy to use helper to get you started!
MIT License
53 stars 20 forks source link

How to listen to a drill down event with Meteor? #23

Open javaknight opened 9 years ago

javaknight commented 9 years ago

What I am trying to achieve:

  1. I need to use Template.myTemplate.events to access the bar-chart drilldown click in HighCharts via meteor.
  2. I need this because I need access to the template where it lives.
  3. Using the highcharts API, I don't know how to reference the template and pass on the information to the attachedFilter (see below).

The api for drilldown is here. http://api.highcharts.com/highcharts#plotOptions.series.point.events.click

I am trying to listen to an event. For example, if a column chart is set up with A = 4, B = 9, and C = 2

Here's my (pseudo) code. If someone clicks column B, I want B and 9.

Template.myChartTemplate.events({ "dontknowwhattoputhere" : function (e,t) { var aaa = ... something that retrieves the column name, which is B... ; var bbb = .... something that retrieves the value of the column, which is 9...; console.log("looks like you clicked on "+aaa+" and the val is "+bbb); // I also need access to the template (t) , because I have something attached to it that I need to reference. t.attachedFilter.set(aaa, bbb); // <== Passing on aaa and bbb to an attached filter on the template } });

jhuenges commented 9 years ago

Have you tried this? You need to register the click event in the chart. If you dont want to write the function in the chart object, you can reference a function.