Funnel with Centered Labels instead of on the right - Javascript highcharts

Javascript examples for highcharts:Chart Configuration

Description

Funnel with Centered Labels instead of on the right

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script> 
      <script type="text/javascript">
$(function() {//from   www . j  ava2 s  .c om
  $('#container').highcharts({
    chart: {
      type: 'funnel',
      events: {
        load: function() {
          var chart = this;
          Highcharts.each(chart.series[0].data, function(p, i) {
            p.dataLabel.attr({
              x: (chart.plotWidth - chart.plotLeft) / 2,
              'text-anchor': 'middle'
            })
          })
        },
        redraw: function() {
          var chart = this;
          Highcharts.each(chart.series[0].data, function(p, i) {
            p.dataLabel.attr({
              x: (chart.plotWidth - chart.plotLeft) / 2,
              'text-anchor': 'middle'
            })
          })
        }
      }
    },
    plotOptions: {
      series: {
        dataLabels: {
          enabled: true,
          connectorWidth: 0,
          distance: 0,
          format: '<b>{point.name}</b> ({point.y:,.0f})',
        },
        neckWidth: '30%',
        neckHeight: '25%'
      }
    },
    series: [{
      data: [
        ['Website visits', 15654],
        ['Downloads', 4064],
        ['Requested price list', 1987],
        ['Invoice sent', 976],
        ['Finalized', 846]
      ]
    }]
  });
});

      </script> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <script src="https://code.highcharts.com/modules/funnel.js"></script> 
      <script src="https://code.highcharts.com/modules/exporting.js"></script> 
      <div id="container" style="min-width: 410px; max-width: 600px; height: 400px; margin: 0 auto"></div>  
   </body>
</html>

Related Tutorials