<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content=
"width=device-width, initial-scale=1.0">
<title>Scatter Chart</title>
<script src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js">
</script>
<script src=
"https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.1.2/chart.umd.js">
</script>
</head>
<body>
<div>
<h2 style="color:green">
GeeksforGeeks
</h2>
<h5>Chart JS Scatter Chart 1</h5>
<div>
<canvas id="visitorsChart"
width="700" height="300"></canvas>
</div>
</div>
<script>
const visitorsData = [
{ x: 1, y: 500 },
{ x: 2, y: 700 },
{ x: 3, y: 1200 },
{ x: 4, y: 900 },
{ x: 5, y: 1500 },
];
const config = {
type: 'scatter',
data: {
datasets: [{
label: 'Visitors Data',
data: visitorsData,
backgroundColor: 'rgba(75, 192, 192, 0.7)',
}],
},
options: {
scales: {
x: {
type: 'linear',
position: 'bottom',
title: {
display: true,
text: 'Months',
},
},
y: {
type: 'linear',
position: 'left',
title: {
display: true,
text: 'Number of Visitors',
},
},
},
elements: {
point: {
radius: 8,
hoverRadius: 10,
},
},
plugins: {
title: {
display: true,
text: 'GeeksforGeeks Monthly Visitors',
},
},
},
};
const ctx = document.getElementById(
'visitorsChart').getContext('2d');
new Chart(ctx, config);
</script>
</body>
</html>