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