adapt a chart to a responsive view - Javascript highcharts

Javascript examples for highcharts:Responsive Chart

Description

adapt a chart to a responsive view

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Highcharts Demo</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <div id="grafica1" class="chart1Slide2"></div> 
      <script type="text/javascript">
Highcharts.chart('grafica1', {
  chart: {/*from   ww w. jav a  2s  . c o  m*/
    type: 'column',
    inverted: true,
    plotBackgroundColor: null,
    plotBorderWidth: 0,
    plotShadow: false
  },
  title: {
    text: ' '
  },
  xAxis: {
    type: 'category',
    labels: {
      useHTML: true
    }
  },
  yAxis: {
    min: 0,
    max: 100,
    title: {
      text: null,
    },
    labels: {
      enabled: false,
    }
  },
  legend: {
    enabled: false
  },
  tooltip: {
    enabled: false
  },
  plotOptions: {
    series: {
      borderWidth: 0,
      dataLabels: {
        enabled: true,
        format: '({point.y:.1f} Million tones)%'
      }
    }
  },
  responsive: {
    rules: [{
      condition: {
        maxWidth: 500
      },
      chartOptions: {
        chart: {
          inverted: false
        },
        legend: {
          align: 'center',
          verticalAlign: 'bottom',
          layout: 'horizontal'
        }
      }
    }]
  },
  series: [{
    name: 'Production',
    colorByPoint: true,
    data: [{
      name: 'PACKAGING PAPERS<br>AND BOARDS',
      y: 49,
      color: '#005eb8',
    }, {
      name: 'CASE MATERIALS',
      y: 29.9,
      color: '#fff',
      borderWidth: 2,
      borderColor: '#005eb8'
    }, {
      name: 'OTHER PACKAGING & PAPER',
      y: 14.4,
      color: '#fff',
      borderWidth: 2,
      borderColor: '#005eb8'
    }, {
      name: 'WRAPPINGS',
      y: 4.7,
      color: '#fff',
      borderWidth: 2,
      borderColor: '#005eb8'
    }]
  }]
});

      </script>  
   </body>
</html>

Related Tutorials