Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6942293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:59:48+00:00 2026-05-27T12:59:48+00:00

In the old Google Chart API it was possible to use PHP to render

  • 0

In the old Google Chart API it was possible to use PHP to render a chart, there was even a wrapper to do it:
http://code.google.com/p/gchartphp/

But with the new Chart API
http://code.google.com/apis/chart/
which produces much fancier chart, but loads only with javascript in the browser.

The effect I am trying to achieve is submitting a multiple choice form to the server via AJAX, have the PHP update the DB serverside, then return the updated chart.

In the old API way I could have done this. But in the new way I would be returning javascript to the browser and appending it to the document in order to render the chart. It wouldn’t execute because of this. I believe I could eval() this javascript but that is bad form isn’t it because someone could do some nasty stuff with that couldn’t they – eval()ing a serverside response?

How can I overcome this? Is there a PHP wrapper to help this? Or is there another why which I have overlooked?

Many thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:59:49+00:00Added an answer on May 27, 2026 at 12:59 pm

    The way I solved this issue was pretty obvious in the end. I just needed to step outside my thoughts and approach it from a different angle.

    I was trying to all the leg work of processing the database information AND creating the Google Chart (a Pie Chart in this case) on the server side, using PHP. Then return that as the AJAX response.

    Actually all I needed to do was return the data needed to create the Pie Chart (along with some extra meta data such as target element id). I did this as JSON. Then by picking through the Google Charts documentation I was able to find out how to trigger the API using client side javascript to load the returned JSON data. Then let the Google code render the chart client side – so I basically shifted all the rendering responsibility to the client browser. This is where the old and new chart APIs differ.

    It took a lot of trial and error and plenty of help from Firebug. One big tripping point which is worth mentioning is that you need to load all the Google JSAPI before you receive the JSON response – so as the initial page renders – and one thing you must do with:

    google.load("visualization", "1", {packages:["corechart"]});
    

    is make sure it loads as the page is rendering. If you call this after the page has completely rendered then the page will reload.

    Hope this helps someone.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to add TCMPortMapper (http://code.google.com/p/tcmportmapper/) I have linked the framework in the
Is Google font api supported in all current and old browsers? and will it
Google Docs Viewer ( http://docs.google.com/viewer ) creates a cache of a document after the
Since Google has deprecated their old web search API as of recently, what are
I'm using the GSON library and calling the fromJson() method: http://google-gson.googlecode.com/svn/tags/1.2.3/docs/javadocs/com/google/gson/Gson.html My old code:
http://chart.googleapis.com/chart?cht=map:fixed=?,?,?,?&chs=550x350 how do you display the world map in the new version above like
There was this old game (J2ME) but I cannot find it now in google.
For unofficial google reader api, we can use Atom feed api and also can
Scenario: old legacy code in rpg have to consume data from a new web
I have inherited an old crusty PHP application , and I'd like to refactor

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.