Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
782b5ef
feat: add pathToPolygon. improve hierarchy management
pissang Jan 14, 2021
1dc0cd3
fix null access
pissang Jan 14, 2021
fb7b604
chore: update eslint version
pissang Jan 14, 2021
c6b7dcb
fix(morph): fix sub paths animation in mergeMorph
pissang Jan 14, 2021
b33fcba
refact: use param object as arg in splitPath
pissang Jan 15, 2021
787cf7d
refact: rename exported morphing methods
pissang Jan 15, 2021
9448de2
fix: add children to zr in combine animation
pissang Jan 16, 2021
06fa2a3
expose individual elements in morphing
pissang Jan 19, 2021
11b5fc2
fix text transform
pissang Jan 21, 2021
3cd7b3a
fix(morph): apply transform before morphing.
pissang Jan 23, 2021
fd813b1
Also support setToFinal in animateFrom
pissang Jan 23, 2021
312330a
fix clonePath
pissang Jan 24, 2021
9eacb58
fix(morph): fix sub path list can't be animated in combine morph
pissang Feb 1, 2021
da7fdad
fix: optimize performance for polygon morphing
pissang Feb 2, 2021
05d47b1
fix(morph): ignore transform on divided paths
pissang Feb 2, 2021
52208b8
refact: rename splitPath to dividePath
pissang Feb 2, 2021
8ffbd6e
refact: rename split to divide
pissang Feb 3, 2021
cb69e54
feat: add default path divider
pissang Feb 4, 2021
0292ef0
fix license.
pissang Feb 4, 2021
44e58c7
feat: try polygon dividing
pissang Feb 5, 2021
957f51b
fix(morph): fix polygon divide
pissang Feb 6, 2021
6347cdf
fix(morph): optimize rect and sector dividing
pissang Feb 9, 2021
ca96e42
fix(svg):
plainheart May 28, 2021
6a9b4af
fix(svg): add missing comma.
plainheart May 28, 2021
7fe6d0b
Merge branch 'master' into enhance-morph
pissang Jun 7, 2021
30934cc
refact: use innerTransformable instead of modify getLocalTransform
pissang Jun 7, 2021
842371e
fix wrong param when overriding method
pissang Jun 7, 2021
49dd564
morph: sort paths in z order.
pissang Jun 8, 2021
3f82980
fix(morph): normalize in z order sort
pissang Jun 9, 2021
950e025
Merge pull request #771 from ecomfe/release
pissang Jun 10, 2021
cb2d8eb
test: optimize test cases
pissang Jun 11, 2021
fd2b72f
test: optimize path converting test case
pissang Jun 11, 2021
8eccba5
fix typo in dividePath
pissang Jun 11, 2021
4b08c51
fix dividing rect may have wrong empty grid rows
pissang Jun 14, 2021
26ce7e8
refact(type): optimize eventful type
pissang Jun 15, 2021
b54bcd2
feat(label): support sector label positions
Ovilia Jun 16, 2021
cfad032
fix: legend text.lineHeight option not work
ssthouse Jun 16, 2021
a0b0f24
morph: handle error more robust
pissang Jun 16, 2021
a722edf
fix typo in z-order calculation
pissang Jun 17, 2021
840032a
morph: optimize polygon dividing of multiple subpaths
pissang Jun 17, 2021
ec670d9
feat(label): remove sector text position to echarts
Ovilia Jun 18, 2021
a20ad4b
feat(label): move position type to echarts
Ovilia Jun 18, 2021
9d736d7
fix transform issue in morph
pissang Jun 18, 2021
9371182
fix: consider scale when converting path to polygon
pissang Jun 19, 2021
8c6eda8
fix path clone may have wrong path data.
pissang Jun 19, 2021
792229e
seems there is no need to ignore the transform old from path
pissang Jun 20, 2021
80c4b27
Merge pull request #774 from ecomfe/feat-sector-label
pissang Jun 22, 2021
e7c89ae
naming tweak
pissang Jun 22, 2021
9db813a
fix(animation): ignore track that max time is 0
pissang Jun 22, 2021
3677ba3
feat: add individualDelay callback for separate/combine morph
pissang Jun 22, 2021
625efc0
Merge pull request #773 from ssthouse/fix/legend-text-lineHeight
pissang Jun 22, 2021
0ee303f
Update index.d.ts
lzxb Jun 23, 2021
df2aea1
Merge pull request #775 from ecomfe/enhance-morph
pissang Jun 25, 2021
74a2d35
Update package-lock.json
pissang Jun 25, 2021
4c018d2
Merge pull request #778 from ecomfe/enhance-morph
pissang Jun 25, 2021
a4f4943
sort path on hilbert instead zorder to reduce the large cross
pissang Jun 25, 2021
be54aab
morph: consider transform in path sorting.
pissang Jun 25, 2021
2bb98b3
morph: add basic delay with individual delay
pissang Jun 25, 2021
66a2212
Merge pull request #779 from ecomfe/enhance-morph
pissang Jun 30, 2021
69c0936
chore: update ts version
pissang Jul 1, 2021
71c082d
Merge pull request #780 from ecomfe/update-ts
pissang Jul 1, 2021
be9b2fd
Merge pull request #781 from lzxb/patch-3
pissang Jul 2, 2021
c36025e
fix(canvas): fix unexpected `none` or `null` value for ctx.strokeStyl…
plainheart Jul 12, 2021
bb4a978
fix(canvas): check if stroke/fill color is valid before setting strok…
plainheart Jul 15, 2021
cdaed61
fix(canvas): remove unnecessary null check.
plainheart Jul 15, 2021
38fa090
Merge pull request #784 from ecomfe/fix-css-warning
pissang Jul 15, 2021
1aef978
Merge pull request #767 from ecomfe/fix-svg-export
pissang Jul 15, 2021
cc4b938
Merge pull request #786 from ecomfe/fix-css-warning
pissang Jul 15, 2021
ed471f6
fix(text): fix a typo. `getStroke` should be `getFill`.
plainheart Jul 16, 2021
2252e44
Merge pull request #787 from ecomfe/fix-typo
pissang Jul 16, 2021
5b1738b
fix(svg): fix gradient color render error
pissang Jul 20, 2021
b06f531
fix(path): should flush pending point in other draw commands
pissang Jul 20, 2021
bb66667
Merge pull request #788 from ecomfe/fix-render-bug
pissang Jul 20, 2021
10cde27
fix(matrix): union return type for function invert
Aug 19, 2021
26cf408
Merge pull request #801 from baojd42/fix-invert-return-type
pissang Aug 19, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './src/zrender';
export * from './src/export';
export * from './lib/zrender';
export * from './lib/export';
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ import {registerPainter} from './lib/zrender';
import CanvasPainter from './lib/canvas/Painter';
import SVGPainter from './lib/svg/Painter';
registerPainter('canvas', CanvasPainter);
registerPainter('svg', SVGPainter);
registerPainter('svg', SVGPainter);
369 changes: 292 additions & 77 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"module": "index.js",
"main": "dist/zrender.js",
"dependencies": {
"tslib": "2.0.3"
"tslib": "2.3.0"
},
"sideEffects": [
"lib/canvas/canvas.js",
Expand All @@ -35,8 +35,8 @@
"devDependencies": {
"@microsoft/api-extractor": "^7.7.2",
"@types/jest": "^25.1.2",
"@typescript-eslint/eslint-plugin": "^2.24.0",
"@typescript-eslint/parser": "^2.24.0",
"@typescript-eslint/eslint-plugin": "^4.9.1",
"@typescript-eslint/parser": "^4.9.1",
"chalk": "^3.0.0",
"commander": "2.11.0",
"eslint": "6.3.0",
Expand All @@ -47,7 +47,7 @@
"rollup-plugin-typescript2": "^0.25.3",
"rollup-plugin-uglify": "^6.0.4",
"ts-jest": "^25.2.0",
"typescript": "^4.1.2",
"typescript": "4.3.5",
"uglify-js": "^3.10.0"
}
}
85 changes: 42 additions & 43 deletions src/Element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from './core/types';
import Path from './graphic/Path';
import BoundingRect, { RectLike } from './core/BoundingRect';
import Eventful, {EventQuery, EventCallback} from './core/Eventful';
import Eventful from './core/Eventful';
import ZRText, { DefaultTextStyle } from './graphic/Text';
import { calculateTextPosition, TextPositionCalculationResult, parsePercent } from './contain/text';
import {
Expand All @@ -28,7 +28,7 @@ import Point from './core/Point';
import { LIGHT_LABEL_COLOR, DARK_LABEL_COLOR } from './config';
import { parse, stringify } from './tool/color';
import env from './core/env';
import { REDARAW_BIT, STYLE_CHANGED_BIT } from './graphic/constants';
import { REDARAW_BIT } from './graphic/constants';

export interface ElementAnimateConfig {
duration?: number
Expand Down Expand Up @@ -284,16 +284,22 @@ export type ElementCommonState = {
hoverLayer?: boolean
}

export type ElementCalculateTextPosition = (
out: TextPositionCalculationResult,
style: ElementTextConfig,
rect: RectLike
) => TextPositionCalculationResult;

let tmpTextPosCalcRes = {} as TextPositionCalculationResult;
let tmpBoundingRect = new BoundingRect(0, 0, 0, 0);

interface Element<Props extends ElementProps = ElementProps> extends Transformable, Eventful, ElementEventHandlerProps {
// Provide more typed event callback params for mouse events.
on<Ctx>(event: ElementEventName, handler: ElementEventCallback<Ctx, this>, context?: Ctx): this
on<Ctx>(event: string, handler: EventCallback<Ctx, this>, context?: Ctx): this

on<Ctx>(event: ElementEventName, query: EventQuery, handler: ElementEventCallback<Ctx, this>, context?: Ctx): this
on<Ctx>(event: string, query: EventQuery, handler: EventCallback<Ctx, this>, context?: Ctx): this
interface Element<Props extends ElementProps = ElementProps> extends Transformable,
Eventful<{
[key in ElementEventName]: (e: ElementEvent) => void | boolean
} & {
[key in string]: (...args: any) => void | boolean
}>,
ElementEventHandlerProps {
}

class Element<Props extends ElementProps = ElementProps> {
Expand Down Expand Up @@ -487,6 +493,7 @@ class Element<Props extends ElementProps = ElementProps> {
*/
update() {
this.updateTransform();

if (this.__dirty) {
this.updateInnerText();
}
Expand All @@ -501,35 +508,21 @@ class Element<Props extends ElementProps = ElementProps> {
}
const textConfig = this.textConfig;
const isLocal = textConfig.local;
const attachedTransform = textEl.attachedTransform;
const innerTransformable = textEl.innerTransformable;

let textAlign: TextAlign;
let textVerticalAlign: TextVerticalAlign;

let textStyleChanged = false;

// TODO Restore the element after textConfig changed.

// NOTE: Can't be used both as normal element and as textContent.
if (isLocal) {
// Apply host's transform.
// TODO parent is always be group for developers. But can be displayble inside.
attachedTransform.parent = this as unknown as Group;
}
else {
attachedTransform.parent = null;
}
// Apply host's transform.
innerTransformable.parent = isLocal ? this as unknown as Group : null;

let innerOrigin = false;

// Reset x/y/rotation
attachedTransform.x = textEl.x;
attachedTransform.y = textEl.y;
attachedTransform.originX = textEl.originX;
attachedTransform.originY = textEl.originY;
attachedTransform.rotation = textEl.rotation;
attachedTransform.scaleX = textEl.scaleX;
attachedTransform.scaleY = textEl.scaleY;
innerTransformable.copyTransform(textEl);

// Force set attached text's position if `position` is in config.
if (textConfig.position != null) {
let layoutRect = tmpBoundingRect;
Expand All @@ -552,8 +545,8 @@ class Element<Props extends ElementProps = ElementProps> {

// TODO Should modify back if textConfig.position is set to null again.
// Or textContent is detached.
attachedTransform.x = tmpTextPosCalcRes.x;
attachedTransform.y = tmpTextPosCalcRes.y;
innerTransformable.x = tmpTextPosCalcRes.x;
innerTransformable.y = tmpTextPosCalcRes.y;

// User specified align/verticalAlign has higher priority, which is
// useful in the case that attached text is rotated 90 degree.
Expand All @@ -574,26 +567,26 @@ class Element<Props extends ElementProps = ElementProps> {
}

innerOrigin = true;
attachedTransform.originX = -attachedTransform.x + relOriginX + (isLocal ? 0 : layoutRect.x);
attachedTransform.originY = -attachedTransform.y + relOriginY + (isLocal ? 0 : layoutRect.y);
innerTransformable.originX = -innerTransformable.x + relOriginX + (isLocal ? 0 : layoutRect.x);
innerTransformable.originY = -innerTransformable.y + relOriginY + (isLocal ? 0 : layoutRect.y);
}
}


if (textConfig.rotation != null) {
attachedTransform.rotation = textConfig.rotation;
innerTransformable.rotation = textConfig.rotation;
}

// TODO
const textOffset = textConfig.offset;
if (textOffset) {
attachedTransform.x += textOffset[0];
attachedTransform.y += textOffset[1];
innerTransformable.x += textOffset[0];
innerTransformable.y += textOffset[1];

// Not change the user set origin.
if (!innerOrigin) {
attachedTransform.originX = -textOffset[0];
attachedTransform.originY = -textOffset[1];
innerTransformable.originX = -textOffset[0];
innerTransformable.originY = -textOffset[1];
}
}

Expand Down Expand Up @@ -1288,7 +1281,7 @@ class Element<Props extends ElementProps = ElementProps> {
throw new Error('Text element has been added to zrender.');
}

textEl.attachedTransform = new Transformable();
textEl.innerTransformable = new Transformable();

this._attachComponent(textEl);

Expand Down Expand Up @@ -1323,7 +1316,7 @@ class Element<Props extends ElementProps = ElementProps> {
removeTextContent() {
const textEl = this._textContent;
if (textEl) {
textEl.attachedTransform = null;
textEl.innerTransformable = null;
this._detachComponent(textEl);
this._textContent = null;
this._innerTextDefaultStyle = null;
Expand Down Expand Up @@ -1402,6 +1395,10 @@ class Element<Props extends ElementProps = ElementProps> {
* Not recursively because it will be invoked when element added to storage.
*/
addSelfToZr(zr: ZRenderType) {
if (this.__zr === zr) {
return;
}

this.__zr = zr;
// 添加动画
const animators = this.animators;
Expand All @@ -1427,6 +1424,10 @@ class Element<Props extends ElementProps = ElementProps> {
* Not recursively because it will be invoked when element added to storage.
*/
removeSelfFromZr(zr: ZRenderType) {
if (!this.__zr) {
return;
}

this.__zr = null;
// Remove animation
const animators = this.animators;
Expand Down Expand Up @@ -1564,7 +1565,7 @@ class Element<Props extends ElementProps = ElementProps> {

// Overload definitions
animateFrom(
target: Props, cfg: Omit<ElementAnimateConfig, 'setToFinal'>, animationProps?: MapToType<Props, boolean>
target: Props, cfg: ElementAnimateConfig, animationProps?: MapToType<Props, boolean>
) {
animateTo(this, target, cfg, animationProps, true);
}
Expand Down Expand Up @@ -1608,9 +1609,7 @@ class Element<Props extends ElementProps = ElementProps> {
* verticalAlign: string. optional. use style.textVerticalAlign by default.
* }
*/
calculateTextPosition: (
out: TextPositionCalculationResult, style: ElementTextConfig, rect: RectLike
) => TextPositionCalculationResult
calculateTextPosition: ElementCalculateTextPosition;

protected static initDefaultProps = (function () {
const elProto = Element.prototype;
Expand Down
6 changes: 3 additions & 3 deletions src/Storage.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as util from './core/util';
import env from './core/env';
import Group from './graphic/Group';
import Group, { GroupLike } from './graphic/Group';
import Element from './Element';

// Use timsort because in most case elements are partially sorted
Expand Down Expand Up @@ -133,8 +133,8 @@ export default class Storage {
}

// ZRText and Group and combining morphing Path may use children
if ((el as Group).childrenRef) {
const children = (el as Group).childrenRef();
if ((el as GroupLike).childrenRef) {
const children = (el as GroupLike).childrenRef();

for (let i = 0; i < children.length; i++) {
const child = children[i];
Expand Down
53 changes: 20 additions & 33 deletions src/animation/Animator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,21 +145,6 @@ function is1DArraySame(arr0: NumberArray, arr1: NumberArray) {
return true;
}

function is2DArraySame(arr0: NumberArray[], arr1: NumberArray[]) {
const len = arr0.length;
if (len !== arr1.length) {
return false;
}
const len2 = arr0[0].length;
for (let i = 0; i < len; i++) {
for (let j = 0; j < len2; j++) {
if (arr0[i][j] !== arr1[i][j]) {
return false;
}
}
}
return true;
}

/**
* Catmull Rom interpolate number
Expand Down Expand Up @@ -311,8 +296,10 @@ class Track {
}

needsAnimate() {
// return this.keyframes.length >= 2;
return !this._isAllValueEqual && this.keyframes.length >= 2 && this.interpolable;
return !this._isAllValueEqual
&& this.keyframes.length >= 2
&& this.interpolable
&& this.maxTime > 0;
}

getAdditiveTrack() {
Expand Down Expand Up @@ -706,10 +693,10 @@ export default class Animator<T> {

private _additiveAnimators: Animator<any>[]

private _doneList: DoneCallback[]
private _onframeList: OnframeCallback<T>[]
private _doneCbs: DoneCallback[]
private _onframeCbs: OnframeCallback<T>[]

private _abortedList: AbortCallback[]
private _abortedCbs: AbortCallback[]

private _clip: Clip = null

Expand Down Expand Up @@ -811,7 +798,7 @@ export default class Animator<T> {
// Clear clip
this._clip = null;

const doneList = this._doneList;
const doneList = this._doneCbs;
if (doneList) {
const len = doneList.length;
for (let i = 0; i < len; i++) {
Expand All @@ -823,7 +810,7 @@ export default class Animator<T> {
this._setTracksFinished();

const animation = this.animation;
const abortedList = this._abortedList;
const abortedList = this._abortedCbs;

if (animation) {
animation.removeClip(this._clip);
Expand Down Expand Up @@ -877,7 +864,7 @@ export default class Animator<T> {
for (let i = 0; i < this._trackKeys.length; i++) {
const propName = this._trackKeys[i];
const track = this._tracks[propName];
const additiveTrack = this._getAdditiveTrack(propName)
const additiveTrack = this._getAdditiveTrack(propName);
const kfs = track.keyframes;
track.prepare(additiveTrack);
if (track.needsAnimate()) {
Expand Down Expand Up @@ -920,7 +907,7 @@ export default class Animator<T> {
// Because target may be changed.
tracks[i].step(self._target, percent);
}
const onframeList = self._onframeList;
const onframeList = self._onframeCbs;
if (onframeList) {
for (let i = 0; i < onframeList.length; i++) {
onframeList[i](self._target, percent);
Expand Down Expand Up @@ -980,10 +967,10 @@ export default class Animator<T> {
*/
during(cb: OnframeCallback<T>) {
if (cb) {
if (!this._onframeList) {
this._onframeList = [];
if (!this._onframeCbs) {
this._onframeCbs = [];
}
this._onframeList.push(cb);
this._onframeCbs.push(cb);
}
return this;
}
Expand All @@ -993,20 +980,20 @@ export default class Animator<T> {
*/
done(cb: DoneCallback) {
if (cb) {
if (!this._doneList) {
this._doneList = [];
if (!this._doneCbs) {
this._doneCbs = [];
}
this._doneList.push(cb);
this._doneCbs.push(cb);
}
return this;
}

aborted(cb: AbortCallback) {
if (cb) {
if (!this._abortedList) {
this._abortedList = [];
if (!this._abortedCbs) {
this._abortedCbs = [];
}
this._abortedList.push(cb);
this._abortedCbs.push(cb);
}
return this;
}
Expand Down
Loading