angular-ui / ui-chart

This directive lets you use jqPlot with Angular
http://angular-ui.github.io/ui-chart
111 stars 62 forks source link

Not working on 1.0.8 version of jqPlot #20

Open newtonwagner opened 9 years ago

newtonwagner commented 9 years ago

I've tried to use ui-chart with jqPlot 1.0.8 and kept getting error:

TypeError: elem.jqplot is not a function at renderChart (ui-chart.min.js:29) at Object.fn (ui-chart.min.js:33) at m.$get.m.$digest (angular.min.js:124) at m.$get.m.$apply (angular.min.js:127) at l (angular.min.js:81) at P (angular.min.js:85) at XMLHttpRequest.H.onload (angular.min.js:86)

The error was on line 29:

elem.jqplot(data, opts);

Looking for examples on jqPlot, looks like they have changed the way you use jqplot, so I've solved this changing the template to add an element ID, and calling the element ID on line 29:

template: '<div id="chart"></div>',
// ...
$.jqplot('chart',data, opts);

Worked fine! I will try to make a pull request changing this, but I need to figure out how to allow more than one chart for the same page (make the element id dynamic).

If someone has an idea about this, it would be great. ty.

newtonwagner commented 9 years ago

$.jqplot(elem.attr('id'), data, opts); is enough to make ui-chart back to work. No need to change the template. It is already dynamic! :)

tohyf commented 8 years ago

I had this problem and the fix above is working ! Anyone going to merge the pull request ?

PowerKiKi commented 8 years ago

The first thing to do would be to fix Travis build, then fix the PR and their tests. Only then could it be merged.