Skip to content

Conversation

@neuqzxy
Copy link
Contributor

@neuqzxy neuqzxy commented Mar 31, 2025

[中文版模板 / Chinese template]

🤔 This is a ...

  • New feature
  • Bug fix
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Enhancement feature
  • Refactoring
  • Update dependency
  • Code style optimization
  • Test Case
  • Branch merge
  • Release
  • Site / documentation update
  • Demo update
  • Workflow
  • Other (about what?)

🔗 Related issue link

🔗 Related PR link

🐞 Bugserver case id

💡 Background and solution

📝 Changelog

Language Changelog
🇺🇸 English
🇨🇳 Chinese

☑️ Self-Check before Merge

⚠️ Please check all items below before requesting a reviewing. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

🚀 Summary

copilot:summary

🔍 Walkthrough

copilot:walkthrough

* 水平柱状图拆分策略
* 针对水平柱状图,先更新y和height,再更新x和width
*/
export class HorizontalBarSplitStrategy implements IAnimationSplitStrategy {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

按照代码规范,最好不要把两个 class 定义放在一个文件里面

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

按照代码规范,最好不要把两个 class 定义放在一个文件里面

已修改

.find(e => e.context.data[0]?.[DEFAULT_DATA_INDEX] < dataIndex);
if (outState.includes(state)) {
return prevMarkElement?.getNextGraphicAttributes()?.endAngle;
return prevMarkElement?.getFinalAttribute()?.endAngle;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vrender getFinalAttribute 是什么含义?只有这里需要改成这个api吗

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vrender getFinalAttribute 是什么含义?只有这里需要改成这个api吗

就是获取最终的属性,只要有动画,就用这个拿到encode出来的属性

/**
* 用于保存mark对应series的fieldX
*/
_originalFieldX?: string[];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public 属性,最好不要 以 "_"开头

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

以修改

if (!this._animationConfig) {
return false;
}
return Object.keys(this._animationConfig).length > 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里应该会有问题,this._animationConfig 里面会有如下配置吧:

{
  state: false
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没有,_animationConfig是个对象,里面结构如下

{
    "appear": [
        {
            "duration": 300,
            "easing": "cubicOut",
            "type": "growHeightIn"
        }
    ],
    "update": [
        {
            "type": "update",
            "duration": 300,
            "easing": "linear"
        }
    ],
    "enter": [
        {
            "duration": 300,
            "easing": "linear",
            "type": "growHeightIn"
        }
    ],
    "exit": [
        {
            "duration": 300,
            "easing": "linear",
            "type": "growHeightOut",
            "controlOptions": {
                "stopWhenStateChange": true
            }
        }
    ],
    "disappear": [
        {
            "duration": 500,
            "easing": "cubicIn",
            "type": "growHeightOut"
        }
    ],
    "state": {
        "duration": 300,
        "easing": "linear"
    }
}

// 有可能又被复用了,所以这里需要判断,如果还是在exiting阶段的话才删除
// TODO 这里如果频繁执行的话,可能会误判
if (g.isExiting) {
this._graphicMap.delete(key);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

下面这段代码有重复使用,可以抽一个函数

 this._graphicMap.delete(key);
          if (g.parent) {
            g.parent.removeChild(g);
          }
          if (g.release) {
            g.release();
          }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已抽象

if (planner.state === 'exit') {
planner.graphics.forEach(g => {
if (g.isExiting) {
(this as any)._graphicMap.delete(g.context.uniqueKey);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

下面的代码出现了三次了,可以抽象一个函数

(this as any)._graphicMap.delete(g.context.uniqueKey);
            if (g.parent) {
              g.parent.removeChild(g);
            }
            if (g.release) {
              g.release();
            }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修复

);

// 按顺序执行planner
this._executePlanners(planners, 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果有多个 planners ,是什么时机去执行 index > 0 的planner?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

里面有递归的,串行调用

const enterGraphics: IMarkGraphic[] = [];
const appearGraphics: IMarkGraphic[] = [];

const fieldX = (this.mark.model as any).fieldX;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

model 哪里来的?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

接口上mark是有model的,this.mark就是图元mark


// 保存原始fieldX/fieldY以供比较
if (context.fieldX) {
context._originalFieldX = context.fieldX;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不要下划线吧

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

context.fieldY = fieldY;

const state = defaultState ?? g.context.animationState;
switch (state) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xiaoluoHe 一起看看这段有必要吗

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

其实现在。animationState 和。diffState. 就是一样的,这样反复处理,有必要吗

@neuqzxy neuqzxy force-pushed the feat/animate-enhance branch from 4813af1 to e9bfb53 Compare April 9, 2025 13:55
@xile611 xile611 added this to the v2.0.0 milestone Apr 17, 2025
@xile611 xile611 force-pushed the feat/animate-enhance branch from 7af479f to b677cfa Compare May 7, 2025 09:17
@xile611 xile611 merged commit b046cc2 into dev/2.0.0 May 8, 2025
3 of 5 checks passed
@xile611 xile611 deleted the feat/animate-enhance branch May 8, 2025 02:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants