使用highchart.js

使用highchar.js

注意内容

script要写在body前,不然显示不了。

html部分
<div id="container_column" style="min-width: 310px; height:220px; margin: 20px auto 5px"></div>

<div id="container_line" style="min-width: 310px; height:220px; margin: 20px auto 5px"></div>

 <div id="container_pie" style="min-width: 310px; height:220px; margin: 20px auto 5px"></div>

script部分
  <script type="text/javascript" src="http://cdn.hcharts.cn/jquery/jquery-1.8.3.min.js"></script>



    <script type="text/javascript">
        $(function () {
            // Create the chart
            $('#container_column').highcharts({
                credits: {
                    text: ' ',
                    href: ' '
                },
                chart: {
                    type: 'column'
                },
                title: {
                    text: ''
                },
                subtitle: {
                    text: ''
                },
                xAxis: {
                    type: 'category'
                },
                yAxis: {
                    title: {
                        text: ''
                    }

                },
                legend: {
                    enabled: false
                },
                plotOptions: {
                    series: {
                        borderWidth: 0,
                        dataLabels: {
                            enabled: true,
                            format: '{point.y:.1f}分'
                        }
                    }
                },


                tooltip: {
                    headerFormat: '<span style="font-size:3px">{series.name}</span><br>',
                    pointFormat: '<span style="color:{point.color}">{point.name}</span>: <b>{point.y:.2f}分</b><br/>'
                },

                series: [{
                    name: '成绩',
                    colorByPoint: true,
                    data: [{
                        name: '语文',
                        y: 119,
                        drilldown: ''
                    }, {
                        name: '数学',
                        y: 91,
                        drilldown: ''
                    }, {
                        name: '外语',
                        y: 130,
                        drilldown: ''
                    }, {
                        name: '物理',
                        y: 110,
                        drilldown: ''
                    }, {
                        name: '化学',
                        y:90,
                        drilldown: ''
                    }, {
                        name: '生物',
                        y:110,
                        drilldown: ''
                    }]
                }],

                colors: [
                    '#f7672a',
                    '#1596F1',
                    '#f7672a',
                    '#f7672a',
                    '#21E4DE',
                    '#21E4DE'
                ]


            });
        });
    </script>

    <script type="text/javascript">
        $(function () {
            $('#container_line').highcharts({
                chart: {
                    type: 'line'
                },
                credits: {
                    text: ' ',
                    href: ' '
                },
                title: {
                    text: ''
                },
                subtitle: {
                    text: ''
                },
                plotOptions: {
                    series: {
                        borderWidth: 0,
                        dataLabels: {
                            enabled: true,
                            format: '{point.y:.1f}%'
                        }
                    }
                },

                xAxis: {
                    categories: ['第一次', '第二次', '第三次', '第四次', '第五次', '第六次'],
                    lineColor:['#000']
                },
                yAxis: {
                    title: {
                        text: ''
                    }

                },
                plotOptions: {
                    line: {
                        dataLabels: {
                            enabled: true,
                            format:'{point.y:.1f}%'
                        },
                        enableMouseTracking: true
                    }
                },
                series: [{
                    name:  ' ',
                    data: [65, 60, 45, 60, 90, 30]
                }]
            });
        });
    </script>

    <script type="text/javascript">
        $(function () {
            $('#container_pie').highcharts({
                chart: {
                    type: 'pie',
                    options3d: {
                        enabled: true,
                        alpha: 45,
                        beta: 0
                    }
                },
                credits: {
                    text: ' ',
                    href: ' '
                },
                title: {
                    text: ''
                },
                tooltip: {
//                    pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
                    pointFormat: ''
                },
                plotOptions: {
                    pie: {
                        allowPointSelect: true,
                        cursor: 'pointer',
                        depth: 35,
                        dataLabels: {
                            enabled: true,
                            format: '{point.name}'
                        }
                    }
                },
                series: [{
                    type: 'pie',
                    name: '',
                    data: [
                        ['已交作业(75%)', 75.0],

                        {
                            name: '未交作业(25%)',
                            y: 25,
                            sliced: true,
                            selected: true
                        },
                    ]
                }],colors: [
                    '#f7672a',
                    '#1596F1'
                ]
            });
        });
    </script>

主要看hightchar中文文档。资料充足

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值