function interpolate(data, xs, ys , x) {
const sorted = data.toSorted((a, b) => a[xs] - b[xs])
const indx = d3.bisectLeft(sorted.map(v=>v[xs]), x)
if (indx==0 || x==sorted[indx][xs]) return sorted[indx][ys]
const a=sorted[indx-1]
const b=sorted[indx]
return a[ys] + ((b[ys] - a[ys])/(b[xs]-a[xs])*(x-a[xs]))
}