0

I want to draw a chart using Flot. The data is stored in my database (MongoDB) and Flot is being rendered in JS - so I need to somehow pass the data from my controller to Javascript in order to give this data to Flot. I tried to make a restful api with FosRestBundle, but when i tried to call it from the javascript on document.ready, i got the following error:

XMLHttpRequest cannot load localhost:8000/ajax/loginsperday. 
Cross origin requests are only supported for protocol schemes:
http, data, chrome, chrome-extension, https, chrome-extension-resource.

What is the most efficient and proper way to draw a chart with Flot (JS) using the data from a database (MongoDB administered by Doctrine ODM)?

msniezko
  • 321
  • 1
  • 3
  • 11
  • How do you open the Flot page? Look at http://stackoverflow.com/questions/10752055/cross-origin-requests-are-only-supported-for-http-error-when-loading-a-local for inspiration. – Alex Blex Jan 22 '16 at 09:04

1 Answers1

0

you can :

  • use AJAX for load or reload data in your resolve web page or action on this (button, etc...)
  • add DOM element statically with your data from database that you have retrieve by your symfony controller doctrine. After load you plugin JS with jquery for get those element DOM data for initiate your plugins (I already use this method for google chart)

Don't forget to hide element DOM technical for just render a JS plugins

miltone
  • 4,416
  • 11
  • 42
  • 76