Data Visualization
(
3160717 )
Practical and Source Codes
<!DOCTYPE HTML>
<html>
<head>
<title>Google API Line chart</title>
<meta charset="utf-8">
<meta name="author" content="SidPro" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<meta name="description" content="Using Google Charts API Basics draw charts like a Line chart" />
<meta name="keywords" content="Google,API,Chart,Line Chart,Line" />
<script src="js/jquery-3.5.1.min.js"></script>
<script src="js/loader.js"></script>
</head>
<body>
<h2>Using Google Charts API Basics draw charts like a Line chart</h2>
<div id="chart" style="width: 900px; height: 500px"></div>
</body>
<script type="text/javascript">
google.charts.load('current', { 'packages': ['corechart'] });
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Month', 'Shampoo', 'Moisturizer'],
['Jan', 1500, 2110],
['Feb', 1200, 1833],
['Mar', 1340, 2247],
['Apr', 1130, 2227],
['May', 1740, 2096],
['Jun', 1555, 2014],
['Jul', 1120, 2955],
['Aug', 1400, 3614],
['Sep', 1780, 2340],
['Oct', 1890, 2667],
['Nov', 2100, 4128],
['Dec', 1760, 3002],
]);
var options = {
title: 'Monthly Sales Data of Shampoo and Moisturizer',
curveType: 'none',
backgroundColor: '#2a2a2a',
colors: ['#51cda0', '#6d78ad'],
titleTextStyle: { color: 'white', bold: true, fontSize: 20, italic: false },
hAxis: {
title: 'Months',
titleTextStyle: { color: 'white', bold: false, italic: false },
textStyle: { color: 'white', bold: false, italic: false },
baselineColor: '#51cda0',
gridlines: { color: 'green', minSpacing: 20 }
},
vAxis: {
title: 'Sales Unit',
titleTextStyle: { color: 'white', bold: false, italic: false },
baselineColor: 'white',
gridlines: { color: 'gray' },
textStyle: { color: 'white', bold: false, italic: false }
},
animation: { duration: 1000, startup: true, easing: 'linear' },
tooltip: { textStyle: { color: '#871b47' }, showColorCode: true },
legend: { position: 'bottom', textStyle: { color: 'white', fontSize: 16 } }
};
var chart = new google.visualization.LineChart(document.getElementById('chart'));
chart.draw(data, options);
}
</script>
</html>
Go Back
No comments:
Post a Comment