-
Notifications
You must be signed in to change notification settings - Fork 404
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Data Visualization Calculator (#1978)
- Loading branch information
Showing
6 changed files
with
175 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# <p align="center">Data Visualization Calculator</p> | ||
|
||
## Description :- | ||
|
||
This is a simple web-based calculator that allows users to input numerical data and visualize it using bar charts. | ||
|
||
## Tech Stacks :- | ||
|
||
- HTML | ||
- CSS | ||
- JavaScript | ||
|
||
## Features :- | ||
|
||
1. User Input: Accepts numerical input from the user. | ||
2. Bar Chart Visualization: Displays a bar for each input number. | ||
3. Clear Functionality: Resets the chart. | ||
|
||
## Screenshots :- | ||
|
||
![image](https://github.com/user-attachments/assets/e0865b50-ff02-4d49-b90d-2cddc10407cb) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script> | ||
<link rel="stylesheet" href="style.css"> | ||
<title>Data Visualization Calculator</title> | ||
</head> | ||
|
||
<body> | ||
<div class="container"> | ||
<h1>Data Visualization Calculator</h1> | ||
|
||
<form id="data-form"> | ||
<div class="form-group"> | ||
<label for="labels">Enter Labels (comma-separated):</label> | ||
<input type="text" id="labels" placeholder="e.g., January, February, March" required> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<label for="values">Enter Values (comma-separated):</label> | ||
<input type="text" id="values" placeholder="e.g., 10, 20, 30" required> | ||
</div> | ||
|
||
<button type="button" id="generate-chart">Generate Chart</button> | ||
</form> | ||
|
||
<div class="chart-container"> | ||
<canvas id="chart"></canvas> | ||
</div> | ||
</div> | ||
|
||
<script src="script.js"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
document.getElementById("generate-chart").addEventListener("click", function () { | ||
const labelsInput = document.getElementById("labels").value; | ||
const valuesInput = document.getElementById("values").value; | ||
|
||
if (!labelsInput || !valuesInput) { | ||
alert("Please fill in both labels and values!"); | ||
return; | ||
} | ||
|
||
const labels = labelsInput.split(",").map(label => label.trim()); | ||
const values = valuesInput.split(",").map(value => parseFloat(value.trim())); | ||
|
||
if (labels.length !== values.length) { | ||
alert("The number of labels must match the number of values!"); | ||
return; | ||
} | ||
|
||
// Create the chart | ||
const ctx = document.getElementById("chart").getContext("2d"); | ||
|
||
// Destroy the previous chart instance if it exists | ||
if (window.myChart) { | ||
window.myChart.destroy(); | ||
} | ||
|
||
window.myChart = new Chart(ctx, { | ||
type: 'bar', | ||
data: { | ||
labels: labels, | ||
datasets: [{ | ||
label: 'Values', | ||
data: values, | ||
backgroundColor: 'rgba(54, 162, 235, 0.6)', | ||
borderColor: 'rgba(54, 162, 235, 1)', | ||
borderWidth: 1 | ||
}] | ||
}, | ||
options: { | ||
responsive: true, | ||
scales: { | ||
y: { | ||
beginAtZero: true | ||
} | ||
} | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
body { | ||
font-family: Arial, sans-serif; | ||
margin: 0; | ||
padding: 0; | ||
background-color: #f4f4f9; | ||
background-image: url('assets/background.jpg'); | ||
background-size: cover; | ||
background-position: center; | ||
} | ||
|
||
.container { | ||
max-width: 600px; | ||
margin: 50px auto; | ||
padding: 20px; | ||
background: #ffffff; | ||
border-radius: 8px; | ||
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); | ||
} | ||
|
||
h1 { | ||
text-align: center; | ||
color: #333; | ||
} | ||
|
||
.form-group { | ||
margin-bottom: 15px; | ||
} | ||
|
||
label { | ||
display: block; | ||
font-weight: bold; | ||
margin-bottom: 5px; | ||
} | ||
|
||
input { | ||
width: 100%; | ||
padding: 8px; | ||
margin-top: 5px; | ||
border: 1px solid #ccc; | ||
border-radius: 4px; | ||
} | ||
|
||
button { | ||
width: 100%; | ||
padding: 10px; | ||
color: #fff; | ||
background: #007bff; | ||
border: none; | ||
border-radius: 4px; | ||
cursor: pointer; | ||
} | ||
|
||
button:hover { | ||
background: #0056b3; | ||
} | ||
|
||
.chart-container { | ||
margin-top: 20px; | ||
padding: 15px; | ||
background: #e9f7ef; | ||
border: 1px solid #c3e6cb; | ||
border-radius: 4px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters