Skip to content

Commit

Permalink
Update visualizations.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Amit30swgoh authored Sep 25, 2024
1 parent 30bd864 commit a1a8786
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions js/scripts/visualizations.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
// visualizations.js
// scripts/visualizations.js
import { astronomyStats } from './data.js';

export function initVisualizations() {
const ctx = document.getElementById('statsChart').getContext('2d');
const statsChartElement = document.getElementById('statsChart');

if (!statsChartElement) {
console.error('Canvas element with id "statsChart" not found.');
return;
}

const ctx = statsChartElement.getContext('2d');
const statsChart = new Chart(ctx, {
type: 'bar',
data: {
Expand All @@ -17,6 +24,15 @@ export function initVisualizations() {
},
options: {
responsive: true,
plugins: {
legend: {
position: 'top',
},
title: {
display: true,
text: 'Astronomical Discoveries Over Years'
}
},
scales: {
y: {
beginAtZero: true,
Expand Down

0 comments on commit a1a8786

Please sign in to comment.