chartshighchartshighcharts-ngangular2-highcharts

How to show time in box chart in highchart?


Pls suggest the below image chart in Highcharts option with example?

enter image description here


Solution

  • You can use bubble series type and Highcharts.SVGRenderer class.

    events: {
      load: function() {
        var xAxis = this.xAxis[0],
          yAxis = this.yAxis[0],
          x1 = xAxis.toPixels(1),
          y1 = yAxis.toPixels(6),
          x2 = xAxis.toPixels(1),
          y2 = yAxis.toPixels(2),
          x3 = xAxis.toPixels(2),
          y3 = yAxis.toPixels(4),
          x4 = xAxis.toPixels(2),
          y4 = yAxis.toPixels(8);
    
        this.renderer.path([
            'M', x1, y1,
            'L', x2, y2,
            'Q', x2 + (x3 - x2) / 2, y2 + (y3 - y2) / 2 - 20, x3, y3,
            'L', x4, y4,
            'Q', x1 + (x4 - x1) / 2, y1 + (y4 - y1) / 2 - 20, x1, y1
          ])
          .attr({
            'stroke-width': 2,
            stroke: 'red',
            'stroke-dasharray': [5, 5]
          })
          .add();
      }
    }
    

    Live demo: https://jsfiddle.net/BlackLabel/wk8p9vhc/

    About SVG path: https://www.w3schools.com/graphics/svg_path.asp

    API Reference:

    https://api.highcharts.com/highcharts/series.bubble

    https://api.highcharts.com/class-reference/Highcharts.Axis#toPixels