I’m trying to get the percentage from the “timeSpend” and “breakTime” and store in fSubject,sSubject, tSubject and store it in dataset: date[],
so that it can output it but it just gives the value of “timeSpend” and “breakTime” not fSubject,sSubject, tSubject enter image description here
let timeSpend = document.querySelector("#time_spend").value;
let breakTime = document.querySelector("#break_time").value;
let fSubject = document.querySelector("#first_subjects").value;
let sSubject = document.querySelector("#second_subjects").value;
let tSubject = document.querySelector("#third_subjects").value;
let fSubjectV = (50/100) * (timeSpend + breakTime);
let sSubjectV = (25/100)* (timeSpend + breakTime);
let tSubjectV = (25/100)* (timeSpend + breakTime);
let myChart = document.getElementById("myChart").getContext("2d");
document.querySelector("button").addEventListener("click", () => {
let pieChart = new Chart(myChart, {
type: "pie",
data: {
labels: [
"Time spend",
"Break Time",
"First Subject",
"Second Subject",
"Third Subject",
],
datasets: [
{
label: "Plan",
data: [
timeSpend.value,
breakTime.value,
fSubjectV.value,
sSubjectV.value,
tSubjectV.value,
],
},
],
},
options: {},
});
});