Saved searches

Use saved searches to filter your results more quickly

Cancel Create saved search Sign up Reseting focus

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Morris.js setData(func()) not working on single call #427

msam1300 opened this issue Jun 9, 2014 · 1 comment

Morris.js setData(func()) not working on single call #427

msam1300 opened this issue Jun 9, 2014 · 1 comment

Comments

msam1300 commented Jun 9, 2014

I am having an issue with the Morris.graph.. In the documentation available on the morris.js homepage, it says we can use the setData function to assign data to the graph. However, in my situation, the graph only gets populated once I call setData in a setInterval atleast 3 times (in a loop).

The first time, it creates the space where the graph is located but doesn't show anything on the graph. My code is as follows:

var lead_array = []; function lead_data() < var jqxhr = $.getJSON( "lead_volume", function(data) < lead_array = data; console.log('success'); console.log(JSON.stringify(lead_array)); >); return lead_array; > var lead_volume = Morris.Line(< element: 'lead_volume', xkey: 'date', ykeys: ['total'], labels: ['Total'] >); lead_volume.setData(lead_data()); 

My console displays the following:

> c success [] Uncaught TypeError: Cannot read property 'length' of undefined 

If the data is called from the Url: lead_volume and is displayed by the JSON.stringify, then why isn't the graph being populated. Please keep in mind that if I were to copy that data and paste it directly under Morris.Line < data: my data here as seen above >, then it works and I also don't get the [property 'length' of undefined] error.

Any help will be very appreciated.

The text was updated successfully, but these errors were encountered: