1. 程式人生 > >highcharts為X軸標簽添加鏈接

highcharts為X軸標簽添加鏈接

highlight mage for clas mat Matter nbsp chart img

$(function () {
	var categoryLinks = {
		‘Foo‘: ‘http://www.google.com/search?q=foo‘,
		‘Bar‘: ‘http://www.google.com/search?q=foo+bar‘,
		‘Foobar‘: ‘http://www.google.com/serach?q=foobar‘
	};
	$(‘#container‘).highcharts({
		xAxis: {
			categories: [‘Foo‘, ‘Bar‘, ‘Foobar‘],
			labels: {
				formatter: function () {
					return ‘<a href="‘ + categoryLinks[this.value] + ‘">‘ +
						this.value + ‘</a>‘;
				}
			}
		},
		series: [{
			data: [29.9, 71.5, 106.4]
		}]
	});
});

  技術分享圖片

highcharts為X軸標簽添加鏈接