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

  • Home
  • SEARCH
  • 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 9295483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T21:36:54+00:00 2026-06-18T21:36:54+00:00

I’m writing a program that take a generated data set via Google API and

  • 0

I’m writing a program that take a generated data set via Google API and displays it in PHP. This is perfectly fine and has been achieved, however I wish to add thumbnails to the code which displays different charts of the same dataset (in thumbnail form).

I am using the Google API to generate the data and display it, but I’m not sure how I would get it to change the visualisation type (currently using Pie as the main chart) so the user is able to view the different visualisations for that dataset.

Here is the code in question:

Load the AJAX API

 <script type="text/javascript" src='https://www.google.com/jsapi?autoload={"modules":[{"name":"visualization","version":"1","packages":["corechart","table"]}]}'></script>

The data:

var data = new google.visualization.DataTable();
data.addColumn('string', 'City');
data.addColumn('number', 'Number of Crimes');
data.addRows([
             ['Cardiff', 300],
             ['London', 900],
             ['Manchester', 500],
             ['Dublin', 400],
             ['Liverpool', 600]
             ]);

Draw the Graph:

var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);

Here are the thumbnails:

<div id="left">
  <p>Bar chart</p>
  <a href="#"><img src="http://donsmaps.com/clickphotos/dolnivi200x100.jpg"></img></a>
  <p>Another chart</p>
  <a href="#"><img src="http://donsmaps.com/clickphotos/dolnivi200x100.jpg"></img></a>
  <p>Another chart</p>
  <a href="#"><img src="http://donsmaps.com/clickphotos/dolnivi200x100.jpg"></img></a>
</div>
<div id="right">
  <p>Scatter Chart</p>
  <a href="#"><img src="http://donsmaps.com/clickphotos/dolnivi200x100.jpg"></img></a>
  <p>Another chart</p>
  <a href="#"><img src="http://donsmaps.com/clickphotos/dolnivi200x100.jpg"></img></a>
  <p>Another chart</p>
  <a href="#"><img src="http://donsmaps.com/clickphotos/dolnivi200x100.jpg"></img></a>
</div>

So basically, how would I get google.visualization.BarChart (and others) into the img src for the thumbnails?

IS this even possible?

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-06-18T21:36:55+00:00Added an answer on June 18, 2026 at 9:36 pm

    I’ve had to solve a similar problem, and there are two solutions (that I’m aware of), neither of which is perfect.

    The first solution is to use Google’s image chart api to essentially re-create your SVG charts. You can pass in your dynamic data via the src URL of an image. The major drawbacks of this approach are (a) You have to re-create each chart via the image-chart api; and (b) Google Image Chart API is officially deprecated. However, Google has committed to maintaining the service at least through April 2015, so if you expect the site to evolve by then it’s a valid approach. One other thing to mention is that you’ll likely want to create relatively large thumbnails and then scale them down, so that the proportions (text size, for instance) match the relative proportions of the final SVG version.

    The second solution (which I’m currently using) is to employ a screen-capture service like URL2PNG. Most screen capture APIs won’t work because they either ignore JS or take the screenshot before the JS has been applied, but url2png and a few other services are able to do this. Just create a simple caching system to store screenshots of each chart (you may want to have each chart be accessible via a URL that displays the chart on an otherwise blank template so that you don’t have to worry about screen position or cropping issues), and have this cache get cleared and rebuilt any time the data is altered (you’ll need a cache, though, as screen-capture services are inherently pretty slow). The major drawback of this approach is that you’ll have to pay for the service (I’m not aware of any free screen-capture service that can accurately capture google charts).

    Personally, I’m disappointed that Google hasn’t created an easy way to create thumbnails, as it seems like a pretty common task, but to my knowledge some kind of workaround like this is necessary.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I know there's a lot of other questions out there that deal with this
I'm trying to create an if statement in PHP that prevents a single post
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text

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.