Amcharts插件实现3D饼图

主要引入两个js文件:

pie.js和amcharts.js

实现的效果如下:

171821_SNuT_3544533.png

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>amCharts examples</title>
        <link rel="stylesheet" href="style.css" type="text/css">
        <script src="amcharts/amcharts.js" type="text/javascript"></script>
        <script src="amcharts/pie.js" type="text/javascript"></script>
        
        <script type="text/javascript">
            var chart;

            var chartData = [
                {
                    "country": "大宝",
                    "visits": 6000
                },
                {
                    "country": "二宝",
                    "visits": 1882
                },
                {
                    "country": "三宝",
                    "visits": 1809
                },
                {
                    "country": "四宝",
                    "visits": 1322
                },
                {
                    "country": "五宝",
                    "visits": 1122
                },
                {
                    "country": "六宝",
                    "visits": 1114
                },
                {
                    "country": "七宝",
                    "visits": 984
                },
                {
                    "country": "八宝",
                    "visits": 711
                }
            ];

            AmCharts.ready(function () {
                // PIE CHART
                chart = new AmCharts.AmPieChart();

                // title of the chart
                chart.addTitle("宝宝们随着年龄增长的小秘密", 16);
                chart.dataProvider = chartData;
                chart.titleField = "country";   //分类类别项
                chart.valueField = "visits";  //比例值
                chart.sequencedAnimation = true;
                chart.startEffect = "elastic";
                chart.innerRadius = "30%";
                chart.startDuration =2;  //饼图的渲染时间,时间越长,动画越长,展示的准备时间越久
                chart.labelRadius = 10;  //饼图上标签,值越大,饼图越小,说明的标签指示线越长
                chart.balloonText = "[[title]]<br><span style='font-size:14px'><b>[[value]]</b> ([[percents]]%)</span>";
                // the following two lines makes the chart 3D
                chart.depth3D = 10;  //3D效果的立体度 ,值越大立体感越强
                chart.angle = 20;  //角度占的分额基数,值大则显示的饼图倍数就会扩大,但是值不能超过限定的最大值,否则会变小

                // WRITE                                 
                chart.write("chartdiv");
            });
        </script>
    </head>
    
    <body>
        <div id="chartdiv" style="width:600px; height:400px;"></div>
    </body>

</html>

 

转载于:https://my.oschina.net/u/3544533/blog/1609222

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值