Google APIs... Heaven for Programmers..!

Working for a client according to his requirement is not an easy task. And when he limits you to the conventional programming then you can't find a narrow escape...! And if you have a chance to make the decision on your own then do follow the recent market techniques.

Today I ll just let you know about one Google API i.e. Google Charts API. It is very helpful for a beginner to start with and get command over it. A few lines of code help you in making dynamic Charts, Graphs and Diagrams. https://developers.google.com/chart/

Very helpful in making dynamic charts with much more clear graphics in no span of time. Specially when you are making a web application, such small snippets make your life much more easier. As these APIs runs through internet. Given below is the url to practically make changes and get your desired chart.

https://code.google.com/apis/ajax/playground/?type=visualization#pie_chart

Just Change the values given in the code and Press Run Code. For instance:

//Original Line of Code

var data = google.visualization.arrayToDataTable([
    ['Task', 'Hours per Day'],
    ['Work', 11],
    ['Eat', 2],
    ['Commute', 2],
    ['Watch TV', 2],
    ['Sleep', 7]
  ]);


// Change it to your desired data



var data = google.visualization.arrayToDataTable([
    ['Products', 'Sales'],
    ['Oil Packets', 10],
    ['Shampoo', 2],
    ['Soap', 2]
  ]);


//Setting the title

new google.visualization.PieChart(document.getElementById('visualization')).
      draw(data, {title:"Sales for Today"});

Press Run Code button and you' ll get the chart like given below:
Copy the code and save this in any html file and run on your desktop ... :) You can find other charts like Graphs, bar charts etc on this link. https://google-developers.appspot.com/chart/interactive/docs/gallery

No comments:

Post a Comment