Currently, I am in the process of creating a graph plotting website for my homework assignment. After successfully drawing the graph using graph.js, I am now faced with the challenge of calculating the area under the graph.
Attached is a screenshot of the graph: https://i.sstatic.net/enmA8.png
My goal is to determine the total grey area underneath the graph.
Below is the code used to generate the graph using graph.js:
new Chart(document.getElementById("line-chart"), {
type: 'line',
data: {
labels: labels,
datasets: [{
data : graphValue,
borderwidth : 1,
label : lineLabel,
fill : true,
lineTension : 0,
pointBackgroundColor : 'rgba (83,81,84,1)',
borderColor : 'rgba(83,81,84,1)'
}]
},
options: {
responsive: false,
title: {
display: true,
text: graphName
},
scales : {
yAxes : [{
ticks : {
beginAtZero : true,
min :0,
max :200
}
}]
}
}
});
The values used for the graph are simply an array of numbers passed from the HTML page:
var graphValue = [98,12,19,64,85,91,56,181,171,90];