-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo1.html
151 lines (141 loc) · 3.78 KB
/
demo1.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Echarts demo1</title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
body{
font-size: 12px;
font-family: "Arial";
}
.demo{
width: 50%;
margin: 20px auto 70px;
}
.demo p{
margin-bottom: 5px;
margin-left: 60px;
}
#chart{
width: 100%;
}
a,a:link{
text-decoration: none;
color: #188F83;
}
</style>
</head>
<body>
<div class="demo">
<div id="chart" style="height:400px;max-width:700px"></div>
<p>Source: WSJ/NBC News poll</p>
<p><a href="http://blogs.wsj.com/washwire/2015/08/03/american-public-split-on-iran-nuclear-deal-wsjnbc-poll/" target="_blank">Poll completed July 30, 2015</p>
</div>
<script src="./build/echarts.js"></script>
<script type="text/javascript">
require.config({
paths: {
echarts: './build'
}
});
require(
[
'echarts',
'echarts/chart/bar',
],
function(ec){
var chart = ec.init(document.getElementById("chart"));
var option = {
title:{
text:'Support for Iran nuclear deal',
textStyle:{
fontFamily:'helvetica',
fontSize:15,
},
x:50,
},
tooltip : {
trigger: 'item',
backgroundColor: 'rgba(255,255,255,0.8)',
borderColor: '#ccc',
borderWidth: 1.5,
formatter:
function(params){
var colorList = ['#C1232B','#B5C334','#FCCE10'];
var color = colorList[params.dataIndex];
var res = '<div style="color:'+color+'">';
res += params.name+':'+params.value + '%';
res += '</div>';
return res;
},
textStyle : {
color : '#000',
fontWeight: '700',
fontFamily:'Arial',
fontSize: '16px'
},
},
toolbox: {
show : false,
},
calculable : true,
grid: {
borderWidth: 0,
},
xAxis : [
{
type : 'category',
splitLine: 'none',
axisLine: 'none',
axisTick: 'none',
boundaryGap: 30,
axisLabel: {
textStyle:{
fontFamily:'Arial',
fontWeight:'bolder',
}
},
data : ['Support','Oppose','Don\'t know enough']
}
],
yAxis : [
{
type : 'value',
axisLine: 'none',
splitLine: {
lineStyle : {
type : "dashed",
color : "#ccc",
width : 1,
},
},
}
],
series : [
{
name:'Support for Iran nuclear deal',
type:'bar',
data:[35,33,32],
barCategoryGap : "40%",
itemStyle:{
normal:{
color: function(params){
var colorList = ['#C1232B','#B5C334','#FCCE10'];
return colorList[params.dataIndex]
},
}
}
},
]
};
chart.setOption(option);
window.onresize = chart.resize;
}
);
</script>
</body>
</html>