score:7

*Accepted answer*

This is a well studied problem. Before optimizing, though, I'd try the "computational heavy" brute-force approach. Borrowing from the excellent answers here, I've coded up a quick integration with highcharts (fiddle here):

```
get_line_intersection = function(p0,p1,p2,p3)
{
var p0_x = p0.x;
var p0_y = p0.y;
var p1_x = p1.x;
var p1_y = p1.y;
var p2_x = p2.x;
var p2_y = p2.y;
var p3_x = p3.x;
var p3_y = p3.y;
var s1_x, s1_y, s2_x, s2_y;
s1_x = p1_x - p0_x; s1_y = p1_y - p0_y;
s2_x = p3_x - p2_x; s2_y = p3_y - p2_y;
var s = (-s1_y * (p0_x - p2_x) + s1_x * (p0_y - p2_y)) / (-s2_x * s1_y + s1_x * s2_y);
var t = ( s2_x * (p0_y - p2_y) - s2_y * (p0_x - p2_x)) / (-s2_x * s1_y + s1_x * s2_y);
if (s >= 0 && s <= 1 && t >= 0 && t <= 1)
{
return [p0_x + (t * s1_x),p0_y + (t * s1_y)];
}
return false;
}
$(function () {
$('#container').highcharts({
series: [{
name: 'line1',
data: $.map(new Array(10), function(){return Math.random() * 10;})
}, {
name: 'line2',
data: $.map(new Array(10), function(){return Math.random() * 10;})
}, {
name: 'intersect',
data: [],
type: 'scatter'
}
]
}, function(chart){
var s0 = chart.series[0].points;
var s1 = chart.series[1].points;
var s2 = chart.series[2];
var n0 = s0.length;
var n1 = s1.length;
var i,j,isect;
for (i = 1; i < n0; i++){
for (j = 1; j < n1; j++){
if (isect = get_line_intersection(s0[i-1],s0[i],
s1[j-1],s1[j])){
s2.addPoint(isect, false, false);
}
}
}
chart.redraw();
});
});
```

Source: stackoverflow.com

#### Related Query

- Highcharts - Get crossing point of crossing series
- Highcharts js: get errors if there is a big point in a 3d series chart
- How to get Highcharts X-Axis Categories starting at the left most point
- Get Highcharts Series Data after Load
- Hiding _groups_ of series in Highcharts and jQuery: how to get acceptable performance?
- How do I get the value of a highcharts graph point on mouseover?
- How to get multiple data series into Highcharts
- how to get chart object inside a point event function in Highcharts
- Highcharts - get visible series name dynamically
- Highcharts How to get decimal point values on y-axis with big numbers
- Get name of clicked point in Highcharts when the point has drilldown
- How to get next point in Highcharts tooltip
- unable to get series id in HighCharts chart
- How to get the highlighted point from shared tooltip formatter, Highcharts
- Highcharts get series data zoom indices
- How to get Series Name Based on Selection in Highcharts
- Highcharts series data select point video sync
- Highcharts Boxplots How to get five point summary?
- how to get index of a point in Highcharts to use in an event?
- Highcharts pie get series color in tooltip headerFormat
- Highcharts Bubble Chart - How to get the size of the point
- Highcharts multiple data on single point in series
- Highcharts - How can I get the nearest point on click event
- HighCharts Drill Down multiple series , how to get drill down on second item on drill down?
- Can we get index from series data in highcharts
- highcharts get dashstyle from existing series
- Get max value and label in series after zoom in JS HighCharts
- Making two series point in opposite directions in highcharts
- Get Tooltip content from a point from a line/scatter plot in highcharts from javascript
- highcharts group series click event to get all data in catagory

#### More Query from same tag

- chart width changes when a trendline is added in highcharts
- Rendering chart in the background
- Xaxis Highcharts data loading issue
- Change aspect of highcharts sankey chart
- Dynamically update gauge on highcharts
- Highcharts: why does redrawing change the radius of the selected point?
- How to tie tooltips to the currently hovered SERIES, not just the point?
- Highcharts: set only last chunk of line as a dotted zone
- Highcharts line chart doesn't respect legend customization
- Add a colored text in italic to Highchart plot
- Custom styles on Highcharts legends
- jQuery + PHP HighChart not updating correctly
- Highcharts: How can I find out which which legend items are disabled?
- The graph is not equal on the basis of the addition code in Highcharts
- HighStocks series does not show line on Black Colors
- How to insert json within an array into highcharts?
- How to add percent symbol with data inside column in highchart?
- ServiceNow Dynamic content Block Issues
- clearing interval inside highcharts (React)
- How to get Highcharts X-Axis Categories starting at the left most point
- MYSQL query for concatenating values (highcharts series data)
- How to match columns height with spline in Highcharts
- trouble with highchart and .clone()
- Highcharts:add click event on data label for pie chart
- What's the angular way to handle redraws?
- Finding the Y axis value for a plot line in HIghCharts.js
- How to do highcharts in coldFusion?
- Add buttons in chart of Highcharts at runtime
- Highcharts not plotting Date string as Category
- Highcharts set X axis label on tick