jmgraph 3.1.77 → 3.1.90
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -7
- package/dist/jmgraph.core.min.js +1 -1
- package/dist/jmgraph.core.min.js.map +1 -1
- package/dist/jmgraph.js +880 -818
- package/dist/jmgraph.min.js +1 -1
- package/index.js +14 -13
- package/package.json +3 -2
- package/src/core/jmControl.js +7 -7
- package/src/core/jmEvents.js +24 -7
- package/src/core/jmGraph.js +9 -6
- package/src/core/jmUtils.js +18 -1
- package/src/shapes/{jmArraw.js → jmArrow.js} +10 -10
- package/src/shapes/{jmArrawLine.js → jmArrowLine.js} +8 -8
- package/src/shapes/jmHArc.js +2 -2
package/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
3
|
import {jmArc} from "./src/shapes/jmArc.js";
|
|
4
|
-
import {
|
|
4
|
+
import {jmArrow} from "./src/shapes/jmArrow.js";
|
|
5
5
|
import {jmBezier} from "./src/shapes/jmBezier.js";
|
|
6
6
|
import {jmCircle} from "./src/shapes/jmCircle.js";
|
|
7
7
|
import {jmHArc} from "./src/shapes/jmHArc.js";
|
|
8
8
|
import {jmLine} from "./src/shapes/jmLine.js";
|
|
9
9
|
import {jmPrismatic} from "./src/shapes/jmPrismatic.js";
|
|
10
10
|
import {jmRect} from "./src/shapes/jmRect.js";
|
|
11
|
-
import {
|
|
11
|
+
import {jmArrowLine} from "./src/shapes/jmArrowLine.js";
|
|
12
12
|
import {jmImage} from "./src/shapes/jmImage.js";
|
|
13
13
|
import {jmLabel} from "./src/shapes/jmLabel.js";
|
|
14
14
|
import {jmResize} from "./src/shapes/jmResize.js";
|
|
@@ -25,14 +25,14 @@ import { jmGraph as jmGraphCore,
|
|
|
25
25
|
|
|
26
26
|
const shapes = {
|
|
27
27
|
"arc": jmArc,
|
|
28
|
-
"
|
|
28
|
+
"arrow": jmArrow,
|
|
29
29
|
"bezier": jmBezier,
|
|
30
30
|
"circle": jmCircle,
|
|
31
31
|
"harc": jmHArc,
|
|
32
32
|
"line": jmLine,
|
|
33
33
|
"prismatic": jmPrismatic,
|
|
34
34
|
"rect": jmRect,
|
|
35
|
-
"
|
|
35
|
+
"arrowline": jmArrowLine,
|
|
36
36
|
"image": jmImage,
|
|
37
37
|
"img": jmImage,
|
|
38
38
|
"label": jmLabel,
|
|
@@ -41,9 +41,15 @@ const shapes = {
|
|
|
41
41
|
|
|
42
42
|
export default class jmGraph extends jmGraphCore {
|
|
43
43
|
constructor(canvas, option, callback) {
|
|
44
|
+
|
|
45
|
+
const targetType = new.target;
|
|
44
46
|
|
|
47
|
+
// 合并shapes
|
|
48
|
+
option = Object.assign({}, option);
|
|
49
|
+
option.shapes = Object.assign(shapes, option.shapes||{});
|
|
50
|
+
|
|
45
51
|
//不是用new实例化的话,返回一个promise
|
|
46
|
-
if(
|
|
52
|
+
if(!targetType || !(targetType.prototype instanceof jmGraphCore)) {
|
|
47
53
|
return new Promise(function(resolve, reject){
|
|
48
54
|
var g = new jmGraph(canvas, option, callback);
|
|
49
55
|
if(resolve) resolve(g);
|
|
@@ -53,12 +59,7 @@ export default class jmGraph extends jmGraphCore {
|
|
|
53
59
|
if(typeof option == 'function') {
|
|
54
60
|
callback = option;
|
|
55
61
|
option = {};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
// 合并shapes
|
|
60
|
-
option = Object.assign({}, option);
|
|
61
|
-
option.shapes = Object.assign(shapes, option.shapes||{});
|
|
62
|
+
}
|
|
62
63
|
|
|
63
64
|
super(canvas, option, callback);
|
|
64
65
|
}
|
|
@@ -77,14 +78,14 @@ export {
|
|
|
77
78
|
jmShadow,
|
|
78
79
|
jmGradient,
|
|
79
80
|
jmArc,
|
|
80
|
-
|
|
81
|
+
jmArrow,
|
|
81
82
|
jmBezier,
|
|
82
83
|
jmCircle,
|
|
83
84
|
jmHArc,
|
|
84
85
|
jmLine,
|
|
85
86
|
jmPrismatic,
|
|
86
87
|
jmRect,
|
|
87
|
-
|
|
88
|
+
jmArrowLine,
|
|
88
89
|
jmImage,
|
|
89
90
|
jmLabel,
|
|
90
91
|
jmResize,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"family": "jmgraph",
|
|
3
3
|
"name": "jmgraph",
|
|
4
|
-
"version": "3.1.
|
|
4
|
+
"version": "3.1.90",
|
|
5
5
|
"description": "一个简单的canvas画图库",
|
|
6
6
|
"homepage": "http://graph.jm47.com/",
|
|
7
7
|
"keywords": [
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
],
|
|
11
11
|
"author": "jiamao<haofefe@163.com>",
|
|
12
12
|
"engines": {},
|
|
13
|
-
"dependencies": {
|
|
13
|
+
"dependencies": {
|
|
14
|
+
},
|
|
14
15
|
"devDependencies": {
|
|
15
16
|
"@commitlint/cli": "^7.6.1",
|
|
16
17
|
"@commitlint/config-conventional": "^7.6.0",
|
package/src/core/jmControl.js
CHANGED
|
@@ -59,7 +59,7 @@ export default class jmControl extends jmProperty {
|
|
|
59
59
|
|
|
60
60
|
this.on = this.bind;
|
|
61
61
|
|
|
62
|
-
this.
|
|
62
|
+
this.option = params;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
//# region 定义属性
|
|
@@ -1110,22 +1110,22 @@ export default class jmControl extends jmProperty {
|
|
|
1110
1110
|
raiseEvent(name, args) {
|
|
1111
1111
|
if(this.visible === false) return ;//如果不显示则不响应事件
|
|
1112
1112
|
if(!args.position) {
|
|
1113
|
-
|
|
1113
|
+
const graph = this.graph;
|
|
1114
1114
|
|
|
1115
|
-
|
|
1115
|
+
const srcElement = args.srcElement || args.target;
|
|
1116
1116
|
|
|
1117
|
-
|
|
1117
|
+
const position = jmUtils.getEventPosition(args, graph.scaleSize);//初始化事件位置
|
|
1118
1118
|
|
|
1119
1119
|
// 如果有指定scale高清处理,需要对坐标处理
|
|
1120
1120
|
// 因为是对canvas放大N倍,再把style指定为当前大小,所以坐标需要放大N && srcElement === graph.canvas
|
|
1121
1121
|
if(graph.devicePixelRatio > 0) {
|
|
1122
|
-
position.x = position.offsetX = position.x * devicePixelRatio;
|
|
1123
|
-
position.y = position.offsetY = position.y * devicePixelRatio;
|
|
1122
|
+
position.x = position.offsetX = position.x * graph.devicePixelRatio;
|
|
1123
|
+
position.y = position.offsetY = position.y * graph.devicePixelRatio;
|
|
1124
1124
|
}
|
|
1125
1125
|
|
|
1126
1126
|
args = {
|
|
1127
1127
|
position: position,
|
|
1128
|
-
button: args.button == 0||position.isTouch?1:args.button,
|
|
1128
|
+
button: args.button == 0 || position.isTouch? 1: args.button,
|
|
1129
1129
|
keyCode: args.keyCode || args.charCode || args.which,
|
|
1130
1130
|
ctrlKey: args.ctrlKey,
|
|
1131
1131
|
cancel : false,
|
package/src/core/jmEvents.js
CHANGED
|
@@ -16,6 +16,7 @@ export default class jmEvents {
|
|
|
16
16
|
|
|
17
17
|
touchStart(evt) {
|
|
18
18
|
evt = evt || window.event;
|
|
19
|
+
evt.eventName = 'touchstart';
|
|
19
20
|
this.container.raiseEvent('touchstart',evt);
|
|
20
21
|
let t = evt.target || evt.srcElement;
|
|
21
22
|
if(t == this.target) {
|
|
@@ -26,6 +27,7 @@ export default class jmEvents {
|
|
|
26
27
|
|
|
27
28
|
touchMove(evt) {
|
|
28
29
|
evt = evt || window.event;
|
|
30
|
+
evt.eventName = 'touchmove';
|
|
29
31
|
this.container.raiseEvent('touchmove',evt);
|
|
30
32
|
let t = evt.target || evt.srcElement;
|
|
31
33
|
if(t == this.target) {
|
|
@@ -36,6 +38,7 @@ export default class jmEvents {
|
|
|
36
38
|
|
|
37
39
|
touchEnd(evt) {
|
|
38
40
|
evt = evt || window.event;
|
|
41
|
+
evt.eventName = 'touchend';
|
|
39
42
|
|
|
40
43
|
this.container.raiseEvent('touchend',evt);
|
|
41
44
|
let t = evt.target || evt.srcElement;
|
|
@@ -47,6 +50,7 @@ export default class jmEvents {
|
|
|
47
50
|
|
|
48
51
|
touchCancel(evt) {
|
|
49
52
|
evt = evt || window.event;
|
|
53
|
+
evt.eventName = 'touchcancel';
|
|
50
54
|
|
|
51
55
|
this.container.raiseEvent('touchcancel',evt);
|
|
52
56
|
let t = evt.target || evt.srcElement;
|
|
@@ -87,6 +91,7 @@ class jmMouseEvent {
|
|
|
87
91
|
|
|
88
92
|
this.eventEvents['mousedown'] = jmUtils.bindEvent(this.target,'mousedown',function(evt) {
|
|
89
93
|
evt = evt || window.event;
|
|
94
|
+
evt.eventName = 'mousedown';
|
|
90
95
|
let r = container.raiseEvent('mousedown',evt);
|
|
91
96
|
//if(r === false) {
|
|
92
97
|
//if(evt.preventDefault) evt.preventDefault();
|
|
@@ -96,6 +101,7 @@ class jmMouseEvent {
|
|
|
96
101
|
|
|
97
102
|
this.eventEvents['mousedown'] = jmUtils.bindEvent(this.target,'mousemove',function(evt) {
|
|
98
103
|
evt = evt || window.event;
|
|
104
|
+
evt.eventName = 'mousemove';
|
|
99
105
|
let target = evt.target || evt.srcElement;
|
|
100
106
|
if(target == canvas) {
|
|
101
107
|
let r = container.raiseEvent('mousemove',evt);
|
|
@@ -107,19 +113,23 @@ class jmMouseEvent {
|
|
|
107
113
|
});
|
|
108
114
|
|
|
109
115
|
this.eventEvents['mousedown'] = jmUtils.bindEvent(this.target,'mouseover',function(evt) {
|
|
110
|
-
evt = evt || window.event;
|
|
116
|
+
evt = evt || window.event;
|
|
117
|
+
evt.eventName = 'mouseover';
|
|
111
118
|
container.raiseEvent('mouseover',evt);
|
|
112
119
|
});
|
|
113
120
|
this.eventEvents['mouseleave'] = jmUtils.bindEvent(this.target,'mouseleave',function(evt) {
|
|
114
|
-
evt = evt || window.event;
|
|
121
|
+
evt = evt || window.event;
|
|
122
|
+
evt.eventName = 'mouseleave';
|
|
115
123
|
container.raiseEvent('mouseleave',evt);
|
|
116
124
|
});
|
|
117
125
|
this.eventEvents['mouseout'] = jmUtils.bindEvent(this.target,'mouseout',function(evt) {
|
|
118
|
-
evt = evt || window.event;
|
|
126
|
+
evt = evt || window.event;
|
|
127
|
+
evt.eventName = 'mouseout';
|
|
119
128
|
container.raiseEvent('mouseout',evt);
|
|
120
129
|
});
|
|
121
130
|
doc && (this.eventEvents['mouseup'] = jmUtils.bindEvent(doc,'mouseup',function(evt) {
|
|
122
|
-
evt = evt || window.event;
|
|
131
|
+
evt = evt || window.event;
|
|
132
|
+
evt.eventName = 'mouseup';
|
|
123
133
|
//let target = evt.target || evt.srcElement;
|
|
124
134
|
//if(target == canvas) {
|
|
125
135
|
let r = container.raiseEvent('mouseup',evt);
|
|
@@ -132,33 +142,40 @@ class jmMouseEvent {
|
|
|
132
142
|
|
|
133
143
|
this.eventEvents['dblclick'] = jmUtils.bindEvent(this.target,'dblclick',function(evt) {
|
|
134
144
|
evt = evt || window.event;
|
|
145
|
+
evt.eventName = 'dblclick';
|
|
135
146
|
container.raiseEvent('dblclick',evt);
|
|
136
147
|
});
|
|
137
148
|
this.eventEvents['click'] = jmUtils.bindEvent(this.target,'click',function(evt) {
|
|
138
149
|
evt = evt || window.event;
|
|
150
|
+
evt.eventName = 'click';
|
|
139
151
|
container.raiseEvent('click',evt);
|
|
140
152
|
});
|
|
141
153
|
|
|
142
154
|
doc && (this.eventEvents['resize'] = jmUtils.bindEvent(doc,'resize',function(evt) {
|
|
143
155
|
evt = evt || window.event;
|
|
156
|
+
evt.eventName = 'resize';
|
|
144
157
|
return container.raiseEvent('resize',evt);
|
|
145
158
|
}));
|
|
146
159
|
|
|
147
160
|
// passive: false 为了让浏览器不告警并且preventDefault有效
|
|
148
161
|
// 另一种处理:touch-action: none; 这样任何触摸事件都不会产生默认行为,但是 touch 事件照样触发。
|
|
149
162
|
this.eventEvents['touchstart'] = jmUtils.bindEvent(this.target,'touchstart', function(evt) {
|
|
163
|
+
evt.eventName = 'touchstart';
|
|
150
164
|
return instance.touchStart(evt);
|
|
151
165
|
},{ passive: false });
|
|
152
166
|
|
|
153
167
|
this.eventEvents['touchmove'] = jmUtils.bindEvent(this.target,'touchmove', function(evt) {
|
|
168
|
+
evt.eventName = 'touchmove';
|
|
154
169
|
return instance.touchMove(evt);
|
|
155
170
|
},{ passive: false });
|
|
156
171
|
|
|
157
172
|
doc && (this.eventEvents['touchend'] = jmUtils.bindEvent(doc,'touchend', function(evt) {
|
|
173
|
+
evt.eventName = 'touchend';
|
|
158
174
|
return instance.touchEnd(evt);
|
|
159
175
|
},{ passive: false }));
|
|
160
176
|
|
|
161
177
|
doc && (this.eventEvents['touchcancel'] = jmUtils.bindEvent(doc,'touchcancel', function(evt) {
|
|
178
|
+
evt.eventName = 'touchcancel';
|
|
162
179
|
return instance.touchCancel(evt);
|
|
163
180
|
},{ passive: false }));
|
|
164
181
|
}
|
|
@@ -213,7 +230,7 @@ class jmKeyEvent {
|
|
|
213
230
|
return true;
|
|
214
231
|
}
|
|
215
232
|
|
|
216
|
-
doc && (this.eventEvents['
|
|
233
|
+
doc && (this.eventEvents['keypress'] = jmUtils.bindEvent(doc,'keypress',function(evt) {
|
|
217
234
|
evt = evt || window.event;
|
|
218
235
|
if(!checkKeyEvent(evt)) return;//如果事件为其它输入框,则不响应
|
|
219
236
|
let r = container.raiseEvent('keypress',evt);
|
|
@@ -221,7 +238,7 @@ class jmKeyEvent {
|
|
|
221
238
|
evt.preventDefault();
|
|
222
239
|
return r;
|
|
223
240
|
}));
|
|
224
|
-
doc && (this.eventEvents['
|
|
241
|
+
doc && (this.eventEvents['keydown'] = jmUtils.bindEvent(doc,'keydown',function(evt) {
|
|
225
242
|
evt = evt || window.event;
|
|
226
243
|
if(!checkKeyEvent(evt)) return;//如果事件为其它输入框,则不响应
|
|
227
244
|
let r = container.raiseEvent('keydown',evt);
|
|
@@ -229,7 +246,7 @@ class jmKeyEvent {
|
|
|
229
246
|
evt.preventDefault();
|
|
230
247
|
return r;
|
|
231
248
|
}));
|
|
232
|
-
doc && (this.eventEvents['
|
|
249
|
+
doc && (this.eventEvents['keyup'] = jmUtils.bindEvent(doc,'keyup',function(evt) {
|
|
233
250
|
evt = evt || window.event;
|
|
234
251
|
if(!checkKeyEvent(evt)) return;//如果事件为其它输入框,则不响应
|
|
235
252
|
let r = container.raiseEvent('keyup',evt);
|
package/src/core/jmGraph.js
CHANGED
|
@@ -27,7 +27,7 @@ export default class jmGraph extends jmControl {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
option = option || {};
|
|
30
|
-
|
|
30
|
+
option.mode = option.mode || '2d'; // webgl | 2d
|
|
31
31
|
option.interactive = true;
|
|
32
32
|
|
|
33
33
|
super(option, 'jmGraph');
|
|
@@ -47,6 +47,7 @@ export default class jmGraph extends jmControl {
|
|
|
47
47
|
if(typeof wx != 'undefined' && wx.createCanvasContext) {
|
|
48
48
|
this.context = wx.createCanvasContext(canvas);
|
|
49
49
|
canvas = wx.createSelectorQuery().select('#' + canvas);
|
|
50
|
+
this.isWXMiniApp = true;// 微信小程序平台
|
|
50
51
|
}
|
|
51
52
|
else {
|
|
52
53
|
if(typeof canvas === 'string' && typeof document != 'undefined') {
|
|
@@ -66,8 +67,7 @@ export default class jmGraph extends jmControl {
|
|
|
66
67
|
}
|
|
67
68
|
else {
|
|
68
69
|
this.container = canvas.parentElement;
|
|
69
|
-
}
|
|
70
|
-
|
|
70
|
+
}
|
|
71
71
|
this.context = canvas.getContext('2d');
|
|
72
72
|
}
|
|
73
73
|
this.canvas = canvas;
|
|
@@ -379,7 +379,7 @@ export default class jmGraph extends jmControl {
|
|
|
379
379
|
* @param {string} value 样式值
|
|
380
380
|
*/
|
|
381
381
|
css(name, value) {
|
|
382
|
-
if(this.canvas) {
|
|
382
|
+
if(this.canvas && this.canvas.style) {
|
|
383
383
|
if(typeof value != 'undefined') this.canvas.style[name] = value;
|
|
384
384
|
return this.canvas.style[name];
|
|
385
385
|
}
|
|
@@ -495,16 +495,19 @@ export default class jmGraph extends jmControl {
|
|
|
495
495
|
if(this.___isAutoRefreshing) return;
|
|
496
496
|
const self = this;
|
|
497
497
|
this.___isAutoRefreshing = true;
|
|
498
|
+
|
|
498
499
|
function update() {
|
|
499
500
|
if(self.destoryed) {
|
|
500
501
|
self.___isAutoRefreshing = false;
|
|
501
502
|
return;// 已销毁
|
|
502
503
|
}
|
|
503
504
|
if(self.needUpdate) self.redraw();
|
|
504
|
-
|
|
505
|
+
self.__requestAnimationFrameFunHandler && jmUtils.cancelAnimationFrame(self.__requestAnimationFrameFunHandler);
|
|
506
|
+
self.__requestAnimationFrameFunHandler = jmUtils.requestAnimationFrame(update);
|
|
505
507
|
if(callback) callback();
|
|
506
508
|
}
|
|
507
|
-
|
|
509
|
+
self.__requestAnimationFrameFunHandler && jmUtils.cancelAnimationFrame(self.__requestAnimationFrameFunHandler);
|
|
510
|
+
self.__requestAnimationFrameFunHandler = jmUtils.requestAnimationFrame(update);
|
|
508
511
|
return this;
|
|
509
512
|
}
|
|
510
513
|
|
package/src/core/jmUtils.js
CHANGED
|
@@ -169,7 +169,7 @@ export default class jmUtils {
|
|
|
169
169
|
let isTouch = false;
|
|
170
170
|
let touches = evt.changedTouches || evt.targetTouches || evt.touches;
|
|
171
171
|
let target = evt.target || evt.srcElement;
|
|
172
|
-
if(touches) {
|
|
172
|
+
if(touches && touches.length) {
|
|
173
173
|
evt = touches[0];//兼容touch事件
|
|
174
174
|
if(!evt.target) evt.target = target;
|
|
175
175
|
isTouch = true;
|
|
@@ -702,5 +702,22 @@ export default class jmUtils {
|
|
|
702
702
|
}
|
|
703
703
|
return r;
|
|
704
704
|
}
|
|
705
|
+
// window.requestAnimationFrame() 告诉浏览器——你希望执行一个动画,并且要求浏览器在下次重绘之前调用指定的回调函数更新动画。该方法需要传入一个回调函数作为参数,该回调函数会在浏览器下一次重绘之前执行
|
|
706
|
+
static requestAnimationFrame(callback) {
|
|
707
|
+
if(typeof requestAnimationFrame === 'undefined') {
|
|
708
|
+
return setTimeout(callback, 20);
|
|
709
|
+
}
|
|
710
|
+
else {
|
|
711
|
+
return requestAnimationFrame(callback);
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
static cancelAnimationFrame(handler) {
|
|
715
|
+
if(typeof requestAnimationFrame === 'undefined') {
|
|
716
|
+
return clearTimeout(handler);
|
|
717
|
+
}
|
|
718
|
+
else {
|
|
719
|
+
return cancelAnimationFrame(handler);
|
|
720
|
+
}
|
|
721
|
+
}
|
|
705
722
|
}
|
|
706
723
|
export { jmUtils };
|
|
@@ -3,13 +3,13 @@ import {jmUtils} from "../core/jmUtils.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* 画箭头,继承自jmPath
|
|
5
5
|
*
|
|
6
|
-
* @class
|
|
6
|
+
* @class jmArrow
|
|
7
7
|
* @extends jmPath
|
|
8
8
|
* @param {object} 生成箭头所需的参数
|
|
9
9
|
*/
|
|
10
|
-
export default class
|
|
10
|
+
export default class jmArrow extends jmPath {
|
|
11
11
|
|
|
12
|
-
constructor(params, t='
|
|
12
|
+
constructor(params, t='jmArrow') {
|
|
13
13
|
super(params, t);
|
|
14
14
|
this.style.lineJoin = 'miter';
|
|
15
15
|
this.style.lineCap = 'square';
|
|
@@ -25,7 +25,7 @@ export default class jmArraw extends jmPath {
|
|
|
25
25
|
* 控制起始点
|
|
26
26
|
*
|
|
27
27
|
* @property start
|
|
28
|
-
* @for
|
|
28
|
+
* @for jmArrow
|
|
29
29
|
* @type {point}
|
|
30
30
|
*/
|
|
31
31
|
get start() {
|
|
@@ -40,7 +40,7 @@ export default class jmArraw extends jmPath {
|
|
|
40
40
|
* 控制结束点
|
|
41
41
|
*
|
|
42
42
|
* @property end
|
|
43
|
-
* @for
|
|
43
|
+
* @for jmArrow
|
|
44
44
|
* @type {point} 结束点
|
|
45
45
|
*/
|
|
46
46
|
get end() {
|
|
@@ -55,7 +55,7 @@ export default class jmArraw extends jmPath {
|
|
|
55
55
|
* 箭头角度
|
|
56
56
|
*
|
|
57
57
|
* @property angle
|
|
58
|
-
* @for
|
|
58
|
+
* @for jmArrow
|
|
59
59
|
* @type {number} 箭头角度
|
|
60
60
|
*/
|
|
61
61
|
get angle() {
|
|
@@ -70,7 +70,7 @@ export default class jmArraw extends jmPath {
|
|
|
70
70
|
* 箭头X偏移量
|
|
71
71
|
*
|
|
72
72
|
* @property offsetX
|
|
73
|
-
* @for
|
|
73
|
+
* @for jmArrow
|
|
74
74
|
* @type {number}
|
|
75
75
|
*/
|
|
76
76
|
get offsetX() {
|
|
@@ -85,7 +85,7 @@ export default class jmArraw extends jmPath {
|
|
|
85
85
|
* 箭头Y偏移量
|
|
86
86
|
*
|
|
87
87
|
* @property offsetY
|
|
88
|
-
* @for
|
|
88
|
+
* @for jmArrow
|
|
89
89
|
* @type {number}
|
|
90
90
|
*/
|
|
91
91
|
get offsetY() {
|
|
@@ -102,7 +102,7 @@ export default class jmArraw extends jmPath {
|
|
|
102
102
|
* @method initPoint
|
|
103
103
|
* @private
|
|
104
104
|
* @param {boolean} solid 是否为实心的箭头
|
|
105
|
-
* @for
|
|
105
|
+
* @for jmArrow
|
|
106
106
|
*/
|
|
107
107
|
initPoints(solid) {
|
|
108
108
|
let rotate = this.angle;
|
|
@@ -157,4 +157,4 @@ export default class jmArraw extends jmPath {
|
|
|
157
157
|
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
export {
|
|
160
|
+
export { jmArrow };
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import {jmLine} from "./jmLine.js";
|
|
2
|
-
import {
|
|
2
|
+
import {jmArrow} from "./jmArrow.js";
|
|
3
3
|
/**
|
|
4
4
|
* 带箭头的直线,继承jmPath
|
|
5
5
|
*
|
|
6
|
-
* @class
|
|
6
|
+
* @class jmArrowLine
|
|
7
7
|
* @extends jmLine
|
|
8
8
|
* @param {object} params 生成当前直线的参数对象,(style=当前线条样式,start=直线起始点,end=直线终结点)
|
|
9
9
|
*/
|
|
10
|
-
export default class
|
|
10
|
+
export default class jmArrowLine extends jmLine {
|
|
11
11
|
|
|
12
12
|
constructor(params, t) {
|
|
13
13
|
|
|
14
14
|
params.start = params.start || {x:0,y:0};
|
|
15
15
|
params.end = params.end || {x:0,y:0};
|
|
16
16
|
|
|
17
|
-
super(params, t||'
|
|
17
|
+
super(params, t||'jmArrowLine');
|
|
18
18
|
this.style.lineJoin = this.style.lineJoin || 'miter';
|
|
19
|
-
this.
|
|
19
|
+
this.arrow = new jmArrow(params);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
/**
|
|
@@ -27,11 +27,11 @@ export default class jmArrawLine extends jmLine {
|
|
|
27
27
|
*/
|
|
28
28
|
initPoints() {
|
|
29
29
|
this.points = super.initPoints();
|
|
30
|
-
if(this.
|
|
31
|
-
this.points = this.points.concat(this.
|
|
30
|
+
if(this.arrowVisible !== false) {
|
|
31
|
+
this.points = this.points.concat(this.arrow.initPoints());
|
|
32
32
|
}
|
|
33
33
|
return this.points;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
export {
|
|
37
|
+
export { jmArrowLine };
|
package/src/shapes/jmHArc.js
CHANGED
|
@@ -12,8 +12,8 @@ export default class jmHArc extends jmArc {
|
|
|
12
12
|
constructor(params, t='jmHArc') {
|
|
13
13
|
super(params, t);
|
|
14
14
|
|
|
15
|
-
this.minRadius = params.minRadius || style.minRadius || 0;
|
|
16
|
-
this.maxRadius = params.maxRadius || style.maxRadius || 0;
|
|
15
|
+
this.minRadius = params.minRadius || this.style.minRadius || 0;
|
|
16
|
+
this.maxRadius = params.maxRadius || this.style.maxRadius || 0;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/**
|