Echarts基本使用

Echarts基本使用

友情提示 需要先写div标签 然后应用echarts

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>123</title>
	</head>
	<!--<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>-->
	<script type="text/javascript" src="js/echarts.js" ></script>
	
		
		
    
	<body>
	//先写这个div    不然加载不出来
		<div id="main" style="width:600px; height:400px; background-color:rgba(255, 255, 0,0.5);">123</div>
		
		<script type="text/javascript">
    	console.log('1');
        // 基于准备好的 DOM,初始化 echarts 实例
        var myChart = echarts.init(document.getElementById("main"));
        console.log('begin');
        // 指定图表的配置项和数据
        var option = {
            title:{
                text:"ECharts 入门示例"
            },
            tooltip:{},
            legend:{
                data:["销量"]
            },
            xAxis:{
                data:["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
            },
            yAxis:{},
            series:{
                name:["销量"],
                type: "bar",
                data:[5, 20, 36, 10, 10, 20]
            }
        }
        // 使用刚指定的配置项和数据显示图表
        myChart.setOption(option);
    </script>
	</body>
</html>

运行效果

在这里插入图片描述
南丁格尔图

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>ECharts Demo02-南丁格尔图</title>
    <!-- 引入 ECharts 脚本文件 -->
    <script src="js/echarts.js"></script>
</head>
<body>
    <!-- 为 ECharts 准备一个具备大小的(宽高)的 DOM -->
    <div id="main" style="width:600px; height:400px; background-color:rgba(255, 255, 255,0.5);">123</div>
    <script type="text/javascript">
        // 基于准备好的 DOM,初始化 echarts 实例
        console.log('1');
        var myChart = echarts.init(document.getElementById("main"));
        console.log('2');
        // 指定图表的配置项和数据
        var option = {
            backgroundColor: '#FFFFFF',            
            series : [
                {
                    name: '访问来源',
                    type: 'pie',
                    radius: '55%',
                    data:[
                        {value:235, name:'视频广告'},
                        {value:274, name:'联盟广告'},
                        {value:310, name:'邮件营销'},
                        {value:335, name:'直接访问'},
                        {value:400, name:'搜索引擎'}
                    ],
                    roseType: 'angle',
                    label: {
                        normal: {
                            textStyle: {
                                color: 'rgba(0, 0, 0, 0.7)'
                            }
                        }
                    },
                    labelLine: {
                        normal: {
                            lineStyle: {
                                color: 'rgba(0, 0, 0, 0.5)'
                            }
                        }
                    },
                    itemStyle: {
                        normal: {
                            color: '#c23531',
                            shadowBlur: 200,
                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                        }
                    }
                }
            ]       
        }
        // 使用刚指定的配置项和数据显示图表
        myChart.setOption(option);
    </script>
</body>
</html>

南丁格尔图

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值