Format axis label with link

Description

The following code shows how to format axis label with link.

Example


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<script type='text/javascript'>
$(function () {<!-- w w w  .ja v  a2s .  c  o m-->
    var categoryLinks = {
        'Foo': 'http://www.java2s.com',
        'Bar': 'http://www.java2s.com',
        'Foobar': 'http://www.java2s.com'
    };
    $('#container').highcharts({
        xAxis: {
            categories: ['Foo', 'Bar', 'Foobar'],

            labels: {
                formatter: function () {
                    return '<a href="' + categoryLinks[this.value] + '">' +
                        this.value + '</a>';
                }
            }
        },
        series: [{
            data: [300, 200, 600]
        }]
    });
});
</script>
</head>
<body>
<script src="http://code.highcharts.com/highcharts.js"></script>
<div id="container" style="height: 400px"></div>
</body>
</html>

Click to view the demo





















Home »
  highcharts »
    Axis »




Axis
Axis Data
Axis Label
Axis Plot
Axis Tick
Axis Title