详解JavaScript模块化开发
2017-10-26 16:59
375 查看
一、效果图
二、代码
html
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
[/code]
PercentPie.js
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
[/code]
(function () {('pre.prettyprint code').each(function () {
var lines = (this).text().split(′\n′).length;varnumbering = $('').addClass('pre-numbering').hide();
(this).addClass(′has−numbering′).parent().append(numbering);
for (i = 1; i
二、代码
html
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> </head> <body> <div id="pieDiagram" class="floatLeft" style="height:400px;width:400px;"></div> <script src="js/jquery/jquery-1.11.0.min.js" type="text/javascript"></script> 4000 <script src="js/echarts/echarts.min.js" type="text/javascript"></script> <script src="js/PercentPie.js"></script> <script type="text/javascript"> var option1 = { value:20,//百分比,必填 name:'及格率',//必填 title:'学习成绩', backgroundColor:null, color:['#38a8da','#d4effa'], fontSize:16, domEle:document.getElementById("pieDiagram")//必填 },percentPie1 = new PercentPie(option1); percentPie1.init(); </script> </body> </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
[/code]
PercentPie.js
function PercentPie(option){ this.backgroundColor = option.backgroundColor||'#fff'; this.color = option.color||['#38a8da','#d4effa']; this.fontSize = option.fontSize||12; this.domEle = option.domEle; this.value = option.value; this.name = option.name; this.title = option.title; } PercentPie.prototype.init = function(){ var _that = this; var option = { backgroundColor:_that.backgroundColor, color:_that.color, title: { text: _that.title, top:'3%', left:'1%', textStyle:{ color: '#333', fontStyle: 'normal', fontWeight: 'normal', fontFamily: 'sans-serif', fontSize: 16, } }, series: [{ name: '来源', type: 'pie', radius: ['60%', '75%'], avoidLabelOverlap: false, hoverAnimation:false, label: { normal: { show: false, position: 'center', textStyle: { fontSize: _that.fontSize, fontWeight: 'bold' }, formatter:'{b}\n{c}%' } }, data: [{ value: _that.value, name: _that.name, label:{ normal:{ show:true } } }, { value: 100-_that.value, name: '' } ] }] }; echarts.init(_that.domEle).setOption(option); };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
[/code]
(function () {('pre.prettyprint code').each(function () {
var lines = (this).text().split(′\n′).length;varnumbering = $('').addClass('pre-numbering').hide();
(this).addClass(′has−numbering′).parent().append(numbering);
for (i = 1; i
相关文章推荐
- 详解JavaScript模块化开发
- 详解JavaScript模块化开发
- 详解JavaScript模块化开发
- 详解JavaScript模块化开发
- 详解JavaScript模块化开发
- 详解JavaScript模块化开发
- 详解JavaScript模块化开发
- 详解JavaScript模块化开发
- JavaScript使用自定义事件实现简单的模块化开发
- 前端模块化开发解决方案详解
- 使用SeaJS实现模块化JavaScript开发
- 也谈JavaScript模块化开发类库的实现
- 使用SeaJS实现模块化JavaScript开发
- [javascript] <完全开源,开心分享> HTML5 Canvas 在线图片处理《imageMagic》(single page app)开发详解[1]
- JavaScript模块化开发一瞥
- JavaScript模块化开发一瞥
- JavaScript模块化开发技术概述
- IE8"开发人员工具"使用详解下(浏览器模式、文本模式、JavaScript调试、探查器)
- JavaScript模块化开发之SeaJS
- JavaScript个人笔记:js模块化开发seajs实战拖拽