Skip to content Skip to sidebar Skip to footer

Can We Find Breakdown Point/ Break Down Analysis In High Chart Line Graph?

I want a graph like this image. I have tried making this using high chart , But I am unable to calculate break point (the point where 2 line graphs are colliding. Does anyone know

Solution 1:

You need to find the intersection points of the series - and having coordinates you can plot a line (line with an arrow) and a text - both can be rendered with Renderer.

  chart: {
    type: 'column',
    events: {
      load: function() {
        const points1 = this.series[2].points;
        const points2 = this.series[3].points;

        const intersection = [];

        for (let i = 1; i < points1.length; i++) {
          const intersect = getLineIntersection(points1[i - 1], points1[i], points2[i - 1], points2[i]);

          if (intersect) {
            intersection.push(intersect);
          }
        }

        const xAxis = this.xAxis[0];
        const yAxis = this.yAxis[0];

        intersection.forEach(coord => {
          const text = this.renderer.text('break point', -999, -999).add();
          const anchorX = xAxis.toPixels(coord[0]);
          const anchorY = yAxis.toPixels(coord[1]);

          const connector = this.renderer.path([
            'M', anchorX, anchorY,
            'L', anchorX - 5, anchorY - 100
          ]).attr({
            stroke: 'black',
            'stroke-width': 1,
            zIndex: 99
          }).add();


          text.attr({
            align: 'center',
            x: anchorX - 5,
            y: anchorY - 110,
            zIndex: 99
          }).css({
            color: 'black',
            fontSize: '14px',
            fontWeight: 'bold'
          });
        })
      }
    }
  },

Live example and output

https://jsfiddle.net/858b4x0c/

Annotated chart


Post a Comment for "Can We Find Breakdown Point/ Break Down Analysis In High Chart Line Graph?"