利用highcharts.js画圆饼

最近需要项目需要画图表,在网上搜索N多方法,最后选择用highcharts.js;

具体实例如下:

html部分

<body>
<div id="container" style="width: 250px; height: 250px; margin: 0 auto"></div>
</body>
Script部分
首先引入jquery.js,然后再引入highcharts.js
<script type="text/javascript" src="js/jquery-3.1.1.min.js"></script>
<script type="text/javascript" src="js/highcharts.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var chart = {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
};
var title = {
text: '圆饼图例'
};
var tooltip = {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
};
var plotOptions = {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: false
},
showInLegend: true
}
};
var series= [{
type: 'pie',
name: '占百分比',
data: [
['火狐', 45.0],
['IE', 26.8],
{
name: '谷歌',
y: 12.8,
sliced: true,
selected: true
},
['苹果', 8.5],
['欧朋', 6.2],
['其他', 0.7]
]
}];

var json = {};
json.chart = chart;
json.title = title;
json.tooltip = tooltip;
json.series = series;
json.plotOptions = plotOptions;
$('#container').highcharts(json);
    
$('#container .highcharts-container svg').children(':last').text('');//去除底部链接
});
</script>
效果如下图:



转载于:https://www.cnblogs.com/lingdu87/p/7985439.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值