jmchart 1.2.7 → 1.2.9

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.
@@ -173,6 +173,151 @@
173
173
  }
174
174
  }
175
175
 
176
+ const colorKeywords = {
177
+ aliceblue: "#f0f8ff",
178
+ antiquewhite: "#faebd7",
179
+ aqua: "#00ffff",
180
+ aquamarine: "#7fffd4",
181
+ azure: "#f0ffff",
182
+ beige: "#f5f5dc",
183
+ bisque: "#ffe4c4",
184
+ black: "#000000",
185
+ blanchedalmond: "#ffebcd",
186
+ blue: "#0000ff",
187
+ blueviolet: "#8a2be2",
188
+ brown: "#a52a2a",
189
+ burlywood: "#deb887",
190
+ cadetblue: "#5f9ea0",
191
+ chartreuse: "#7fff00",
192
+ chocolate: "#d2691e",
193
+ coral: "#ff7f50",
194
+ cornflowerblue: "#6495ed",
195
+ cornsilk: "#fff8dc",
196
+ crimson: "#dc143c",
197
+ cyan: "#00ffff",
198
+ darkblue: "#00008b",
199
+ darkcyan: "#008b8b",
200
+ darkgoldenrod: "#b8860b",
201
+ darkgray: "#a9a9a9",
202
+ darkgreen: "#006400",
203
+ darkkhaki: "#bdb76b",
204
+ darkmagenta: "#8b008b",
205
+ darkolivegreen: "#556b2f",
206
+ darkorange: "#ff8c00",
207
+ darkorchid: "#9932cc",
208
+ darkred: "#8b0000",
209
+ darksalmon: "#e9967a",
210
+ darkseagreen: "#8fbc8f",
211
+ darkslateblue: "#483d8b",
212
+ darkslategray: "#2f4f4f",
213
+ darkturquoise: "#00ced1",
214
+ darkviolet: "#9400d3",
215
+ deeppink: "#ff1493",
216
+ deepskyblue: "#00bfff",
217
+ dimgray: "#696969",
218
+ dodgerblue: "#1e90ff",
219
+ firebrick: "#b22222",
220
+ floralwhite: "#fffaf0",
221
+ forestgreen: "#228b22",
222
+ fuchsia: "#ff00ff",
223
+ gainsboro: "#dcdcdc",
224
+ ghostwhite: "#f8f8ff",
225
+ gold: "#ffd700",
226
+ goldenrod: "#daa520",
227
+ gray: "#808080",
228
+ green: "#008000",
229
+ greenyellow: "#adff2f",
230
+ grey: "#808080",
231
+ honeydew: "#f0fff0",
232
+ hotpink: "#ff69b4",
233
+ indianred: "#cd5c5c",
234
+ indigo: "#4b0082",
235
+ ivory: "#fffff0",
236
+ khaki: "#f0e68c",
237
+ lavender: "#e6e6fa",
238
+ lavenderblush: "#fff0f5",
239
+ lawngreen: "#7cfc00",
240
+ lemonchiffon: "#fffacd",
241
+ lightblue: "#add8e6",
242
+ lightcoral: "#f08080",
243
+ lightcyan: "#e0ffff",
244
+ lightgoldenrodyellow: "#fafad2",
245
+ lightgrey: "#d3d3d3",
246
+ lightgreen: "#90ee90",
247
+ lightpink: "#ffb6c1",
248
+ lightsalmon: "#ffa07a",
249
+ lightseagreen: "#20b2aa",
250
+ lightskyblue: "#87cefa",
251
+ lightslategray: "#778899",
252
+ lightsteelblue: "#b0c4de",
253
+ lightyellow: "#ffffe0",
254
+ lime: "#00ff00",
255
+ limegreen: "#32cd32",
256
+ linen: "#faf0e6",
257
+ magenta: "#ff00ff",
258
+ maroon: "#800000",
259
+ mediumaquamarine: "#66cdaa",
260
+ mediumblue: "#0000cd",
261
+ mediumorchid: "#ba55d3",
262
+ mediumpurple: "#9370d8",
263
+ mediumseagreen: "#3cb371",
264
+ mediumslateblue: "#7b68ee",
265
+ mediumspringgreen: "#00fa9a",
266
+ mediumturquoise: "#48d1cc",
267
+ mediumvioletred: "#c71585",
268
+ midnightblue: "#191970",
269
+ mintcream: "#f5fffa",
270
+ mistyrose: "#ffe4e1",
271
+ moccasin: "#ffe4b5",
272
+ navajowhite: "#ffdead",
273
+ navy: "#000080",
274
+ oldlace: "#fdf5e6",
275
+ olive: "#808000",
276
+ olivedrab: "#6b8e23",
277
+ orange: "#ffa500",
278
+ orangered: "#ff4500",
279
+ orchid: "#da70d6",
280
+ palegoldenrod: "#eee8aa",
281
+ palegreen: "#98fb98",
282
+ paleturquoise: "#afeeee",
283
+ palevioletred: "#d87093",
284
+ papayawhip: "#ffefd5",
285
+ peachpuff: "#ffdab9",
286
+ peru: "#cd853f",
287
+ pink: "#ffc0cb",
288
+ plum: "#dda0dd",
289
+ powderblue: "#b0e0e6",
290
+ purple: "#800080",
291
+ red: "#ff0000",
292
+ rosybrown: "#bc8f8f",
293
+ royalblue: "#4169e1",
294
+ saddlebrown: "#8b4513",
295
+ salmon: "#fa8072",
296
+ sandybrown: "#f4a460",
297
+ seagreen: "#2e8b57",
298
+ seashell: "#fff5ee",
299
+ sienna: "#a0522d",
300
+ silver: "#c0c0c0",
301
+ skyblue: "#87ceeb",
302
+ slateblue: "#6a5acd",
303
+ slategray: "#708090",
304
+ snow: "#fffafa",
305
+ springgreen: "#00ff7f",
306
+ steelblue: "#4682b4",
307
+ tan: "#d2b48c",
308
+ teal: "#008080",
309
+ thistle: "#d8bfd8",
310
+ tomato: "#ff6347",
311
+ turquoise: "#40e0d0",
312
+ violet: "#ee82ee",
313
+ wheat: "#f5deb3",
314
+ white: "#ffffff",
315
+ whitesmoke: "#f5f5f5",
316
+ yellow: "#ffff00",
317
+ yellowgreen: "#9acd32",
318
+ transparent: "rgba(0,0,0,0)"
319
+ };
320
+
176
321
  /**
177
322
  * 画图基础对象
178
323
  * 当前库的工具类
@@ -235,7 +380,10 @@
235
380
  if(k === 'constructor') continue;
236
381
  const v = source[k];
237
382
  // 不复制页面元素和class对象
238
- if(v && (v.tagName || v.getContext)) continue;
383
+ if(v && (v.tagName || v.getContext)) {
384
+ target[k] = v;
385
+ continue;
386
+ }
239
387
 
240
388
  // 如果不是对象和空,则采用target的属性
241
389
  if(typeof target[k] === 'object' || typeof target[k] === 'undefined') {
@@ -785,65 +933,104 @@
785
933
  * @param {string}} hex 16进度的颜色
786
934
  */
787
935
  static hexToRGBA(hex) {
788
- hex = this.trim(hex);
936
+ if(typeof hex === 'string') hex = this.trim(hex);
937
+ else return hex;
938
+
939
+ // 如果缓存存在,则直接返回
940
+ this.__hexToRGBA_Cache = this.__hexToRGBA_Cache || {};
941
+ if(this.__hexToRGBA_Cache[hex]) return this.__hexToRGBA_Cache[hex];
942
+
943
+ let res = hex;
944
+
945
+ // 系统颜色
946
+ if(colorKeywords[res]) res = colorKeywords[res];
789
947
 
790
948
  //当为7位时,表示需要转为带透明度的rgba
791
- if(hex[0] == '#') {
949
+ if(res[0] == '#') {
792
950
  const color = {
793
951
  a: 1
794
952
  };
795
- if(hex.length >= 8) {
796
- color.a = hex.substr(1,2);
797
- color.g = hex.substr(5,2);
798
- color.b = hex.substr(7,2);
799
- color.r = hex.substr(3,2);
953
+ if(res.length >= 8) {
954
+ color.a = res.substr(1,2);
955
+ color.g = res.substr(5,2);
956
+ color.b = res.substr(7,2);
957
+ color.r = res.substr(3,2);
800
958
  //透明度
801
- color.a = (this.hexToNumber(color.a) / 255).toFixed(4);
959
+ color.a = Number((this.hexToNumber(color.a) / 255).toFixed(4));
802
960
 
803
961
  color.r = this.hexToNumber(color.r||0);
804
962
  color.g = this.hexToNumber(color.g||0);
805
963
  color.b = this.hexToNumber(color.b||0);
806
- return color;
964
+ res = color;
807
965
  }
808
966
  // #cccccc || #ccc
809
- else if(hex.length === 7 || hex.length === 4) {
967
+ else if(res.length === 7 || res.length === 4) {
810
968
  // #ccc这种情况,把每个位复制一份
811
- if(hex.length === 4) {
812
- color.g = hex.substr(2, 1);
969
+ if(res.length === 4) {
970
+ color.g = res.substr(2, 1);
813
971
  color.g = color.g + color.g;
814
- color.b = hex.substr(3, 1);
972
+ color.b = res.substr(3, 1);
815
973
  color.b = color.b + color.b;
816
- color.r = hex.substr(1, 1);
974
+ color.r = res.substr(1, 1);
817
975
  color.r = color.r + color.r;
818
976
  }
819
977
  else {
820
- color.g = hex.substr(3, 2);//除#号外的第二位
821
- color.b = hex.substr(5, 2);
822
- color.r = hex.substr(1, 2);
978
+ color.g = res.substr(3, 2);//除#号外的第二位
979
+ color.b = res.substr(5, 2);
980
+ color.r = res.substr(1, 2);
823
981
  }
824
982
 
825
983
  color.r = this.hexToNumber(color.r||0);
826
984
  color.g = this.hexToNumber(color.g||0);
827
985
  color.b = this.hexToNumber(color.b||0);
828
986
 
829
- return color;
987
+ res = color;
830
988
  }
831
989
  //如果是5位的话,# 则第2位表示A,后面依次是r,g,b
832
- else if(hex.length === 5) {
833
- color.a = hex.substr(1,1);
834
- color.g = hex.substr(3,1);//除#号外的第二位
835
- color.b = hex.substr(4,1);
836
- color.r = hex.substr(2,1);
990
+ else if(res.length === 5) {
991
+ color.a = res.substr(1,1);
992
+ color.g = res.substr(3,1);//除#号外的第二位
993
+ color.b = res.substr(4,1);
994
+ color.r = res.substr(2,1);
837
995
 
838
996
  color.r = this.hexToNumber(color.r||0);
839
997
  color.g = this.hexToNumber(color.g||0);
840
998
  color.b = this.hexToNumber(color.b||0);
841
999
  //透明度
842
- color.a = (this.hexToNumber(color.a) / 255).toFixed(4);
843
- return color;
1000
+ color.a = Number((this.hexToNumber(color.a) / 255).toFixed(4));
1001
+ res = color;
844
1002
  }
845
1003
  }
846
- return hex;
1004
+ if(typeof res === 'string') {
1005
+ const m = res.match(/rgb(a)?\s*\(\s*([\d\.]+)\s*,\s*([\d\.]+)\s*,\s*([\d\.]+)\s*(,\s*[\d\.]+)?\s*\)/i);
1006
+ if(m && m.length === 6) {
1007
+ const color = {
1008
+ r: Number(m[2]),
1009
+ g: Number(m[3]),
1010
+ b: Number(m[4]),
1011
+ a: Number(this.trimStart(m[5]||'1', ','))
1012
+ };
1013
+ res = color;
1014
+ }
1015
+ }
1016
+ return this.__hexToRGBA_Cache[hex] = res;
1017
+ }
1018
+
1019
+ /**
1020
+ * 把255的rgb值转为0-1的值
1021
+ * @param {rgba} color 颜色
1022
+ */
1023
+ static rgbToDecimal(color) {
1024
+ color = this.clone(color);
1025
+ color.r = this.byteToDecimal(color.r);
1026
+ color.g = this.byteToDecimal(color.g);
1027
+ color.b = this.byteToDecimal(color.b);
1028
+ return color;
1029
+ }
1030
+
1031
+ //255值转为0-1的小数
1032
+ static byteToDecimal(b) {
1033
+ return b / 255;
847
1034
  }
848
1035
 
849
1036
  /**
@@ -863,10 +1050,10 @@
863
1050
  const color = this.hexToRGBA(r);
864
1051
  if(typeof color === 'string') return color;
865
1052
 
866
- r = color.r || r;
867
- g = color.g || g;
868
- b = color.b || b;
869
- a = color.a || a;
1053
+ r = typeof color.r !== 'undefined'? color.r: r;
1054
+ g = typeof color.g !== 'undefined'? color.g: g;
1055
+ b = typeof color.b !== 'undefined'? color.b: b;
1056
+ a = typeof color.a !== 'undefined'? color.a: a;
870
1057
  }
871
1058
  if(typeof r != 'undefined' && typeof g != 'undefined' && typeof b != 'undefined') {
872
1059
  if(typeof a != 'undefined') {
@@ -972,8 +1159,13 @@
972
1159
  let sy1 = Number(y1) + bounds.top;
973
1160
  let sx2 = Number(x2) + bounds.left;
974
1161
  let sy2 = Number(y2) + bounds.top;
975
- if(this.type === 'linear') {
976
- gradient = context.createLinearGradient(sx1, sy1, sx2, sy2);
1162
+ if(this.type === 'linear') {
1163
+ if(control.mode === 'webgl' && control.webglControl) {
1164
+ gradient = control.webglControl.createLinearGradient(x1, y1, x2, y2, bounds);
1165
+ }
1166
+ else {
1167
+ context.createLinearGradient && (gradient = context.createLinearGradient(sx1, sy1, sx2, sy2));
1168
+ }
977
1169
  }
978
1170
  else if(this.type === 'radial') {
979
1171
  let r1 = this.r1||0;
@@ -985,22 +1177,32 @@
985
1177
  if(jmUtils.checkPercent(r2)) {
986
1178
  r2 = jmUtils.percentToNumber(r2);
987
1179
  r2 = d * r2;
1180
+ }
1181
+ if(control.mode === 'webgl' && control.webglControl) {
1182
+ gradient = control.webglControl.createRadialGradient(x1, y1, r1, x2, y2, r2, bounds);
988
1183
  }
989
1184
  //offsetLine = Math.abs(r2 - r1);//二圆半径差
1185
+ else if(context.createRadialGradient) {
1186
+ gradient = context.createRadialGradient(sx1, sy1, r1, sx2, sy2, r2);
1187
+ }
990
1188
  //小程序的接口特殊
991
- if(context.createCircularGradient) {
1189
+ else if(context.createCircularGradient) {
992
1190
  gradient = context.createCircularGradient(sx1, sy1, r2);
993
1191
  }
994
- else {
995
- gradient = context.createRadialGradient(sx1, sy1, r1, sx2, sy2, r2);
996
- }
997
1192
  }
1193
+
998
1194
  //颜色渐变
999
- this.stops.each(function(i,s) {
1000
- let c = jmUtils.toColor(s.color);
1001
- //s.offset 0.0 ~ 1.0
1002
- gradient.addColorStop(s.offset, c);
1003
- });
1195
+ if(gradient) {
1196
+ this.stops.each(function(i,s) {
1197
+ let c = jmUtils.toColor(s.color);
1198
+ //s.offset 0.0 ~ 1.0
1199
+ gradient && gradient.addColorStop(s.offset, c);
1200
+ });
1201
+ }
1202
+ else {
1203
+ const s = this.stops.get(0);
1204
+ return (s && s.color) || '#000';
1205
+ }
1004
1206
 
1005
1207
  return gradient;
1006
1208
  }
@@ -1079,14 +1281,14 @@
1079
1281
  toString() {
1080
1282
  let str = this.type + '-gradient(';
1081
1283
  if(this.type == 'linear') {
1082
- str += this.x1 + ' ' + this.y1 + ' ' + this.x2 + ' ' + this.y2;
1284
+ str += this.x1.toFixed(2) + ' ' + this.y1.toFixed(2) + ' ' + this.x2.toFixed(2) + ' ' + this.y2.toFixed(2);
1083
1285
  }
1084
1286
  else {
1085
- str += this.x1 + ' ' + this.y1 + ' ' + this.r1 + ' ' + this.x2 + ' ' + this.y2 + ' ' + this.r2;
1287
+ str += this.x1.toFixed(2) + ' ' + this.y1.toFixed(2) + ' ' + this.r1.toFixed(2) + ' ' + this.x2.toFixed(2) + ' ' + this.y2.toFixed(2) + ' ' + this.r2.toFixed(2);
1086
1288
  }
1087
1289
  //颜色渐变
1088
1290
  this.stops.each(function(i,s) {
1089
- str += ',' + s.color + ' ' + s.offset;
1291
+ str += ',' + s.color + ' ' + s.offset.toFixed(2);
1090
1292
  });
1091
1293
  return str + ')';
1092
1294
  }
@@ -1155,6 +1357,7 @@
1155
1357
  }
1156
1358
  }
1157
1359
 
1360
+ var control_id_counter = 0;
1158
1361
  /**
1159
1362
  * 所有jm对象的基础对象
1160
1363
  *
@@ -1167,7 +1370,7 @@
1167
1370
  if(g && g.type == 'jmGraph') {
1168
1371
  this.graph = g;
1169
1372
  }
1170
- //this.id = Symbol("id"); //生成一个唯一id
1373
+ this.id = ++control_id_counter; //生成一个唯一id
1171
1374
  }
1172
1375
 
1173
1376
  /**
@@ -1265,31 +1468,31 @@
1265
1468
  */
1266
1469
  class jmProperty extends jmObject {
1267
1470
 
1268
- constructor() {
1471
+ constructor(params) {
1269
1472
  super();
1270
-
1271
1473
  this[PROPERTY_KEY] = {};
1474
+ if(params && params.mode) this.mode = params.mode;
1272
1475
  }
1273
1476
 
1274
1477
  /**
1275
1478
  * 基础属性读写接口
1276
- * @method __pro
1479
+ * @method property
1277
1480
  * @param {string} name 属性名
1278
1481
  * @param {any} value 属性的值
1279
1482
  * @returns {any} 属性的值
1280
1483
  */
1281
- __pro(...pars) {
1484
+ property(...pars) {
1282
1485
  if(pars) {
1283
- let pros = this[PROPERTY_KEY];
1284
- let name = pars[0];
1486
+ const pros = this[PROPERTY_KEY];
1487
+ const name = pars[0];
1285
1488
  if(pars.length > 1) {
1286
- let value = pars[1];
1287
- let args = {oldValue: pros[name], newValue: value};
1489
+ const value = pars[1];
1490
+ const args = {oldValue: pros[name], newValue: value};
1288
1491
  pros[name] = pars[1];
1289
1492
  if(this.emit) this.emit('propertyChange', name, args);
1290
1493
  return pars[1];
1291
1494
  }
1292
- else if(pars.length == 1) {
1495
+ else if(name) {
1293
1496
  return pros[name];
1294
1497
  }
1295
1498
  }
@@ -1301,10 +1504,10 @@
1301
1504
  * @type {boolean}
1302
1505
  */
1303
1506
  get needUpdate() {
1304
- return this.__pro('needUpdate');
1507
+ return this.property('needUpdate');
1305
1508
  }
1306
1509
  set needUpdate(v) {
1307
- this.__pro('needUpdate', v);
1510
+ this.property('needUpdate', v);
1308
1511
  //子控件属性改变,需要更新整个画板
1309
1512
  if(v && !this.is('jmGraph') && this.graph) {
1310
1513
  this.graph.needUpdate = true;
@@ -1317,12 +1520,27 @@
1317
1520
  * @type {jmGraph}
1318
1521
  */
1319
1522
  get graph() {
1320
- let g = this.__pro('graph');
1321
- g = g || (this.__pro('graph', this.findParent('jmGraph')));
1523
+ let g = this.property('graph');
1524
+ g = g || (this.property('graph', this.findParent('jmGraph')));
1322
1525
  return g;
1323
1526
  }
1324
1527
  set graph(v) {
1325
- return this.__pro('graph', v);
1528
+ return this.property('graph', v);
1529
+ }
1530
+
1531
+ /**
1532
+ * 绘制模式 2d/webgl
1533
+ * @property mode
1534
+ * @type {string}
1535
+ */
1536
+ get mode() {
1537
+ let m = this.property('mode');
1538
+ if(m) return m;
1539
+ else if(this.is('jmGraph')) return this.property('mode');
1540
+ return this.graph.mode;
1541
+ }
1542
+ set mode(v) {
1543
+ return this.property('mode', v);
1326
1544
  }
1327
1545
 
1328
1546
  /**
@@ -1342,9 +1560,12 @@
1342
1560
  }
1343
1561
  }
1344
1562
 
1563
+ //import WebglPath from "../lib/webgl/path.js";
1564
+
1345
1565
  //样式名称,也当做白名单使用
1346
1566
  const jmStyleMap = {
1347
1567
  'fill':'fillStyle',
1568
+ 'fillImage':'fillImage',
1348
1569
  'stroke':'strokeStyle',
1349
1570
  'shadow.blur':'shadowBlur',
1350
1571
  'shadow.x':'shadowOffsetX',
@@ -1377,8 +1598,8 @@
1377
1598
 
1378
1599
  constructor(params, t) {
1379
1600
  params = params||{};
1380
- super();
1381
- this.__pro('type', t || new.target.name);
1601
+ super(params);
1602
+ this.property('type', t || new.target.name);
1382
1603
  this.style = params && params.style ? params.style : {};
1383
1604
  //this.position = params.position || {x:0,y:0};
1384
1605
  this.width = params.width || 0;
@@ -1392,6 +1613,15 @@
1392
1613
  this.zIndex = params.zIndex || 0;
1393
1614
  this.interactive = typeof params.interactive == 'undefined'? true : params.interactive;
1394
1615
 
1616
+ // webgl模式
1617
+ /*if(this.mode === 'webgl') {
1618
+ this.webglControl = new WebglPath(this.graph, {
1619
+ style: this.style,
1620
+ isRegular: params.isRegular,
1621
+ needCut: params.needCut
1622
+ });
1623
+ }*/
1624
+
1395
1625
  this.initializing();
1396
1626
 
1397
1627
  this.on = this.bind;
@@ -1407,7 +1637,7 @@
1407
1637
  * @type string
1408
1638
  */
1409
1639
  get type() {
1410
- return this.__pro('type');
1640
+ return this.property('type');
1411
1641
  }
1412
1642
 
1413
1643
  /**
@@ -1416,17 +1646,17 @@
1416
1646
  * @type {object}
1417
1647
  */
1418
1648
  get context() {
1419
- let s = this.__pro('context');
1649
+ let s = this.property('context');
1420
1650
  if(s) return s;
1421
1651
  else if(this.is('jmGraph') && this.canvas && this.canvas.getContext) {
1422
- return this.context = this.canvas.getContext('2d');
1652
+ return this.context = this.canvas.getContext(this.mode || '2d');
1423
1653
  }
1424
- let g = this.graph;
1654
+ const g = this.graph;
1425
1655
  if(g) return g.context;
1426
- return g.canvas.getContext('2d');
1656
+ return g.canvas.getContext(this.mode || '2d');
1427
1657
  }
1428
1658
  set context(v) {
1429
- return this.__pro('context', v);
1659
+ return this.property('context', v);
1430
1660
  }
1431
1661
 
1432
1662
  /**
@@ -1435,13 +1665,13 @@
1435
1665
  * @type {object}
1436
1666
  */
1437
1667
  get style() {
1438
- let s = this.__pro('style');
1439
- if(!s) s = this.__pro('style', {});
1668
+ let s = this.property('style');
1669
+ if(!s) s = this.property('style', {});
1440
1670
  return s;
1441
1671
  }
1442
1672
  set style(v) {
1443
1673
  this.needUpdate = true;
1444
- return this.__pro('style', v);
1674
+ return this.property('style', v);
1445
1675
  }
1446
1676
 
1447
1677
  /**
@@ -1451,13 +1681,13 @@
1451
1681
  * @type {boolean}
1452
1682
  */
1453
1683
  get visible() {
1454
- let s = this.__pro('visible');
1455
- if(typeof s == 'undefined') s = this.__pro('visible', true);
1684
+ let s = this.property('visible');
1685
+ if(typeof s == 'undefined') s = this.property('visible', true);
1456
1686
  return s;
1457
1687
  }
1458
1688
  set visible(v) {
1459
1689
  this.needUpdate = true;
1460
- return this.__pro('visible', v);
1690
+ return this.property('visible', v);
1461
1691
  }
1462
1692
 
1463
1693
  /**
@@ -1468,11 +1698,11 @@
1468
1698
  * @type {boolean}
1469
1699
  */
1470
1700
  get interactive() {
1471
- let s = this.__pro('interactive');
1701
+ let s = this.property('interactive');
1472
1702
  return s;
1473
1703
  }
1474
1704
  set interactive(v) {
1475
- return this.__pro('interactive', v);
1705
+ return this.property('interactive', v);
1476
1706
  }
1477
1707
 
1478
1708
  /**
@@ -1481,13 +1711,13 @@
1481
1711
  * @type {list}
1482
1712
  */
1483
1713
  get children() {
1484
- let s = this.__pro('children');
1485
- if(!s) s = this.__pro('children', new jmList());
1714
+ let s = this.property('children');
1715
+ if(!s) s = this.property('children', new jmList());
1486
1716
  return s;
1487
1717
  }
1488
1718
  set children(v) {
1489
1719
  this.needUpdate = true;
1490
- return this.__pro('children', v);
1720
+ return this.property('children', v);
1491
1721
  }
1492
1722
 
1493
1723
  /**
@@ -1496,13 +1726,13 @@
1496
1726
  * @type {number}
1497
1727
  */
1498
1728
  get width() {
1499
- let s = this.__pro('width');
1500
- if(typeof s == 'undefined') s = this.__pro('width', 0);
1729
+ let s = this.property('width');
1730
+ if(typeof s == 'undefined') s = this.property('width', 0);
1501
1731
  return s;
1502
1732
  }
1503
1733
  set width(v) {
1504
1734
  this.needUpdate = true;
1505
- return this.__pro('width', v);
1735
+ return this.property('width', v);
1506
1736
  }
1507
1737
 
1508
1738
  /**
@@ -1511,13 +1741,13 @@
1511
1741
  * @type {number}
1512
1742
  */
1513
1743
  get height() {
1514
- let s = this.__pro('height');
1515
- if(typeof s == 'undefined') s = this.__pro('height', 0);
1744
+ let s = this.property('height');
1745
+ if(typeof s == 'undefined') s = this.property('height', 0);
1516
1746
  return s;
1517
1747
  }
1518
1748
  set height(v) {
1519
1749
  this.needUpdate = true;
1520
- return this.__pro('height', v);
1750
+ return this.property('height', v);
1521
1751
  }
1522
1752
 
1523
1753
  /**
@@ -1526,13 +1756,13 @@
1526
1756
  * @type {number}
1527
1757
  */
1528
1758
  get zIndex() {
1529
- let s = this.__pro('zIndex');
1530
- if(!s) s = this.__pro('zIndex', 0);
1759
+ let s = this.property('zIndex');
1760
+ if(!s) s = this.property('zIndex', 0);
1531
1761
  return s;
1532
1762
  }
1533
1763
  set zIndex(v) {
1534
1764
  this.needUpdate = true;
1535
- this.__pro('zIndex', v);
1765
+ this.property('zIndex', v);
1536
1766
  this.children.sort();//层级发生改变,需要重新排序
1537
1767
  this.needUpdate = true;
1538
1768
  return v;
@@ -1713,12 +1943,25 @@
1713
1943
  __setStyle(styleValue.toGradient(this), mpname||name);
1714
1944
  }
1715
1945
  else if(mpname) {
1716
- //只有存在白名单中才处理
1717
- //颜色转换
1718
- if(t == 'string' && ['fillStyle', 'strokeStyle', 'shadowColor'].indexOf(mpname) > -1) {
1719
- styleValue = jmUtils.toColor(styleValue);
1946
+
1947
+ if(this.webglControl) {
1948
+ //只有存在白名单中才处理
1949
+ //颜色转换
1950
+ if(t == 'string' && ['fillStyle', 'strokeStyle', 'shadowColor'].indexOf(mpname) > -1) {
1951
+ styleValue = jmUtils.hexToRGBA(styleValue);
1952
+ }
1953
+
1954
+ this.webglControl.setStyle(mpname, styleValue);
1955
+ }
1956
+ else {
1957
+ //只有存在白名单中才处理
1958
+ //颜色转换
1959
+ if(t == 'string' && ['fillStyle', 'strokeStyle', 'shadowColor'].indexOf(mpname) > -1) {
1960
+ styleValue = jmUtils.toColor(styleValue);
1961
+ }
1962
+
1963
+ this.context[mpname] = styleValue;
1720
1964
  }
1721
- this.context[mpname] = styleValue;
1722
1965
  }
1723
1966
  else {
1724
1967
  switch(name) {
@@ -1735,7 +1978,7 @@
1735
1978
  }
1736
1979
  //平移
1737
1980
  case 'translate' : {
1738
- this.context.translate(styleValue.x, styleValue.y);
1981
+ this.context.translate && this.context.translate(styleValue.x, styleValue.y);
1739
1982
  break;
1740
1983
  }
1741
1984
  //旋转
@@ -1754,9 +1997,9 @@
1754
1997
  tranY = styleValue.rotateY + bounds.top;
1755
1998
  }
1756
1999
 
1757
- if(tranX!=0 || tranY != 0) this.context.translate(tranX,tranY);
2000
+ if(tranX!=0 || tranY != 0) this.context.translate && this.context.translate(tranX,tranY);
1758
2001
  this.context.rotate(styleValue.angle);
1759
- if(tranX!=0 || tranY != 0) this.context.translate(-tranX,-tranY);
2002
+ if(tranX!=0 || tranY != 0) this.context.translate && this.context.translate(-tranX,-tranY);
1760
2003
  break;
1761
2004
  }
1762
2005
  case 'transform' : {
@@ -2115,7 +2358,8 @@
2115
2358
  */
2116
2359
  beginDraw() {
2117
2360
  this.getLocation(true);//重置位置信息
2118
- this.context.beginPath();
2361
+ this.context.beginPath && this.context.beginPath();
2362
+ //if(this.webglControl && this.webglControl.beginDraw) this.webglControl.beginDraw();
2119
2363
  }
2120
2364
 
2121
2365
  /**
@@ -2126,16 +2370,24 @@
2126
2370
  endDraw() {
2127
2371
  //如果当前为封闭路径
2128
2372
  if(this.style.close) {
2129
- this.context.closePath();
2373
+ //if(this.webglControl) this.webglControl.closePath();
2374
+ this.context.closePath && this.context.closePath();
2130
2375
  }
2131
2376
 
2132
2377
  if(this.style['fill']) {
2133
- this.context.fill();
2378
+ /*if(this.webglControl) {
2379
+ const bounds = this.getBounds();
2380
+ this.webglControl.fill(bounds);
2381
+ }*/
2382
+ this.context.fill && this.context.fill();
2134
2383
  }
2135
- if(this.style['stroke'] || !this.style['fill']) {
2136
- this.context.stroke();
2384
+ if(this.style['stroke'] || (!this.style['fill'] && !this.is('jmGraph'))) {
2385
+ //if(this.webglControl) this.webglControl.stroke();
2386
+ this.context.stroke && this.context.stroke();
2137
2387
  }
2138
2388
 
2389
+ //if(this.webglControl && this.webglControl.endDraw) this.webglControl.endDraw();
2390
+
2139
2391
  this.needUpdate = false;
2140
2392
  }
2141
2393
 
@@ -2148,20 +2400,27 @@
2148
2400
  draw() {
2149
2401
  if(this.points && this.points.length > 0) {
2150
2402
  //获取当前控件的绝对位置
2151
- let bounds = this.parent && this.parent.absoluteBounds?this.parent.absoluteBounds:this.absoluteBounds;
2152
-
2153
- this.context.moveTo(this.points[0].x + bounds.left,this.points[0].y + bounds.top);
2154
- let len = this.points.length;
2155
- for(let i=1; i < len;i++) {
2156
- let p = this.points[i];
2157
- //移至当前坐标
2158
- if(p.m) {
2159
- this.context.moveTo(p.x + bounds.left,p.y + bounds.top);
2160
- }
2161
- else {
2162
- this.context.lineTo(p.x+ bounds.left,p.y + bounds.top);
2163
- }
2164
- }
2403
+ const bounds = this.parent && this.parent.absoluteBounds?this.parent.absoluteBounds:this.absoluteBounds;
2404
+ /*if(this.webglControl) {
2405
+ this.webglControl.setParentBounds(bounds);
2406
+ this.webglControl.draw([
2407
+ ...this.points
2408
+ ]);
2409
+ }*/
2410
+ if(this.context && this.context.moveTo) {
2411
+ this.context.moveTo(this.points[0].x + bounds.left,this.points[0].y + bounds.top);
2412
+ let len = this.points.length;
2413
+ for(let i=1; i < len;i++) {
2414
+ let p = this.points[i];
2415
+ //移至当前坐标
2416
+ if(p.m) {
2417
+ this.context.moveTo(p.x + bounds.left,p.y + bounds.top);
2418
+ }
2419
+ else {
2420
+ this.context.lineTo(p.x+ bounds.left,p.y + bounds.top);
2421
+ }
2422
+ }
2423
+ }
2165
2424
  }
2166
2425
  }
2167
2426
 
@@ -2185,7 +2444,7 @@
2185
2444
  else if(this.absoluteBounds.bottom <= 0) needDraw = false;
2186
2445
  }
2187
2446
 
2188
- this.context.save();
2447
+ this.context.save && this.context.save();
2189
2448
 
2190
2449
  this.emit('beginDraw', this);
2191
2450
 
@@ -2202,7 +2461,7 @@
2202
2461
  }
2203
2462
 
2204
2463
  this.emit('endDraw',this);
2205
- this.context.restore();
2464
+ this.context.restore && this.context.restore();
2206
2465
 
2207
2466
  this.needUpdate = false;
2208
2467
  }
@@ -2702,7 +2961,7 @@
2702
2961
  constructor(params, t='jmPath') {
2703
2962
  super(params, t);
2704
2963
  this.points = params && params.points ? params.points : [];
2705
-
2964
+ this.polygonIndices = params && params.polygonIndices ? params.polygonIndices : [];
2706
2965
  }
2707
2966
 
2708
2967
  /**
@@ -2712,13 +2971,29 @@
2712
2971
  * @type {array}
2713
2972
  */
2714
2973
  get points() {
2715
- let s = this.__pro('points');
2974
+ let s = this.property('points');
2716
2975
  return s;
2717
2976
  }
2718
2977
  set points(v) {
2719
2978
  this.needUpdate = true;
2720
- return this.__pro('points', v);
2979
+ return this.property('points', v);
2980
+ }
2981
+
2982
+ /**
2983
+ * 顶点数组索引,对应points中的顶点
2984
+ * @property polygonIndices
2985
+ * @type {array}
2986
+ */
2987
+ get polygonIndices() {
2988
+ let s = this.property('polygonIndices');
2989
+ return s;
2990
+ }
2991
+ set polygonIndices(v) {
2992
+ this.needUpdate = true;
2993
+ return this.property('polygonIndices', v);
2721
2994
  }
2995
+
2996
+
2722
2997
  }
2723
2998
 
2724
2999
  /**
@@ -2732,6 +3007,9 @@
2732
3007
 
2733
3008
  constructor(params, t='jmArc') {
2734
3009
  if(!params) params = {};
3010
+ params.isRegular = params.isRegular === false? false: true;// 规则的
3011
+ params.needCut = params.needCut === true? true: false;// 规则的
3012
+
2735
3013
  super(params, t);
2736
3014
 
2737
3015
  this.center = params.center || {x:0,y:0};
@@ -2752,11 +3030,11 @@
2752
3030
  * @type {point}
2753
3031
  */
2754
3032
  get center() {
2755
- return this.__pro('center');
3033
+ return this.property('center');
2756
3034
  }
2757
3035
  set center(v) {
2758
3036
  this.needUpdate = true;
2759
- return this.__pro('center', v);
3037
+ return this.property('center', v);
2760
3038
  }
2761
3039
 
2762
3040
  /**
@@ -2765,11 +3043,11 @@
2765
3043
  * @type {number}
2766
3044
  */
2767
3045
  get radius() {
2768
- return this.__pro('radius');
3046
+ return this.property('radius');
2769
3047
  }
2770
3048
  set radius(v) {
2771
3049
  this.needUpdate = true;
2772
- return this.__pro('radius', v);
3050
+ return this.property('radius', v);
2773
3051
  }
2774
3052
 
2775
3053
  /**
@@ -2778,11 +3056,11 @@
2778
3056
  * @type {number}
2779
3057
  */
2780
3058
  get startAngle() {
2781
- return this.__pro('startAngle');
3059
+ return this.property('startAngle');
2782
3060
  }
2783
3061
  set startAngle(v) {
2784
3062
  this.needUpdate = true;
2785
- return this.__pro('startAngle', v);
3063
+ return this.property('startAngle', v);
2786
3064
  }
2787
3065
 
2788
3066
  /**
@@ -2791,11 +3069,11 @@
2791
3069
  * @type {number}
2792
3070
  */
2793
3071
  get endAngle() {
2794
- return this.__pro('endAngle');
3072
+ return this.property('endAngle');
2795
3073
  }
2796
3074
  set endAngle(v) {
2797
3075
  this.needUpdate = true;
2798
- return this.__pro('endAngle', v);
3076
+ return this.property('endAngle', v);
2799
3077
  }
2800
3078
 
2801
3079
  /**
@@ -2805,11 +3083,11 @@
2805
3083
  * @type {boolean}
2806
3084
  */
2807
3085
  get anticlockwise() {
2808
- return this.__pro('anticlockwise');
3086
+ return this.property('anticlockwise');
2809
3087
  }
2810
3088
  set anticlockwise(v) {
2811
3089
  this.needUpdate = true;
2812
- return this.__pro('anticlockwise', v);
3090
+ return this.property('anticlockwise', v);
2813
3091
  }
2814
3092
 
2815
3093
 
@@ -2859,7 +3137,7 @@
2859
3137
  if(step > 0 && r > end) r = end;
2860
3138
  else if(step < 0 && r < end) r = end;
2861
3139
 
2862
- let p = {
3140
+ const p = {
2863
3141
  x : Math.cos(r) * mw + cx,
2864
3142
  y : Math.sin(r) * mh + cy
2865
3143
  };
@@ -2900,11 +3178,11 @@
2900
3178
  * @type {point}
2901
3179
  */
2902
3180
  get start() {
2903
- return this.__pro('start');
3181
+ return this.property('start');
2904
3182
  }
2905
3183
  set start(v) {
2906
3184
  this.needUpdate = true;
2907
- return this.__pro('start', v);
3185
+ return this.property('start', v);
2908
3186
  }
2909
3187
 
2910
3188
  /**
@@ -2915,11 +3193,11 @@
2915
3193
  * @type {point} 结束点
2916
3194
  */
2917
3195
  get end() {
2918
- return this.__pro('end');
3196
+ return this.property('end');
2919
3197
  }
2920
3198
  set end(v) {
2921
3199
  this.needUpdate = true;
2922
- return this.__pro('end', v);
3200
+ return this.property('end', v);
2923
3201
  }
2924
3202
 
2925
3203
  /**
@@ -2930,11 +3208,11 @@
2930
3208
  * @type {number} 箭头角度
2931
3209
  */
2932
3210
  get angle() {
2933
- return this.__pro('angle');
3211
+ return this.property('angle');
2934
3212
  }
2935
3213
  set angle(v) {
2936
3214
  this.needUpdate = true;
2937
- return this.__pro('angle', v);
3215
+ return this.property('angle', v);
2938
3216
  }
2939
3217
 
2940
3218
  /**
@@ -2945,11 +3223,11 @@
2945
3223
  * @type {number}
2946
3224
  */
2947
3225
  get offsetX() {
2948
- return this.__pro('offsetX');
3226
+ return this.property('offsetX');
2949
3227
  }
2950
3228
  set offsetX(v) {
2951
3229
  this.needUpdate = true;
2952
- return this.__pro('offsetX', v);
3230
+ return this.property('offsetX', v);
2953
3231
  }
2954
3232
 
2955
3233
  /**
@@ -2960,11 +3238,11 @@
2960
3238
  * @type {number}
2961
3239
  */
2962
3240
  get offsetY() {
2963
- return this.__pro('offsetY');
3241
+ return this.property('offsetY');
2964
3242
  }
2965
3243
  set offsetY(v) {
2966
3244
  this.needUpdate = true;
2967
- return this.__pro('offsetY', v);
3245
+ return this.property('offsetY', v);
2968
3246
  }
2969
3247
 
2970
3248
  /**
@@ -3056,11 +3334,11 @@
3056
3334
  * @type {array}
3057
3335
  */
3058
3336
  get cpoints() {
3059
- return this.__pro('cpoints');
3337
+ return this.property('cpoints');
3060
3338
  }
3061
3339
  set cpoints(v) {
3062
3340
  this.needUpdate = true;
3063
- return this.__pro('cpoints', v);
3341
+ return this.property('cpoints', v);
3064
3342
  }
3065
3343
 
3066
3344
  /**
@@ -3147,6 +3425,7 @@
3147
3425
  class jmCircle extends jmArc {
3148
3426
 
3149
3427
  constructor(params, t='jmCircle') {
3428
+ params.isRegular = true;// 规则的
3150
3429
  super(params, t);
3151
3430
  }
3152
3431
  /**
@@ -3156,7 +3435,10 @@
3156
3435
  * @private
3157
3436
  * @for jmCircle
3158
3437
  */
3159
- initPoints() {
3438
+ initPoints() {
3439
+ if(this.graph.mode === 'webgl') {
3440
+ return super.initPoints();
3441
+ }
3160
3442
  let location = this.getLocation();
3161
3443
 
3162
3444
  if(!location.radius) {
@@ -3175,6 +3457,9 @@
3175
3457
  * @method draw
3176
3458
  */
3177
3459
  draw() {
3460
+ if(this.graph.mode === 'webgl') {
3461
+ return super.draw();
3462
+ }
3178
3463
  let bounds = this.parent && this.parent.absoluteBounds?this.parent.absoluteBounds:this.absoluteBounds;
3179
3464
  let location = this.getLocation();
3180
3465
 
@@ -3200,6 +3485,8 @@
3200
3485
  class jmHArc extends jmArc {
3201
3486
 
3202
3487
  constructor(params, t='jmHArc') {
3488
+ params.isRegular = true;// 规则的
3489
+ params.needCut = true;
3203
3490
  super(params, t);
3204
3491
 
3205
3492
  this.minRadius = params.minRadius || this.style.minRadius || 0;
@@ -3214,11 +3501,11 @@
3214
3501
  * @type {number}
3215
3502
  */
3216
3503
  get minRadius() {
3217
- return this.__pro('minRadius');
3504
+ return this.property('minRadius');
3218
3505
  }
3219
3506
  set minRadius(v) {
3220
3507
  this.needUpdate = true;
3221
- return this.__pro('minRadius', v);
3508
+ return this.property('minRadius', v);
3222
3509
  }
3223
3510
 
3224
3511
  /**
@@ -3229,11 +3516,11 @@
3229
3516
  * @type {number}
3230
3517
  */
3231
3518
  get maxRadius() {
3232
- return this.__pro('maxRadius');
3519
+ return this.property('maxRadius');
3233
3520
  }
3234
3521
  set maxRadius(v) {
3235
3522
  this.needUpdate = true;
3236
- return this.__pro('maxRadius', v);
3523
+ return this.property('maxRadius', v);
3237
3524
  }
3238
3525
 
3239
3526
  /**
@@ -3243,18 +3530,18 @@
3243
3530
  * @private
3244
3531
  */
3245
3532
  initPoints() {
3246
- let location = this.getLocation();
3533
+ const location = this.getLocation();
3247
3534
  //如果设定了半径。则以半径为主
3248
- let minr = this.minRadius;
3249
- let maxr = this.maxRadius;
3535
+ const minr = this.minRadius;
3536
+ const maxr = this.maxRadius;
3250
3537
 
3251
3538
  let start = this.startAngle;
3252
3539
  let end = this.endAngle;
3253
- let anticlockwise = this.anticlockwise;
3540
+ const anticlockwise = this.anticlockwise;
3254
3541
 
3255
3542
  //如果是逆时针绘制,则角度为负数,并且结束角为2Math.PI-end
3256
3543
  if(anticlockwise) {
3257
- let p2 = Math.PI*2;
3544
+ const p2 = Math.PI*2;
3258
3545
  start = p2 - start;
3259
3546
  end = p2 - end;
3260
3547
  }
@@ -3262,8 +3549,8 @@
3262
3549
  let step = 0.1;
3263
3550
  if(start > end) step = -step;
3264
3551
 
3265
- let minps = [];
3266
- let maxps = [];
3552
+ const minps = [];
3553
+ const maxps = [];
3267
3554
  //椭圆方程x=a*cos(r) ,y=b*sin(r)
3268
3555
  for(let r=start;;r += step) {
3269
3556
  if(step > 0 && r > end) {
@@ -3273,13 +3560,13 @@
3273
3560
  r = end;
3274
3561
  }
3275
3562
 
3276
- let cos = Math.cos(r);
3277
- let sin = Math.sin(r);
3278
- let p1 = {
3563
+ const cos = Math.cos(r);
3564
+ const sin = Math.sin(r);
3565
+ const p1 = {
3279
3566
  x : cos * minr + location.center.x,
3280
3567
  y : sin * minr + location.center.y
3281
3568
  };
3282
- let p2 = {
3569
+ const p2 = {
3283
3570
  x : cos * maxr + location.center.x,
3284
3571
  y : sin * maxr + location.center.y
3285
3572
  };
@@ -3307,12 +3594,16 @@
3307
3594
  class jmLine extends jmPath {
3308
3595
 
3309
3596
  constructor(params, t='jmLine') {
3597
+
3598
+ params.isRegular = true;// 规则的
3599
+
3310
3600
  super(params, t);
3311
3601
 
3312
3602
  this.start = params.start || {x:0,y:0};
3313
3603
  this.end = params.end || {x:0,y:0};
3314
3604
  this.style.lineType = this.style.lineType || 'solid';
3315
3605
  this.style.dashLength = this.style.dashLength || 4;
3606
+ this.style.close = false;
3316
3607
  }
3317
3608
 
3318
3609
  /**
@@ -3323,11 +3614,11 @@
3323
3614
  * @type {point}
3324
3615
  */
3325
3616
  get start() {
3326
- return this.__pro('start');
3617
+ return this.property('start');
3327
3618
  }
3328
3619
  set start(v) {
3329
3620
  this.needUpdate = true;
3330
- return this.__pro('start', v);
3621
+ return this.property('start', v);
3331
3622
  }
3332
3623
 
3333
3624
  /**
@@ -3338,11 +3629,11 @@
3338
3629
  * @type {point}
3339
3630
  */
3340
3631
  get end() {
3341
- return this.__pro('end');
3632
+ return this.property('end');
3342
3633
  }
3343
3634
  set end(v) {
3344
3635
  this.needUpdate = true;
3345
- return this.__pro('end', v);
3636
+ return this.property('end', v);
3346
3637
  }
3347
3638
 
3348
3639
  /**
@@ -3351,30 +3642,34 @@
3351
3642
  * @private
3352
3643
  */
3353
3644
  initPoints() {
3354
- let start = this.start;
3355
- let end = this.end;
3645
+ const start = this.start;
3646
+ const end = this.end;
3356
3647
  this.points = [];
3357
3648
  this.points.push(start);
3358
3649
 
3359
3650
  if(this.style.lineType === 'dotted') {
3360
3651
  let dx = end.x - start.x;
3361
3652
  let dy = end.y - start.y;
3362
- let lineLen = Math.sqrt(dx * dx + dy * dy);
3653
+ const lineLen = Math.sqrt(dx * dx + dy * dy);
3363
3654
  dx = dx / lineLen;
3364
3655
  dy = dy / lineLen;
3365
3656
  let dottedstart = false;
3366
3657
 
3367
- let dashLen = this.style.dashLength || 5;
3368
- let dottedsp = dashLen / 2;
3658
+ const dashLen = this.style.dashLength || 5;
3659
+ const dottedsp = dashLen / 2;
3369
3660
  for(let l=dashLen; l<=lineLen;) {
3370
- if(dottedstart == false) {
3371
- this.points.push({x: start.x + dx * l, y: start.y + dy * l});
3661
+ const p = {
3662
+ x: start.x + dx * l,
3663
+ y: start.y + dy * l
3664
+ };
3665
+ if(dottedstart === false) {
3372
3666
  l += dottedsp;
3373
3667
  }
3374
3668
  else {
3375
- this.points.push({x: start.x + dx * l, y: start.y+ dy * l, m: true});
3669
+ p.m = true;// 移动到当时坐标
3376
3670
  l += dashLen;
3377
3671
  }
3672
+ this.points.push(p);
3378
3673
  dottedstart = !dottedstart;
3379
3674
  }
3380
3675
  }
@@ -3393,6 +3688,8 @@
3393
3688
  class jmPrismatic extends jmPath {
3394
3689
 
3395
3690
  constructor(params, t='jmPrismatic') {
3691
+ params.isRegular = true;// 规则的
3692
+
3396
3693
  super(params, t);
3397
3694
  this.style.close = typeof this.style.close == 'undefined'? true : this.style.close;
3398
3695
 
@@ -3410,11 +3707,11 @@
3410
3707
  * @type {point}
3411
3708
  */
3412
3709
  get center() {
3413
- return this.__pro('center');
3710
+ return this.property('center');
3414
3711
  }
3415
3712
  set center(v) {
3416
3713
  this.needUpdate = true;
3417
- return this.__pro('center', v);
3714
+ return this.property('center', v);
3418
3715
  }
3419
3716
 
3420
3717
  /**
@@ -3448,6 +3745,7 @@
3448
3745
 
3449
3746
  constructor(params, t='jmRect') {
3450
3747
  params = params||{};
3748
+ params.isRegular = true;// 规则的
3451
3749
  super(params, t);
3452
3750
 
3453
3751
  this.style.close = true;
@@ -3459,11 +3757,11 @@
3459
3757
  * @type {number}
3460
3758
  */
3461
3759
  get radius() {
3462
- return this.__pro('radius');
3760
+ return this.property('radius');
3463
3761
  }
3464
3762
  set radius(v) {
3465
3763
  this.needUpdate = true;
3466
- return this.__pro('radius', v);
3764
+ return this.property('radius', v);
3467
3765
  }
3468
3766
 
3469
3767
  /**
@@ -3472,11 +3770,11 @@
3472
3770
  * @type {point}
3473
3771
  */
3474
3772
  get position() {
3475
- return this.__pro('position');
3773
+ return this.property('position');
3476
3774
  }
3477
3775
  set position(v) {
3478
3776
  this.needUpdate = true;
3479
- return this.__pro('position', v);
3777
+ return this.property('position', v);
3480
3778
  }
3481
3779
 
3482
3780
  /**
@@ -3651,6 +3949,7 @@
3651
3949
 
3652
3950
  constructor(params, t) {
3653
3951
  params = params || {};
3952
+ params.isRegular = true;// 规则的
3654
3953
  super(params, t||'jmImage');
3655
3954
 
3656
3955
  this.style.fill = this.fill || 'transparent';//默认指定一个fill,为了可以鼠标选中
@@ -3668,10 +3967,10 @@
3668
3967
  * @type {point}
3669
3968
  */
3670
3969
  get sourcePosition() {
3671
- return this.__pro('sourcePosition');
3970
+ return this.property('sourcePosition');
3672
3971
  }
3673
3972
  set sourcePosition(v) {
3674
- return this.__pro('sourcePosition', v);
3973
+ return this.property('sourcePosition', v);
3675
3974
  }
3676
3975
 
3677
3976
  /**
@@ -3681,11 +3980,11 @@
3681
3980
  * @type {number}
3682
3981
  */
3683
3982
  get sourceWidth() {
3684
- return this.__pro('sourceWidth');
3983
+ return this.property('sourceWidth');
3685
3984
  }
3686
3985
  set sourceWidth(v) {
3687
3986
  this.needUpdate = true;
3688
- return this.__pro('sourceWidth', v);
3987
+ return this.property('sourceWidth', v);
3689
3988
  }
3690
3989
 
3691
3990
  /**
@@ -3695,11 +3994,11 @@
3695
3994
  * @type {number}
3696
3995
  */
3697
3996
  get sourceHeight() {
3698
- return this.__pro('sourceHeight');
3997
+ return this.property('sourceHeight');
3699
3998
  }
3700
3999
  set sourceHeight(v) {
3701
4000
  this.needUpdate = true;
3702
- return this.__pro('sourceHeight', v);
4001
+ return this.property('sourceHeight', v);
3703
4002
  }
3704
4003
 
3705
4004
  /**
@@ -3709,11 +4008,11 @@
3709
4008
  * @type {img}
3710
4009
  */
3711
4010
  get image() {
3712
- return this.__pro('image');
4011
+ return this.property('image');
3713
4012
  }
3714
4013
  set image(v) {
3715
4014
  this.needUpdate = true;
3716
- return this.__pro('image', v);
4015
+ return this.property('image', v);
3717
4016
  }
3718
4017
 
3719
4018
  /**
@@ -3723,23 +4022,9 @@
3723
4022
  * @method draw
3724
4023
  */
3725
4024
  draw() {
3726
- try {
3727
-
3728
- let img = this.getImage();
3729
- if(this.graph.isWXMiniApp && this.graph.canvas && typeof img === 'string') {
3730
- // 图片对象
3731
- const image = this.graph.canvas.createImage();
3732
- // 图片加载完成回调
3733
- image.onload = () => {
3734
- // 将图片绘制到 canvas 上
3735
- this.drawImg(image);
3736
- };
3737
- // 设置图片src
3738
- image.src = img;
3739
- }
3740
- else {
3741
- this.drawImg(img);
3742
- }
4025
+ try {
4026
+ const img = this.getImage();
4027
+ this.drawImg(img);
3743
4028
  }
3744
4029
  catch(e) {
3745
4030
  console.error && console.error(e);
@@ -3748,42 +4033,72 @@
3748
4033
 
3749
4034
  // 绘制
3750
4035
  drawImg(img) {
3751
- if(!img) {
4036
+ if(!img || !img.complete) {
3752
4037
  console.warn('image is empty');
3753
4038
  return;
3754
4039
  }
3755
4040
  let bounds = this.parent && this.parent.absoluteBounds?this.parent.absoluteBounds:this.absoluteBounds;
3756
4041
  if(!bounds) bounds = this.parent && this.parent.getAbsoluteBounds?this.parent.getAbsoluteBounds():this.getAbsoluteBounds();
3757
- let p = this.getLocation();
3758
- p.left += bounds.left;
3759
- p.top += bounds.top;
4042
+
4043
+ let p = this.getLocation();
3760
4044
 
3761
4045
  let sp = this.sourcePosition;
3762
4046
  let sw = this.sourceWidth;
3763
4047
  let sh = this.sourceHeight;
3764
4048
 
4049
+ const ctx = this.webglControl || this.context;
4050
+ if(this.webglControl) {
4051
+ ctx.setParentBounds && ctx.setParentBounds(bounds);
4052
+ const localBounds = this.getBounds();
4053
+ // 给图片给定顶点
4054
+ ctx.draw([
4055
+ {
4056
+ x: localBounds.left,
4057
+ y: localBounds.top
4058
+ },
4059
+ {
4060
+ x: localBounds.left + localBounds.width,
4061
+ y: localBounds.top
4062
+ },
4063
+ {
4064
+ x: localBounds.left + localBounds.width,
4065
+ y: localBounds.top + localBounds.height
4066
+ },
4067
+ {
4068
+ x: localBounds.left,
4069
+ y: localBounds.top + localBounds.height
4070
+ }
4071
+ ], bounds);
4072
+ ctx.drawImage(img, localBounds.left, localBounds.top, localBounds.width, localBounds.height);
4073
+ return;
4074
+ }
4075
+
4076
+ // 计算绝对定位
4077
+ p.left += bounds.left;
4078
+ p.top += bounds.top;
4079
+
3765
4080
  if(sp || typeof sw != 'undefined' || typeof sh != 'undefined') {
3766
4081
  if(typeof sw == 'undefined') sw= p.width || img.width || 0;
3767
4082
  if(typeof sh == 'undefined') sh= p.height || img.height || 0;
3768
4083
  sp = sp || {x:0, y:0};
3769
4084
 
3770
- if(p.width && p.height) this.context.drawImage(img,sp.x,sp.y,sw,sh,p.left,p.top,p.width,p.height);
4085
+ if(p.width && p.height) ctx.drawImage(img,sp.x,sp.y,sw,sh,p.left,p.top,p.width,p.height);
3771
4086
  else if(p.width) {
3772
- this.context.drawImage(img,sp.x,sp.y,sw,sh,p.left,p.top,p.width,sh);
4087
+ ctx.drawImage(img,sp.x,sp.y,sw,sh,p.left,p.top,p.width,sh);
3773
4088
  }
3774
4089
  else if(p.height) {
3775
- this.context.drawImage(img,sp.x,sp.y,sw,sh,p.left,p.top,sw,p.height);
4090
+ ctx.drawImage(img,sp.x,sp.y,sw,sh,p.left,p.top,sw,p.height);
3776
4091
  }
3777
- else this.context.drawImage(img,sp.x,sp.y,sw,sh,p.left,p.top,sw,sh);
4092
+ else ctx.drawImage(img,sp.x,sp.y,sw,sh,p.left,p.top,sw,sh);
3778
4093
  }
3779
4094
  else if(p) {
3780
- if(p.width && p.height) this.context.drawImage(img,p.left,p.top,p.width,p.height);
3781
- else if(p.width) this.context.drawImage(img,p.left,p.top,p.width,img.height);
3782
- else if(p.height) this.context.drawImage(img,p.left,p.top,img.width,p.height);
3783
- else this.context.drawImage(img,p.left,p.top);
4095
+ if(p.width && p.height) ctx.drawImage(img,p.left,p.top,p.width,p.height);
4096
+ else if(p.width) ctx.drawImage(img,p.left,p.top,p.width,img.height);
4097
+ else if(p.height) ctx.drawImage(img,p.left,p.top,img.width,p.height);
4098
+ else ctx.drawImage(img,p.left,p.top);
3784
4099
  }
3785
4100
  else {
3786
- this.context.drawImage(img);
4101
+ ctx.drawImage(img);
3787
4102
  }
3788
4103
  }
3789
4104
 
@@ -3815,7 +4130,7 @@
3815
4130
  * @return {img} 图片对象
3816
4131
  */
3817
4132
  getImage() {
3818
- let src = this.image || this.style.src || this.style.image;
4133
+ const src = this.image || this.style.src || this.style.image;
3819
4134
  if(this.__img && this.__img.src && this.__img.src.indexOf(src) != -1) {
3820
4135
  return this.__img;
3821
4136
  }
@@ -3824,11 +4139,24 @@
3824
4139
  }
3825
4140
  else if(typeof document !== 'undefined' && document.createElement) {
3826
4141
  this.__img = document.createElement('img');
4142
+ this.__img.onload = ()=>{
4143
+ this.needUpdate = true;
4144
+ };
3827
4145
  if(src && typeof src == 'string') this.__img.src = src;
3828
4146
  }
4147
+ else if(this.graph.isWXMiniApp && this.graph.canvas && typeof src === 'string') {
4148
+ // 图片对象
4149
+ this.__img = this.graph.canvas.createImage();
4150
+ this.__img.onload = ()=>{
4151
+ this.needUpdate = true;
4152
+ };
4153
+ // 设置图片src
4154
+ this.__img.src = src;
4155
+ }
3829
4156
  else {
3830
4157
  this.__img = src;
3831
4158
  }
4159
+ if(this.__img) this.image = this.__img.src;
3832
4160
  return this.__img;
3833
4161
  }
3834
4162
  }
@@ -3844,6 +4172,7 @@
3844
4172
 
3845
4173
  constructor(params, t) {
3846
4174
  params = params || {};
4175
+ params.isRegular = true;// 规则的
3847
4176
  super(params, t||'jmLabel');
3848
4177
 
3849
4178
  this.style.font = this.style.font || "15px Arial";
@@ -3866,11 +4195,11 @@
3866
4195
  * @type {string}
3867
4196
  */
3868
4197
  get text() {
3869
- return this.__pro('text');
4198
+ return this.property('text');
3870
4199
  }
3871
4200
  set text(v) {
3872
4201
  this.needUpdate = true;
3873
- return this.__pro('text', v);
4202
+ return this.property('text', v);
3874
4203
  }
3875
4204
 
3876
4205
  /**
@@ -3880,11 +4209,11 @@
3880
4209
  * @type {point}
3881
4210
  */
3882
4211
  get center() {
3883
- return this.__pro('center');
4212
+ return this.property('center');
3884
4213
  }
3885
4214
  set center(v) {
3886
4215
  this.needUpdate = true;
3887
- return this.__pro('center', v);
4216
+ return this.property('center', v);
3888
4217
  }
3889
4218
 
3890
4219
  /**
@@ -3893,11 +4222,11 @@
3893
4222
  * @type {point}
3894
4223
  */
3895
4224
  get position() {
3896
- return this.__pro('position');
4225
+ return this.property('position');
3897
4226
  }
3898
4227
  set position(v) {
3899
4228
  this.needUpdate = true;
3900
- return this.__pro('position', v);
4229
+ return this.property('position', v);
3901
4230
  }
3902
4231
 
3903
4232
  /**
@@ -3948,17 +4277,17 @@
3948
4277
  testSize() {
3949
4278
  if(this.__size) return this.__size;
3950
4279
 
3951
- this.context.save();
4280
+ this.context.save && this.context.save();
3952
4281
  // 修改字体,用来计算
3953
4282
  this.setStyle({
3954
- font: this.style.font || (this.style.fontSize + 'px ' + this.style.fontFamily)
4283
+ font: this.style.font || `${this.style.fontSize}px "${this.style.fontFamily}"`
3955
4284
  });
3956
4285
  //计算宽度
3957
4286
  this.__size = this.context.measureText?
3958
4287
  this.context.measureText(this.text):
3959
4288
  {width:15};
3960
- this.context.restore();
3961
- this.__size.height = this.style.fontSize?this.style.fontSize:15;
4289
+ this.context.restore && this.context.restore();
4290
+ if(!this.__size.height) this.__size.height = this.style.fontSize? this.style.fontSize: 15;
3962
4291
  if(!this.width) this.width = this.__size.width;
3963
4292
  if(!this.height) this.height = this.__size.height;
3964
4293
  return this.__size;
@@ -4026,7 +4355,7 @@
4026
4355
  if(this.style.border) {
4027
4356
  //如果指定了边框样式
4028
4357
  if(this.style.border.style) {
4029
- this.context.save();
4358
+ this.context.save && this.context.save();
4030
4359
  this.setStyle(this.style.border.style);
4031
4360
  }
4032
4361
  this.context.moveTo(this.points[0].x + bounds.left,this.points[0].y + bounds.top);
@@ -4050,7 +4379,7 @@
4050
4379
  }
4051
4380
  //如果指定了边框颜色
4052
4381
  if(this.style.border.style) {
4053
- this.context.restore();
4382
+ this.context.restore && this.context.restore();
4054
4383
  }
4055
4384
  }
4056
4385
  }
@@ -4068,6 +4397,8 @@
4068
4397
 
4069
4398
  constructor(params, t='jmResize') {
4070
4399
  params = params || {};
4400
+ params.isRegular = true;// 规则的
4401
+
4071
4402
  super(params, t);
4072
4403
  //是否可拉伸
4073
4404
  this.resizable = params.resizable === false?false:true;
@@ -4083,10 +4414,10 @@
4083
4414
  * @type {number}
4084
4415
  */
4085
4416
  get rectSize() {
4086
- return this.__pro('rectSize');
4417
+ return this.property('rectSize');
4087
4418
  }
4088
4419
  set rectSize(v) {
4089
- return this.__pro('rectSize', v);
4420
+ return this.property('rectSize', v);
4090
4421
  }
4091
4422
 
4092
4423
  /**
@@ -4095,10 +4426,10 @@
4095
4426
  * @type {boolean}
4096
4427
  */
4097
4428
  get resizable() {
4098
- return this.__pro('resizable');
4429
+ return this.property('resizable');
4099
4430
  }
4100
4431
  set resizable(v) {
4101
- return this.__pro('resizable', v);
4432
+ return this.property('resizable', v);
4102
4433
  }
4103
4434
 
4104
4435
  /**
@@ -4413,7 +4744,7 @@
4413
4744
 
4414
4745
  init(instance, container, target) {
4415
4746
  let canvas = this.target;
4416
- let doc = typeof typeof document != 'undefined'?document:null;
4747
+ let doc = typeof document != 'undefined'? document: null;
4417
4748
  //禁用鼠标右健系统菜单
4418
4749
  //canvas.oncontextmenu = function() {
4419
4750
  // return false;
@@ -4538,7 +4869,7 @@
4538
4869
  * 初始化健盘事件
4539
4870
  */
4540
4871
  init(container, target) {
4541
- let doc = typeof typeof document != 'undefined'?document:null;
4872
+ let doc = typeof document != 'undefined'? document: null;
4542
4873
  /**
4543
4874
  * 检查是否触发健盘事件至画布
4544
4875
  * 如果触发对象为输入框等对象则不响应事件
@@ -4616,9 +4947,10 @@
4616
4947
  }
4617
4948
 
4618
4949
  option = option || {};
4619
- option.mode = option.mode || '2d'; // webgl | 2d
4950
+ option.mode = '2d'; // webgl | 2d 暂不支持webgl
4620
4951
  option.interactive = true;
4621
-
4952
+ option.isRegular = true;// 规则的
4953
+
4622
4954
  super(option, 'jmGraph');
4623
4955
 
4624
4956
  this.option = option || {};
@@ -4630,7 +4962,9 @@
4630
4962
  * @property utils/util
4631
4963
  * @type {jmUtils}
4632
4964
  */
4633
- this.util = this.utils = jmUtils;
4965
+ this.util = this.utils = jmUtils;
4966
+ // 模式 webgl | 2d
4967
+ this.mode = option.mode;
4634
4968
 
4635
4969
  //如果是小程序
4636
4970
  if(typeof wx != 'undefined' && wx.canIUse && wx.canIUse('canvas')) {
@@ -4646,7 +4980,7 @@
4646
4980
  canvas = canvas[0];
4647
4981
  }
4648
4982
 
4649
- if(canvas.tagName != 'CANVAS') {
4983
+ if(!canvas.getContext && typeof document != 'undefined') {
4650
4984
  this.container = canvas;
4651
4985
  let cn = document.createElement('canvas');
4652
4986
  canvas.appendChild(cn);
@@ -4659,7 +4993,25 @@
4659
4993
  }
4660
4994
  }
4661
4995
  this.canvas = canvas;
4662
- this.context = canvas.getContext('2d');
4996
+ this.context = canvas.getContext(this.mode);
4997
+
4998
+ this.textureCanvas = option.textureCanvas || null;
4999
+
5000
+ // webgl模式
5001
+ if(this.mode === 'webgl') {
5002
+
5003
+ this.context.enable(this.context.BLEND);// 开启混合功能:(注意,它不可和gl.DEPTH_TEST一起使用)
5004
+ this.context.blendFunc(this.context.SRC_ALPHA, this.context.ONE_MINUS_SRC_ALPHA); // 指定混合函数:
5005
+ // webglcontextlost webglcontextrestored
5006
+ jmUtils.bindEvent(canvas, 'webglcontextlost', (e)=> {
5007
+ console.log('canvas webglcontextlost', e);
5008
+ this.emit('webglcontextlost', e);
5009
+ });
5010
+ jmUtils.bindEvent(canvas, 'webglcontextrestored', (e)=> {
5011
+ console.log('canvas webglcontextrestored', e);
5012
+ this.emit('webglcontextrestored', e);
5013
+ });
5014
+ }
4663
5015
  this.__init(callback);
4664
5016
  }
4665
5017
 
@@ -4682,13 +5034,13 @@
4682
5034
  * 为了解决一像素线条问题
4683
5035
  */
4684
5036
  this.on('beginDraw', function() {
4685
- this.context.translate(0.5, 0.5);
5037
+ this.context.translate && this.context.translate(0.5, 0.5);
4686
5038
  });
4687
5039
  /**
4688
5040
  * 结束控件绘制 为了解决一像素线条问题
4689
5041
  */
4690
5042
  this.on('endDraw', function() {
4691
- this.context.translate(-0.5, -0.5);
5043
+ this.context.translate && this.context.translate(-0.5, -0.5);
4692
5044
  });
4693
5045
 
4694
5046
  // devicePixelRatio初始化
@@ -4699,7 +5051,7 @@
4699
5051
  this.devicePixelRatio = dpr;
4700
5052
  // 为了解决锯齿问题,先放大canvas再缩放
4701
5053
  this.dprScaleSize = this.devicePixelRatio > 1? this.devicePixelRatio : 2;
4702
-
5054
+
4703
5055
  if(this.option.width > 0) this.width = this.option.width;
4704
5056
  if(this.option.height > 0) this.height = this.option.height;
4705
5057
  this.resize();
@@ -4727,9 +5079,17 @@
4727
5079
 
4728
5080
  this.css('width', w + "px");
4729
5081
  this.css('height', h + "px");
4730
- this.canvas.height = h * this.dprScaleSize;
4731
- this.canvas.width = w * this.dprScaleSize;
4732
- this.context.scale(this.dprScaleSize, this.dprScaleSize);
5082
+ if(this.mode === '2d') {
5083
+ this.canvas.height = h * this.dprScaleSize;
5084
+ this.canvas.width = w * this.dprScaleSize;
5085
+ if(this.dprScaleSize !== 1) this.context.scale && this.context.scale(this.dprScaleSize, this.dprScaleSize);
5086
+ }
5087
+ else {
5088
+ this.canvas.width = w;
5089
+ this.canvas.height = h;
5090
+ }
5091
+
5092
+ this.context.viewport && this.context.viewport(0, 0, w, h);
4733
5093
  }
4734
5094
 
4735
5095
  /**
@@ -4799,7 +5159,7 @@
4799
5159
  * @return {postion} 返回定位坐标
4800
5160
  */
4801
5161
  getPosition() {
4802
- let p = jmUtils.getElementPosition(this.canvas.canvas || this.canvas);
5162
+ const p = jmUtils.getElementPosition(this.canvas.canvas || this.canvas);
4803
5163
  p.width = this.width;
4804
5164
  p.height = this.height;
4805
5165
  p.right = p.left + p.width;
@@ -4850,7 +5210,7 @@
4850
5210
  * @return {jmShadow} 阴影对象
4851
5211
  */
4852
5212
  createShadow(x, y, blur, color) {
4853
- let sh = new jmShadow(x, y, blur, color);
5213
+ const sh = new jmShadow(x, y, blur, color);
4854
5214
  return sh;
4855
5215
  }
4856
5216
 
@@ -4865,7 +5225,7 @@
4865
5225
  * @return {jmGradient} 线性渐变对象
4866
5226
  */
4867
5227
  createLinearGradient(x1, y1, x2, y2) {
4868
- let gradient = new jmGradient({
5228
+ const gradient = new jmGradient({
4869
5229
  type:'linear',
4870
5230
  x1: x1,
4871
5231
  y1: y1,
@@ -4888,7 +5248,7 @@
4888
5248
  * @return {jmGradient} 放射渐变对象
4889
5249
  */
4890
5250
  createRadialGradient(x1, y1, r1, x2, y2, r2) {
4891
- let gradient = new jmGradient({
5251
+ const gradient = new jmGradient({
4892
5252
  type:'radial',
4893
5253
  x1: x1,
4894
5254
  y1: y1,
@@ -4943,16 +5303,30 @@
4943
5303
  h = h / this.scaleSize.y;
4944
5304
  }*/
4945
5305
  }
4946
- //如果有指定背景,则等到draw再全屏绘制一次,也同样达到清除画布的功能
4947
- if(this.style && this.style.fill) {
4948
- this.points = [
4949
- {x:0,y:0},
4950
- {x:w,y:0},
4951
- {x:w,y:h},
4952
- {x:0,y:h}
4953
- ];
5306
+
5307
+ if(this.context.clearRect) {
5308
+ if(this.style && this.style.fill) {
5309
+ this.points = [
5310
+ {x:0, y:0},
5311
+ {x:w, y:0},
5312
+ {x:w, y:h},
5313
+ {x:0, y:h}
5314
+ ];
5315
+ this.style.close = true;// 封闭填充
5316
+ }
5317
+
5318
+ this.context.clearRect(0, 0, w, h);
5319
+ }
5320
+ else if(this.mode === 'webgl' && this.context.clear) {
5321
+ const color = this.style && this.style.fill? this.utils.hexToRGBA(this.style.fill): {
5322
+ r: 0,
5323
+ g: 0,
5324
+ b: 0,
5325
+ a: 0
5326
+ };
5327
+ this.context.clearColor(color.r, color.g, color.b, color.a); // 设置清空颜色缓冲时的颜色值
5328
+ this.context.clear(this.context.COLOR_BUFFER_BIT); // 清空颜色缓冲区,也就是清空画布
4954
5329
  }
4955
- else if(this.context.clearRect) this.context.clearRect(0,0,w,h);
4956
5330
  }
4957
5331
 
4958
5332
  /**
@@ -4977,10 +5351,11 @@
4977
5351
  * @param {style} style 当前路径的样式
4978
5352
  * @return {jmPath} 路径对象jmPath
4979
5353
  */
4980
- createPath(points, style) {
4981
- let path = this.createShape('path',{
5354
+ createPath(points, style, option={}) {
5355
+ const path = this.createShape('path',{
4982
5356
  points: points,
4983
- style: style
5357
+ style: style,
5358
+ ...option
4984
5359
  });
4985
5360
  return path;
4986
5361
  }
@@ -4995,7 +5370,7 @@
4995
5370
  * @return {jmLine} 直线对象
4996
5371
  */
4997
5372
  createLine(start, end, style) {
4998
- let line = this.createShape('line', {
5373
+ const line = this.createShape('line', {
4999
5374
  start: start,
5000
5375
  end: end,
5001
5376
  style: style
@@ -5145,7 +5520,16 @@
5145
5520
 
5146
5521
  super(canvas, option, callback);
5147
5522
  }
5148
- }
5523
+
5524
+ static create(...args) {
5525
+ return createJmGraph(...args);
5526
+ }
5527
+ }
5528
+
5529
+ //创建实例
5530
+ const createJmGraph = (...args) => {
5531
+ return new jmGraph(...args);
5532
+ };
5149
5533
 
5150
5534
  /**
5151
5535
  * 基础样式