<div id="chart_div"></div>
Copy above JavaScript code and html code and save as .html page. The above Pie chart will be displayed on your page. You should have internet connection to connect to Google Chart library.
var options = {'title':'Tutorials at plus2net.com',
'width':400,
'height':300};
is3D=true
, by default its value is false.
var options = {title:'plus2net.com :Nos of tutorials',
width:600,
height:500,
legend:'left',
is3D:true};
$php_data_array
first and then transfer the data to JavaScript array my_2d
to create the graph.
var chart_div = document.getElementById('chart_div');
var chart = new google.visualization.PieChart(chart_div);
google.visualization.events.addListener(chart, 'ready', function () {
chart_div.innerHTML = '<img src="' + chart.getImageURI() + '">';
console.log(chart_div.innerHTML);
});
chart.draw(data, options);
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.