Highcharts Demo

author(s): Torstein Hønsi

by Pranav Desai

HTML

<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>

<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>

JavaScript

Highcharts.chart('container', {
    chart: {
        zoomType: 'xy'
    },
    title: {
        text: 'Average Rating and total reviews'
    },
    subtitle: {
        text: 'Source: Unreliable city'
    },
    xAxis: [{
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
            'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
        crosshair: true
    }],
    yAxis: [{ // Primary yAxis
        labels: {
            format: ' ',
            style: {
                color: Highcharts.getOptions().colors[1]
            }
        },
        title: {
            text: 'Total Reviews',
            style: {
                color: Highcharts.getOptions().colors[1]
            }
        }
    }, { // Secondary yAxis
        title: {
            text: 'Average Rating',
            style: {
                color: Highcharts.getOptions().colors[0]
            }
        },
        labels: {
            format: '',
            style: {
                color: Highcharts.getOptions().colors[0]
            }
        },
        opposite: true
    }],
    tooltip: {
        shared: true
    },
    legend: {
        layout: 'vertical',
        align: 'left',
        x: 120,
        verticalAlign: 'top',
        y: 100,
        floating: true,
        backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
    },
    series: [{
        name: 'Average Rating',
        type: 'line',
        zIndex:3,
        yAxis: 1,
        data: [4.9, 4.5, 4.4, 4.2, 4.0, 4.2, 4.6, 4.5, 4.4, 4.1, 4.6, 3.2],
        tooltip: {
            valueSuffix: ' mm'
        }

    }, {
        name: 'Total Reviews',
        zIndex: 2,
        type: 'column',
        data: [2677, 2524, 2345, 2451, 2888 , 2345, 2521, 2651, 2330, 2833, 2309, 306],
        tooltip: {
            valueSuffix: '°C'
        }
    }]
});