I think I have discovered your problem ...
The problem is in the arrays that are passing, do not have the same number of parameters.
In the second graphic you have this:
var xVals2 = [[1, 2, 3, 4, 5, 6, 7],[3.5, 4.5, 5.5, 6.5, 7, 8]]; //data coube x1, courbe x2
var yVals2 = [[2, 10, 15, 5], [5, 9, 13, 15, 10 ]]; //data
In x you have two elements, the first with 7 positions and the second with 6 positions, in y you have two elements where the first one has 4 positions and the second one has 5 positions ...
Trying to simplify more ... in x the first element, must have the same number of positions as the first element in y.
I send you the arrays of the second chart:
var xVals2 = [[1, 2, 3, 4],[3.5, 4.5, 5.5, 6.5, 7]]; //data coube x1, courbe x2
var yVals2 = [[2, 10, 15, 5], [5, 9, 13, 15, 10 ]]; //data