It’s because you are expecting vars to be interpreted as the x and y parameters of the entity.
Try with this instead:
- entity: ""
name: SCOP
mode: markers
y: |
$fn ({ vars }) => {
const y = [];
const input = vars.energy_input.ys;
const output = vars.energy_output.ys;
let inlen = input.length;
for (let i = 0; i < inlen; i++) {
const scop = output[i] / input[i];
y.push(Math.round(parseFloat(scop) * 100) / 100);
}
return y
}
x: $ex vars.energy_input.xs
You could even make y
a bit more compact too:
y: |
$ex vars.energy_output.ys.map((o, i) =>
Math.round(o / vars.energy_input.ys[i] * 100) / 100
)