Highcharts Demo

author(s): Torstein Hønsi

by sgearhart2

HTML

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

<div id="container"></div>

JavaScript

var chart = Highcharts.chart('container', {
    chart: {
        type: 'area',
        backgroundColor: 'aliceblue',
        events : {
        	load : setCreditSizeAndPosition,
          redraw: setCreditSizeAndPosition
        }
    },
    title: {
        text: 'Fruit consumption *'
    },
    legend: {
        floating: false
    },
    xAxis: {
        categories: ['Apples', 'Pears', 'Oranges', 'Bananas', 'Grapes', 'Plums', 'Strawberries', 'Raspberries']
    },
    yAxis: {
        title: {
            text: 'Y-Axis'
        },
        labels: {
            formatter: function () {
                return this.value;
            }
        }
    },
    tooltip: {
        formatter: function () {
            return '<b>' + this.series.name + '</b><br/>' +
                this.x + ': ' + this.y;
        }
    },
    plotOptions: {
        area: {
            fillOpacity: 0.5
        }
    },
    credits: {
        enabled: true,
        href : null,
        text : "It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way - in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.",
        position: {
          align: 'left'
        },
        style : {
        	cursor : 'normal'
        }
    },
    series: [{
        name: 'John',
        data: [0, 1, 4, 4, 5, 2, 3, 7]
    }, {
        name: 'Jane',
        data: [1, 0, 3, null, 3, 1, 2, 1]
    }]
});

function setCreditSizeAndPosition() {
  var creditsElem = $('.highcharts-credits').get(0);
	var intialCreditsBoxHeight =...