views:

91

answers:

3

I have been looking at the YouTube Insight function and want to learn how their chart PNGs are created.

If you have a video and look at the statistics, you get a bunch of PNG-images that in many ways can be considered interactive. Look at the image below.

As far as I can tell, everything consist of PNG images. I expected to see flash elements, but I do not.

For example: The slider where you chose date range can be dragged, clicked and the image updates dynamically without the page reloading. I am thinking, maybe ajax-style calls are made that replaces the image? It is totally seamless as far as I can see.

Another example: You can chose country by clicking the world map. The images are instantly updated to display the demography chosen. Are something simple as image maps used to catch the clicks?

Google/YouTube Insight screenshot

My questions are:

1). How do you create PNG images with information from a database? I prefer to use PHP so if you like tweak your answers in that direction. I am not looking for any third part "plugins", other than perhaps jQuery.

2). How are they creating the "interactivity" on their PNGs?

The PNGs are only clickeable and interactive when you check Google Insight on your own videos. Checking normal statistics for a video only loads static PNGs.

I know about Open Flash Chart and the likes, however I want to create my own code to learn as much as possible and be able to tailor the code for my use.

I truly appreciate any answers. Please ask for clarification if I am unclear.

EDIT: I examined the Google/YouTube source code further and found one of the images to be:

<img src="http://chart.apis.google.com/chart?chs=422x110&amp;amp;cht=lc&amp;amp;chco=808080&amp;amp;chd=s:At9j0jSUPJKMM&amp;amp;chls=1&amp;amp;chm=B,F7F7F7,0,0,0%7Ch,CCCCCC,0,-0.5,1" class="GDYWU0EBBG">

Which looks like this (saved from my valid session):

Image from source

As you can see, this is the background PNG image without the bars and the range selection overlay.

+1  A: 

AFAIK you will always need a plugin to generate images from PHP (be it GD or ImageMagick). I don't have any experience with ImageMagick, but I know GD isn't the quickest of cats.. I wouldn't count on it to generate your charts on-the-fly!

And as suggested by justkt, you could use any js library to create interactivity. No fancy flash required :)

Dennis Haarbrink
After thinking quite a bit about it I am sure you are right. I am leaning toward developing Flot or something similar to suit my own needs. Thanks!
Mattis
+2  A: 
<div id="GEOMAP_map" style="">
  <embed type="application/x-shockwave-flash" 
    src="/insights/search/resources/544738731-geomap.swf" 
    width="500" height="310" style="undefined" id="geomap"
    name="geomap" bgcolor="#FFFFFF" quality="high"
    allowscriptaccess="always" wmode="opaque" flashvars="(...)"></div>

Looks like flash to me.

troelskn
Yeah I'm using it right now... If I right click I get the Flash menu... Is it possible that Mattis is using a newer version (you know how Google only rolls out changes to some people) that uses Canvas?
Matt Olenik
Mattis
Look at my edit above.
Mattis
It might be generated by javascript. Or they might be serving different markup to different browsers.
troelskn
A: 

After thinking about it, examining the source even more, and considering the replies you guys have made I have come to the following conclusions:

1). The PNG's are generated with the Google Charts API (thanks Tom!).

2). The interactivity is created with nifty javascript programming. The seamlessness of it is hugely impressive, and I will try to implement something alike in my project.

Thank you for your replies and your time.

Mattis