Use graph->Integral() encouter problem

I found an example for calculating the area under the graph.

double x[] = { 1,2,3,4,5,6,7,8,9,10};
double y[] = { 1,2,3,4,5,6,7,8,9,10}; 
TGraph g(10,x,y);
TF1 f1("f",[&](double *x, double *){ return g.Eval(x[0]); },1,10,0);
double integral = f1.Integral(1,10);

cite: Integral of TGraph