zoukankan      html  css  js  c++  java
  • 利用highcharts.js画圆饼

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

    具体实例如下:

    html部分

    <body>
    <div id="container" style=" 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>
    效果如下图:



  • 相关阅读:
    简单的测试用例计划放法
    黑盒测试用例设计方法-等价类划分
    Redis净化板
    爬虫部署与Django
    怎样实现前端的优化
    关于Apache简介笔记
    yield生成器的经典案例
    石头剪刀布
    函数内是否可以修改传递进来的列表
    不定长参数的传递
  • 原文地址:https://www.cnblogs.com/lingdu87/p/7985439.html
Copyright © 2011-2022 走看看