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