चार्ट.जेएस एक ओपन सोर्स जावास्क्रिप्ट लाइब्रेरी है। चार्ट.जेएस का उपयोग करके, अपनी वेबसाइट पर एनिमेटेड, इंटरैक्टिव ग्राफ़ जोड़ें।
जावास्क्रिप्ट में चार्ट.जेएस पुस्तकालय के लिए कोड निम्नलिखित है -
उदाहरण
<!DOCTYPE html>
<html>
<head>
<script
<script src="https://cdn.jsdelivr.net/npm/chart.js@2.8.0"></script>
</script>
</head>
<body>
<canvas id="myChart" width="500" height="300"></canvas>
<script type="text/javascript">
var ctx = document.getElementById("myChart");
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ["2005", "2007" , "2009" , "2012", "2014"],
datasets: [
{ label: 'HouseHold income',
data: [5000,8000,10000,1200,15000],
backgroundColor :['rgba(255, 129, 102, 1)',
'rgba(234, 162, 235, 1)',
'rgba(255, 206, 36, 1)',
'rgba(75, 192, 192, 1)',
'rgba(153, 102, 255, 1)',
],
}
]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero:true
}
}]
}
}
});
</script>
</body>
</html> आउटपुट
