Surround Highcharts points

I'm working on a project where we have several graphs Highcharts

populated from a database; one of them is a scatter plot, and we need to surround the points located on the outside of the plot.

We want a graph of type this , but we want the area surrounding the outer scatter points; is there an easy way to do this using Highcharts

? We need it to work on IE11 (client spec).

We can do this with a new series of polygons to get from code or from a database, but this can take too long to develop and slow down queries. Therefore, we need to know if there is an easier way to do this with Highcharts

orJavascript

Thanks in advance.

+3


source to share


1 answer


I'm not very familiar with Highcharts, but I haven't been able to find such functionality in my API .
However, there is a simple algorithm to solve your problem. All you need is to have an array containing the border elements and connect the dots from that list, for example here .

Finding those items isn't too hard. Calculate a linear equation between the two extreme points (for example, with the same top and very correct).
The resulting formula looks like this:f(x) = m*x + b



Now you check all points in this x range if their y-coordinate is higher than that line (or lower when you do it with a point at the very bottom). If so, just add them to your boundary array and continue with the other extreme points.

+3


source







All Articles