NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8" />
<title></title>
<link rel="stylesheet" href="style.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.8.2/css/all.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="custom-chart.min.js"></script>
</head>
<body>
<header>
<h1>Expense Chart</h1>
</header>
<main>
<select class="amount-for">
<option value="">Select category</option>
<option value="food">Food</option>
<option value="travel">Travel</option>
<option value="health">Health</option>
<option value="rent">Rent</option>
</select>
<input type="number" class="amount" placeholder="Amount spent" />
<button id="add-button">Add</button>
<section class="exp-chart">
<h3>Expense chart</h3>
<canvas id="myChart" width="200" height="200"></canvas>
<ul class="labels">
<!-- Template for labels -->
<!-- End -->
</ul>
</section>
<section class="exp-list">
<h3>Expense Log</h3>
<!-- Template for each log -->
<!-- End -->
</section>
</main>

<script type="text/javascript">
const exp = { food: 0, travel: 0, health: 0, rent: 0 };
const colors = {food: "greenyellow", travel: "yellow", health: "lightblue", rent: "grey"};

$("#add-button").on("click", function (e) {
let label1 = $('.amount-for').val();
let label = label1[0].toUpperCase()+label1.substring(1);
let amount = $('.amount').val();

let li = document.createElement('li');
li.id='li_'+label1;
li.innerHTML = `<span class="dot" style="background-color: ${colors[label1]}"></span>${label} ₹${amount}`;
$(".labels").append(li);

let spent = ` <article class="log" id =article_${label1}>
<span class="category">${label}</span><i class="fas fa-trash-alt" onclick="handleOnDelete(this,'${label1}')"></i><span class="spent">₹${amount}</span>
</article>`

$('.exp-list').html($('.exp-list').html()+spent);

exp[label1]=amount;
$.fn.displayChart();
});

const handleOnDelete = (el,id)=>{
exp[id]=0;
$("#article_"+id).remove();
$("#li_"+id).remove();
$.fn.displayChart();
}

//Function to display pie chart
$.fn.displayChart = function () {
let data = [
{
value: exp["food"],
color: "greenyellow",
label: "Food",
},
{
value: exp["travel"],
color: "yellow",
label: "Travel",
},
{
value: exp["health"],
color: "lightblue",
label: "Health",
},
{
value: exp["rent"],
color: "grey",
label: "Rent",
},
];
let ctx = $("#myChart").get(0).getContext("2d");
let myPieChart = new Chart(ctx).Pie(data);
};

$.fn.displayChart();
</script>
</body>
</html>
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.