I am trying to reproduce this image below in Chart.js.
My question is how do I fill the area based on the line values as in the image? At the moment the data is correctly displayed, but the coloring is not managed.
Here is the code I have at the moment:
var xPoints = [];
var yPoints = [];
var storage = [];
for(var i=0; i<data.cost.length; i++)
{
xPoints[i] = data.electricity[i];
yPoints[i] = data.cost[i];
x = xPoints[i];
y = yPoints[i];
var coordinates = {x: x, y: y};
storage.push(coordinates);
}
var ctx = document.getElementById("myChart");
var chart_wrapper = document.getElementsByClassName("chart-wrapper");
var myChart = new Chart(ctx, {
type: "scatter",
data: {
datasets: [
{
label: label,
data: storage,
yAxisID: "primary",
borderWidth: 4,
type: "line",
backgroundColor: "rgba(107, 80, 255)",
},
],
},
options: options }});