-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
196 lines (185 loc) · 6.31 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
body, ul, li{
margin: 0;
padding: 0;
}
li{
list-style: none;
float: left;
margin: 10px;
width: 600px;
height: 400px;
}
.div{
list-style: none;
float: left;
margin: 10px;
width: 373px;
height: 214px;
}
</style>
</head>
<body>
<ul>
<li id="div1" class="div"></li>
<li id="div2" class="div"></li>
<li id="div3" class="div"></li>
<li class="div4"></li>
<li id="div5"></li>
</ul>
</body>
<script src="echarts.min.js"></script>
<script src="./index.js"></script>
<script>
//解决charts变量冲突
var ch = charts.noConflict();
//设置柱形图的默认选项
//传入数据生成柱形图
charts = ch('line', '#div1');
// charts.setTitle('心电图')
// .setXAxisSplitLine(true)
charts.setYAxisSplitLine(true)
// .setXAxisInterval(8)
// .setAxisType('xAxis', 'value')
// .setXAxisFontColor('rgb(125,125,125)')
// .setYAxisFontColor('rgb(125,125,125)')
// .setXAxisMinAndMax(0, 10)
// .setYAxisMinAndMax(0, 10)
// .setAxisType('xAxis', 'HH:mm:ss')
// .setAxisType('xAxis', 'yyyy-mm-dd HH:mm:ss')
// .setXAxisData([5, 4, 19, 15, 16, 20, 31, 1, 5, 4, 20, 15, 40, 28])
// .setYAxisData([[0,2,3,8,4,7,5,0,9,2,8,3,7,4,0,9,8,3,7,9,4,8,7,9,3,8,7,4,9,2,8,7,0,3,4,7,5,8,0]])
.setSeries([{data:[['1年内', 0],['1-5年内', 34],['5-10年内', 40],['10年以上', 50]]},{data:[['1年内', 40],['1-5年内', 30],['5-10年内', 28],['10年以上', 35]]}])
.setAreaColor(['rgba(7,161,167,0.2)','rgba(185,141,232,0.2)'])
.setItemColor(['#07A1A7 ','#B98DE8'])
.setSmooth(true)
// .setChartInterval(1100)
.create();
setInterval(function(){charts.pushPoint([date(), parseInt(10*Math.random())])}, 1001);
chart2 = ch('bar', '#div2');
chart2.setLegend(['类目一', '类目二'])
.setYAxisSplitLine(true)
// .setAreaColor('rgb(125,125,125)')
.setSeries([{name:'类目一', data:[['1年内', 40],['1-5年内', 34],['5-10年内', 40],['10年以上', 50]]},{name:'类目二', data:[['1年内', 40],['1-5年内', 30],['5-10年内', 28],['10年以上', 35]]}])
.setItemColor(['#FF817F','#8FADFE'])
.create();
chart3 = ch('bar', '#div3')
// chart3.setTitle('柱形图')
chart3.setXAxisType('value')
.setYAxisType('category')
.setYAxisData(['周一', '周二', '周三', '周四', '周五'], true)
.setSeries([{name: '直接访问',data: [320, 302, 301, 334, 390]},{name: '邮件营销',data: [120, 132, 101, 134, 90]}])
.setItemColor(['#FFCB4A','#9AE370'])
.setYAxisLine(true)
.setXAxisLine(false)
.create();
//
// //自定义扩展,为了执行链式调用,必须要在function中返回this对象
// ch.extend('formatter', function(){
// this.option.tooltip.formatter = function(params, ticket, callback){
// var res = '访问来源 : <br/>' + params.name + params.value;
// setTimeout(function (){
// // 仅为了模拟异步回调
// callback(ticket, res);
// }, 1000)
// return 'loading';
// };
// return this;
// });
//
// //设置饼图默认选项
// ch.setDefault('pie', {
// backgroundColor:'rgba(80,140,100,.3)',
// calculable:true,
// calculableColor:'rgba(0,0,0,0)'
// },{
// title:{
// x:'center',
// textStyle:{
// fontSize:18
// }
// },
// tooltip:{
// formatter:'{b}:{c}' + '({d}%)'
// },
// legend:{
// x:'right',
// y:35,
// orient:'vertical'
// }
// },{
// series:[{
// center:['50%', '55%'],
// radius:[60, 120]
// }]
// });
//
// //传入数据生成饼图
// ch('pie', '.div4')
// .title('饼图1')
// .legend(['直接访问', '邮件营销', '联盟广告', '视频广告', '搜索引擎'])
// .series([
// {
// name:'访问来源',
// data:[
// {value:335, name:'直接访问'},
// {value:310, name:'邮件营销'},
// {value:234, name:'联盟广告'},
// {value:135, name:'视频广告'},
// {value:1548, name:'搜索引擎'}
// ]
// }
// ])
// .formatter()
// .create();
//
// ch.setDefault('map', {
// backgroundColor:'#f1f1f1'
// },{
// series:[{
// selectedMode : 'multiple',
// itemStyle:{
// normal:{label:{show:true}},
// emphasis:{label:{show:true}}
// }
// }]
// });
// //中国地图
// ch('map', '#div5')
// .title('中国地图')
// .series([
// {
// name: '中国',
// mapType: 'china',
// data:[
// {name:'广东',selected:true}
// ]
// }
// ]).create();
var date = (function() {
return new Date().format('yyyy-MM-dd hh:mm:ss');
});
Date.prototype.format = function(fmt){
var o = {
"M+" : this.getMonth()+1, //月份
"d+" : this.getDate(), //日
"h+" : this.getHours(), //小时
"m+" : this.getMinutes(), //分
"s+" : this.getSeconds(), //秒
"q+" : Math.floor((this.getMonth()+3)/3), //季度
"S" : this.getMilliseconds() //毫秒
};
if(/(y+)/.test(fmt))
fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
for(var k in o)
if(new RegExp("("+ k +")").test(fmt))
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
return fmt;
}
</script>
</html>