Highcharts Demo

author(s): Torstein Hønsi

HTML

<script src="http://code.highcharts.com/highcharts.js"></script>

<div id="container" style="height: 400px"></div>
<button id='b1'> change formatter </button>

JavaScript

$(function() {
    function myCustomFormatter(t) {
        return t.value + "x";
    }
    var chart = new Highcharts.Chart({
        chart: {
            renderTo: 'container',
            zoomType: 'x',
           // plotBackgroundColor: '#COCOCO'
            plotBackgroundColor: '#F2F2F2',
            plotBorderColor: '#C0C0C0',
            plotBorderWidth: 2
        },
        xAxis: {
            type: 'datetime',
            maxZoom: 48 * 3600 * 1000,
            labels: {
                formatter: function() {
                    return myCustomFormatter(this)
                }
            }
        },

        series: [{
            data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4],
            pointStart: Date.UTC(2010, 0, 1),
            pointInterval: 3600 * 1000 // one hour
            }]
    });

    $('#b1').click(function() {
        myCustomFormatter = function myCustomFormatter(t) {
            return Highcharts.dateFormat('%H', t.value);
        };
        chart.redraw();

    });
});