score:20

Accepted answer

the solution seems rather simple.

just don't give the graph's a fixed width, i.e., don't define the width or set width:100% and, unlike the demo i mention, the bar chart width and accompanying bars will shrink as much as the browser width is reduced.

score:0

try add this on the <head></head>

<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>

score:1

an example with bootstrap

 <!doctype html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title>highcharts data from json response</title>
        <style>
        body{
            margin-top: 30px;
            margin-left:40px;
        }
        .col-md-4{
        padding-left:5px !important;
        padding-right:5px !important;
        }
        </style>
    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
    <script src="http://code.highcharts.com/highcharts.js"></script>    
<script src="https://code.highcharts.com/modules/exporting.js"></script>
    <script type="text/javascript">
       // data gathered from http://populationpyramid.net/germany/2015/

// age categories
var categories = ['0-4', '5-9', '10-14', '15-19',
        '20-24', '25-29', '30-34', '35-39', '40-44',
        '45-49', '50-54', '55-59', '60-64', '65-69',
        '70-74', '75-79', '80-84', '85-89', '90-94',
        '95-99', '100 + '];
$(document).ready(function () {
    highcharts.chart('container', {
        chart: {
            type: 'bar'
        },

        xaxis: [{
            categories: categories,
            reversed: false,
            labels: {
                step: 1
            }
        }, { // mirror axis on right side
            opposite: true,
            reversed: false,
            categories: categories,
            linkedto: 0,
            labels: {
                step: 1
            }
        }],
        yaxis: {
            title: {
                text: null
            },
            labels: {
                formatter: function () {
                    return math.abs(this.value) + '%';
                }
            }
        },

        plotoptions: {
            series: {
                stacking: 'normal'
            }
        },

        tooltip: {
            formatter: function () {
                return '<b>' + this.series.name + ', age ' + this.point.category + '</b><br/>' +
                    'population: ' + highcharts.numberformat(math.abs(this.point.y), 0);
            }
        },

        series: [{
            name: 'male',
            data: [-2.2, -2.2, -2.3, -2.5, -2.7, -3.1, -3.2,
                -3.0, -3.2, -4.3, -4.4, -3.6, -3.1, -2.4,
                -2.5, -2.3, -1.2, -0.6, -0.2, -0.0, -0.0]
        }, {
            name: 'female',
            data: [2.1, 2.0, 2.2, 2.4, 2.6, 3.0, 3.1, 2.9,
                3.1, 4.1, 4.3, 3.6, 3.4, 2.6, 2.9, 2.9,
                1.8, 1.2, 0.6, 0.1, 0.0]
        }]
    });
     highcharts.chart('container2', {
        chart: {
            type: 'bar'
        },
        title: {
            text: 'population pyramid for germany, 2015'
        },
        subtitle: {
            text: 'source: <a href="http://populationpyramid.net/germany/2015/">population pyramids of the world from 1950 to 2100</a>'
        },
        xaxis: [{
            categories: categories,
            reversed: false,
            labels: {
                step: 1
            }
        }, { // mirror axis on right side
            opposite: true,
            reversed: false,
            categories: categories,
            linkedto: 0,
            labels: {
                step: 1
            }
        }],
        yaxis: {
            title: {
                text: null
            },
            labels: {
                formatter: function () {
                    return math.abs(this.value) + '%';
                }
            }
        },

        plotoptions: {
            series: {
                stacking: 'normal'
            }
        },

        tooltip: {
            formatter: function () {
                return '<b>' + this.series.name + ', age ' + this.point.category + '</b><br/>' +
                    'population: ' + highcharts.numberformat(math.abs(this.point.y), 0);
            }
        },

        series: [{
            name: 'male',
            data: [-2.2, -2.2, -2.3, -2.5, -2.7, -3.1, -3.2,
                -3.0, -3.2, -4.3, -4.4, -3.6, -3.1, -2.4,
                -2.5, -2.3, -1.2, -0.6, -0.2, -0.0, -0.0]
        }, {
            name: 'female',
            data: [2.1, 2.0, 2.2, 2.4, 2.6, 3.0, 3.1, 2.9,
                3.1, 4.1, 4.3, 3.6, 3.4, 2.6, 2.9, 2.9,
                1.8, 1.2, 0.6, 0.1, 0.0]
        }]
    });
     highcharts.chart('container3', {
        chart: {
            type: 'bar'
        },
        title: {
            text: 'population pyramid for germany, 2015'
        },
        subtitle: {
            text: 'source: <a href="http://populationpyramid.net/germany/2015/">population pyramids of the world from 1950 to 2100</a>'
        },
        xaxis: [{
            categories: categories,
            reversed: false,
            labels: {
                step: 1
            }
        }, { // mirror axis on right side
            opposite: true,
            reversed: false,
            categories: categories,
            linkedto: 0,
            labels: {
                step: 1
            }
        }],
        yaxis: {
            title: {
                text: null
            },
            labels: {
                formatter: function () {
                    return math.abs(this.value) + '%';
                }
            }
        },

        plotoptions: {
            series: {
                stacking: 'normal'
            }
        },

        tooltip: {
            formatter: function () {
                return '<b>' + this.series.name + ', age ' + this.point.category + '</b><br/>' +
                    'population: ' + highcharts.numberformat(math.abs(this.point.y), 0);
            }
        },

        series: [{
            name: 'male',
            data: [-2.2, -2.2, -2.3, -2.5, -2.7, -3.1, -3.2,
                -3.0, -3.2, -4.3, -4.4, -3.6, -3.1, -2.4,
                -2.5, -2.3, -1.2, -0.6, -0.2, -0.0, -0.0]
        }, {
            name: 'female',
            data: [2.1, 2.0, 2.2, 2.4, 2.6, 3.0, 3.1, 2.9,
                3.1, 4.1, 4.3, 3.6, 3.4, 2.6, 2.9, 2.9,
                1.8, 1.2, 0.6, 0.1, 0.0]
        }]
    });
})

    </script>
</head>
<body>
<div class="col-md-12 row">
<div class="col-md-4">
hello
</div>
  <div class="col-md-8 row">
  <div class="col-md-4"><div id="container" style="height: 400px;border:1px solid;"></div></div> <div class="col-md-4"><div id="container2" style="height: 400px;border:1px solid;"></div></div> 
  <div class="col-md-4"><div id="container3" style="height: 400px;border:1px solid;"></div></div>
  </div>
  </div>


</body>
</html>

score:2

you can set the chart container div width:100% . then just remove the highchart width property. i resolved it for a sparkline chart. now it is mobile responsive.

highcharts.chart('my-sparkline-chart, {
        chart: {
            type: 'areaspline',
            height: '70',
            //width: '189', //comment width property.
            spacing: [0, 0, 0, 0],
            backgroundcolor: "transparent"
        }
...

score:4

it probably depends on which types of charts that you are displaying. on mobile, if you're displaying a column chart, you might want to rotate the chart so that it becomes a bar chart.

if you're displaying a line chart, you could "scope" the data, so that you're only displaying the least amount of points needed to get the point across. as you zoom in, re-scope the data to fit the current view. this can be done using some events combined with some hand rolled js.


Related Query

More Query from same tag