02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoNext Video

Google Visualization API

Google Visualization API

Video Transcript

00:00All right so this is enough of a programming intro and it's time for us to actually start working.
00:05So what we'll do is what I want to do is I want to start off just going right into the
00:09javascript file. Now although a lot of times you would want to create some sort of an on listener
00:14you might want to go to the body and create an onload and then call your javascript file
00:18or create some sort of a listener inside of our javascript file itself, in our case we're not
00:23going to do that. Now the reason is it's very simple is because we're going to be using the
00:27google visualization api. We are not actually going to use anything inside of the visualization
00:34api itself beyond a usage of data. What we want to do is we want to load in the content of the file
00:42or in and the south. To do that what we want to do is we want to load the visualization api
00:48in its most stable version which it means is basically the live version of it currently
00:53and for that we would type google.load and we would load the visualization api by typing
00:59visualization by telling basically that way we're telling google that we want to load
01:05in the visualization api and the next step after that we want to tell it one version of it. Now
01:10this is a very important thing to note we're going to set it as 1.0. Now 1.0 means it's
01:17the most current up-to-date api. Now the most the biggest problem with using the 1.0 is that
01:23the api changes and updates with that said google always creates a backup of a version before it
01:29moves on to another version thus if you're building something that's not specifically in the google
01:34api or you're afraid that the api will update your best move and smartest move would be to update
01:41it to the specific version that you want and need. Now with that said and i'm i won't say much more
01:48regarding this besides the fact that if this is a really important factor now if in another month
01:54or two or three months while you're building your site suddenly something breaks your best chances
01:59are and your highest odds are that the visual i hate that word the visualization and i wrote a
02:07book that has a word visualization in it and i hate saying it look and if you're wondering what
02:12book that is it's the html5 um i don't even remember the name of my book here me let me check
02:19what the name of my book is so it's actually inside of books it's called html5 graphing
02:23it's actually graphing not graphics html5 graphing and data visualization cookbook so in case you
02:29want to learn from it which we explore really really deeply into javascript in general and into
02:34visualization apis in general and how to create charts and even how to work with google maps and
02:38data apis and so on and so forth and actually this this this source um that we're using is also used
02:45inside of my book in chapter i believe nine so i hope you check that out as well but in the meantime
02:51let's get back to our training and we were talking about going back into our code itself we were
02:55talking about that it's really important for you to know what version you're in now for our sake
02:59and purpose right now we're just going to put 1.0 because we're going to work with whatever's
03:03there right now the only challenge with that is things change and when things change we might get
03:09into trouble all right so once we already set to google and we told that we want to load the
03:13visualization api the next thing we want to do is tell google what to do once it's loaded so
03:19we're going to set an on load callback and notice the camel casing really important so our
03:26o our l our c is all camelback and by the way a callback is literally an event you could say
03:32or it's it's um it's an important thing to note well we talked about events briefly we didn't go
03:38deep into the concept of events but we will and what better time than right now to to get that
03:44juices flowing an event basically in object-oriented programming enables you to basically
03:50listen into something and wait for it until it happens we've used it whenever we were listening
03:55into events we can even create our own events now there are two different types of events in
04:00object-oriented programming in general one is in a literal event and the other one is a callback
04:06now the difference between a callback and event is not very big a callback usually has only one
04:11function specific that it calls whatever an operation is done such as in this case we're
04:17literally telling google once you're done call the init function that basically means there's
04:21really only one function that would ever be called once we create that interface now there might be a
04:26way to call it twice but we would never really want to when we're using callbacks
04:31events on the other hand we basically register them to a model that basically enables us to trigger
04:38events and that model that triggers events will cycle through all the different functions that
04:42need to be called and it calls them and that's really the difference between events that are
04:46callbacks and events that are a little bit more structured which are fully formed events
04:53now in our case because we're outside we're not actually triggering an event
04:57all we are doing is listening to an event or in our case we're sending in that we're beyond
05:02listening we're actually sending in our method directly inside of google to the api itself
05:08telling it well call this function once you're ready all right now obviously the next thing
05:12that we'd want to do is create that function so we're going to create that function
05:20now before we do anything else i would love to be able to test out and see what actually
05:24happened once we load it well actually nothing will happen right because we're literally inside
05:29now of the end our visualization is over but let's type into our console dot com and we'll
05:35just type here the zoo look i hate that word um and just let me make sure that i type the word
05:43visualization correctly let me copy that from a side note that i have here because i hate that
05:48word as i've told you so let me just double triple whoops what am i doing okay and this
05:55is just something that um the version of um dreamweaver that i have is just so messed up
06:02that it just gives me so many errors and we're just going to ignore them so i'm just going to
06:07type your visualization load it and i just ignore the errors because the errors usually mean
06:11nothing and unfortunately um dreamweaver is not smart enough currently right now to deal with it
06:17i just ignore the errors because the errors are are at least at cs6 and the current version that
06:21i have is not that great to be honest all right so um we got our function but there's a lot of really
06:30cool stuff going on so the next thing i want to do is i'm just going to jump back right into the
06:33browser go into my um global mass traveling and i will right click go to my firebug and from my
06:43firebug panel itself i'll go into my console and now that i'm in the console i'm going to
06:48refresh my page and hope that i'll be able to see once the load is complete the visualization
06:53was loaded and we could see that it definitely was loaded now by the way if you're working with
06:58a different browser i think we've talked about it but in case we didn't you just have to google it
07:04and or come to our our blog or even send us an email and ask us how do you expose the console
07:09in your application if you really can't find it and you're really shy you could change the word
07:14console to just alert although not as friendly because this is stuff the users see well this
07:20is something only programmers would see which makes life easier because then you don't have to
07:24worry about by mistake exposing the users to traces that you didn't want them to trace
07:29so it's actually really really convenient to work with the console.log so we just showed you how
07:36to do it in firefox but obviously there are a lot of different browsers and most of them today
07:39enable doing it if you do a quick google on it or even come maybe into our course information we
07:47will try to upload the different links for you to learn how to do it in the specific browser
07:51that you're working in so we'll get on top of that make sure that our writers know that they
07:55need to write about that yep all right cool so moving on so we got that set it's time for us now
08:02to actually start using the visualization api

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!