实例:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Highcharts Test</title>
<!--<style type="text/css">
$ {demo.css}
</style>-->
<!-- 引入Js -->
<script type="text/javascript" src="js/jquery-3.1.0.js"></script>
<script type="text/javascript" src="js/highcharts/highcharts.js"></script>
<!--<script type="text/javascript" src="js/highcharts/exporting.js"></script>-->
<script type="text/javascript">
$(function() {
$('#container').highcharts({
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie'
},
title: {
text: 'Highcharts 饼状图 Demo !'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: false
},
// 显示图例
showInLegend: true
}
},
legend: { // 图例显示位置
layout: 'vertical',
align: 'left',
verticalAlign: 'top',
x: 20,
y: 20,
floating: true,
backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || 'transparent'
},
credits: { // 右下角水印
enabled: true,
text: 'By - 吥悔',
href: 'http://www.javazlm.com'
},
series: [{
name: 'Brands',
colorByPoint: true,
data: [{
name: 'Microsoft Internet Explorer',
y: 56.33
}, {
name: 'Chrome',
y: 24.03,
sliced: true,
selected: true
}, {
name: 'Firefox',
y: 10.38
}, {
name: 'Safari',
y: 4.77
}, {
name: 'Opera',
y: 0.91
}, {
name: 'Proprietary or Undetectable',
y: 0.2
}]
}]
});
});
</script>
</head>
<body>
<div id="container" style="min-width: 310px; height: 400px; max-width: 600px; margin: 0 auto"></div>
</body>
</html>