Polar (radar) chart

author(s): Torstein Hønsi

by KSK Kushwah

HTML

<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-more.js"></script>

<div id="container"></div>

JavaScript

Highcharts.Series.prototype.getConnectors = function(segment, index, calculateNeighbours, connectEnds) {
          var i, prevPointInd, nextPointInd, previousPoint, nextPoint, previousX, previousY, nextX, nextY, plotX, plotY, ret,
            // 1 means control points midway between points, 2 means 1/3 from
            // the point, 3 is 1/4 etc;
            smoothing = 1,
            denom = smoothing + 1,
            leftContX, leftContY, rightContX, rightContY, dLControlPoint, // distance left control point
            dRControlPoint, leftContAngle, rightContAngle, jointAngle, addedNumber = connectEnds ? 1 : 0;
          // Calculate final index of points depending on the initial index value.
          // Because of calculating neighbours, index may be outisde segment
          // array.
          if (index >= 0 && index <= segment.length - 1) {
            i = index;
          } else if (index < 0) {
            i = segment.length - 1 + index;
          } else {
            i = 0;
          }
          prevPointInd = (i - 1 < 0) ? segment.length - (1 + addedNumber) : i - 1;
          nextPointInd = (i + 1 > segment.length - 1) ? addedNumber : i + 1;
          previousPoint = segment[prevPointInd];
          nextPoint = segment[nextPointInd];
          previousX = previousPoint.plotX;
          previousY = previousPoint.plotY;
          nextX = nextPoint.plotX;
          nextY = nextPoint.plotY;
          plotX = segment[i].plotX; // actual point
          plotY = segment[i].plotY;
          leftContX = (smoothing * plotX + previousX) / denom;
          leftContY = (smoothing * plotY + previousY) / denom;
          rightContX = (smoothing * plotX + nextX) / denom;
          rightContY = (smoothing * plotY + nextY) / denom;
          dLControlPoint = Math.sqrt(Math.pow(leftContX - plotX, 2) + Math.pow(leftContY - plotY, 2));
          dRControlPoint = Math.sqrt(Math.pow(rightContX - plotX, 2) + Math.pow(rightContY - plotY, 2));
          leftContAngle =...