jmgraph 3.2.7 → 3.2.8
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 +0 -1
- package/dist/jmgraph.core.min.js +1 -1
- package/dist/jmgraph.core.min.js.map +1 -1
- package/dist/jmgraph.js +2834 -325
- package/dist/jmgraph.min.js +1 -1
- package/example/ball.html +8 -14
- package/example/cell.html +1 -1
- package/example/controls/arc.html +10 -7
- package/example/controls/arrowline.html +1 -0
- package/example/controls/img.html +30 -23
- package/example/controls/label.html +6 -4
- package/example/controls/line.html +54 -51
- package/example/controls/resize.html +45 -8
- package/example/index.html +2 -1
- package/example/music.html +101 -82
- package/example/webgl.html +48 -25
- package/package.json +56 -56
- package/src/core/jmControl.js +124 -95
- package/src/core/jmEvents.js +2 -2
- package/src/core/jmGradient.js +5 -3
- package/src/core/jmGraph.js +10 -20
- package/src/core/jmPath.js +1 -17
- package/src/core/jmUtils.js +6 -0
- package/src/lib/webgl/base.js +253 -1
- package/src/lib/webgl/core/buffer.js +2 -1
- package/src/lib/webgl/core/program.js +2 -2
- package/src/lib/webgl/core/texture.js +8 -8
- package/src/lib/webgl/gradient.js +11 -38
- package/src/lib/webgl/path.js +118 -235
- package/src/shapes/jmImage.js +18 -3
- package/src/shapes/jmLabel.js +84 -38
- package/src/shapes/jmRect.js +5 -2
- package/docs/_config.yml +0 -1
- package/docs/about.html +0 -41
- package/docs/api/jmGraph.md +0 -2302
- package/docs/css/index.css +0 -131
- package/docs/images/ball.gif +0 -0
- package/docs/images/bezier.gif +0 -0
- package/docs/images/cell.gif +0 -0
- package/docs/images/chart.gif +0 -0
- package/docs/images/editor.gif +0 -0
- package/docs/images/sort.gif +0 -0
- package/docs/index.html +0 -80
- package/docs/js/helper.js +0 -89
- package/docs/js/jquery.min.js +0 -6
- package/example/love/img/music/bg.mp3 +0 -0
- package/example/love/img/music/bg_2019130144035.mp3 +0 -0
- package/example/love/img/music/f.mp3 +0 -0
- package/example/love/img/music/fail.mp3 +0 -0
- package/example/love/img/music/s.mp3 +0 -0
- package/example/love/img/music/s_201913014415.mp3 +0 -0
package/src/core/jmControl.js
CHANGED
|
@@ -4,7 +4,7 @@ import {jmList} from "./jmList.js";
|
|
|
4
4
|
import {jmGradient} from "./jmGradient.js";
|
|
5
5
|
import {jmShadow} from "./jmShadow.js";
|
|
6
6
|
import {jmProperty} from "./jmProperty.js";
|
|
7
|
-
|
|
7
|
+
import WebglPath from "../lib/webgl/path.js";
|
|
8
8
|
|
|
9
9
|
//样式名称,也当做白名单使用
|
|
10
10
|
const jmStyleMap = {
|
|
@@ -55,16 +55,17 @@ export default class jmControl extends jmProperty {
|
|
|
55
55
|
|
|
56
56
|
this.graph = params.graph || null;
|
|
57
57
|
this.zIndex = params.zIndex || 0;
|
|
58
|
-
this.interactive = typeof params.interactive == 'undefined'?
|
|
58
|
+
this.interactive = typeof params.interactive == 'undefined'? false : params.interactive;
|
|
59
59
|
|
|
60
60
|
// webgl模式
|
|
61
|
-
|
|
61
|
+
if(this.mode === 'webgl') {
|
|
62
62
|
this.webglControl = new WebglPath(this.graph, {
|
|
63
63
|
style: this.style,
|
|
64
|
+
control: this,
|
|
64
65
|
isRegular: params.isRegular,
|
|
65
66
|
needCut: params.needCut
|
|
66
67
|
});
|
|
67
|
-
}
|
|
68
|
+
}
|
|
68
69
|
|
|
69
70
|
this.initializing();
|
|
70
71
|
|
|
@@ -142,7 +143,7 @@ export default class jmControl extends jmProperty {
|
|
|
142
143
|
* @type {boolean}
|
|
143
144
|
*/
|
|
144
145
|
get interactive() {
|
|
145
|
-
|
|
146
|
+
const s = this.property('interactive');
|
|
146
147
|
return s;
|
|
147
148
|
}
|
|
148
149
|
set interactive(v) {
|
|
@@ -205,7 +206,6 @@ export default class jmControl extends jmProperty {
|
|
|
205
206
|
return s;
|
|
206
207
|
}
|
|
207
208
|
set zIndex(v) {
|
|
208
|
-
this.needUpdate = true;
|
|
209
209
|
this.property('zIndex', v);
|
|
210
210
|
this.children.sort();//层级发生改变,需要重新排序
|
|
211
211
|
this.needUpdate = true;
|
|
@@ -389,11 +389,6 @@ export default class jmControl extends jmProperty {
|
|
|
389
389
|
else if(mpname) {
|
|
390
390
|
|
|
391
391
|
if(this.webglControl) {
|
|
392
|
-
//只有存在白名单中才处理
|
|
393
|
-
//颜色转换
|
|
394
|
-
if(t == 'string' && ['fillStyle', 'strokeStyle', 'shadowColor'].indexOf(mpname) > -1) {
|
|
395
|
-
styleValue = jmUtils.hexToRGBA(styleValue);
|
|
396
|
-
}
|
|
397
392
|
|
|
398
393
|
this.webglControl.setStyle(mpname, styleValue);
|
|
399
394
|
}
|
|
@@ -422,41 +417,36 @@ export default class jmControl extends jmProperty {
|
|
|
422
417
|
}
|
|
423
418
|
//平移
|
|
424
419
|
case 'translate' : {
|
|
425
|
-
this.context.translate && this.context.translate(styleValue.x, styleValue.y);
|
|
426
420
|
break;
|
|
427
421
|
}
|
|
428
422
|
//旋转
|
|
429
423
|
case 'rotation' : {
|
|
430
|
-
if(
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
let tranY = 0;
|
|
424
|
+
if(typeof styleValue.angle === 'undefined' || isNaN(styleValue.angle)) break;
|
|
425
|
+
styleValue = this.getRotation(styleValue);
|
|
426
|
+
|
|
434
427
|
//旋转,则移位,如果有中心位则按中心旋转,否则按左上角旋转
|
|
435
428
|
//这里只有style中的旋转才能生效,不然会导至子控件多次旋转
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
tranY = styleValue.rotateY + bounds.top;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
if(tranX!=0 || tranY != 0) this.context.translate && this.context.translate(tranX,tranY);
|
|
445
|
-
this.context.rotate(styleValue.angle);
|
|
446
|
-
if(tranX!=0 || tranY != 0) this.context.translate && this.context.translate(-tranX,-tranY);
|
|
429
|
+
styleValue = this.toAbsolutePoint(styleValue);
|
|
430
|
+
|
|
431
|
+
this.context.translate && this.context.translate(styleValue.x, styleValue.y);
|
|
432
|
+
this.context.rotate && this.context.rotate(styleValue.angle);
|
|
433
|
+
this.context.translate && this.context.translate(-styleValue.x, -styleValue.y);
|
|
447
434
|
break;
|
|
448
435
|
}
|
|
449
436
|
case 'transform' : {
|
|
437
|
+
if(!this.context.transform) break;
|
|
450
438
|
if(Array.isArray(styleValue)) {
|
|
451
439
|
this.context.transform.apply(this.context, styleValue);
|
|
452
440
|
}
|
|
453
441
|
else if(typeof styleValue == 'object') {
|
|
454
|
-
this.context.transform(
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
442
|
+
this.context.transform(
|
|
443
|
+
styleValue.scaleX || 1,//水平缩放
|
|
444
|
+
styleValue.skewX || 0,//水平倾斜
|
|
445
|
+
styleValue.skewY || 0,//垂直倾斜
|
|
446
|
+
styleValue.scaleY || 1,//垂直缩放
|
|
447
|
+
styleValue.offsetX || 0,//水平位移
|
|
448
|
+
styleValue.offsetY || 0//垂直位移
|
|
449
|
+
);
|
|
460
450
|
}
|
|
461
451
|
break;
|
|
462
452
|
}
|
|
@@ -523,8 +513,7 @@ export default class jmControl extends jmProperty {
|
|
|
523
513
|
}
|
|
524
514
|
}
|
|
525
515
|
else if(this.points && this.points.length > 0) {
|
|
526
|
-
for(
|
|
527
|
-
let p = this.points[i];
|
|
516
|
+
for(const p of this.points) {
|
|
528
517
|
if(typeof rect.left === 'undefined' || rect.left > p.x) {
|
|
529
518
|
rect.left = p.x;
|
|
530
519
|
}
|
|
@@ -555,6 +544,7 @@ export default class jmControl extends jmProperty {
|
|
|
555
544
|
if(!rect.bottom) rect.bottom = 0;
|
|
556
545
|
rect.width = rect.right - rect.left;
|
|
557
546
|
rect.height = rect.bottom - rect.top;
|
|
547
|
+
|
|
558
548
|
return this.bounds=rect;
|
|
559
549
|
}
|
|
560
550
|
|
|
@@ -579,7 +569,7 @@ export default class jmControl extends jmProperty {
|
|
|
579
569
|
local.width = this.width;
|
|
580
570
|
local.height = this.height;
|
|
581
571
|
|
|
582
|
-
|
|
572
|
+
const margin = jmUtils.clone(this.style.margin, {});
|
|
583
573
|
margin.left = (margin.left || 0);
|
|
584
574
|
margin.top = (margin.top || 0);
|
|
585
575
|
margin.right = (margin.right || 0);
|
|
@@ -595,38 +585,39 @@ export default class jmControl extends jmProperty {
|
|
|
595
585
|
local.top = margin.top;
|
|
596
586
|
}
|
|
597
587
|
|
|
598
|
-
if(
|
|
599
|
-
|
|
588
|
+
if(this.parent) {
|
|
589
|
+
const parentBounds = this.parent.getBounds();
|
|
600
590
|
|
|
601
|
-
//处理百分比参数
|
|
602
|
-
if(jmUtils.checkPercent(local.left)) {
|
|
603
|
-
local.left = jmUtils.percentToNumber(local.left) * parentBounds.width;
|
|
604
|
-
}
|
|
605
|
-
if(jmUtils.checkPercent(local.top)) {
|
|
606
|
-
local.top = jmUtils.percentToNumber(local.top) * parentBounds.height;
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
//如果没有指定宽度或高度,则按百分之百计算其父宽度或高度
|
|
610
|
-
if(jmUtils.checkPercent(local.width)) {
|
|
611
|
-
local.width = jmUtils.percentToNumber(local.width) * parentBounds.width;
|
|
612
|
-
}
|
|
613
|
-
if(jmUtils.checkPercent(local.height)) {
|
|
614
|
-
local.height = jmUtils.percentToNumber(local.height) * parentBounds.height;
|
|
615
|
-
}
|
|
616
|
-
//处理中心点
|
|
617
|
-
if(local.center) {
|
|
618
591
|
//处理百分比参数
|
|
619
|
-
if(jmUtils.checkPercent(local.
|
|
620
|
-
local.
|
|
592
|
+
if(jmUtils.checkPercent(local.left)) {
|
|
593
|
+
local.left = jmUtils.percentToNumber(local.left) * parentBounds.width;
|
|
621
594
|
}
|
|
622
|
-
if(jmUtils.checkPercent(local.
|
|
623
|
-
local.
|
|
595
|
+
if(jmUtils.checkPercent(local.top)) {
|
|
596
|
+
local.top = jmUtils.percentToNumber(local.top) * parentBounds.height;
|
|
624
597
|
}
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
598
|
+
|
|
599
|
+
//如果没有指定宽度或高度,则按百分之百计算其父宽度或高度
|
|
600
|
+
if(jmUtils.checkPercent(local.width)) {
|
|
601
|
+
local.width = jmUtils.percentToNumber(local.width) * parentBounds.width;
|
|
602
|
+
}
|
|
603
|
+
if(jmUtils.checkPercent(local.height)) {
|
|
604
|
+
local.height = jmUtils.percentToNumber(local.height) * parentBounds.height;
|
|
605
|
+
}
|
|
606
|
+
//处理中心点
|
|
607
|
+
if(local.center) {
|
|
608
|
+
//处理百分比参数
|
|
609
|
+
if(jmUtils.checkPercent(local.center.x)) {
|
|
610
|
+
local.center.x = jmUtils.percentToNumber(local.center.x) * parentBounds.width;
|
|
611
|
+
}
|
|
612
|
+
if(jmUtils.checkPercent(local.center.y)) {
|
|
613
|
+
local.center.y = jmUtils.percentToNumber(local.center.y) * parentBounds.height;
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
if(local.radius) {
|
|
617
|
+
//处理百分比参数
|
|
618
|
+
if(jmUtils.checkPercent(local.radius)) {
|
|
619
|
+
local.radius = jmUtils.percentToNumber(local.radius) * Math.min(parentBounds.width, parentBounds.height);
|
|
620
|
+
}
|
|
630
621
|
}
|
|
631
622
|
}
|
|
632
623
|
return local;
|
|
@@ -636,34 +627,54 @@ export default class jmControl extends jmProperty {
|
|
|
636
627
|
* 获取当前控制的旋转信息
|
|
637
628
|
* @returns {object} 旋转中心和角度
|
|
638
629
|
*/
|
|
639
|
-
getRotation(rotation) {
|
|
640
|
-
rotation = rotation || this.style.rotation;
|
|
630
|
+
getRotation(rotation, bounds = null) {
|
|
631
|
+
rotation = rotation || jmUtils.clone(this.style.rotation);
|
|
632
|
+
|
|
641
633
|
if(!rotation) {
|
|
642
634
|
//如果本身没有,则可以继承父级的
|
|
643
635
|
rotation = this.parent && this.parent.getRotation?this.parent.getRotation():null;
|
|
644
636
|
//如果父级有旋转,则把坐标转换为当前控件区域
|
|
645
637
|
if(rotation) {
|
|
646
|
-
|
|
647
|
-
rotation.
|
|
648
|
-
rotation.
|
|
638
|
+
bounds = bounds || this.getBounds();
|
|
639
|
+
rotation.x -= bounds.left;
|
|
640
|
+
rotation.y -= bounds.top;
|
|
649
641
|
}
|
|
650
642
|
}
|
|
651
643
|
else {
|
|
652
|
-
|
|
653
|
-
rotation.
|
|
654
|
-
if(
|
|
655
|
-
|
|
644
|
+
bounds = bounds || this.getBounds();
|
|
645
|
+
if(typeof rotation.x === 'undefined') rotation.x = '50%';
|
|
646
|
+
if(typeof rotation.y === 'undefined') rotation.y = '50%';
|
|
647
|
+
if(jmUtils.checkPercent(rotation.x)) {
|
|
648
|
+
rotation.x = jmUtils.percentToNumber(rotation.x) * bounds.width;
|
|
656
649
|
}
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
if(jmUtils.checkPercent(rotation.rotateY)) {
|
|
660
|
-
rotation.rotateY = jmUtils.percentToNumber(rotation.rotateY) * bounds.height;
|
|
650
|
+
if(jmUtils.checkPercent(rotation.y)) {
|
|
651
|
+
rotation.y = jmUtils.percentToNumber(rotation.y) * bounds.height;
|
|
661
652
|
}
|
|
662
653
|
}
|
|
663
654
|
return rotation;
|
|
664
655
|
|
|
665
656
|
}
|
|
666
657
|
|
|
658
|
+
// 计算位移偏移量
|
|
659
|
+
getTranslate(translate, bounds = null) {
|
|
660
|
+
translate = translate || this.style.translate;
|
|
661
|
+
if(!translate) return {x: 0, y: 0};
|
|
662
|
+
const result = {
|
|
663
|
+
x: translate.x || 0,
|
|
664
|
+
y: translate.y || 0
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
if(jmUtils.checkPercent(result.x)) {
|
|
668
|
+
if(!bounds && this.parent) bounds = this.parent.getBounds();
|
|
669
|
+
result.x = jmUtils.percentToNumber(result.x) * bounds.width;
|
|
670
|
+
}
|
|
671
|
+
if(jmUtils.checkPercent(result.y)) {
|
|
672
|
+
if(!bounds && this.parent) bounds = this.parent.getBounds();
|
|
673
|
+
result.y = jmUtils.percentToNumber(result.y) * bounds.height;
|
|
674
|
+
}
|
|
675
|
+
return result;
|
|
676
|
+
}
|
|
677
|
+
|
|
667
678
|
/**
|
|
668
679
|
* 移除当前控件
|
|
669
680
|
* 如果是VML元素,则调用其删除元素
|
|
@@ -794,6 +805,22 @@ export default class jmControl extends jmProperty {
|
|
|
794
805
|
return rec;
|
|
795
806
|
}
|
|
796
807
|
|
|
808
|
+
/**
|
|
809
|
+
* 把当前控制内部坐标转为canvas绝对定位坐标
|
|
810
|
+
*
|
|
811
|
+
* @method toAbsolutePoint
|
|
812
|
+
* @param {x: number, y: number} 内部坐标
|
|
813
|
+
*/
|
|
814
|
+
toAbsolutePoint(point) {
|
|
815
|
+
if(point.x || point.y) {
|
|
816
|
+
const bounds = this.absoluteBounds?this.absoluteBounds:this.getAbsoluteBounds();
|
|
817
|
+
|
|
818
|
+
point.x = (point.x||0) + bounds.left;
|
|
819
|
+
point.y = (point.y||0) + bounds.top;
|
|
820
|
+
}
|
|
821
|
+
return point;
|
|
822
|
+
}
|
|
823
|
+
|
|
797
824
|
/**
|
|
798
825
|
* 画控件前初始化
|
|
799
826
|
* 执行beginPath开始控件的绘制
|
|
@@ -803,7 +830,7 @@ export default class jmControl extends jmProperty {
|
|
|
803
830
|
beginDraw() {
|
|
804
831
|
this.getLocation(true);//重置位置信息
|
|
805
832
|
this.context.beginPath && this.context.beginPath();
|
|
806
|
-
|
|
833
|
+
if(this.webglControl && this.webglControl.beginDraw) this.webglControl.beginDraw();
|
|
807
834
|
}
|
|
808
835
|
|
|
809
836
|
/**
|
|
@@ -814,24 +841,24 @@ export default class jmControl extends jmProperty {
|
|
|
814
841
|
endDraw() {
|
|
815
842
|
//如果当前为封闭路径
|
|
816
843
|
if(this.style.close) {
|
|
817
|
-
|
|
844
|
+
if(this.webglControl) this.webglControl.closePath();
|
|
818
845
|
this.context.closePath && this.context.closePath();
|
|
819
846
|
}
|
|
820
847
|
|
|
821
848
|
const fill = this.style['fill'] || this.style['fillStyle'];
|
|
822
849
|
if(fill) {
|
|
823
|
-
|
|
850
|
+
if(this.webglControl) {
|
|
824
851
|
const bounds = this.getBounds();
|
|
825
852
|
this.webglControl.fill(bounds);
|
|
826
|
-
}
|
|
853
|
+
}
|
|
827
854
|
this.context.fill && this.context.fill();
|
|
828
855
|
}
|
|
829
856
|
if(this.style['stroke'] || (!fill && !this.is('jmGraph'))) {
|
|
830
|
-
|
|
857
|
+
if(this.webglControl) this.webglControl.stroke();
|
|
831
858
|
this.context.stroke && this.context.stroke();
|
|
832
859
|
}
|
|
833
860
|
|
|
834
|
-
|
|
861
|
+
if(this.webglControl && this.webglControl.endDraw) this.webglControl.endDraw();
|
|
835
862
|
|
|
836
863
|
this.needUpdate = false;
|
|
837
864
|
}
|
|
@@ -846,13 +873,13 @@ export default class jmControl extends jmProperty {
|
|
|
846
873
|
if(this.points && this.points.length > 0) {
|
|
847
874
|
//获取当前控件的绝对位置
|
|
848
875
|
const bounds = this.parent && this.parent.absoluteBounds?this.parent.absoluteBounds:this.absoluteBounds;
|
|
849
|
-
|
|
876
|
+
if(this.webglControl) {
|
|
850
877
|
this.webglControl.setParentBounds(bounds);
|
|
851
878
|
this.webglControl.draw([
|
|
852
879
|
...this.points
|
|
853
880
|
]);
|
|
854
|
-
}
|
|
855
|
-
if(this.context && this.context.moveTo) {
|
|
881
|
+
}
|
|
882
|
+
else if(this.context && this.context.moveTo) {
|
|
856
883
|
this.context.moveTo(this.points[0].x + bounds.left,this.points[0].y + bounds.top);
|
|
857
884
|
let len = this.points.length;
|
|
858
885
|
for(let i=1; i < len;i++) {
|
|
@@ -1038,8 +1065,8 @@ export default class jmControl extends jmProperty {
|
|
|
1038
1065
|
return true;
|
|
1039
1066
|
}
|
|
1040
1067
|
|
|
1041
|
-
|
|
1042
|
-
|
|
1068
|
+
const bounds = this.getBounds();
|
|
1069
|
+
const rotation = this.getRotation(null, bounds);//获取当前旋转参数
|
|
1043
1070
|
let ps = this.points;
|
|
1044
1071
|
//如果不是路径组成,则采用边界做为顶点
|
|
1045
1072
|
if(!ps || !ps.length) {
|
|
@@ -1059,27 +1086,27 @@ export default class jmControl extends jmProperty {
|
|
|
1059
1086
|
ps = jmUtils.clone(ps, true);//拷贝一份数据
|
|
1060
1087
|
//rotateX ,rotateY 是相对当前控件的位置
|
|
1061
1088
|
ps = jmUtils.rotatePoints(ps, {
|
|
1062
|
-
x: rotation.
|
|
1063
|
-
y: rotation.
|
|
1089
|
+
x: rotation.x + bounds.left,
|
|
1090
|
+
y: rotation.y + bounds.top
|
|
1064
1091
|
}, rotation.angle);
|
|
1065
1092
|
}
|
|
1066
1093
|
//如果当前路径不是实心的
|
|
1067
1094
|
//就只用判断点是否在边上即可
|
|
1068
1095
|
if(ps.length > 2 && (!this.style['fill'] || this.style['stroke'])) {
|
|
1069
1096
|
let i = 0;
|
|
1070
|
-
|
|
1097
|
+
const count = ps.length;
|
|
1071
1098
|
for(let j = i+1; j <= count; j = (++i + 1)) {
|
|
1072
1099
|
//如果j超出最后一个
|
|
1073
1100
|
//则当为封闭图形时跟第一点连线处理.否则直接返回false
|
|
1074
1101
|
if(j == count) {
|
|
1075
1102
|
if(this.style.close) {
|
|
1076
|
-
|
|
1103
|
+
const r = jmUtils.pointInPolygon(p,[ps[i],ps[0]], pad);
|
|
1077
1104
|
if(r) return true;
|
|
1078
1105
|
}
|
|
1079
1106
|
}
|
|
1080
1107
|
else {
|
|
1081
1108
|
//判断是否在点i,j连成的线上
|
|
1082
|
-
|
|
1109
|
+
const s = jmUtils.pointInPolygon(p,[ps[i],ps[j]], pad);
|
|
1083
1110
|
if(s) return true;
|
|
1084
1111
|
}
|
|
1085
1112
|
}
|
|
@@ -1087,7 +1114,7 @@ export default class jmControl extends jmProperty {
|
|
|
1087
1114
|
if(!this.style['fill']) return false;
|
|
1088
1115
|
}
|
|
1089
1116
|
|
|
1090
|
-
|
|
1117
|
+
const r = jmUtils.pointInPolygon(p,ps, pad);
|
|
1091
1118
|
return r;
|
|
1092
1119
|
}
|
|
1093
1120
|
|
|
@@ -1117,7 +1144,7 @@ export default class jmControl extends jmProperty {
|
|
|
1117
1144
|
|
|
1118
1145
|
const srcElement = args.srcElement || args.target;
|
|
1119
1146
|
|
|
1120
|
-
const position = jmUtils.getEventPosition(args
|
|
1147
|
+
const position = jmUtils.getEventPosition(args);//初始化事件位置
|
|
1121
1148
|
|
|
1122
1149
|
args = {
|
|
1123
1150
|
position: position,
|
|
@@ -1388,6 +1415,8 @@ export default class jmControl extends jmProperty {
|
|
|
1388
1415
|
graph.unbind('touchend',this.__mvMonitor.mu);
|
|
1389
1416
|
this.unbind('touchstart',this.__mvMonitor.md);
|
|
1390
1417
|
}
|
|
1418
|
+
|
|
1419
|
+
this.interactive = true;// 如果可以移动,则响应事件
|
|
1391
1420
|
return this;
|
|
1392
1421
|
}
|
|
1393
1422
|
};
|
package/src/core/jmEvents.js
CHANGED
|
@@ -99,7 +99,7 @@ class jmMouseEvent {
|
|
|
99
99
|
//}
|
|
100
100
|
});
|
|
101
101
|
|
|
102
|
-
this.eventEvents['
|
|
102
|
+
this.eventEvents['mousemove'] = jmUtils.bindEvent(this.target,'mousemove',function(evt) {
|
|
103
103
|
evt = evt || window.event;
|
|
104
104
|
evt.eventName = 'mousemove';
|
|
105
105
|
let target = evt.target || evt.srcElement;
|
|
@@ -112,7 +112,7 @@ class jmMouseEvent {
|
|
|
112
112
|
}
|
|
113
113
|
});
|
|
114
114
|
|
|
115
|
-
this.eventEvents['
|
|
115
|
+
this.eventEvents['mouseover'] = jmUtils.bindEvent(this.target,'mouseover',function(evt) {
|
|
116
116
|
evt = evt || window.event;
|
|
117
117
|
evt.eventName = 'mouseover';
|
|
118
118
|
container.raiseEvent('mouseover',evt);
|
package/src/core/jmGradient.js
CHANGED
|
@@ -91,6 +91,7 @@ export default class jmGradient {
|
|
|
91
91
|
if(this.type === 'linear') {
|
|
92
92
|
if(control.mode === 'webgl' && control.webglControl) {
|
|
93
93
|
gradient = control.webglControl.createLinearGradient(x1, y1, x2, y2, bounds);
|
|
94
|
+
gradient.key = this.toString();
|
|
94
95
|
}
|
|
95
96
|
else {
|
|
96
97
|
context.createLinearGradient && (gradient = context.createLinearGradient(sx1, sy1, sx2, sy2));
|
|
@@ -109,6 +110,7 @@ export default class jmGradient {
|
|
|
109
110
|
}
|
|
110
111
|
if(control.mode === 'webgl' && control.webglControl) {
|
|
111
112
|
gradient = control.webglControl.createRadialGradient(x1, y1, r1, x2, y2, r2, bounds);
|
|
113
|
+
gradient.key = this.toString();
|
|
112
114
|
}
|
|
113
115
|
//offsetLine = Math.abs(r2 - r1);//二圆半径差
|
|
114
116
|
else if(context.createRadialGradient) {
|
|
@@ -210,14 +212,14 @@ export default class jmGradient {
|
|
|
210
212
|
toString() {
|
|
211
213
|
let str = this.type + '-gradient(';
|
|
212
214
|
if(this.type == 'linear') {
|
|
213
|
-
str += this.x1
|
|
215
|
+
str += this.x1 + ' ' + this.y1 + ' ' + this.x2 + ' ' + this.y2;
|
|
214
216
|
}
|
|
215
217
|
else {
|
|
216
|
-
str += this.x1
|
|
218
|
+
str += this.x1 + ' ' + this.y1 + ' ' + this.r1 + ' ' + this.x2 + ' ' + this.y2 + ' ' + this.r2;
|
|
217
219
|
}
|
|
218
220
|
//颜色渐变
|
|
219
221
|
this.stops.each(function(i,s) {
|
|
220
|
-
str += ',' + s.color + ' ' + s.offset
|
|
222
|
+
str += ',' + s.color + ' ' + s.offset;
|
|
221
223
|
});
|
|
222
224
|
return str + ')';
|
|
223
225
|
}
|
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
|
-
option.mode = '2d'; // webgl | 2d 暂不支持webgl
|
|
30
|
+
//option.mode = '2d'; // webgl | 2d 暂不支持webgl
|
|
31
31
|
option.interactive = true;
|
|
32
32
|
option.isRegular = true;// 规则的
|
|
33
33
|
|
|
@@ -170,20 +170,7 @@ export default class jmGraph extends jmControl {
|
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
this.context.viewport && this.context.viewport(0, 0, w, h);
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* 内部坐标转为页面坐标,这里主要是有devicePixelRatio倍数问题
|
|
177
|
-
* @param {x, y} point 内部坐标
|
|
178
|
-
*/
|
|
179
|
-
pointToPixes(point) {
|
|
180
|
-
if(this.dprScaleSize && this.dprScaleSize !== 1) {
|
|
181
|
-
point = Object.assign({}, point, {
|
|
182
|
-
x: point.x / this.dprScaleSize,
|
|
183
|
-
y: point.y / this.dprScaleSize
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
return point;
|
|
173
|
+
this.needUpdate = true;
|
|
187
174
|
}
|
|
188
175
|
|
|
189
176
|
/**
|
|
@@ -507,14 +494,14 @@ export default class jmGraph extends jmControl {
|
|
|
507
494
|
};
|
|
508
495
|
}
|
|
509
496
|
|
|
510
|
-
this.context.scale(dx,dy);
|
|
497
|
+
//this.context.scale && this.context.scale(dx,dy);
|
|
511
498
|
if(!this.scaleSize) {
|
|
512
|
-
this.scaleSize = {x:
|
|
499
|
+
this.scaleSize = {x: 1,y: 1};
|
|
513
500
|
}
|
|
514
501
|
else {
|
|
515
|
-
this.scaleSize = {x:dx * this.scaleSize.x, y:dy * this.scaleSize.y};
|
|
502
|
+
this.scaleSize = {x: dx * this.scaleSize.x, y: dy * this.scaleSize.y};
|
|
516
503
|
}
|
|
517
|
-
this.
|
|
504
|
+
this.canvas.style && (this.canvas.style.transform = `scale(${this.scaleSize.x}, ${this.scaleSize.y})`);
|
|
518
505
|
}
|
|
519
506
|
|
|
520
507
|
/**
|
|
@@ -537,14 +524,17 @@ export default class jmGraph extends jmControl {
|
|
|
537
524
|
const self = this;
|
|
538
525
|
this.___isAutoRefreshing = true;
|
|
539
526
|
|
|
527
|
+
const refreshStartTime = Date.now();
|
|
540
528
|
function update() {
|
|
541
529
|
if(self.destroyed) {
|
|
542
530
|
self.___isAutoRefreshing = false;
|
|
543
531
|
return;// 已销毁
|
|
544
532
|
}
|
|
545
533
|
if(self.needUpdate) self.redraw();
|
|
534
|
+
|
|
535
|
+
const time = Date.now() - refreshStartTime;
|
|
546
536
|
// 触发刷新事件
|
|
547
|
-
self.emit('update');
|
|
537
|
+
self.emit('update', time);
|
|
548
538
|
|
|
549
539
|
self.__requestAnimationFrameFunHandler && self.cancelAnimationFrame(self.__requestAnimationFrameFunHandler);
|
|
550
540
|
self.__requestAnimationFrameFunHandler = self.requestAnimationFrame(update);
|
package/src/core/jmPath.js
CHANGED
|
@@ -13,7 +13,6 @@ export default class jmPath extends jmControl {
|
|
|
13
13
|
constructor(params, t='jmPath') {
|
|
14
14
|
super(params, t);
|
|
15
15
|
this.points = params && params.points ? params.points : [];
|
|
16
|
-
this.polygonIndices = params && params.polygonIndices ? params.polygonIndices : [];
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
/**
|
|
@@ -29,22 +28,7 @@ export default class jmPath extends jmControl {
|
|
|
29
28
|
set points(v) {
|
|
30
29
|
this.needUpdate = true;
|
|
31
30
|
return this.property('points', v);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* 顶点数组索引,对应points中的顶点
|
|
36
|
-
* @property polygonIndices
|
|
37
|
-
* @type {array}
|
|
38
|
-
*/
|
|
39
|
-
get polygonIndices() {
|
|
40
|
-
let s = this.property('polygonIndices');
|
|
41
|
-
return s;
|
|
42
|
-
}
|
|
43
|
-
set polygonIndices(v) {
|
|
44
|
-
this.needUpdate = true;
|
|
45
|
-
return this.property('polygonIndices', v);
|
|
46
|
-
}
|
|
47
|
-
|
|
31
|
+
}
|
|
48
32
|
|
|
49
33
|
}
|
|
50
34
|
|
package/src/core/jmUtils.js
CHANGED
|
@@ -883,6 +883,12 @@ export default class jmUtils {
|
|
|
883
883
|
b = typeof color.b !== 'undefined'? color.b: b;
|
|
884
884
|
a = typeof color.a !== 'undefined'? color.a: a;
|
|
885
885
|
}
|
|
886
|
+
if(r && typeof r === 'object') {
|
|
887
|
+
g = r.g;
|
|
888
|
+
b = r.b;
|
|
889
|
+
a = r.a || 1;
|
|
890
|
+
r = r.r;
|
|
891
|
+
}
|
|
886
892
|
if(typeof r != 'undefined' && typeof g != 'undefined' && typeof b != 'undefined') {
|
|
887
893
|
if(typeof a != 'undefined') {
|
|
888
894
|
return 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')';
|