zrender-nightly 5.5.0-dev.20240131 → 5.5.1-dev.20240131

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.
Files changed (61) hide show
  1. package/README.md +1 -1
  2. package/build/package.json +3 -0
  3. package/dist/package.json +3 -0
  4. package/dist/zrender.js +218 -27
  5. package/dist/zrender.js.map +1 -1
  6. package/dist/zrender.min.js +1 -1
  7. package/lib/Element.d.ts +1 -0
  8. package/lib/Element.js +12 -0
  9. package/lib/Handler.js +3 -3
  10. package/lib/canvas/Layer.d.ts +0 -1
  11. package/lib/canvas/Layer.js +2 -2
  12. package/lib/canvas/Painter.js +1 -1
  13. package/lib/core/PathProxy.js +0 -1
  14. package/lib/core/Transformable.js +5 -1
  15. package/lib/core/env.js +2 -1
  16. package/lib/core/matrix.d.ts +1 -1
  17. package/lib/core/matrix.js +4 -3
  18. package/lib/core/timsort.js +0 -9
  19. package/lib/graphic/helper/parseText.d.ts +1 -1
  20. package/lib/svg/Painter.d.ts +2 -0
  21. package/lib/svg/Painter.js +3 -2
  22. package/lib/svg/core.d.ts +3 -1
  23. package/lib/svg/core.js +2 -1
  24. package/lib/svg/cssAnimation.js +2 -1
  25. package/lib/svg/cssClassId.d.ts +1 -0
  26. package/lib/svg/cssClassId.js +4 -0
  27. package/lib/svg/cssEmphasis.d.ts +3 -0
  28. package/lib/svg/cssEmphasis.js +60 -0
  29. package/lib/svg/graphic.js +21 -1
  30. package/lib/svg/patch.js +4 -1
  31. package/lib/tool/color.d.ts +3 -0
  32. package/lib/tool/color.js +21 -0
  33. package/lib/tool/parseSVG.js +4 -1
  34. package/lib/zrender.d.ts +10 -4
  35. package/lib/zrender.js +69 -6
  36. package/package.README.md +9 -0
  37. package/package.json +29 -2
  38. package/src/.eslintrc.yaml +1 -1
  39. package/src/Element.ts +16 -0
  40. package/src/Handler.ts +3 -3
  41. package/src/canvas/Layer.ts +2 -5
  42. package/src/canvas/Painter.ts +2 -2
  43. package/src/core/PathProxy.ts +0 -2
  44. package/src/core/Transformable.ts +6 -1
  45. package/src/core/env.ts +4 -1
  46. package/src/core/matrix.ts +8 -3
  47. package/src/core/timsort.ts +0 -13
  48. package/src/core/util.ts +4 -4
  49. package/src/dom/HandlerProxy.ts +7 -7
  50. package/src/graphic/helper/parseText.ts +4 -4
  51. package/src/svg/Painter.ts +13 -6
  52. package/src/svg/core.ts +10 -2
  53. package/src/svg/cssAnimation.ts +2 -1
  54. package/src/svg/cssClassId.ts +5 -0
  55. package/src/svg/cssEmphasis.ts +73 -0
  56. package/src/svg/graphic.ts +23 -1
  57. package/src/svg/patch.ts +5 -2
  58. package/src/tool/color.ts +27 -1
  59. package/src/tool/parseSVG.ts +4 -1
  60. package/src/zrender.ts +82 -11
  61. package/.travis.yml +0 -12
package/lib/zrender.js CHANGED
@@ -68,7 +68,7 @@ var ZRender = (function () {
68
68
  var ssrMode = opts.ssr || painter.ssrOnly;
69
69
  this.storage = storage;
70
70
  this.painter = painter;
71
- var handerProxy = (!env.node && !env.worker && !ssrMode)
71
+ var handlerProxy = (!env.node && !env.worker && !ssrMode)
72
72
  ? new HandlerProxy(painter.getViewportRoot(), painter.root)
73
73
  : null;
74
74
  var useCoarsePointer = opts.useCoarsePointer;
@@ -80,7 +80,7 @@ var ZRender = (function () {
80
80
  if (usePointerSize) {
81
81
  pointerSize = zrUtil.retrieve2(opts.pointerSize, defaultPointerSize);
82
82
  }
83
- this.handler = new Handler(storage, painter, handerProxy, painter.root, pointerSize);
83
+ this.handler = new Handler(storage, painter, handlerProxy, painter.root, pointerSize);
84
84
  this.animation = new Animation({
85
85
  stage: {
86
86
  update: ssrMode ? null : function () { return _this._flush(true); }
@@ -91,7 +91,7 @@ var ZRender = (function () {
91
91
  }
92
92
  }
93
93
  ZRender.prototype.add = function (el) {
94
- if (!el) {
94
+ if (this._disposed || !el) {
95
95
  return;
96
96
  }
97
97
  this.storage.addRoot(el);
@@ -99,7 +99,7 @@ var ZRender = (function () {
99
99
  this.refresh();
100
100
  };
101
101
  ZRender.prototype.remove = function (el) {
102
- if (!el) {
102
+ if (this._disposed || !el) {
103
103
  return;
104
104
  }
105
105
  this.storage.delRoot(el);
@@ -107,12 +107,18 @@ var ZRender = (function () {
107
107
  this.refresh();
108
108
  };
109
109
  ZRender.prototype.configLayer = function (zLevel, config) {
110
+ if (this._disposed) {
111
+ return;
112
+ }
110
113
  if (this.painter.configLayer) {
111
114
  this.painter.configLayer(zLevel, config);
112
115
  }
113
116
  this.refresh();
114
117
  };
115
118
  ZRender.prototype.setBackgroundColor = function (backgroundColor) {
119
+ if (this._disposed) {
120
+ return;
121
+ }
116
122
  if (this.painter.setBackgroundColor) {
117
123
  this.painter.setBackgroundColor(backgroundColor);
118
124
  }
@@ -130,6 +136,9 @@ var ZRender = (function () {
130
136
  return this._darkMode;
131
137
  };
132
138
  ZRender.prototype.refreshImmediately = function (fromInside) {
139
+ if (this._disposed) {
140
+ return;
141
+ }
133
142
  if (!fromInside) {
134
143
  this.animation.update(true);
135
144
  }
@@ -138,10 +147,16 @@ var ZRender = (function () {
138
147
  this._needsRefresh = false;
139
148
  };
140
149
  ZRender.prototype.refresh = function () {
150
+ if (this._disposed) {
151
+ return;
152
+ }
141
153
  this._needsRefresh = true;
142
154
  this.animation.start();
143
155
  };
144
156
  ZRender.prototype.flush = function () {
157
+ if (this._disposed) {
158
+ return;
159
+ }
145
160
  this._flush(false);
146
161
  };
147
162
  ZRender.prototype._flush = function (fromInside) {
@@ -173,6 +188,9 @@ var ZRender = (function () {
173
188
  this._sleepAfterStill = stillFramesCount;
174
189
  };
175
190
  ZRender.prototype.wakeUp = function () {
191
+ if (this._disposed) {
192
+ return;
193
+ }
176
194
  this.animation.start();
177
195
  this._stillFrameAccum = 0;
178
196
  };
@@ -180,42 +198,74 @@ var ZRender = (function () {
180
198
  this._needsRefreshHover = true;
181
199
  };
182
200
  ZRender.prototype.refreshHoverImmediately = function () {
201
+ if (this._disposed) {
202
+ return;
203
+ }
183
204
  this._needsRefreshHover = false;
184
205
  if (this.painter.refreshHover && this.painter.getType() === 'canvas') {
185
206
  this.painter.refreshHover();
186
207
  }
187
208
  };
188
209
  ZRender.prototype.resize = function (opts) {
210
+ if (this._disposed) {
211
+ return;
212
+ }
189
213
  opts = opts || {};
190
214
  this.painter.resize(opts.width, opts.height);
191
215
  this.handler.resize();
192
216
  };
193
217
  ZRender.prototype.clearAnimation = function () {
218
+ if (this._disposed) {
219
+ return;
220
+ }
194
221
  this.animation.clear();
195
222
  };
196
223
  ZRender.prototype.getWidth = function () {
224
+ if (this._disposed) {
225
+ return;
226
+ }
197
227
  return this.painter.getWidth();
198
228
  };
199
229
  ZRender.prototype.getHeight = function () {
230
+ if (this._disposed) {
231
+ return;
232
+ }
200
233
  return this.painter.getHeight();
201
234
  };
202
235
  ZRender.prototype.setCursorStyle = function (cursorStyle) {
236
+ if (this._disposed) {
237
+ return;
238
+ }
203
239
  this.handler.setCursorStyle(cursorStyle);
204
240
  };
205
241
  ZRender.prototype.findHover = function (x, y) {
242
+ if (this._disposed) {
243
+ return;
244
+ }
206
245
  return this.handler.findHover(x, y);
207
246
  };
208
247
  ZRender.prototype.on = function (eventName, eventHandler, context) {
209
- this.handler.on(eventName, eventHandler, context);
248
+ if (!this._disposed) {
249
+ this.handler.on(eventName, eventHandler, context);
250
+ }
210
251
  return this;
211
252
  };
212
253
  ZRender.prototype.off = function (eventName, eventHandler) {
254
+ if (this._disposed) {
255
+ return;
256
+ }
213
257
  this.handler.off(eventName, eventHandler);
214
258
  };
215
259
  ZRender.prototype.trigger = function (eventName, event) {
260
+ if (this._disposed) {
261
+ return;
262
+ }
216
263
  this.handler.trigger(eventName, event);
217
264
  };
218
265
  ZRender.prototype.clear = function () {
266
+ if (this._disposed) {
267
+ return;
268
+ }
219
269
  var roots = this.storage.getRoots();
220
270
  for (var i = 0; i < roots.length; i++) {
221
271
  if (roots[i] instanceof Group) {
@@ -226,6 +276,9 @@ var ZRender = (function () {
226
276
  this.painter.clear();
227
277
  };
228
278
  ZRender.prototype.dispose = function () {
279
+ if (this._disposed) {
280
+ return;
281
+ }
229
282
  this.animation.stop();
230
283
  this.clear();
231
284
  this.storage.dispose();
@@ -235,6 +288,7 @@ var ZRender = (function () {
235
288
  this.storage =
236
289
  this.painter =
237
290
  this.handler = null;
291
+ this._disposed = true;
238
292
  delInstance(this.id);
239
293
  };
240
294
  return ZRender;
@@ -261,5 +315,14 @@ export function getInstance(id) {
261
315
  export function registerPainter(name, Ctor) {
262
316
  painterCtors[name] = Ctor;
263
317
  }
264
- export var version = '5.5.0-dev.20240131';
318
+ var ssrDataGetter;
319
+ export function getElementSSRData(el) {
320
+ if (typeof ssrDataGetter === 'function') {
321
+ return ssrDataGetter(el);
322
+ }
323
+ }
324
+ export function registerSSRDataGetter(getter) {
325
+ ssrDataGetter = getter;
326
+ }
327
+ export var version = '5.5.1-dev.20240131';
265
328
  ;
@@ -0,0 +1,9 @@
1
+ # NOTICE about package.json
2
+
3
+ Only `zrender.js` are officially exported to users.
4
+
5
+ The other entries listed in the `"exports"` field of `package.json` make the internal files visible, but they are legacy usages, not recommended but not forbidden (for the sake of keeping backward compatible). These entries are made from the search in github about which internal files are imported.
6
+
7
+ Since `v5.5.0`, `"type": "module"` and `"exports: {...}"` are added to `package.json`. When upgrading to `v5.5.0+`, if you meet some problems about "can not find/resolve xxx" when importing some internal files, it probably because of the issue "file extension not fully specified". Please try to make the file extension fully specified (that is, `import 'xxx/xxx/xxx.js'` rather than `import 'xxx/xxx/xxx'`), or change the config of you bundler tools to support auto adding file extensions.
8
+
9
+ See more details about the `"exports"` field of `package.json` and why it is written like that in https://github.com/apache/echarts/pull/19513 .
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zrender-nightly",
3
- "version": "5.5.0-dev.20240131",
3
+ "version": "5.5.1-dev.20240131",
4
4
  "description": "A lightweight graphic library providing 2d draw for Apache ECharts",
5
5
  "keywords": [
6
6
  "canvas",
@@ -36,7 +36,8 @@
36
36
  },
37
37
  "sideEffects": [
38
38
  "lib/canvas/canvas.js",
39
- "lib/svg/svg.js"
39
+ "lib/svg/svg.js",
40
+ "lib/all.js"
40
41
  ],
41
42
  "devDependencies": {
42
43
  "@microsoft/api-extractor": "^7.7.2",
@@ -58,5 +59,31 @@
58
59
  "ts-jest": "^27.0.6",
59
60
  "typescript": "^4.4.3",
60
61
  "uglify-js": "^3.10.0"
62
+ },
63
+ "type": "module",
64
+ "exports": {
65
+ ".": {
66
+ "types": "./index.d.ts",
67
+ "require": "./dist/zrender.js",
68
+ "import": "./index.js"
69
+ },
70
+ "./lib/canvas/canvas": "./lib/canvas/canvas.js",
71
+ "./lib/svg/svg": "./lib/svg/svg.js",
72
+ "./lib/vml/vml": "./lib/vml/vml.js",
73
+ "./lib/canvas/Painter": "./lib/canvas/Painter.js",
74
+ "./lib/svg/Painter": "./lib/svg/Painter.js",
75
+ "./lib/svg/patch": "./lib/svg/patch.js",
76
+ "./lib/Storage": "./lib/Storage.js",
77
+ "./lib/core/util": "./lib/core/util.js",
78
+ "./lib/core/env": "./lib/core/env.js",
79
+ "./lib/core/Transformable": "./lib/core/Transformable.js",
80
+ "./lib/core/BoundingRect": "./lib/core/BoundingRect.js",
81
+ "./lib/core/vector": "./lib/core/vector.js",
82
+ "./lib/core/bbox": "./lib/core/bbox.js",
83
+ "./lib/contain/polygon": "./lib/contain/polygon.js",
84
+ "./lib/tool/color": "./lib/tool/color.js",
85
+ "./lib/graphic/LinearGradient": "./lib/graphic/LinearGradient.js",
86
+ "./lib/graphic/RadialGradient": "./lib/graphic/RadialGradient.js",
87
+ "./*": "./*"
61
88
  }
62
89
  }
@@ -21,7 +21,7 @@ rules:
21
21
  - "warn"
22
22
  - "error"
23
23
  no-constant-condition: 0
24
- comma-dangle: 2
24
+ comma-dangle: 0
25
25
  no-debugger: 2
26
26
  no-dupe-keys: 2
27
27
  no-empty-character-class: 2
package/src/Element.ts CHANGED
@@ -1017,6 +1017,22 @@ class Element<Props extends ElementProps = ElementProps> {
1017
1017
  }
1018
1018
  }
1019
1019
 
1020
+ /**
1021
+ * Return if el.silent or any ancestor element has silent true.
1022
+ */
1023
+ isSilent() {
1024
+ let isSilent = this.silent;
1025
+ let ancestor = this.parent;
1026
+ while (!isSilent && ancestor) {
1027
+ if (ancestor.silent) {
1028
+ isSilent = true;
1029
+ break;
1030
+ }
1031
+ ancestor = ancestor.parent;
1032
+ }
1033
+ return isSilent;
1034
+ }
1035
+
1020
1036
  /**
1021
1037
  * Update animation targets when reference is changed.
1022
1038
  */
package/src/Handler.ts CHANGED
@@ -497,9 +497,9 @@ function isHover(displayable: Displayable, x: number, y: number) {
497
497
  if (clipPath && !clipPath.contain(x, y)) {
498
498
  return false;
499
499
  }
500
- if (el.silent) {
501
- isSilent = true;
502
- }
500
+ }
501
+ if (el.silent) {
502
+ isSilent = true;
503
503
  }
504
504
  // Consider when el is textContent, also need to be silent
505
505
  // if any of its host el and its ancestors is silent.
@@ -89,8 +89,6 @@ export default class Layer extends Eventful {
89
89
 
90
90
  private _paintRects: BoundingRect[]
91
91
 
92
- __painter: CanvasPainter
93
-
94
92
  __dirty = true
95
93
  __firstTimePaint = true
96
94
 
@@ -311,7 +309,7 @@ export default class Layer extends Eventful {
311
309
  * rect if and only if it's not painted this frame and was
312
310
  * previously painted on the canvas.
313
311
  */
314
- const shouldPaint = el.shouldBePainted(viewWidth, viewHeight, true, true);
312
+ const shouldPaint = el && el.shouldBePainted(viewWidth, viewHeight, true, true);
315
313
  if (el && (!shouldPaint || !el.__zr) && el.__isRendered) {
316
314
  // el was removed
317
315
  const prevRect = el.getPrevPaintRect();
@@ -449,9 +447,8 @@ export default class Layer extends Eventful {
449
447
  clearColorGradientOrPattern = createCanvasPattern(
450
448
  ctx, clearColor, {
451
449
  dirty() {
452
- // TODO
453
450
  self.setUnpainted();
454
- self.__painter.refresh();
451
+ self.painter.refresh();
455
452
  }
456
453
  }
457
454
  );
@@ -597,7 +597,7 @@ export default class CanvasPainter implements PainterBase {
597
597
 
598
598
  layersMap[zlevel] = layer;
599
599
 
600
- // Vitual layer will not directly show on the screen.
600
+ // Virtual layer will not directly show on the screen.
601
601
  // (It can be a WebGL layer and assigned to a ZRImage element)
602
602
  // But it still under management of zrender.
603
603
  if (!layer.virtual) {
@@ -623,7 +623,7 @@ export default class CanvasPainter implements PainterBase {
623
623
  }
624
624
  }
625
625
 
626
- layer.__painter = this;
626
+ layer.painter || (layer.painter = this);
627
627
  }
628
628
 
629
629
  // Iterate each layer
@@ -675,8 +675,6 @@ export default class PathProxy {
675
675
  const endAngle = delta + startAngle;
676
676
  // TODO Arc 旋转
677
677
  i += 1;
678
- const anticlockwise = !data[i++];
679
-
680
678
  if (isFirst) {
681
679
  // 直接使用 arc 命令
682
680
  // 第一个命令起点还未定义
@@ -108,7 +108,11 @@ class Transformable {
108
108
 
109
109
  let m = this.transform;
110
110
  if (!(needLocalTransform || parentTransform)) {
111
- m && mIdentity(m);
111
+ if (m) {
112
+ mIdentity(m);
113
+ // reset invTransform
114
+ this.invTransform = null;
115
+ }
112
116
  return;
113
117
  }
114
118
 
@@ -213,6 +217,7 @@ class Transformable {
213
217
  let m = this.transform;
214
218
  if (parent && parent.transform) {
215
219
  // Get local transform and decompose them to position, scale, rotation
220
+ parent.invTransform = parent.invTransform || matrix.create();
216
221
  matrix.mul(tmpTransform, parent.invTransform, m);
217
222
  m = tmpTransform;
218
223
  }
package/src/core/env.ts CHANGED
@@ -37,7 +37,10 @@ else if (typeof document === 'undefined' && typeof self !== 'undefined') {
37
37
  // In worker
38
38
  env.worker = true;
39
39
  }
40
- else if (typeof navigator === 'undefined') {
40
+ else if (
41
+ typeof navigator === 'undefined'
42
+ || navigator.userAgent.indexOf('Node.js') === 0
43
+ ) {
41
44
  // In node
42
45
  env.node = true;
43
46
  env.svgSupported = true;
@@ -79,7 +79,12 @@ export function translate(out: MatrixArray, a: MatrixArray, v: VectorArray): Mat
79
79
  /**
80
80
  * 旋转变换
81
81
  */
82
- export function rotate(out: MatrixArray, a: MatrixArray, rad: number): MatrixArray {
82
+ export function rotate(
83
+ out: MatrixArray,
84
+ a: MatrixArray,
85
+ rad: number,
86
+ pivot: VectorArray = [0, 0]
87
+ ): MatrixArray {
83
88
  const aa = a[0];
84
89
  const ac = a[2];
85
90
  const atx = a[4];
@@ -93,8 +98,8 @@ export function rotate(out: MatrixArray, a: MatrixArray, rad: number): MatrixArr
93
98
  out[1] = -aa * st + ab * ct;
94
99
  out[2] = ac * ct + ad * st;
95
100
  out[3] = -ac * st + ct * ad;
96
- out[4] = ct * atx + st * aty;
97
- out[5] = ct * aty - st * atx;
101
+ out[4] = ct * (atx - pivot[0]) + st * (aty - pivot[1]) + pivot[0];
102
+ out[5] = ct * (aty - pivot[1]) - st * (atx - pivot[0]) + pivot[1];
98
103
  return out;
99
104
  }
100
105
 
@@ -3,8 +3,6 @@ const DEFAULT_MIN_MERGE = 32;
3
3
 
4
4
  const DEFAULT_MIN_GALLOPING = 7;
5
5
 
6
- const DEFAULT_TMP_STORAGE_LENGTH = 256;
7
-
8
6
  type CompareFunc<T> =(a: T, b: T) => number
9
7
 
10
8
  function minRunLength(n: number): number {
@@ -217,23 +215,12 @@ function gallopRight<T>(value: T, array: T[], start: number, length: number, hin
217
215
 
218
216
  function TimSort<T>(array: T[], compare: CompareFunc<T>) {
219
217
  let minGallop = DEFAULT_MIN_GALLOPING;
220
- let length = 0;
221
- let tmpStorageLength = DEFAULT_TMP_STORAGE_LENGTH;
222
- let stackLength = 0;
223
218
  let runStart: number[];
224
219
  let runLength: number[];
225
220
  let stackSize = 0;
226
221
 
227
- length = array.length;
228
-
229
- if (length < 2 * DEFAULT_TMP_STORAGE_LENGTH) {
230
- tmpStorageLength = length >>> 1;
231
- }
232
-
233
222
  var tmp: T[] = [];
234
223
 
235
- stackLength = length < 120 ? 5 : length < 1542 ? 10 : length < 119151 ? 19 : 40;
236
-
237
224
  runStart = [];
238
225
  runLength = [];
239
226
 
package/src/core/util.ts CHANGED
@@ -65,7 +65,7 @@ export function logError(...args: any[]) {
65
65
  /**
66
66
  * Those data types can be cloned:
67
67
  * Plain object, Array, TypedArray, number, string, null, undefined.
68
- * Those data types will be assgined using the orginal data:
68
+ * Those data types will be assigned using the original data:
69
69
  * BUILTIN_OBJECT
70
70
  * Instance of user defined class will be cloned to a plain object, without
71
71
  * properties in prototype.
@@ -626,8 +626,8 @@ export function assert(condition: any, message?: string) {
626
626
  }
627
627
 
628
628
  /**
629
- * @param str string to be trimed
630
- * @return trimed string
629
+ * @param str string to be trimmed
630
+ * @return trimmed string
631
631
  */
632
632
  export function trim(str: string): string {
633
633
  if (str == null) {
@@ -717,7 +717,7 @@ export class HashMap<T, KEY extends string | number = string | number> {
717
717
  constructor(obj?: HashMap<T, KEY> | { [key in KEY]?: T } | KEY[]) {
718
718
  const isArr = isArray(obj);
719
719
  // Key should not be set on this, otherwise
720
- // methods get/set/... may be overrided.
720
+ // methods get/set/... may be overridden.
721
721
  this.data = maybeNativeMap<T, KEY>();
722
722
  const thisMap = this;
723
723
 
@@ -152,7 +152,7 @@ function isLocalEl(instance: HandlerDomProxy, el: Node) {
152
152
 
153
153
  /**
154
154
  * Make a fake event but not change the original event,
155
- * becuase the global event probably be used by other
155
+ * because the global event probably be used by other
156
156
  * listeners not belonging to zrender.
157
157
  * @class
158
158
  */
@@ -259,8 +259,8 @@ const localDOMHandlers: DomHandlersMap = {
259
259
  mousewheel(event: ZRRawEvent) {
260
260
  // IE8- and some other lagacy agent do not support event `wheel`, so we still listen
261
261
  // to the legacy event `mouseevent`.
262
- // Typically if event `wheel` is suppored and the handler has been mounted on a
263
- // DOM element, the lagecy `mousewheel` event will not be triggered (Chrome and Safari).
262
+ // Typically if event `wheel` is supported and the handler has been mounted on a
263
+ // DOM element, the legacy `mousewheel` event will not be triggered (Chrome and Safari).
264
264
  // But we still do this guard to avoid to duplicated handle.
265
265
  if (wheelEventSupported) {
266
266
  return;
@@ -337,7 +337,7 @@ const localDOMHandlers: DomHandlersMap = {
337
337
  // FIXME
338
338
  // pointermove is so sensitive that it always triggered when
339
339
  // tap(click) on touch screen, which affect some judgement in
340
- // upper application. So, we dont support mousemove on MS touch
340
+ // upper application. So, we don't support mousemove on MS touch
341
341
  // device yet.
342
342
  if (!isPointerFromTouch(event)) {
343
343
  localDOMHandlers.mousemove.call(this, event);
@@ -385,7 +385,7 @@ const globalDOMHandlers: DomHandlersMap = {
385
385
  // FIXME
386
386
  // pointermove is so sensitive that it always triggered when
387
387
  // tap(click) on touch screen, which affect some judgement in
388
- // upper application. So, we dont support mousemove on MS touch
388
+ // upper application. So, we don't support mousemove on MS touch
389
389
  // device yet.
390
390
  if (!isPointerFromTouch(event)) {
391
391
  globalDOMHandlers.mousemove.call(this, event);
@@ -441,7 +441,7 @@ function mountLocalDOMEventListeners(instance: HandlerDomProxy, scope: DOMHandle
441
441
  // touch screen. And we only support click behavior on MS touch screen now.
442
442
 
443
443
  // MS Gesture Event is only supported on IE11+/Edge and on Windows 8+.
444
- // We dont support touch on IE on win7.
444
+ // We don't support touch on IE on win7.
445
445
  // See <https://msdn.microsoft.com/en-us/library/dn433243(v=vs.85).aspx>
446
446
  // if (typeof MSGesture === 'function') {
447
447
  // (this._msGesture = new MSGesture()).target = dom; // jshint ignore:line
@@ -540,7 +540,7 @@ class DOMHandlerScope {
540
540
  domTarget: HTMLElement | HTMLDocument
541
541
  domHandlers: DomHandlersMap
542
542
 
543
- // Key: eventName, value: mounted handler funcitons.
543
+ // Key: eventName, value: mounted handler functions.
544
544
  // Used for unmount.
545
545
  mounted: Dictionary<EventListener> = {};
546
546
 
@@ -41,8 +41,8 @@ export function truncateText(
41
41
  text: string,
42
42
  containerWidth: number,
43
43
  font: string,
44
- ellipsis: string,
45
- options: InnerTruncateOption
44
+ ellipsis?: string,
45
+ options?: InnerTruncateOption
46
46
  ): string {
47
47
  if (!containerWidth) {
48
48
  return '';
@@ -63,8 +63,8 @@ export function truncateText(
63
63
  function prepareTruncateOptions(
64
64
  containerWidth: number,
65
65
  font: string,
66
- ellipsis: string,
67
- options: InnerTruncateOption
66
+ ellipsis?: string,
67
+ options?: InnerTruncateOption
68
68
  ): InnerPreparedTruncateOption {
69
69
  options = options || {};
70
70
  let preparedOpts = extend({}, options) as InnerPreparedTruncateOption;
@@ -124,10 +124,11 @@ class SVGPainter implements PainterBase {
124
124
  }
125
125
 
126
126
  renderToVNode(opts?: {
127
- animation?: boolean
128
- willUpdate?: boolean
127
+ animation?: boolean,
128
+ willUpdate?: boolean,
129
129
  compress?: boolean,
130
- useViewBox?: boolean
130
+ useViewBox?: boolean,
131
+ emphasis?: boolean
131
132
  }) {
132
133
 
133
134
  opts = opts || {};
@@ -140,6 +141,7 @@ class SVGPainter implements PainterBase {
140
141
  scope.animation = opts.animation;
141
142
  scope.willUpdate = opts.willUpdate;
142
143
  scope.compress = opts.compress;
144
+ scope.emphasis = opts.emphasis;
143
145
 
144
146
  const children: SVGVNode[] = [];
145
147
 
@@ -173,7 +175,12 @@ class SVGPainter implements PainterBase {
173
175
  * If add css animation.
174
176
  * @default true
175
177
  */
176
- cssAnimation?: boolean
178
+ cssAnimation?: boolean,
179
+ /**
180
+ * If add css emphasis.
181
+ * @default true
182
+ */
183
+ cssEmphasis?: boolean,
177
184
  /**
178
185
  * If use viewBox
179
186
  * @default true
@@ -183,6 +190,7 @@ class SVGPainter implements PainterBase {
183
190
  opts = opts || {};
184
191
  return vNodeToString(this.renderToVNode({
185
192
  animation: retrieve2(opts.cssAnimation, true),
193
+ emphasis: retrieve2(opts.cssEmphasis, true),
186
194
  willUpdate: false,
187
195
  compress: true,
188
196
  useViewBox: retrieve2(opts.useViewBox, true)
@@ -374,8 +382,7 @@ function createBackgroundVNode(
374
382
  width,
375
383
  height,
376
384
  x: '0',
377
- y: '0',
378
- id: '0'
385
+ y: '0'
379
386
  }
380
387
  );
381
388
  if (isGradient(backgroundColor)) {
package/src/svg/core.ts CHANGED
@@ -8,6 +8,7 @@ export const SVGNS = 'http://www.w3.org/2000/svg';
8
8
  export const XLINKNS = 'http://www.w3.org/1999/xlink';
9
9
  export const XMLNS = 'http://www.w3.org/2000/xmlns/';
10
10
  export const XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
11
+ export const META_DATA_PREFIX = 'ecmeta_';
11
12
 
12
13
  export function createElement(name: string) {
13
14
  return document.createElementNS(SVGNS, name);
@@ -128,8 +129,11 @@ export interface BrushScope {
128
129
 
129
130
  cssNodes: Record<string, CSSSelectorVNode>
130
131
  cssAnims: Record<string, Record<string, Record<string, string>>>
132
+ /**
133
+ * Cache for css style string, mapping from style string to class name.
134
+ */
135
+ cssStyleCache: Record<string, string>
131
136
 
132
- cssClassIdx: number
133
137
  cssAnimIdx: number
134
138
 
135
139
  shadowIdx: number
@@ -141,6 +145,10 @@ export interface BrushScope {
141
145
  * If create animates nodes.
142
146
  */
143
147
  animation?: boolean,
148
+ /**
149
+ * If create emphasis styles.
150
+ */
151
+ emphasis?: boolean,
144
152
 
145
153
  /**
146
154
  * If will update. Some optimization for string generation can't be applied.
@@ -164,8 +172,8 @@ export function createBrushScope(zrId: string): BrushScope {
164
172
 
165
173
  cssNodes: {},
166
174
  cssAnims: {},
175
+ cssStyleCache: {},
167
176
 
168
- cssClassIdx: 0,
169
177
  cssAnimIdx: 0,
170
178
 
171
179
  shadowIdx: 0,