In this post, I will give a complete example how to use Google Charts to draw a realtime chart, which reads data from a REST API and automatically refresh itself. In order to use Google Charts, the familiarity of the language HTML, JavaScript, and CSS will be required. I think the guide of Google Charts make it very easy for new learners to approach the technique. For people who feel hard following the guide, some tutorial resources have been provided at the end of the post to help catch up the required basic concepts.
The code of the example can be found in my GitHub. My working flow on this program is as follows.
- Prepare a REST API which provides JSON data to serve as chart data for visualization. A public GitHub API mentioned in this post is used. It contains some data about issues related to ggplot2 repository on GitHub. We can create our own REST API, as mentioned in my last post.
- Use AJAX to read JSON data from REST API to a JavaScript variable, which will be transformed to the format of Google Chart data table.
- Set up Google Chart refresh effect by using the function setRefreshInterval().
- Set up Google Chart option animation.
- Draw the chart.
For people who haven't had experiences with HTML, CSS, JavaScript, and AJAX, I would recommend the following tutorial resources. Three weeks ago, I only knew a little bit about HTML and absolutely nothing about CSS, JavaScript, AJAX, or the concept of front end development. I referred to the following tutorials, grasped all of them in three weeks, and finished my task of user interface development from work.
- tutorialspoint (English)
- Front-End Web Developer Nanodegree courses on Udacity (English)
- Python Web Development on maiziedu (Chinese)
For people who want to learn more about REST API development, Python full-stack web development, and HTTP, the above resources will also be helpful.
Last but not least, I would like to share a little bit about my motivation to learn the web development. After reading many posts and studying current successful business applications, my feeling is that machine learning and web development go hand by hand. Many machine learning systems are deployed on web applications. A complete web solution may contain some machine learning algorithms as a specific problem solution. I guess that makes sense by just thinking about what Amazon does.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.