jQuery UI Widgets › Forums › Chart › Undefined Chart.Source.Records
Tagged: charting, charts, javascript charts, jquery charts
This topic contains 3 replies, has 3 voices, and was last updated by Peter Stoev 9 years, 3 months ago.
-
Author
-
I have a chart which has dynamic data depending on user selections (I change the source and adaptor depending on what the user has selected) and want to allow users to click on the series to open up a more detailed chart depending on what is clicked. In order to do this I reference the chart instance, lookup the source and records from the elementIndex when clicked and then pass to another function (see code) called getEmployeeDetails.
$('#ContactsPerAgent_Chart').on('click', function (event) { if (event.args) var index = event.args.elementIndex; var chart = $('#ContactsPerAgent_Chart').jqxChart('getInstance'); var items = chart.source.records[index]; console.log(items); var name = items.endUser; getEmployeeDetails(chart.source.records[index].endUser); });
In the console I get the object returned with the right information but also a second return of undefined.
Object {endUser: "Test, Case", Totals: "37", uid: 0} EmployeesContactEvents.js:149 undefined EmployeesContactEvents.js:150 Uncaught TypeError: Cannot read property 'endUser' of undefined
Chrome will continue and work as intended, with the error in the console above, however IE (with the console.log removed) it breaks and will not continue with the same error.
Am I missing something very obscure or is this something I will need to rework the manner in which I was going to code?
Hi AdamC,
Here is how to handle click events in jqxChart: http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxchart/javascript_chart_events.htm?arctic.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter,
Thanks for the reply, but I must say its not that helpful for two reasons.
1) The link you provide opens only the chart not the actual information for it as opposed to linking “http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxchart/#demos/jqxchart/javascript_chart_events.htm”
2) Your answer does not point me to a solution. I would liken it to someone asking a question in a school room to be handed a textbook from the teacher saying “its in here”.
Now after a weekend of trial and error I have taken the coding from each event and placed into a second function (seams a little strange to call a second function but will run with it) called after the if statement in the click function.
While I appreciate the reply a simple “Place the code you have written into myEventHandler like the demo code and call it in your click function” would have been alot more constructive I feel.
Adam.
Hi Adam,
When the solution is simple, so the answer is. The demo I pointed you out shows exactly how to handle Events in jqxChart, shows the clicked data source fields and values.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.