0👍
✅
This is very specific to the problem
Chart.plugins.register({
afterInit: function(chart) {
var intersect = getIntersection();
var datasets = chart.data.datasets;
var labels = chart.data.labels;
labels.push(intersect.x)
labels.sort(function(a,b){return a - b});
y = labels.indexOf(intersect.x);
chart.data.datasets.forEach(function(ds,i){ds.data.splice(y, 0, intersect.y)});
}
})
function getIntersection(){
var y2=17.68, y1=8.84,x2=2,x1=1,x3 = x1, x4 = x2,
y4=80,y3=80;
var x=((x1*y2-y1*x2)*(x3-x4)-(x1-x2)*(x3*y4-y3*x4))/((x1-x2)*(y3-y4)-(y1-y2)*(x3-x4));
var y=((x1*y2-y1*x2)*(y3-y4)-(y1-y2)*(x3*y4-y3*x4))/((x1-x2)*(y3-y4)-(y1-y2)*(x3-x4));
x = Math.round(x*100)/100;
y = Math.round(y*100)/100;
return {x:x,y:y} ;
Source:stackexchange.com