jmgraph 3.1.96 → 3.1.98
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/dist/jmgraph.core.min.js +1 -1
- package/dist/jmgraph.core.min.js.map +1 -1
- package/dist/jmgraph.js +105 -140
- package/dist/jmgraph.min.js +1 -1
- package/package.json +1 -1
- package/src/core/jmControl.js +59 -94
- package/src/core/jmGraph.js +6 -6
- package/src/core/jmProperty.js +18 -0
- package/src/core/jmUtils.js +6 -14
package/dist/jmgraph.js
CHANGED
|
@@ -268,6 +268,31 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
268
268
|
|
|
269
269
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
270
270
|
|
|
271
|
+
//样式名称,也当做白名单使用
|
|
272
|
+
var jmStyleMap = {
|
|
273
|
+
'fill': 'fillStyle',
|
|
274
|
+
'stroke': 'strokeStyle',
|
|
275
|
+
'shadow.blur': 'shadowBlur',
|
|
276
|
+
'shadow.x': 'shadowOffsetX',
|
|
277
|
+
'shadow.y': 'shadowOffsetY',
|
|
278
|
+
'shadow.color': 'shadowColor',
|
|
279
|
+
'lineWidth': 'lineWidth',
|
|
280
|
+
'miterLimit': 'miterLimit',
|
|
281
|
+
'fillStyle': 'fillStyle',
|
|
282
|
+
'strokeStyle': 'strokeStyle',
|
|
283
|
+
'font': 'font',
|
|
284
|
+
'opacity': 'globalAlpha',
|
|
285
|
+
'textAlign': 'textAlign',
|
|
286
|
+
'textBaseline': 'textBaseline',
|
|
287
|
+
'shadowBlur': 'shadowBlur',
|
|
288
|
+
'shadowOffsetX': 'shadowOffsetX',
|
|
289
|
+
'shadowOffsetY': 'shadowOffsetY',
|
|
290
|
+
'shadowColor': 'shadowColor',
|
|
291
|
+
'lineJoin': 'lineJoin',
|
|
292
|
+
//线交汇处的形状,miter(默认,尖角),bevel(斜角),round(圆角)
|
|
293
|
+
'lineCap': 'lineCap' //线条终端点,butt(默认,平),round(圆),square(方)
|
|
294
|
+
|
|
295
|
+
};
|
|
271
296
|
/**
|
|
272
297
|
* 控件基础对象
|
|
273
298
|
* 控件的基础属性和方法
|
|
@@ -275,6 +300,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
275
300
|
* @class jmControl
|
|
276
301
|
* @extends jmProperty
|
|
277
302
|
*/
|
|
303
|
+
|
|
278
304
|
var jmControl = /*#__PURE__*/function (_jmProperty) {
|
|
279
305
|
_inherits(jmControl, _jmProperty);
|
|
280
306
|
|
|
@@ -301,32 +327,7 @@ var jmControl = /*#__PURE__*/function (_jmProperty) {
|
|
|
301
327
|
|
|
302
328
|
_this2.graph = params.graph || null;
|
|
303
329
|
_this2.zIndex = params.zIndex || 0;
|
|
304
|
-
_this2.interactive = typeof params.interactive == 'undefined' ? true : params.interactive;
|
|
305
|
-
|
|
306
|
-
_this2.jmStyleMap = {
|
|
307
|
-
'fill': 'fillStyle',
|
|
308
|
-
'stroke': 'strokeStyle',
|
|
309
|
-
'shadow.blur': 'shadowBlur',
|
|
310
|
-
'shadow.x': 'shadowOffsetX',
|
|
311
|
-
'shadow.y': 'shadowOffsetY',
|
|
312
|
-
'shadow.color': 'shadowColor',
|
|
313
|
-
'lineWidth': 'lineWidth',
|
|
314
|
-
'miterLimit': 'miterLimit',
|
|
315
|
-
'fillStyle': 'fillStyle',
|
|
316
|
-
'strokeStyle': 'strokeStyle',
|
|
317
|
-
'font': 'font',
|
|
318
|
-
'opacity': 'globalAlpha',
|
|
319
|
-
'textAlign': 'textAlign',
|
|
320
|
-
'textBaseline': 'textBaseline',
|
|
321
|
-
'shadowBlur': 'shadowBlur',
|
|
322
|
-
'shadowOffsetX': 'shadowOffsetX',
|
|
323
|
-
'shadowOffsetY': 'shadowOffsetY',
|
|
324
|
-
'shadowColor': 'shadowColor',
|
|
325
|
-
'lineJoin': 'lineJoin',
|
|
326
|
-
//线交汇处的形状,miter(默认,尖角),bevel(斜角),round(圆角)
|
|
327
|
-
'lineCap': 'lineCap' //线条终端点,butt(默认,平),round(圆),square(方)
|
|
328
|
-
|
|
329
|
-
};
|
|
330
|
+
_this2.interactive = typeof params.interactive == 'undefined' ? true : params.interactive;
|
|
330
331
|
|
|
331
332
|
_this2.initializing();
|
|
332
333
|
|
|
@@ -670,77 +671,50 @@ var jmControl = /*#__PURE__*/function (_jmProperty) {
|
|
|
670
671
|
*/
|
|
671
672
|
|
|
672
673
|
var __setStyle = function __setStyle(style, name, mpkey) {
|
|
673
|
-
//let styleValue = style[mpkey||name]||style;
|
|
674
674
|
if (style) {
|
|
675
|
-
|
|
675
|
+
var styleValue = style;
|
|
676
|
+
|
|
677
|
+
if (typeof styleValue === 'function') {
|
|
676
678
|
try {
|
|
677
|
-
|
|
679
|
+
styleValue = styleValue.call(_this3);
|
|
678
680
|
} catch (e) {
|
|
679
681
|
console.warn(e);
|
|
680
682
|
return;
|
|
681
683
|
}
|
|
682
684
|
}
|
|
683
685
|
|
|
684
|
-
var t = _typeof(
|
|
686
|
+
var t = _typeof(styleValue);
|
|
685
687
|
|
|
686
|
-
var mpname =
|
|
688
|
+
var mpname = jmStyleMap[mpkey || name]; //如果为渐变对象
|
|
687
689
|
|
|
688
|
-
if (
|
|
690
|
+
if (styleValue instanceof _jmGradient.jmGradient || t == 'string' && styleValue.indexOf('-gradient') > -1) {
|
|
689
691
|
//如果是渐变,则需要转换
|
|
690
|
-
if (t == 'string' &&
|
|
691
|
-
|
|
692
|
+
if (t == 'string' && styleValue.indexOf('-gradient') > -1) {
|
|
693
|
+
styleValue = new _jmGradient.jmGradient(styleValue);
|
|
692
694
|
}
|
|
693
695
|
|
|
694
|
-
__setStyle(
|
|
695
|
-
} else if (t == 'function') {
|
|
696
|
-
if (mpname) {
|
|
697
|
-
style = style.call(_this3, mpname);
|
|
698
|
-
|
|
699
|
-
if (style) {
|
|
700
|
-
__setStyle(style, mpname);
|
|
701
|
-
}
|
|
702
|
-
}
|
|
696
|
+
__setStyle(styleValue.toGradient(_this3), mpname || name);
|
|
703
697
|
} else if (mpname) {
|
|
704
698
|
//只有存在白名单中才处理
|
|
705
699
|
//颜色转换
|
|
706
700
|
if (t == 'string' && ['fillStyle', 'strokeStyle', 'shadowColor'].indexOf(mpname) > -1) {
|
|
707
|
-
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
switch(mpname) {
|
|
712
|
-
case 'lineWidth': {
|
|
713
|
-
style *= scale;
|
|
714
|
-
break;
|
|
715
|
-
}
|
|
716
|
-
// 字体放大
|
|
717
|
-
case 'fontSize':
|
|
718
|
-
case 'font': {
|
|
719
|
-
const ms = style.toString().match(/[\d\.]+/);
|
|
720
|
-
if(ms && ms.length) {
|
|
721
|
-
const size = Number(ms[0]) * scale;
|
|
722
|
-
style = style.toString().replace(ms[0], size);
|
|
723
|
-
}
|
|
724
|
-
break;
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
} */
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
_this3.context[mpname] = style;
|
|
701
|
+
styleValue = _jmUtils.jmUtils.toColor(styleValue);
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
_this3.context[mpname] = styleValue;
|
|
731
705
|
} else {
|
|
732
706
|
switch (name) {
|
|
733
707
|
//阴影样式
|
|
734
708
|
case 'shadow':
|
|
735
709
|
{
|
|
736
710
|
if (t == 'string') {
|
|
737
|
-
__setStyle(new _jmShadow.jmShadow(
|
|
711
|
+
__setStyle(new _jmShadow.jmShadow(styleValue), name);
|
|
738
712
|
|
|
739
713
|
break;
|
|
740
714
|
}
|
|
741
715
|
|
|
742
|
-
for (var k in
|
|
743
|
-
__setStyle(
|
|
716
|
+
for (var k in styleValue) {
|
|
717
|
+
__setStyle(styleValue[k], k, name + '.' + k);
|
|
744
718
|
}
|
|
745
719
|
|
|
746
720
|
break;
|
|
@@ -749,7 +723,7 @@ var jmControl = /*#__PURE__*/function (_jmProperty) {
|
|
|
749
723
|
|
|
750
724
|
case 'translate':
|
|
751
725
|
{
|
|
752
|
-
_this3.context.translate(
|
|
726
|
+
_this3.context.translate(styleValue.x, styleValue.y);
|
|
753
727
|
|
|
754
728
|
break;
|
|
755
729
|
}
|
|
@@ -757,22 +731,22 @@ var jmControl = /*#__PURE__*/function (_jmProperty) {
|
|
|
757
731
|
|
|
758
732
|
case 'rotation':
|
|
759
733
|
{
|
|
760
|
-
if (!
|
|
734
|
+
if (!styleValue.angle) break; //旋 转先移位偏移量
|
|
761
735
|
|
|
762
736
|
var tranX = 0;
|
|
763
737
|
var tranY = 0; //旋转,则移位,如果有中心位则按中心旋转,否则按左上角旋转
|
|
764
738
|
//这里只有style中的旋转才能生效,不然会导至子控件多次旋转
|
|
765
739
|
|
|
766
|
-
if (
|
|
740
|
+
if (styleValue.point) {
|
|
767
741
|
var bounds = _this3.absoluteBounds ? _this3.absoluteBounds : _this3.getAbsoluteBounds();
|
|
768
|
-
|
|
769
|
-
tranX =
|
|
770
|
-
tranY =
|
|
742
|
+
styleValue = _this3.getRotation(styleValue);
|
|
743
|
+
tranX = styleValue.rotateX + bounds.left;
|
|
744
|
+
tranY = styleValue.rotateY + bounds.top;
|
|
771
745
|
}
|
|
772
746
|
|
|
773
747
|
if (tranX != 0 || tranY != 0) _this3.context.translate(tranX, tranY);
|
|
774
748
|
|
|
775
|
-
_this3.context.rotate(
|
|
749
|
+
_this3.context.rotate(styleValue.angle);
|
|
776
750
|
|
|
777
751
|
if (tranX != 0 || tranY != 0) _this3.context.translate(-tranX, -tranY);
|
|
778
752
|
break;
|
|
@@ -780,15 +754,15 @@ var jmControl = /*#__PURE__*/function (_jmProperty) {
|
|
|
780
754
|
|
|
781
755
|
case 'transform':
|
|
782
756
|
{
|
|
783
|
-
if (Array.isArray(
|
|
784
|
-
_this3.context.transform.apply(_this3.context,
|
|
785
|
-
} else if (_typeof(
|
|
786
|
-
_this3.context.transform(
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
757
|
+
if (Array.isArray(styleValue)) {
|
|
758
|
+
_this3.context.transform.apply(_this3.context, styleValue);
|
|
759
|
+
} else if (_typeof(styleValue) == 'object') {
|
|
760
|
+
_this3.context.transform(styleValue.scaleX, //水平缩放
|
|
761
|
+
styleValue.skewX, //水平倾斜
|
|
762
|
+
styleValue.skewY, //垂直倾斜
|
|
763
|
+
styleValue.scaleY, //垂直缩放
|
|
764
|
+
styleValue.offsetX, //水平位移
|
|
765
|
+
styleValue.offsetY); //垂直位移
|
|
792
766
|
|
|
793
767
|
}
|
|
794
768
|
|
|
@@ -798,7 +772,7 @@ var jmControl = /*#__PURE__*/function (_jmProperty) {
|
|
|
798
772
|
|
|
799
773
|
case 'cursor':
|
|
800
774
|
{
|
|
801
|
-
_this3.cursor =
|
|
775
|
+
_this3.cursor = styleValue;
|
|
802
776
|
break;
|
|
803
777
|
}
|
|
804
778
|
}
|
|
@@ -852,16 +826,12 @@ var jmControl = /*#__PURE__*/function (_jmProperty) {
|
|
|
852
826
|
if (this.type == 'jmGraph' && this.canvas) {
|
|
853
827
|
if (typeof this.canvas.width === 'function') {
|
|
854
828
|
rect.right = this.canvas.width();
|
|
855
|
-
} else if (this.canvas.width) {
|
|
856
|
-
rect.right = this.canvas.width;
|
|
857
829
|
} else if (this.width) {
|
|
858
830
|
rect.right = this.width;
|
|
859
831
|
}
|
|
860
832
|
|
|
861
833
|
if (typeof this.canvas.height === 'function') {
|
|
862
834
|
rect.bottom = this.canvas.height();
|
|
863
|
-
} else if (this.canvas.height) {
|
|
864
|
-
rect.bottom = this.canvas.height;
|
|
865
835
|
} else if (this.height) {
|
|
866
836
|
rect.bottom = this.height;
|
|
867
837
|
}
|
|
@@ -1273,9 +1243,7 @@ var jmControl = /*#__PURE__*/function (_jmProperty) {
|
|
|
1273
1243
|
}
|
|
1274
1244
|
|
|
1275
1245
|
this.emit('endDraw', this);
|
|
1276
|
-
this.context.restore();
|
|
1277
|
-
|
|
1278
|
-
if (this.is('jmGraph') && this.context.draw) this.context.draw();
|
|
1246
|
+
this.context.restore();
|
|
1279
1247
|
this.needUpdate = false;
|
|
1280
1248
|
}
|
|
1281
1249
|
}
|
|
@@ -1441,8 +1409,8 @@ var jmControl = /*#__PURE__*/function (_jmProperty) {
|
|
|
1441
1409
|
//获取dom位置
|
|
1442
1410
|
var position = this.getPosition(); // 由于高清屏会有放大坐标,所以这里用pagex就只能用真实的canvas大小
|
|
1443
1411
|
|
|
1444
|
-
var right = position.left +
|
|
1445
|
-
var bottom = position.top +
|
|
1412
|
+
var right = position.left + this.width;
|
|
1413
|
+
var bottom = position.top + this.height;
|
|
1446
1414
|
|
|
1447
1415
|
if (p.pageX > right || p.pageX < position.left) {
|
|
1448
1416
|
return false;
|
|
@@ -2758,8 +2726,8 @@ var jmGraph = /*#__PURE__*/function (_jmControl) {
|
|
|
2758
2726
|
function getPosition() {
|
|
2759
2727
|
var p = _jmUtils.jmUtils.getElementPosition(this.canvas.canvas || this.canvas);
|
|
2760
2728
|
|
|
2761
|
-
p.width = this.
|
|
2762
|
-
p.height = this.
|
|
2729
|
+
p.width = this.width;
|
|
2730
|
+
p.height = this.height;
|
|
2763
2731
|
p.right = p.left + p.width;
|
|
2764
2732
|
p.bottom = p.top + p.height;
|
|
2765
2733
|
return p;
|
|
@@ -3096,13 +3064,13 @@ var jmGraph = /*#__PURE__*/function (_jmControl) {
|
|
|
3096
3064
|
if (self.needUpdate) self.redraw(); // 触发刷新事件
|
|
3097
3065
|
|
|
3098
3066
|
self.emit('update');
|
|
3099
|
-
self.__requestAnimationFrameFunHandler && _jmUtils.jmUtils.cancelAnimationFrame(self.__requestAnimationFrameFunHandler);
|
|
3100
|
-
self.__requestAnimationFrameFunHandler = _jmUtils.jmUtils.requestAnimationFrame(update);
|
|
3067
|
+
self.__requestAnimationFrameFunHandler && _jmUtils.jmUtils.cancelAnimationFrame(self.__requestAnimationFrameFunHandler, self.canvas);
|
|
3068
|
+
self.__requestAnimationFrameFunHandler = _jmUtils.jmUtils.requestAnimationFrame(update, self.canvas);
|
|
3101
3069
|
if (callback) callback();
|
|
3102
3070
|
}
|
|
3103
3071
|
|
|
3104
|
-
self.__requestAnimationFrameFunHandler && _jmUtils.jmUtils.cancelAnimationFrame(self.__requestAnimationFrameFunHandler);
|
|
3105
|
-
self.__requestAnimationFrameFunHandler = _jmUtils.jmUtils.requestAnimationFrame(update);
|
|
3072
|
+
self.__requestAnimationFrameFunHandler && _jmUtils.jmUtils.cancelAnimationFrame(self.__requestAnimationFrameFunHandler, self.canvas);
|
|
3073
|
+
self.__requestAnimationFrameFunHandler = _jmUtils.jmUtils.requestAnimationFrame(update, self.canvas);
|
|
3106
3074
|
return this;
|
|
3107
3075
|
} // 销毁当前对象
|
|
3108
3076
|
|
|
@@ -3596,6 +3564,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3596
3564
|
});
|
|
3597
3565
|
exports.jmProperty = exports["default"] = void 0;
|
|
3598
3566
|
|
|
3567
|
+
var _jmUtils = require("./jmUtils.js");
|
|
3568
|
+
|
|
3599
3569
|
var _jmObject2 = require("./jmObject.js");
|
|
3600
3570
|
|
|
3601
3571
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
@@ -3711,6 +3681,27 @@ var jmProperty = /*#__PURE__*/function (_jmObject) {
|
|
|
3711
3681
|
set: function set(v) {
|
|
3712
3682
|
return this.__pro('graph', v);
|
|
3713
3683
|
}
|
|
3684
|
+
/**
|
|
3685
|
+
* 在下次进行重绘时执行
|
|
3686
|
+
* @param {Function} handler
|
|
3687
|
+
*/
|
|
3688
|
+
|
|
3689
|
+
}, {
|
|
3690
|
+
key: "requestAnimationFrame",
|
|
3691
|
+
value: function requestAnimationFrame(handler) {
|
|
3692
|
+
return _jmUtils.jmUtils.requestAnimationFrame(handler, this.graph ? this.graph.canvas : null);
|
|
3693
|
+
}
|
|
3694
|
+
/**
|
|
3695
|
+
* 清除执行回调
|
|
3696
|
+
* @param {Function} handler
|
|
3697
|
+
* @returns
|
|
3698
|
+
*/
|
|
3699
|
+
|
|
3700
|
+
}, {
|
|
3701
|
+
key: "cancelAnimationFrame",
|
|
3702
|
+
value: function cancelAnimationFrame(handler) {
|
|
3703
|
+
return _jmUtils.jmUtils.cancelAnimationFrame(handler, this.graph ? this.graph.canvas : null);
|
|
3704
|
+
}
|
|
3714
3705
|
}]);
|
|
3715
3706
|
|
|
3716
3707
|
return jmProperty;
|
|
@@ -3718,7 +3709,7 @@ var jmProperty = /*#__PURE__*/function (_jmObject) {
|
|
|
3718
3709
|
|
|
3719
3710
|
exports.jmProperty = exports["default"] = jmProperty;
|
|
3720
3711
|
|
|
3721
|
-
},{"./jmObject.js":7}],10:[function(require,module,exports){
|
|
3712
|
+
},{"./jmObject.js":7,"./jmUtils.js":11}],10:[function(require,module,exports){
|
|
3722
3713
|
"use strict";
|
|
3723
3714
|
|
|
3724
3715
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -4326,12 +4317,12 @@ var jmUtils = /*#__PURE__*/function () {
|
|
|
4326
4317
|
p[i].y = x1 * sin + y1 * cos + rp.y;
|
|
4327
4318
|
}
|
|
4328
4319
|
} else {
|
|
4329
|
-
var
|
|
4320
|
+
var _x2 = p.x - rp.x;
|
|
4330
4321
|
|
|
4331
4322
|
var _y = p.y - rp.y;
|
|
4332
4323
|
|
|
4333
|
-
p.x =
|
|
4334
|
-
p.y =
|
|
4324
|
+
p.x = _x2 * cos - _y * sin + rp.x;
|
|
4325
|
+
p.y = _x2 * sin + _y * cos + rp.y;
|
|
4335
4326
|
}
|
|
4336
4327
|
|
|
4337
4328
|
return p;
|
|
@@ -4602,42 +4593,16 @@ var jmUtils = /*#__PURE__*/function () {
|
|
|
4602
4593
|
|
|
4603
4594
|
}, {
|
|
4604
4595
|
key: "requestAnimationFrame",
|
|
4605
|
-
value: function (
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
requestAnimationFrame.toString = function () {
|
|
4611
|
-
return _requestAnimationFrame.toString();
|
|
4612
|
-
};
|
|
4613
|
-
|
|
4614
|
-
return requestAnimationFrame;
|
|
4615
|
-
}(function (callback) {
|
|
4616
|
-
if (typeof requestAnimationFrame === 'undefined') {
|
|
4617
|
-
return setTimeout(callback, 20);
|
|
4618
|
-
} else {
|
|
4619
|
-
return requestAnimationFrame(callback);
|
|
4620
|
-
}
|
|
4621
|
-
})
|
|
4596
|
+
value: function requestAnimationFrame(callback, win) {
|
|
4597
|
+
var fun = win && win.requestAnimationFrame ? win.requestAnimationFrame : typeof window !== 'undefined' && window.requestAnimationFrame ? window.requestAnimationFrame : setTimeout;
|
|
4598
|
+
return fun(callback, 20);
|
|
4599
|
+
}
|
|
4622
4600
|
}, {
|
|
4623
4601
|
key: "cancelAnimationFrame",
|
|
4624
|
-
value: function (
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
cancelAnimationFrame.toString = function () {
|
|
4630
|
-
return _cancelAnimationFrame.toString();
|
|
4631
|
-
};
|
|
4632
|
-
|
|
4633
|
-
return cancelAnimationFrame;
|
|
4634
|
-
}(function (handler) {
|
|
4635
|
-
if (typeof requestAnimationFrame === 'undefined') {
|
|
4636
|
-
return clearTimeout(handler);
|
|
4637
|
-
} else {
|
|
4638
|
-
return cancelAnimationFrame(handler);
|
|
4639
|
-
}
|
|
4640
|
-
})
|
|
4602
|
+
value: function cancelAnimationFrame(handler, win) {
|
|
4603
|
+
var fun = win && win.cancelAnimationFrame ? win.cancelAnimationFrame : typeof window !== 'undefined' && window.cancelAnimationFrame ? window.cancelAnimationFrame : clearTimeout;
|
|
4604
|
+
return fun(handler);
|
|
4605
|
+
}
|
|
4641
4606
|
}]);
|
|
4642
4607
|
|
|
4643
4608
|
return jmUtils;
|