简体   繁体   中英

Insert database data into Google charts?

I'm thinking about going with Google charts for a project I'm working on. I have all my data on my own server and so I was wondering what is the best way to go about inserting this data into a chart, there are a few alternatives:

  1. Create the DataTable object from data that is provided inline. That is, print all the data into the HTML document. This will crowd out everything else since I have a lot of data, but I don't know if this is important. This way we can avoid one HTTP request.
  2. Dynamically create a .js files for every request, holding the data, and letting it be included with a script tag in the document.
  3. Retrieve the data using ajax (Google suggests this in their documentation)
  4. Using the chartwrapper and adding a datasource pointing to my own server. This would be equivalent to the above, I suppose, and functionally equivalent to (2).

So what is the most common solution? What do you usually solve this?

I wouldnt worry about crowding out your data. Printing it out into a javascript datatable wont be visible to the user, and the browser wont care. However I would suggest you only print out what you need for each page so you dont have more than required.

I think probably any of your solutions are fine, so pick the one that suits you best.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM