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