首页 > 代码库 > 玩转highcharts甜圈图
玩转highcharts甜圈图
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Highcharts Example</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$(‘#container‘).highcharts({
chart: {
plotBackgroundColor: ‘red‘,
backgroundColor:‘black‘,
spacingRight: 300,
plotShadow: false
},
title: {
text: ‘Browser<br>shares‘,
align: ‘center‘,
verticalAlign: ‘middle‘,
y: 10
},
tooltip: {
pointFormat: ‘{series.name}: <b>{point.percentage:.1f}%</b>‘
},
credits: {
enabled: false
},
plotOptions: {
pie: {
dataLabels: {
enabled: true,
//distance: -50,
style: {
fontSize:‘3px‘,
color: ‘white‘,
textShadow: ‘0px 1px 2px black‘
}
},
startAngle: -90,
endAngle: 270,
center: [‘50%‘, ‘55%‘]
}
},
series: [{
type: ‘pie‘,
name: ‘Browser share‘,
innerSize: ‘40%‘,
data: [
[‘Firefox‘, 45.0],
[‘IE‘, 26.8],
[‘Chrome‘, 12.8],
[‘Safari‘, 8.5],
[‘Opera‘, 6.2],
{
name: ‘Others‘,
y: 0.7,
dataLabels: {
enabled: false
}
}
]
}]
});
});
</script>
</head>
<body>
<script src="http://www.mamicode.com/js/highcharts.js"></script>
<script src="http://www.mamicode.com/js/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; height: 300px; max-width: 600px; margin: 0 auto;"></div>
</body>
</html>