<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>ECharts</title>
<!-- 引入 echarts.js -->
<script src="./sources/echarts/echarts.min.js"></script>
</head>
<body >
<div id="main" style="width: 100%;height: 500px;"></div>
<script type="text/javascript">
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('main'));
option = {
title: {
text: '卡拉云新用户激活数据',
subtext: 'Demo 虚构数据',
x: 'center'
},
legend: { // 图例配置选项
orient: 'horizontal', //图例布局方式:水平 'horizontal' 、垂直 'vertical'
x: 'left', // 横向放置位置,选项:'center'、'left'、'right'、'number'(横向值 px)
y: 'top',// 纵向放置位置,选项:'top'、'bottom'、'center'、'number'(纵向值 px)
data: ['猜想','预期','实际']
},
grid: { // 图表距离边框的距离,可用百分比和数字(px)配置
top: '20%',
left: '3%',
right: '10%',
bottom: '5%',
containLabel: true
},
xAxis: {
name: '月份',
type: 'category',
data: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月',]
},
yAxis: {
name: '人次',
type: 'value',
min:0, // 配置 Y 轴刻度最小值
max:4000, // 配置 Y 轴刻度最大值
splitNumber:7, // 配置 Y 轴数值间隔
},
series: [
{
name: '猜想',
data: [454,226,891,978,901,581,400,543,272,955,1294,1581],
type: 'line',
symbolSize: function(value) { // 点的大小跟随数值增加而变大
return value / 150;
},
symbol:'circle',
itemStyle: {
normal: {
label : {
show: true
},
lineStyle:{
color: 'rgba(0,0,0,0)'// 折线颜色设置为0,即只显示点,不显示折线
}
}
}
},
{
name: '预期',
data: [2455,2534,2360,2301,2861,2181,1944,2197,1745,1810,2283,2298],
type: 'line',
symbolSize:8, //设置折线上圆点大小
itemStyle:{
normal:{
label : {
show: true // 在折线拐点上显示数据
},
lineStyle:{
width:3, // 设置虚线宽度
type:'dotted' // 虚线'dotted' 实线'solid'
}
}
}
},
{
name: '实际',
data: [1107,'','','',1647,1570,1343,1757,2547,2762,0,3665],
type: 'line',
symbol: 'circle', // 实心圆点
smooth: 0.5, // 设置折线弧度
symbolSize:8, //设置折线上圆点大小
connectNulls:true, //是否连接空数据
label: {
show: true,
position: 'bottom',
formatter: '{c}%',
//color: '#00BFFF',
color: 'white',
},
lineStyle:{
width:5, // 设置虚线宽度
type:'solid' // 虚线'dotted' 实线'solid'
}
}
],
color: ['#3366CC', '#FFCC99','#99CC33'] // 三个折线的颜色
}
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
</script>
</body>
</html>