Week 1: AIM: Develop The Different Basic Graphical Shapes Using Html5 Canvas Code
Week 1: AIM: Develop The Different Basic Graphical Shapes Using Html5 Canvas Code
Week 1: AIM: Develop The Different Basic Graphical Shapes Using Html5 Canvas Code
ctx.fillStyle = 'gray';
ctx.fillRect(10, 10, 60, 60);
ctx.fillRect(100, 10, 90, 60);
ctx.beginPath();
ctx.arc(250, 40, 40, 0, 2*Math.PI);
ctx.fill();
ctx.beginPath();
ctx.moveTo(10, 160);
ctx.lineTo(90, 160);
ctx.lineTo(50, 110);
ctx.closePath();
ctx.fill();
ctx.save();
ctx.scale(2, 1);
ctx.beginPath();
ctx.arc(72, 130, 25, 0, 2*Math.PI);
ctx.fill();
ctx.restore();
ctx.beginPath();
ctx.arc(250, 120, 40, 0, Math.PI);
ctx.fill();
}
</script>
</head>
<body onload="draw();">
<canvas id="myCanvas" width="350"
h="350" height="350">
</canvas>
</body>
</html>
OUTPUT:
WEEK 2
AIM: Develop the different basic Graphical shapes using
HTML5 SVG
CODE:
<!DOCTYPE html>
<html>
<body>
</svg>
</body>
</html>
OUTPUT:
WEEK-3
AIM: Develop javaScript code that receives input from
user,and gets in action based on user input HTML5 and java
Script
CODE:
<!DOCTYPE html>
<html>
<head>
<style>
body{
background-color:Powderblue;
text-align:center;
}
img{
width: 200px;
height: 100px;
}
</style>
</head>
<body>
<h2>What Can JavaScript Do?</h2>
<p>JavaScript can change HTML attribute values.</p>
<p>In this case JavaScript changes the value of the src (source) attribute of an image.</p>
<button onclick="document.getElementById('myImage').src='img_2.jpg'">joyce</button>
<img id="myImage" src="IMG_20210422_103737.jpg" style="width:100px">
<button
onclick="document.getElementById('myImage').src='IMG_20210422_103737.jpg'">charish
ma</button>
</body></html>
OUTPUT:
CODE:
<!DOCTYPE html>
<html>
<body>
<form action="/action_page.php">
</form>
</body>
</html>
OUTPUT:
WEEK-4
AIM: Develop the simple bar chart using HTML5 CANVAS
CODE:
<!DOCTYPE HTML>
<html>
<head>
<script>
window.onload = function () {
animationEnabled: true,
title:{
text:"SEM MARKLIST"
},
axisX:{
interval: 1
},
axisY2:{
interlacedColor: "rgba(1,77,101,.2)",
gridColor: "rgba(1,77,101,.1)",
title: "marks"
},
data: [{
type: "bar",
name: "marks",
axisYType: "secondary",
color: "#014D65",
dataPoints: [
{ y: 9, label: "sem2" },
}]
});
chart.render()
</script>
</head>
<body>
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
</body>
</html>
OUTPUT:
WEEK-5
AIM: Read the data from .txt file and draw table and draw a
bar chart.
CODE:
<!DOCTYPE html>
<html>
<head>
<title>Table and Bar Chart using CanvasJS</title>
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<style>
table {
border-collapse: collapse;
width: 50%;
text-align: center;
}
th, td {
padding: 8px;
border: 1px solid black;
}
th {
background-color: #ddd;
}
</style>
</head>
<body>
<h1>Student Marks Table and Bar Chart</h1>
<table id="table"></table>
<div id="chartContainer" style="height: 370px; width: 100%;"></div>
<script>
// Define the URL of the data file
var dataFile = "marks.txt";
// Load the data and draw the table and bar chart
loadData(function(data) {
var rows = data.split("\n");
var headers = rows[0].split(",");
var table = document.getElementById("table");
var chartData = [];
for (var i = 1; i < rows.length; i++) {
var values = rows[i].split(",");
var row = document.createElement("tr");
for (var j = 0; j < values.length; j++) {
var cell = document.createElement("td");
cell.textContent = values[j];
row.appendChild(cell);
if (j > 0) {
chartData.push({ label: headers[j], y: parseInt(values[j]) });
}
}
table.appendChild(row);
}
var chart = new CanvasJS.Chart("chartContainer", {
animationEnabled: true,
theme: "light2",
title: {
text: "Student Marks Bar Chart"
},
axisY: {
title: "Marks",
includeZero: true
},
axisX: {
title: "Subjects"
},
data: [{
type: "column",
dataPoints: chartData
}]
});
chart.render();
});
</script>
</body>
</html>
Marks.txt
Name,Maths,Science,English,Social Studies
Alice,90,85,95,92
Bob,78,89,82,85
Charlie,92,92,87,90
David,85,81,90,88
Eve,89,87,92,85
Output:
WEEK-6
AIM: Read the data from .csv file and draw table and draw a
bar chart.
CODE:
<!DOCTYPE html>
<html>
<head>
<title>Table and Bar Chart using CanvasJS</title>
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<style>
table {
border-collapse: collapse;
width: 50%;
text-align: center;
}
th, td {
padding: 8px;
border: 1px solid black;
}
th {
background-color: #ddd;
}
</style>
</head>
<body>
<h1>Student Marks Table and Bar Chart</h1>
<table id="table"></table>
<div id="chartContainer" style="height: 370px; width: 100%;"></div>
<script>
// Define the URL of the data file
var dataFile = "data.csv";
// Load the data and draw the table and bar chart
loadData(function(data) {
var rows = data.split("\n");
var headers = rows[0].split(",");
var table = document.getElementById("table");
var chartData = [];
for (var i = 1; i < rows.length; i++) {
var values = rows[i].split(",");
var row = document.createElement("tr");
for (var j = 0; j < values.length; j++) {
var cell = document.createElement("td");
cell.textContent = values[j];
row.appendChild(cell);
if (j > 0) {
chartData.push({ label: headers[j], y: parseInt(values[j]) });
}
}
table.appendChild(row);
}
var chart = new CanvasJS.Chart("chartContainer", {
animationEnabled: true,
theme: "light2",
title: {
text: "Student Marks Bar Chart"
},
axisY: {
title: "Marks",
includeZero: true
},
axisX: {
title: "Subjects"
},
data: [{
type: "column",
dataPoints: chartData
}]
});
chart.render();
});
</script>
</body>
</html>
Data.csv
Name,Maths,Science,English,Social Studies
Alice,90,85,95,92
Bob,78,89,82,85
Charlie,92,92,87,90
David,85,81,90,88
Eve,89,87,92,85
OUTPUT:
Week-7
Aim:Read the data XML file and draw Draw Data Table and draw Column Bar
Chart
Program:
Html:
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script src="week7.js"></script>
<style>
table, th, td {
border-collapse: collapse;
padding: 5px;
canvas {
max-width: 600px;
margin-top: 20px;
</style>
</head>
<body>
<div id="tableContainer"></div>
<canvas id="chartCanvas"></canvas>
</body>
</html>
Js:
$(document).ready(function() {
$('#xmlFile').on('change', function() {
reader.onload = function() {
$(xml).find('person').each(function() {
data.push(age);
labels.push(name);
});
$('#tableContainer').empty().append(createTable(xml));
$('#chartCanvas').replaceWith('<canvas id="chartCanvas"></canvas>');
createChart(labels, data);
$('#chartCanvas').show();
reader.readAsText(file);
});
function createTable(xml) {
header.append('<th>Name</th>');
header.append('<th>Age</th>');
header.append('<th>Gender</th>');
table.append(header);
$(xml).find('person').each(function() {
table.append(row);
});
return table;
type: 'bar',
data: {
labels: labels,
datasets: [{
label: 'Age',
data: data,
borderWidth: 1
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}]
});
});
Json:
<?xml version="1.0"?>
<persons>
<person>
<name>John</name>
<age>25</age>
<gender>Male</gender>
</person>
<person>
<name>Jane</name>
<age>30</age>
<gender>Female</gender>
</person>
<person>
<name>Bob</name>
<age>40</age>
<gender>Male</gender>
</person>
<person>
<name>Susan</name>
<age>50</age>
<gender>Female</gender>
</person>
</persons>
Week-8
Aim:Read json Data and Draw Data Table and draw simple Chart
Program:
HTML:
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script src="week8.js"></script>
<style>
table, th, td {
border-collapse: collapse;
padding: 5px;
canvas {
max-width: 600px;
margin-top: 20px;
</style>
</head>
<body>
<canvas id="chartCanvas"></canvas>
</body>
</html>
Js:
$(document).ready(function() {
$('#jsonFile').on('change', function() {
reader.onload = function() {
labels.push(data[i].name);
values.push(data[i].age);
$('#tableContainer').empty().append(createTable(data));
$('#chartCanvas').replaceWith('<canvas id="chartCanvas"></canvas>');
createChart(labels, values);
$('#chartCanvas').show();
reader.readAsText(file);
});
function createTable(data) {
var table = $('<table></table>');
header.append('<th>Name</th>');
header.append('<th>Age</th>');
header.append('<th>Gender</th>');
table.append(header);
table.append(row);
return table;
type: 'bar',
data: {
labels: labels,
datasets: [{
label: 'Age',
data: values,
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}]
});
});
JSON:
]
Week-11
Week 11:- Develop Following Program Using HTML5 and Google Charts API
and Map API(Consider Market Analysis Data)
a. Using Google Charts API Basics draw charts like a Bar chart
b. Using Google Charts API Basics draw charts like a Line chart
code:-
<!DOCTYPE html>
<html lang="en">
<head>
<script type="text/javascript"
src="https://www.gstatic.com/charts/loader.js">
</script>
<script type="text/javascript">
google.charts.load('current',{packages:['corechart']});
</script>
</head>
<body>
<script language="Javascript">
function chart()
var data=google.visualization.arrayToDataTable([
['year','asia'],
['2012',900],
['2013',230],
['2015',890],
['2013',900]
]);
chart.draw(data,op);
google.charts.setOnLoadCallback(chart);
</script>
</body>
</html>
b).
code:-
<html>
<head>
<script type="text/javascript"
src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load("current", {packages:["imagelinechart"]});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
]);
</script>
</head>
<body>
</body>
</html>
WEEK-12
12.Develop Following Program Using HTML5 and Google Charts API and Map
API(Consider student Data)
a. Draw PieChart.
a.)Code:-
<html>
<head>
<script type="text/javascript"
src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load("current", {packages:["imagepiechart"]});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
['Work', 11],
['Eat', 2],
['Commute', 2],
['Sleep', 7]
]);
</script>
</head>
<body>
</body>
</html>
b)
<html>
<head>
<script type="text/javascript"
src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load("current", {packages:["corechart"]});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
['Work', 11],
['Eat', 2],
['Commute', 2],
]);
var options = {
pieHole: 0.4,
};
chart.draw(data, options);
}
</script>
</head>
<body>
</body>
</html>
Week 13
Aim:- Develop Following Program Using HTML5 and Google Chats API and Map
API
CODE:-
<html>
<head>
<script type="text/javascript"
src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load("current", {packages:["imagechart"]});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
dataTable = google.visualization.arrayToDataTable([
['Gainers',10,30,45,60],
['Losers',20,35,25,45],
], true);
chart.draw(dataTable, options);
</script>
</head>
<body>
</body>
</html>
b)
<html>
<head>
<script type="text/javascript"
src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {
'packages':['geochart'],
});
google.charts.setOnLoadCallback(drawRegionsMap);
function drawRegionsMap() {
['Country', 'Popularity'],
['Germany', 10000],
['australia',900],
['Brazil', 400],
['Canada', 500],
['France', 600],
['RU', 700],
['india',500]
]);
chart.draw(data, options);
}
</script>
</head>
<body>
</body>
</html>