abc

Share This blog with your friends, so that we can improve more & more . our aim is to easy & simple way of learning.

12/14/2020

How to create google chart

 google chart is in bar chat, line chart, circle(pie) chart like various view


helpful link is https://www.gstatic.com/charts/loader.js


simple steps,

1) first call https://www.gstatic.com/charts/loader.js

2) in chart load core chart package, there are various package available 

3) pass some data to data variable

4) called object google.visualization.PieChart and method 'draw'




<html lang="en-US">

<body>

<div id="piechart"></div>

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>


<script>

google.charts.load('current', {'packages':['corechart']});

google.charts.setOnLoadCallback(drawChart);


function drawChart()

{

  var data = google.visualization.arrayToDataTable([

   ['Work', 10], ['Eat', 1], ['TV', 3], ['Gym', 1], ['Sleep', 9] ]);


  var options = {'title':'My Day is planned shown in chart', 'width':550, 'height':400};

  var chart = new google.visualization.PieChart(document.getElementById('piechart'));

  chart.draw(data, options);

}

</script>


</body>

</html>


above google chart is lightweight, easy to load, works on all browser, devices, easy to understand by user and also showing chart indication.

No comments:

Post a Comment

An Introduction to the Laravel Framework: What It Is and Why You Should Use It

  If you're a PHP developer looking for a modern, efficient, and powerful framework to build web applications, look no further than Lara...