-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathindex.js
99 lines (85 loc) · 2.18 KB
/
index.js
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
import {jmArc} from "./src/shapes/jmArc.js";
import {jmArrow} from "./src/shapes/jmArrow.js";
import {jmBezier} from "./src/shapes/jmBezier.js";
import {jmCircle} from "./src/shapes/jmCircle.js";
import {jmHArc} from "./src/shapes/jmHArc.js";
import {jmLine} from "./src/shapes/jmLine.js";
import {jmPrismatic} from "./src/shapes/jmPrismatic.js";
import {jmRect} from "./src/shapes/jmRect.js";
import {jmArrowLine} from "./src/shapes/jmArrowLine.js";
import {jmImage} from "./src/shapes/jmImage.js";
import {jmLabel} from "./src/shapes/jmLabel.js";
import {jmResize} from "./src/shapes/jmResize.js";
import { jmGraph as jmGraphCore,
jmUtils,
jmList,
jmProperty,
jmShadow,
jmGradient,
jmEvents,
jmControl,
jmPath, } from "./src/core/jmGraph.js";
const shapes = {
"arc": jmArc,
"arrow": jmArrow,
"bezier": jmBezier,
"circle": jmCircle,
"harc": jmHArc,
"line": jmLine,
"prismatic": jmPrismatic,
"rect": jmRect,
"arrowline": jmArrowLine,
"image": jmImage,
"img": jmImage,
"label": jmLabel,
"resize": jmResize
}
export default class jmGraph extends jmGraphCore {
constructor(canvas, option, callback) {
const targetType = new.target;
// 合并shapes
option = Object.assign({}, option);
option.shapes = Object.assign(shapes, option.shapes||{});
//不是用new实例化的话,返回一个promise
if(!targetType || !(targetType.prototype instanceof jmGraphCore)) {
return new Promise(function(resolve, reject){
var g = new jmGraph(canvas, option, callback);
if(resolve) resolve(g);
});
}
if(typeof option == 'function') {
callback = option;
option = {};
}
super(canvas, option, callback);
}
static create(...args) {
return createJmGraph(...args);
}
}
//创建实例
const createJmGraph = (...args) => {
return new jmGraph(...args);
}
export {
jmUtils,
jmList,
jmControl,
jmPath,
jmShadow,
jmGradient,
jmArc,
jmArrow,
jmBezier,
jmCircle,
jmHArc,
jmLine,
jmPrismatic,
jmRect,
jmArrowLine,
jmImage,
jmLabel,
jmResize,
jmGraph,
createJmGraph as create
};