├── .babelrc ├── .gitignore ├── README.md ├── abc.json ├── demo ├── area │ ├── index.html │ └── index2.html ├── bar │ ├── index.html │ └── index2.html ├── heatmap │ ├── index.html │ └── test.html ├── line │ ├── index-time.html │ ├── index.html │ ├── index2.html │ └── index3.html └── pie │ ├── bugfix.html │ ├── default.html │ ├── index.html │ └── moredata.html ├── dist ├── amd.js ├── chartx.js ├── chartx.js.map ├── cjs.js ├── es.js └── umd.js ├── gulpfile.js ├── lib ├── bootstrap │ ├── css │ │ ├── bootstrap-theme.css │ │ ├── bootstrap-theme.css.map │ │ ├── bootstrap-theme.min.css │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ └── docs.min.css │ ├── fonts │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.svg │ │ ├── glyphicons-halflings-regular.ttf │ │ ├── glyphicons-halflings-regular.woff │ │ └── glyphicons-halflings-regular.woff2 │ └── js │ │ ├── bootstrap.js │ │ ├── bootstrap.min.js │ │ └── npm.js ├── codemirror │ ├── active-line.js │ ├── ambiance.css │ ├── codemirror.css │ ├── codemirror.js │ ├── docs.css │ ├── javascript.js │ ├── matchbrackets.js │ └── zenburn.css ├── d3.js ├── demo.css ├── demo.js ├── dom.js ├── domReady.js ├── jquery-1.11.1.min.js ├── requirejs.js ├── sea.js └── underscore.js ├── package-lock.json ├── package.json ├── rollup.config.js ├── server.js ├── src ├── chart3d.js ├── components │ ├── Component.js │ ├── cartesian3dUI │ │ ├── axisLine.js │ │ ├── grid.js │ │ ├── index.js │ │ ├── tickLines.js │ │ ├── tickTexts.js │ │ ├── xAxis.js │ │ ├── yAxis.js │ │ └── zAxis.js │ ├── coord │ │ ├── box.js │ │ ├── cube.js │ │ ├── index.js │ │ └── polar3d.js │ ├── cubeUI │ │ ├── axis.js │ │ └── index.js │ ├── graphs │ │ ├── area │ │ │ └── index.js │ │ ├── bar │ │ │ └── index.js │ │ ├── graph.js │ │ ├── heatmap │ │ │ └── index.js │ │ ├── line │ │ │ └── index.js │ │ └── pie │ │ │ └── index.js │ ├── legend │ │ └── index.js │ ├── markpoint │ │ └── index.js │ ├── theme │ │ └── index.js │ └── tips │ │ └── index.js ├── constants.js ├── framework │ ├── OrbitControls.js │ ├── application.js │ ├── coord │ │ ├── cartesian3d.js │ │ ├── cylindrical.js │ │ ├── inertial.js │ │ └── model │ │ │ ├── axisAttribute.js │ │ │ └── polarAttribute.js │ ├── framework.js │ ├── interaction.js │ ├── primitive.js │ ├── renderFont.js │ └── view.js └── index.js ├── utils └── tools.js └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "es2015", 5 | { 6 | "modules": false 7 | } 8 | ], 9 | "stage-1" 10 | ], 11 | // "plugins": [ 12 | // "external-helpers" 13 | // ] 14 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /node_modules/ 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | chartx3d 0.1 代码规范 2 | ================= 3 | 4 | * 配置使用规范约定 5 | 6 | 7 | ``` 8 | var data = [ 9 | ["xfield", "uv", "pv", "click", "ppc"], 10 | [1, 40, 20, 33, 45], 11 | [2, 60, 51, 26, 76], 12 | [3, 80, 50, 50, 45], 13 | [4, 100, 60, 33, 64], 14 | [5, 120, 91, 126, 22], 15 | [6, 20, 50, 90, 45], 16 | [7, 20, 120, 33, 78], 17 | [8, 20, 51, 86, 234], 18 | [9, 20, 90, 150, 63] 19 | 20 | ]; 21 | ``` 22 | ``` 23 | var options = { 24 | //theme : [], 25 | controls: { 26 | 27 | boxWidth: 1500, //空间中X的最大值(最大宽度) 28 | boxHeight: 1000, //空间中Y的最大值(最大高度) 29 | boxDepth: 500, //空间中Z的最大值(最大深度) 30 | 31 | distance: 900, //默认相机距离 32 | maxDistance: 5000, //最大相机距离 33 | minDistance: 300, //最小相机距离 34 | 35 | alpha: 20, //绕X轴旋转 36 | beta: 40, //绕Y轴旋转 37 | }, 38 | tips:{ 39 | enabled:true 40 | }, 41 | coord: { 42 | type: "cartesian3d", 43 | xAxis: { 44 | field: "xfield", 45 | title: { 46 | content: "xAxis" 47 | }, 48 | label: { 49 | textAlign: "center", 50 | format: function (val) { 51 | return val; 52 | // return val%2==0? "x\nodfdfdfdfsdfo":val; 53 | } 54 | } 55 | 56 | //dataSection : [1,3,5,7,9] 57 | }, 58 | zAxis: { 59 | // enabled: false, 60 | // field : "ppc", 61 | //depth: 1000, 62 | title: { 63 | content: "zAxis" 64 | }, 65 | label: { 66 | textAlign: "left", 67 | format: function (val) { 68 | return val; 69 | //return "x\nodfdfdfdfsdfo" 70 | } 71 | }, 72 | 73 | // dataSection: ['页面访问数'] 74 | }, 75 | yAxis: [ 76 | { 77 | // min:0, 78 | field: 'uv', 79 | title: { 80 | content: "left" 81 | }, 82 | // dataSection : [0,100,200,300,400,500,600,700,800], 83 | label: { 84 | format: function (val) { 85 | 86 | } 87 | } 88 | } 89 | ] 90 | }, 91 | 92 | // tips : { 93 | // pointer : "region" 94 | // }, 95 | graphs: [ 96 | { 97 | type: "bar", 98 | field: ['uv','pv','click','ppc'], 99 | yAxisAlign: "left", 100 | label: { 101 | enabled: true, 102 | verticalAlign: "middle", 103 | position: "center", 104 | fontColor: "#fff", 105 | lineWidth: 2, 106 | rotation: -90 107 | } 108 | } 109 | 110 | ] 111 | 112 | }; 113 | Chartx.create("canvasTest", data, options) 114 | ``` 115 | 116 | * 使用demo,请访问[https://davidyanlong.github.io](https://davidyanlong.github.io) -------------------------------------------------------------------------------- /abc.json: -------------------------------------------------------------------------------- 1 | { 2 | "assets":{ 3 | "type":"command", 4 | "command":{ 5 | "cmd":[ 6 | "tnpm install", 7 | "npm run build", 8 | "mv ./dist $BUILD_DEST" 9 | ] 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /demo/area/index2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | xChart demo -- area 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 | 115 | 131 | 132 |
35 |
114 |
116 |
117 |
118 | 119 | 120 |

折线图(bar chart)

121 |

122 | 联系人:@不决 123 |

124 |
125 |
126 |
127 |
128 | 129 |
130 |
133 | 134 | 135 | 136 | 137 | -------------------------------------------------------------------------------- /demo/bar/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | xChart demo -- bar 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 | 128 | 143 | 144 |
35 |
127 |
129 |
130 |
131 | 132 | 133 |

柱状图(bar chart)

134 |

135 | 联系人:@不决 136 |

137 |
138 |
139 |
140 |
141 |
142 |
145 | 146 | 147 | 148 | 149 | -------------------------------------------------------------------------------- /demo/line/index-time.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | xChart demo -- bar 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 | 96 | 112 | 113 |
35 |
95 |
97 |
98 |
99 | 100 | 101 |

折线图(bar chart)

102 |

103 | 联系人:@不决 104 |

105 |
106 |
107 |
108 |
109 | 110 |
111 |
114 | 115 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /demo/line/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | xChart demo -- line 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 | 118 | 134 | 135 |
33 |
117 |
119 |
120 |
121 | 122 | 123 |

折线图(bar chart)

124 |

125 | 联系人:@不决 126 |

127 |
128 |
129 |
130 |
131 | 132 |
133 |
136 | 137 | 138 | 139 | 140 | 141 | 142 | -------------------------------------------------------------------------------- /demo/line/index2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | xChart demo -- line 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 | -------------------------------------------------------------------------------- /demo/line/index3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | xChart demo -- line 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 | 148 | 164 | 165 |
33 |
147 |
149 |
150 |
151 | 152 | 153 |

折线图(bar chart)

154 |

155 | 联系人:@不决 156 |

157 |
158 |
159 |
160 |
161 | 162 |
163 |
166 | 167 | 168 | 169 | 170 | 171 | 172 | -------------------------------------------------------------------------------- /demo/pie/bugfix.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | xChart demo -- 饼图 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 | 82 | 98 | 99 |
33 |
80 | 81 |
83 |
84 |
85 | 86 | 87 |

饼图(pie chart)- 基础饼图

88 |

89 | 联系人:@释剑 90 |

91 |
92 |
93 |
94 |
95 | 96 |
97 |
100 | 101 | 102 | 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /demo/pie/default.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | xChart demo -- 饼图 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 | 77 | 93 | 94 |
33 |
75 | 76 |
78 |
79 |
80 | 81 | 82 |

饼图(pie chart)- 基础饼图

83 |

84 | 联系人:@不决 85 |

86 |
87 |
88 |
89 |
90 | 91 |
92 |
95 | 96 | 97 | 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /demo/pie/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | xChart demo -- 饼图 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 32 | 33 | 34 | 35 | 36 | 37 | 119 | 135 | 136 |
38 |
117 | 118 |
120 |
121 |
122 | 123 | 124 |

饼图(pie chart)- 基础饼图

125 |

126 | 联系人:@释剑 127 |

128 |
129 |
130 |
131 |
132 | 133 |
134 |
137 | 138 | 139 | 140 | 141 | 142 | 143 | -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp'), 2 | 3 | watch = require('gulp-watch'), 4 | exec = require('child_process').exec; 5 | 6 | gulp.task('default', function() { 7 | // 将你的默认的任务代码放在这 8 | }); 9 | 10 | 11 | gulp.task('watch', function (cb) { 12 | 13 | return watch('./src/**/*.js',function(){ 14 | console.log('watching'); 15 | exec('tnpm run rollup', (err, stdout, stderr) => { 16 | if (err) { 17 | console.error(err); 18 | return; 19 | } 20 | console.log(new Date()); 21 | console.log(stdout); 22 | // cb(err); 23 | }); 24 | }); 25 | 26 | }) 27 | 28 | -------------------------------------------------------------------------------- /lib/bootstrap/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Davidyanlong/chartx3d/952e08eaabea46692ceb7e4eb0f498199e667ba0/lib/bootstrap/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /lib/bootstrap/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Davidyanlong/chartx3d/952e08eaabea46692ceb7e4eb0f498199e667ba0/lib/bootstrap/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /lib/bootstrap/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Davidyanlong/chartx3d/952e08eaabea46692ceb7e4eb0f498199e667ba0/lib/bootstrap/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /lib/bootstrap/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Davidyanlong/chartx3d/952e08eaabea46692ceb7e4eb0f498199e667ba0/lib/bootstrap/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /lib/bootstrap/js/npm.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment. 2 | require('../../js/transition.js') 3 | require('../../js/alert.js') 4 | require('../../js/button.js') 5 | require('../../js/carousel.js') 6 | require('../../js/collapse.js') 7 | require('../../js/dropdown.js') 8 | require('../../js/modal.js') 9 | require('../../js/tooltip.js') 10 | require('../../js/popover.js') 11 | require('../../js/scrollspy.js') 12 | require('../../js/tab.js') 13 | require('../../js/affix.js') -------------------------------------------------------------------------------- /lib/codemirror/active-line.js: -------------------------------------------------------------------------------- 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others 2 | // Distributed under an MIT license: http://codemirror.net/LICENSE 3 | 4 | // Because sometimes you need to style the cursor's line. 5 | // 6 | // Adds an option 'styleActiveLine' which, when enabled, gives the 7 | // active line's wrapping
the CSS class "CodeMirror-activeline", 8 | // and gives its background
the class "CodeMirror-activeline-background". 9 | 10 | (function(mod) { 11 | mod(CodeMirror); 12 | return; 13 | if (typeof exports == "object" && typeof module == "object") // CommonJS 14 | mod(require("../../lib/codemirror")); 15 | else if (typeof define == "function" && define.amd) // AMD 16 | define(["../../lib/codemirror"], mod); 17 | else // Plain browser env 18 | mod(CodeMirror); 19 | })(function(CodeMirror) { 20 | "use strict"; 21 | var WRAP_CLASS = "CodeMirror-activeline"; 22 | var BACK_CLASS = "CodeMirror-activeline-background"; 23 | 24 | CodeMirror.defineOption("styleActiveLine", false, function(cm, val, old) { 25 | var prev = old && old != CodeMirror.Init; 26 | if (val && !prev) { 27 | cm.state.activeLines = []; 28 | updateActiveLines(cm, cm.listSelections()); 29 | cm.on("beforeSelectionChange", selectionChange); 30 | } else if (!val && prev) { 31 | cm.off("beforeSelectionChange", selectionChange); 32 | clearActiveLines(cm); 33 | delete cm.state.activeLines; 34 | } 35 | }); 36 | 37 | function clearActiveLines(cm) { 38 | for (var i = 0; i < cm.state.activeLines.length; i++) { 39 | cm.removeLineClass(cm.state.activeLines[i], "wrap", WRAP_CLASS); 40 | cm.removeLineClass(cm.state.activeLines[i], "background", BACK_CLASS); 41 | } 42 | } 43 | 44 | function sameArray(a, b) { 45 | if (a.length != b.length) return false; 46 | for (var i = 0; i < a.length; i++) 47 | if (a[i] != b[i]) return false; 48 | return true; 49 | } 50 | 51 | function updateActiveLines(cm, ranges) { 52 | var active = []; 53 | for (var i = 0; i < ranges.length; i++) { 54 | var range = ranges[i]; 55 | if (!range.empty()) continue; 56 | var line = cm.getLineHandleVisualStart(range.head.line); 57 | if (active[active.length - 1] != line) active.push(line); 58 | } 59 | if (sameArray(cm.state.activeLines, active)) return; 60 | cm.operation(function() { 61 | clearActiveLines(cm); 62 | for (var i = 0; i < active.length; i++) { 63 | cm.addLineClass(active[i], "wrap", WRAP_CLASS); 64 | cm.addLineClass(active[i], "background", BACK_CLASS); 65 | } 66 | cm.state.activeLines = active; 67 | }); 68 | } 69 | 70 | function selectionChange(cm, sel) { 71 | updateActiveLines(cm, sel.ranges); 72 | } 73 | }); 74 | -------------------------------------------------------------------------------- /lib/codemirror/codemirror.css: -------------------------------------------------------------------------------- 1 | /* BASICS */ 2 | 3 | .CodeMirror { 4 | /* Set height, width, borders, and global font properties here */ 5 | font-family: monospace; 6 | height: 300px; 7 | color: black; 8 | } 9 | 10 | /* PADDING */ 11 | 12 | .CodeMirror-lines { 13 | padding: 4px 0; /* Vertical padding around content */ 14 | } 15 | .CodeMirror pre { 16 | padding: 0 4px; /* Horizontal padding of content */ 17 | } 18 | 19 | .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { 20 | background-color: white; /* The little square between H and V scrollbars */ 21 | } 22 | 23 | /* GUTTER */ 24 | 25 | .CodeMirror-gutters { 26 | border-right: 1px solid #ddd; 27 | background-color: #f7f7f7; 28 | white-space: nowrap; 29 | } 30 | .CodeMirror-linenumbers {} 31 | .CodeMirror-linenumber { 32 | padding: 0 3px 0 5px; 33 | min-width: 20px; 34 | text-align: right; 35 | color: #999; 36 | white-space: nowrap; 37 | } 38 | 39 | .CodeMirror-guttermarker { color: black; } 40 | .CodeMirror-guttermarker-subtle { color: #999; } 41 | 42 | /* CURSOR */ 43 | 44 | .CodeMirror div.CodeMirror-cursor { 45 | border-left: 1px solid black; 46 | } 47 | /* Shown when moving in bi-directional text */ 48 | .CodeMirror div.CodeMirror-secondarycursor { 49 | border-left: 1px solid silver; 50 | } 51 | .CodeMirror.cm-fat-cursor div.CodeMirror-cursor { 52 | width: auto; 53 | border: 0; 54 | background: #7e7; 55 | } 56 | .CodeMirror.cm-fat-cursor div.CodeMirror-cursors { 57 | z-index: 1; 58 | } 59 | 60 | .cm-animate-fat-cursor { 61 | width: auto; 62 | border: 0; 63 | -webkit-animation: blink 1.06s steps(1) infinite; 64 | -moz-animation: blink 1.06s steps(1) infinite; 65 | animation: blink 1.06s steps(1) infinite; 66 | } 67 | @-moz-keyframes blink { 68 | 0% { background: #7e7; } 69 | 50% { background: none; } 70 | 100% { background: #7e7; } 71 | } 72 | @-webkit-keyframes blink { 73 | 0% { background: #7e7; } 74 | 50% { background: none; } 75 | 100% { background: #7e7; } 76 | } 77 | @keyframes blink { 78 | 0% { background: #7e7; } 79 | 50% { background: none; } 80 | 100% { background: #7e7; } 81 | } 82 | 83 | /* Can style cursor different in overwrite (non-insert) mode */ 84 | div.CodeMirror-overwrite div.CodeMirror-cursor {} 85 | 86 | .cm-tab { display: inline-block; text-decoration: inherit; } 87 | 88 | .CodeMirror-ruler { 89 | border-left: 1px solid #ccc; 90 | position: absolute; 91 | } 92 | 93 | /* DEFAULT THEME */ 94 | 95 | .cm-s-default .cm-keyword {color: #708;} 96 | .cm-s-default .cm-atom {color: #219;} 97 | .cm-s-default .cm-number {color: #164;} 98 | .cm-s-default .cm-def {color: #00f;} 99 | .cm-s-default .cm-variable, 100 | .cm-s-default .cm-punctuation, 101 | .cm-s-default .cm-property, 102 | .cm-s-default .cm-operator {} 103 | .cm-s-default .cm-variable-2 {color: #05a;} 104 | .cm-s-default .cm-variable-3 {color: #085;} 105 | .cm-s-default .cm-comment {color: #a50;} 106 | .cm-s-default .cm-string {color: #a11;} 107 | .cm-s-default .cm-string-2 {color: #f50;} 108 | .cm-s-default .cm-meta {color: #555;} 109 | .cm-s-default .cm-qualifier {color: #555;} 110 | .cm-s-default .cm-builtin {color: #30a;} 111 | .cm-s-default .cm-bracket {color: #997;} 112 | .cm-s-default .cm-tag {color: #170;} 113 | .cm-s-default .cm-attribute {color: #00c;} 114 | .cm-s-default .cm-header {color: blue;} 115 | .cm-s-default .cm-quote {color: #090;} 116 | .cm-s-default .cm-hr {color: #999;} 117 | .cm-s-default .cm-link {color: #00c;} 118 | 119 | .cm-negative {color: #d44;} 120 | .cm-positive {color: #292;} 121 | .cm-header, .cm-strong {font-weight: bold;} 122 | .cm-em {font-style: italic;} 123 | .cm-link {text-decoration: underline;} 124 | .cm-strikethrough {text-decoration: line-through;} 125 | 126 | .cm-s-default .cm-error {color: #f00;} 127 | .cm-invalidchar {color: #f00;} 128 | 129 | /* Default styles for common addons */ 130 | 131 | div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;} 132 | div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;} 133 | .CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); } 134 | .CodeMirror-activeline-background {background: #e8f2ff;} 135 | 136 | /* STOP */ 137 | 138 | /* The rest of this file contains styles related to the mechanics of 139 | the editor. You probably shouldn't touch them. */ 140 | 141 | .CodeMirror { 142 | position: relative; 143 | overflow: hidden; 144 | background: white; 145 | } 146 | 147 | .CodeMirror-scroll { 148 | overflow: scroll !important; /* Things will break if this is overridden */ 149 | /* 30px is the magic margin used to hide the element's real scrollbars */ 150 | /* See overflow: hidden in .CodeMirror */ 151 | margin-bottom: -30px; margin-right: -30px; 152 | padding-bottom: 30px; 153 | height: 100%; 154 | outline: none; /* Prevent dragging from highlighting the element */ 155 | position: relative; 156 | } 157 | .CodeMirror-sizer { 158 | position: relative; 159 | border-right: 30px solid transparent; 160 | } 161 | 162 | /* The fake, visible scrollbars. Used to force redraw during scrolling 163 | before actuall scrolling happens, thus preventing shaking and 164 | flickering artifacts. */ 165 | .CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { 166 | position: absolute; 167 | z-index: 6; 168 | display: none; 169 | } 170 | .CodeMirror-vscrollbar { 171 | right: 0; top: 0; 172 | overflow-x: hidden; 173 | overflow-y: scroll; 174 | } 175 | .CodeMirror-hscrollbar { 176 | bottom: 0; left: 0; 177 | overflow-y: hidden; 178 | overflow-x: scroll; 179 | } 180 | .CodeMirror-scrollbar-filler { 181 | right: 0; bottom: 0; 182 | } 183 | .CodeMirror-gutter-filler { 184 | left: 0; bottom: 0; 185 | } 186 | 187 | .CodeMirror-gutters { 188 | position: absolute; left: 0; top: 0; 189 | z-index: 3; 190 | } 191 | .CodeMirror-gutter { 192 | white-space: normal; 193 | height: 100%; 194 | display: inline-block; 195 | margin-bottom: -30px; 196 | /* Hack to make IE7 behave */ 197 | *zoom:1; 198 | *display:inline; 199 | } 200 | .CodeMirror-gutter-wrapper { 201 | position: absolute; 202 | z-index: 4; 203 | height: 100%; 204 | } 205 | .CodeMirror-gutter-elt { 206 | position: absolute; 207 | cursor: default; 208 | z-index: 4; 209 | } 210 | .CodeMirror-gutter-wrapper { 211 | -webkit-user-select: none; 212 | -moz-user-select: none; 213 | user-select: none; 214 | } 215 | 216 | .CodeMirror-lines { 217 | cursor: text; 218 | min-height: 1px; /* prevents collapsing before first draw */ 219 | } 220 | .CodeMirror pre { 221 | /* Reset some styles that the rest of the page might have set */ 222 | -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0; 223 | border-width: 0; 224 | background: transparent; 225 | font-family: inherit; 226 | font-size: inherit; 227 | margin: 0; 228 | white-space: pre; 229 | word-wrap: normal; 230 | line-height: inherit; 231 | color: inherit; 232 | z-index: 2; 233 | position: relative; 234 | overflow: visible; 235 | -webkit-tap-highlight-color: transparent; 236 | } 237 | .CodeMirror-wrap pre { 238 | word-wrap: break-word; 239 | white-space: pre-wrap; 240 | word-break: normal; 241 | } 242 | 243 | .CodeMirror-linebackground { 244 | position: absolute; 245 | left: 0; right: 0; top: 0; bottom: 0; 246 | z-index: 0; 247 | } 248 | 249 | .CodeMirror-linewidget { 250 | position: relative; 251 | z-index: 2; 252 | overflow: auto; 253 | } 254 | 255 | .CodeMirror-widget {} 256 | 257 | .CodeMirror-code { 258 | outline: none; 259 | } 260 | 261 | /* Force content-box sizing for the elements where we expect it */ 262 | .CodeMirror-scroll, 263 | .CodeMirror-sizer, 264 | .CodeMirror-gutter, 265 | .CodeMirror-gutters, 266 | .CodeMirror-linenumber { 267 | -moz-box-sizing: content-box; 268 | box-sizing: content-box; 269 | } 270 | 271 | .CodeMirror-measure { 272 | position: absolute; 273 | width: 100%; 274 | height: 0; 275 | overflow: hidden; 276 | visibility: hidden; 277 | } 278 | .CodeMirror-measure pre { position: static; } 279 | 280 | .CodeMirror div.CodeMirror-cursor { 281 | position: absolute; 282 | border-right: none; 283 | width: 0; 284 | } 285 | 286 | div.CodeMirror-cursors { 287 | visibility: hidden; 288 | position: relative; 289 | z-index: 3; 290 | } 291 | .CodeMirror-focused div.CodeMirror-cursors { 292 | visibility: visible; 293 | } 294 | 295 | .CodeMirror-selected { background: #d9d9d9; } 296 | .CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; } 297 | .CodeMirror-crosshair { cursor: crosshair; } 298 | .CodeMirror ::selection { background: #d7d4f0; } 299 | .CodeMirror ::-moz-selection { background: #d7d4f0; } 300 | 301 | .cm-searching { 302 | background: #ffa; 303 | background: rgba(255, 255, 0, .4); 304 | } 305 | 306 | /* IE7 hack to prevent it from returning funny offsetTops on the spans */ 307 | .CodeMirror span { *vertical-align: text-bottom; } 308 | 309 | /* Used to force a border model for a node */ 310 | .cm-force-border { padding-right: .1px; } 311 | 312 | @media print { 313 | /* Hide the cursor when printing */ 314 | .CodeMirror div.CodeMirror-cursors { 315 | visibility: hidden; 316 | } 317 | } 318 | 319 | /* See issue #2901 */ 320 | .cm-tab-wrap-hack:after { content: ''; } 321 | 322 | /* Help users use markselection to safely style text background */ 323 | span.CodeMirror-selectedtext { background: none; } 324 | -------------------------------------------------------------------------------- /lib/codemirror/docs.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | 3 | } 4 | 5 | body, html { margin: 0; padding: 0; height: 100%; } 6 | section, article { display: block; padding: 0; } 7 | 8 | body { 9 | background: #f8f8f8; 10 | font-family: 'Source Sans Pro', Helvetica, Arial, sans-serif; 11 | line-height: 1.5; 12 | } 13 | 14 | p { margin-top: 0; } 15 | 16 | h2, h3, h1 { 17 | font-weight: normal; 18 | margin-bottom: .7em; 19 | } 20 | h1 { font-size: 140%; } 21 | h2 { font-size: 120%; } 22 | h3 { font-size: 110%; } 23 | article > h2:first-child, section:first-child > h2 { margin-top: 0; } 24 | 25 | #nav h1 { 26 | margin-right: 12px; 27 | margin-top: 0; 28 | margin-bottom: 2px; 29 | color: #d30707; 30 | letter-spacing: .5px; 31 | } 32 | 33 | a, a:visited, a:link, .quasilink { 34 | color: #A21313; 35 | text-decoration: none; 36 | } 37 | 38 | em { 39 | padding-right: 2px; 40 | } 41 | 42 | .quasilink { 43 | cursor: pointer; 44 | } 45 | 46 | article { 47 | max-width: 700px; 48 | margin: 0 0 0 160px; 49 | border-left: 2px solid #E30808; 50 | border-right: 1px solid #ddd; 51 | padding: 30px 50px 100px 50px; 52 | background: white; 53 | z-index: 2; 54 | position: relative; 55 | min-height: 100%; 56 | box-sizing: border-box; 57 | -moz-box-sizing: border-box; 58 | } 59 | 60 | #nav { 61 | position: fixed; 62 | padding-top: 30px; 63 | max-height: 100%; 64 | box-sizing: -moz-border-box; 65 | box-sizing: border-box; 66 | overflow-y: auto; 67 | left: 0; right: none; 68 | width: 160px; 69 | text-align: right; 70 | z-index: 1; 71 | } 72 | 73 | @media screen and (min-width: 1000px) { 74 | article { 75 | margin: 0 auto; 76 | } 77 | #nav { 78 | right: 50%; 79 | width: auto; 80 | border-right: 349px solid transparent; 81 | } 82 | } 83 | 84 | #nav ul { 85 | display: block; 86 | margin: 0; padding: 0; 87 | margin-bottom: 32px; 88 | } 89 | 90 | #nav li { 91 | display: block; 92 | margin-bottom: 4px; 93 | } 94 | 95 | #nav li ul { 96 | font-size: 80%; 97 | margin-bottom: 0; 98 | display: none; 99 | } 100 | 101 | #nav li.active ul { 102 | display: block; 103 | } 104 | 105 | #nav li li a { 106 | padding-right: 20px; 107 | display: inline-block; 108 | } 109 | 110 | #nav ul a { 111 | color: black; 112 | padding: 0 7px 1px 11px; 113 | } 114 | 115 | #nav ul a.active, #nav ul a:hover { 116 | border-bottom: 1px solid #E30808; 117 | margin-bottom: -1px; 118 | color: #E30808; 119 | } 120 | 121 | #logo { 122 | border: 0; 123 | margin-right: 12px; 124 | margin-bottom: 25px; 125 | } 126 | 127 | section { 128 | border-top: 1px solid #E30808; 129 | margin: 1.5em 0; 130 | } 131 | 132 | section.first { 133 | border: none; 134 | margin-top: 0; 135 | } 136 | 137 | #demo { 138 | position: relative; 139 | } 140 | 141 | #demolist { 142 | position: absolute; 143 | right: 5px; 144 | top: 5px; 145 | z-index: 25; 146 | } 147 | 148 | .yinyang { 149 | position: absolute; 150 | top: -10px; 151 | left: 0; right: 0; 152 | margin: auto; 153 | display: block; 154 | height: 120px; 155 | } 156 | 157 | .actions { 158 | margin: 1em 0 0; 159 | min-height: 100px; 160 | position: relative; 161 | } 162 | 163 | .actionspicture { 164 | pointer-events: none; 165 | position: absolute; 166 | height: 100px; 167 | top: 0; left: 0; right: 0; 168 | } 169 | 170 | .actionlink { 171 | pointer-events: auto; 172 | font-family: arial; 173 | font-size: 80%; 174 | font-weight: bold; 175 | position: absolute; 176 | top: 0; bottom: 0; 177 | line-height: 1; 178 | height: 1em; 179 | margin: auto; 180 | } 181 | 182 | .actionlink.download { 183 | color: white; 184 | right: 50%; 185 | margin-right: 13px; 186 | text-shadow: -1px 1px 3px #b00, -1px -1px 3px #b00, 1px 0px 3px #b00; 187 | } 188 | 189 | .actionlink.fund { 190 | color: #b00; 191 | left: 50%; 192 | margin-left: 15px; 193 | } 194 | 195 | .actionlink:hover { 196 | text-decoration: underline; 197 | } 198 | 199 | .actionlink a { 200 | color: inherit; 201 | } 202 | 203 | .actionsleft { 204 | float: left; 205 | } 206 | 207 | .actionsright { 208 | float: right; 209 | text-align: right; 210 | } 211 | 212 | @media screen and (max-width: 800px) { 213 | .actions { 214 | padding-top: 120px; 215 | } 216 | .actionsleft, .actionsright { 217 | float: none; 218 | text-align: left; 219 | margin-bottom: 1em; 220 | } 221 | } 222 | 223 | th { 224 | text-decoration: underline; 225 | font-weight: normal; 226 | text-align: left; 227 | } 228 | 229 | #features ul { 230 | list-style: none; 231 | margin: 0 0 1em; 232 | padding: 0 0 0 1.2em; 233 | } 234 | 235 | #features li:before { 236 | content: "-"; 237 | width: 1em; 238 | display: inline-block; 239 | padding: 0; 240 | margin: 0; 241 | margin-left: -1em; 242 | } 243 | 244 | .rel { 245 | margin-bottom: 0; 246 | } 247 | .rel-note { 248 | margin-top: 0; 249 | color: #555; 250 | } 251 | 252 | pre { 253 | padding-left: 15px; 254 | border-left: 2px solid #ddd; 255 | } 256 | 257 | code { 258 | padding: 0 2px; 259 | } 260 | 261 | strong { 262 | text-decoration: underline; 263 | font-weight: normal; 264 | } 265 | 266 | .field { 267 | border: 1px solid #A21313; 268 | } 269 | -------------------------------------------------------------------------------- /lib/codemirror/matchbrackets.js: -------------------------------------------------------------------------------- 1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others 2 | // Distributed under an MIT license: http://codemirror.net/LICENSE 3 | 4 | (function(mod) { 5 | mod(CodeMirror); 6 | return; 7 | if (typeof exports == "object" && typeof module == "object") // CommonJS 8 | mod(require("../../lib/codemirror")); 9 | else if (typeof define == "function" && define.amd) // AMD 10 | define(["../../lib/codemirror"], mod); 11 | else // Plain browser env 12 | mod(CodeMirror); 13 | })(function(CodeMirror) { 14 | var ie_lt8 = /MSIE \d/.test(navigator.userAgent) && 15 | (document.documentMode == null || document.documentMode < 8); 16 | 17 | var Pos = CodeMirror.Pos; 18 | 19 | var matching = {"(": ")>", ")": "(<", "[": "]>", "]": "[<", "{": "}>", "}": "{<"}; 20 | 21 | function findMatchingBracket(cm, where, strict, config) { 22 | var line = cm.getLineHandle(where.line), pos = where.ch - 1; 23 | var match = (pos >= 0 && matching[line.text.charAt(pos)]) || matching[line.text.charAt(++pos)]; 24 | if (!match) return null; 25 | var dir = match.charAt(1) == ">" ? 1 : -1; 26 | if (strict && (dir > 0) != (pos == where.ch)) return null; 27 | var style = cm.getTokenTypeAt(Pos(where.line, pos + 1)); 28 | 29 | var found = scanForBracket(cm, Pos(where.line, pos + (dir > 0 ? 1 : 0)), dir, style || null, config); 30 | if (found == null) return null; 31 | return {from: Pos(where.line, pos), to: found && found.pos, 32 | match: found && found.ch == match.charAt(0), forward: dir > 0}; 33 | } 34 | 35 | // bracketRegex is used to specify which type of bracket to scan 36 | // should be a regexp, e.g. /[[\]]/ 37 | // 38 | // Note: If "where" is on an open bracket, then this bracket is ignored. 39 | // 40 | // Returns false when no bracket was found, null when it reached 41 | // maxScanLines and gave up 42 | function scanForBracket(cm, where, dir, style, config) { 43 | var maxScanLen = (config && config.maxScanLineLength) || 10000; 44 | var maxScanLines = (config && config.maxScanLines) || 1000; 45 | 46 | var stack = []; 47 | var re = config && config.bracketRegex ? config.bracketRegex : /[(){}[\]]/; 48 | var lineEnd = dir > 0 ? Math.min(where.line + maxScanLines, cm.lastLine() + 1) 49 | : Math.max(cm.firstLine() - 1, where.line - maxScanLines); 50 | for (var lineNo = where.line; lineNo != lineEnd; lineNo += dir) { 51 | var line = cm.getLine(lineNo); 52 | if (!line) continue; 53 | var pos = dir > 0 ? 0 : line.length - 1, end = dir > 0 ? line.length : -1; 54 | if (line.length > maxScanLen) continue; 55 | if (lineNo == where.line) pos = where.ch - (dir < 0 ? 1 : 0); 56 | for (; pos != end; pos += dir) { 57 | var ch = line.charAt(pos); 58 | if (re.test(ch) && (style === undefined || cm.getTokenTypeAt(Pos(lineNo, pos + 1)) == style)) { 59 | var match = matching[ch]; 60 | if ((match.charAt(1) == ">") == (dir > 0)) stack.push(ch); 61 | else if (!stack.length) return {pos: Pos(lineNo, pos), ch: ch}; 62 | else stack.pop(); 63 | } 64 | } 65 | } 66 | return lineNo - dir == (dir > 0 ? cm.lastLine() : cm.firstLine()) ? false : null; 67 | } 68 | 69 | function matchBrackets(cm, autoclear, config) { 70 | // Disable brace matching in long lines, since it'll cause hugely slow updates 71 | var maxHighlightLen = cm.state.matchBrackets.maxHighlightLineLength || 1000; 72 | var marks = [], ranges = cm.listSelections(); 73 | for (var i = 0; i < ranges.length; i++) { 74 | var match = ranges[i].empty() && findMatchingBracket(cm, ranges[i].head, false, config); 75 | if (match && cm.getLine(match.from.line).length <= maxHighlightLen) { 76 | var style = match.match ? "CodeMirror-matchingbracket" : "CodeMirror-nonmatchingbracket"; 77 | marks.push(cm.markText(match.from, Pos(match.from.line, match.from.ch + 1), {className: style})); 78 | if (match.to && cm.getLine(match.to.line).length <= maxHighlightLen) 79 | marks.push(cm.markText(match.to, Pos(match.to.line, match.to.ch + 1), {className: style})); 80 | } 81 | } 82 | 83 | if (marks.length) { 84 | // Kludge to work around the IE bug from issue #1193, where text 85 | // input stops going to the textare whever this fires. 86 | if (ie_lt8 && cm.state.focused) cm.focus(); 87 | 88 | var clear = function() { 89 | cm.operation(function() { 90 | for (var i = 0; i < marks.length; i++) marks[i].clear(); 91 | }); 92 | }; 93 | if (autoclear) setTimeout(clear, 800); 94 | else return clear; 95 | } 96 | } 97 | 98 | var currentlyHighlighted = null; 99 | function doMatchBrackets(cm) { 100 | cm.operation(function() { 101 | if (currentlyHighlighted) {currentlyHighlighted(); currentlyHighlighted = null;} 102 | currentlyHighlighted = matchBrackets(cm, false, cm.state.matchBrackets); 103 | }); 104 | } 105 | 106 | CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) { 107 | if (old && old != CodeMirror.Init) 108 | cm.off("cursorActivity", doMatchBrackets); 109 | if (val) { 110 | cm.state.matchBrackets = typeof val == "object" ? val : {}; 111 | cm.on("cursorActivity", doMatchBrackets); 112 | } 113 | }); 114 | 115 | CodeMirror.defineExtension("matchBrackets", function() {matchBrackets(this, true);}); 116 | CodeMirror.defineExtension("findMatchingBracket", function(pos, strict, config){ 117 | return findMatchingBracket(this, pos, strict, config); 118 | }); 119 | CodeMirror.defineExtension("scanForBracket", function(pos, dir, style, config){ 120 | return scanForBracket(this, pos, dir, style, config); 121 | }); 122 | }); 123 | -------------------------------------------------------------------------------- /lib/codemirror/zenburn.css: -------------------------------------------------------------------------------- 1 | /** 2 | * " 3 | * Using Zenburn color palette from the Emacs Zenburn Theme 4 | * https://github.com/bbatsov/zenburn-emacs/blob/master/zenburn-theme.el 5 | * 6 | * Also using parts of https://github.com/xavi/coderay-lighttable-theme 7 | * " 8 | * From: https://github.com/wisenomad/zenburn-lighttable-theme/blob/master/zenburn.css 9 | */ 10 | 11 | .cm-s-zenburn .CodeMirror-gutters { background: #3f3f3f !important; } 12 | .cm-s-zenburn .CodeMirror-foldgutter-open, .CodeMirror-foldgutter-folded { color: #999; } 13 | .cm-s-zenburn .CodeMirror-cursor { border-left: 1px solid white !important; } 14 | .cm-s-zenburn { background-color: #353535; color: #dcdccc; } 15 | .cm-s-zenburn span.cm-builtin { color: #dcdccc; font-weight: bold; } 16 | .cm-s-zenburn span.cm-comment { color: #7f9f7f; } 17 | .cm-s-zenburn span.cm-keyword { color: #f0dfaf; font-weight: bold; } 18 | .cm-s-zenburn span.cm-atom { color: #bfebbf; } 19 | .cm-s-zenburn span.cm-def { color: #dcdccc; } 20 | .cm-s-zenburn span.cm-variable { color: #dfaf8f; } 21 | .cm-s-zenburn span.cm-variable-2 { color: #dcdccc; } 22 | .cm-s-zenburn span.cm-string { color: #cc9393; } 23 | .cm-s-zenburn span.cm-string-2 { color: #cc9393; } 24 | .cm-s-zenburn span.cm-number { color: #dcdccc; } 25 | .cm-s-zenburn span.cm-tag { color: #93e0e3; } 26 | .cm-s-zenburn span.cm-property { color: #dfaf8f; } 27 | .cm-s-zenburn span.cm-attribute { color: #dfaf8f; } 28 | .cm-s-zenburn span.cm-qualifier { color: #7cb8bb; } 29 | .cm-s-zenburn span.cm-meta { color: #f0dfaf; } 30 | .cm-s-zenburn span.cm-header { color: #f0efd0; } 31 | .cm-s-zenburn span.cm-operator { color: #f0efd0; } 32 | .cm-s-zenburn span.CodeMirror-matchingbracket { box-sizing: border-box; background: transparent; border-bottom: 1px solid; } 33 | .cm-s-zenburn span.CodeMirror-nonmatchingbracket { border-bottom: 1px solid; background: none; } 34 | .cm-s-zenburn .CodeMirror-activeline { background: #000000; } 35 | .cm-s-zenburn .CodeMirror-activeline-background { background: #000000; } 36 | .cm-s-zenburn .CodeMirror-selected { background: #545454; } 37 | .cm-s-zenburn .CodeMirror-focused .CodeMirror-selected { background: #4f4f4f; } 38 | 39 | -------------------------------------------------------------------------------- /lib/demo.css: -------------------------------------------------------------------------------- 1 | body{margin:0;padding:0;font-size:12px;background-color:white!important;} 2 | body .CodeMirror pre {font-size:13px;} 3 | table { width:100%;border:none; border-spacing:0; border-collapse:0; } 4 | table td { border:none; vertical-align:top;padding:0;} 5 | .test-c {text-align:left;padding-top:10px;} 6 | #canvasTest {margin:0} 7 | body .CodeMirror { 8 | height: auto; 9 | width : auto; 10 | } 11 | #chartdemo-r { 12 | overflow-y:auto; 13 | } 14 | #run {font-size:38px;cursor:pointer;float:left;margin-right:20px;color:#814C00} 15 | -------------------------------------------------------------------------------- /lib/demo.js: -------------------------------------------------------------------------------- 1 | function mirrorResize(){ 2 | var vh = document.documentElement.clientHeight||document.body.clientHeight 3 | $(".CodeMirror ,#chartdemo-r").css("height" , vh+"px"); 4 | var vw = document.documentElement.clientWidth ||document.body.clientWidth 5 | $(".CodeMirror , #td-vl").css("width" , (vw * 2 / 5) +"px"); 6 | } 7 | $(function(){ 8 | var editor = CodeMirror.fromTextArea(document.getElementById("code"), { 9 | lineNumbers: true, 10 | styleActiveLine: true, 11 | matchBrackets: true 12 | }); 13 | editor.setOption("theme", "zenburn"); 14 | $("#run").on("click" , function(){ 15 | window.eval(editor.getValue()); 16 | }); 17 | mirrorResize(); 18 | document.body.onresize = function(){ 19 | mirrorResize(); 20 | }; 21 | window.eval(editor.getValue()); 22 | }); 23 | -------------------------------------------------------------------------------- /lib/dom.js: -------------------------------------------------------------------------------- 1 | import _ from './underscore'; 2 | 3 | export default { 4 | 5 | // dom操作相关代码 6 | query(el) { 7 | if (_.isString(el)) { 8 | return document.getElementById(el) 9 | } 10 | if (el.nodeType == 1) { 11 | //则为一个element本身 12 | return el 13 | } 14 | if (el.length) { 15 | return el[0] 16 | } 17 | return null; 18 | }, 19 | 20 | createView(_width, _height, id) { 21 | var view = document.createElement("div"); 22 | view.className = "canvax-view"; 23 | view.style.cssText += "position:relative;width:100%;height:100%;" 24 | 25 | var stageView = document.createElement("div"); 26 | stageView.style.cssText += "position:absolute;width:" + _width + "px;height:" + _height + "px;" 27 | 28 | //用来存放一些dom元素 29 | var domView = document.createElement("div"); 30 | domView.style.cssText += "position:absolute;width:" + _width + "px;height:" + _height + "px;" 31 | 32 | view.appendChild(stageView); 33 | view.appendChild(domView); 34 | 35 | return { 36 | view: view, 37 | stageView: stageView, 38 | domView: domView 39 | } 40 | } 41 | 42 | 43 | 44 | } -------------------------------------------------------------------------------- /lib/domReady.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license RequireJS domReady 2.0.1 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved. 3 | * Available via the MIT or new BSD license. 4 | * see: http://github.com/requirejs/domReady for details 5 | */ 6 | /*jslint */ 7 | /*global require: false, define: false, requirejs: false, 8 | window: false, clearInterval: false, document: false, 9 | self: false, setInterval: false */ 10 | 11 | 12 | define(function () { 13 | 'use strict'; 14 | 15 | var isTop, testDiv, scrollIntervalId, 16 | isBrowser = typeof window !== "undefined" && window.document, 17 | isPageLoaded = !isBrowser, 18 | doc = isBrowser ? document : null, 19 | readyCalls = []; 20 | 21 | function runCallbacks(callbacks) { 22 | var i; 23 | for (i = 0; i < callbacks.length; i += 1) { 24 | callbacks[i](doc); 25 | } 26 | } 27 | 28 | function callReady() { 29 | var callbacks = readyCalls; 30 | 31 | if (isPageLoaded) { 32 | //Call the DOM ready callbacks 33 | if (callbacks.length) { 34 | readyCalls = []; 35 | runCallbacks(callbacks); 36 | } 37 | } 38 | } 39 | 40 | /** 41 | * Sets the page as loaded. 42 | */ 43 | function pageLoaded() { 44 | if (!isPageLoaded) { 45 | isPageLoaded = true; 46 | if (scrollIntervalId) { 47 | clearInterval(scrollIntervalId); 48 | } 49 | 50 | callReady(); 51 | } 52 | } 53 | 54 | if (isBrowser) { 55 | if (document.addEventListener) { 56 | //Standards. Hooray! Assumption here that if standards based, 57 | //it knows about DOMContentLoaded. 58 | document.addEventListener("DOMContentLoaded", pageLoaded, false); 59 | window.addEventListener("load", pageLoaded, false); 60 | } else if (window.attachEvent) { 61 | window.attachEvent("onload", pageLoaded); 62 | 63 | testDiv = document.createElement('div'); 64 | try { 65 | isTop = window.frameElement === null; 66 | } catch (e) {} 67 | 68 | //DOMContentLoaded approximation that uses a doScroll, as found by 69 | //Diego Perini: http://javascript.nwbox.com/IEContentLoaded/, 70 | //but modified by other contributors, including jdalton 71 | if (testDiv.doScroll && isTop && window.external) { 72 | scrollIntervalId = setInterval(function () { 73 | try { 74 | testDiv.doScroll(); 75 | pageLoaded(); 76 | } catch (e) {} 77 | }, 30); 78 | } 79 | } 80 | 81 | //Check if document already complete, and if so, just trigger page load 82 | //listeners. Latest webkit browsers also use "interactive", and 83 | //will fire the onDOMContentLoaded before "interactive" but not after 84 | //entering "interactive" or "complete". More details: 85 | //http://dev.w3.org/html5/spec/the-end.html#the-end 86 | //http://stackoverflow.com/questions/3665561/document-readystate-of-interactive-vs-ondomcontentloaded 87 | //Hmm, this is more complicated on further use, see "firing too early" 88 | //bug: https://github.com/requirejs/domReady/issues/1 89 | //so removing the || document.readyState === "interactive" test. 90 | //There is still a window.onload binding that should get fired if 91 | //DOMContentLoaded is missed. 92 | if (document.readyState === "complete") { 93 | pageLoaded(); 94 | } 95 | } 96 | 97 | /** START OF PUBLIC API **/ 98 | 99 | /** 100 | * Registers a callback for DOM ready. If DOM is already ready, the 101 | * callback is called immediately. 102 | * @param {Function} callback 103 | */ 104 | function domReady(callback) { 105 | if (isPageLoaded) { 106 | callback(doc); 107 | } else { 108 | readyCalls.push(callback); 109 | } 110 | return domReady; 111 | } 112 | 113 | domReady.version = '2.0.1'; 114 | 115 | /** 116 | * Loader Plugin API method 117 | */ 118 | domReady.load = function (name, req, onLoad, config) { 119 | if (config.isBuild) { 120 | onLoad(null); 121 | } else { 122 | domReady(onLoad); 123 | } 124 | }; 125 | 126 | /** END OF PUBLIC API **/ 127 | 128 | return domReady; 129 | }); 130 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "chartx3d", 3 | "title": "chartx3D.js", 4 | "description": "Data Visualization Chart Library", 5 | "version": "0.0.34", 6 | "homepage": "https://thx.github.io/chartx/", 7 | "license": "MIT", 8 | "keywords": [ 9 | "chartx", 10 | "chart", 11 | "canvas", 12 | "webgl", 13 | "2d", 14 | "3d", 15 | "Data", 16 | "Visualization" 17 | ], 18 | "author": { 19 | "name": "david_yanlong", 20 | "email": "87141611@qq.com" 21 | }, 22 | "repository": "https://github.com/Davidyanlong/chartx3d", 23 | "main": "./dist/cjs/chartx.js", 24 | "module": "./src/index.js", 25 | "devDependencies": { 26 | "@babel/core": "7.2.0", 27 | "@babel/plugin-external-helpers": "7.2.0", 28 | "@babel/preset-env": "7.2.3", 29 | "rollup": "1.1.2", 30 | "rollup-plugin-babel": "4.3.2", 31 | "rollup-plugin-commonjs": "9.2.0", 32 | "rollup-plugin-node-resolve": "4.0.0", 33 | "rollup-plugin-uglify": "6.0.0", 34 | "rollup-plugin-json": "3.1.0", 35 | "rollup-watch": "4.3.1", 36 | "rollup-plugin-terser": "^3.0.0", 37 | "der-server": "0.0.10" 38 | }, 39 | "magixCliConfig": { 40 | "cloudBuild": true 41 | }, 42 | "dependencies": { 43 | "mmgl": "0.0.44", 44 | "mmvis": "0.0.61" 45 | }, 46 | "scripts": { 47 | "rollup": "NODE_ENV=dev rollup -c", 48 | "build": "NODE_ENV=production rollup -c ", 49 | "dev": "NODE_ENV=dev rollup -c -w -m", 50 | "build:watch": "onchange 'src/**/**' -- npm run dev" 51 | } 52 | } -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | var rollup = require('rollup'); 2 | var babel = require('rollup-plugin-babel'); 3 | var commonjs = require('rollup-plugin-commonjs'); 4 | var resolve = require('rollup-plugin-node-resolve'); 5 | var json = require('rollup-plugin-json'); 6 | var { uglify } = require('rollup-plugin-uglify'); 7 | var { terser } = require('rollup-plugin-terser'); 8 | 9 | 10 | // output format - 'amd', 'cjs', 'es6', 'iife', 'umd' 11 | // amd – 使用像requirejs一样的银木块定义 12 | // cjs – CommonJS,适用于node和browserify / Webpack 13 | // es6 (default) – 保持ES6的格式 14 | // iife – 使用于