Chartjs-Calculate weighted sum over all points in chart.js

0👍

This might help:

 point[0]*2 + (point[1]-point[0])*3 + (point[2]-point[1])*4

is equal to

4* point[2]- (point[0]+ point[1])

so for a point i,
you need to calculate (i+2)*point[i] , minus the sum from point[0] to point[n-1]

And yes, you need a loop to calculate it.

Leave a comment