Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Callback for series-tree.symbol not defined in typescript #17946

Closed
theoarav opened this issue Nov 21, 2022 · 3 comments · Fixed by #18070
Closed

[Bug] Callback for series-tree.symbol not defined in typescript #17946

theoarav opened this issue Nov 21, 2022 · 3 comments · Fixed by #18070
Labels
bug difficulty: easy Issues that can be fixed more easily than the average. en This issue is in English typescript

Comments

@theoarav
Copy link

Version

5.4.0

Link to Minimal Reproduction

https://echarts.apache.org/examples/en/editor.html?c=tree-polyline&lang=ts&code=MYewdgzgLgBAJgQygmBeGBvAUDGYEC2ApgFwwDkAZgDYIBOR5ANDjMABYCW1cDYZAbVa5suMXkKkKiZM2FiO3XkX4wh48aI3j8xMuVBgAbkTpRTEOdvGKefQfOuYJeigGFwJsxeYwjCagBXKQB2ACYARhgAXxYnTRcpcgARImpOAk5zOAAVIgAPKA9jU3M6X38gqQAWMIBOapjHDQBdZtxY9swu3F0k5KQEAFUobit4yuCyAGZpsLCu6Oa28U7NZr79OE4IAAdaAE9xmy47FQcnDET9ZM4zA4BlXbosxiY_AKmYAA5v2Zi4tYrpsKAAZThgIhPF7mCqfKQREJzAFdYGSfQAJSIwCg0NecKqMwAbGFpk1tCsxGsxFodOiKDQCscFKdlKoBGjXOQAGK0BgANR2BK-1QiESJMUpHUBIg29PIAEdgnQjjKWUp7GpUdcKABBADm-oY-qQRAAovlnkQIBBOOBhQiieKUZcdeRdWA4A6yBEAAxhEIuoFu3Uw9jEUbAb0wabfOpRanaTlJXVeBD6t4fQk_eNBpNugBCEPoBwtVptdrA0bCcbJiY0yf0HgIu3oO3t70mUgArH662qEiDyM3diBbeYywwKx2s19pkSQoH64P5R5AmAoNGQt8EwOaW6BuYRmNO_CyKLRXmGwedqMwDjo3V_sv90PJ9bbTOu2Re9NfVeVy5d9pzAABJMokB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PEwHrpQKA-hvhhL3FDH6IiCD6HmHE5oLx9TsGiRQMIvo0nNAgAcAgCTqBkAABT1VDCjA4AAfMAEkoamHeK2FGBAIBkB9lDAAVrjAAlGgAAfBQBgwUClFJKQ8TgAAvUI_jtBEDgBmB47AEDkP0KOagBx0iQnCQsjM3IoIAGsAAKY4siVn0ESaYaS7FgHOQEHIDAiCpD4ewGYcyNDbKhBY-ukiuiy3sVAN5oVmidGaLQRppShHWChggYAhyjRaM9B4agUF9AAGJ2odS6KOccFyKCRI8l0LwkYAi6nSPqdRmR9J32cgEGR6iMlZP0doMF2h64IBMO06F7La5pD-dpXF5zwD6CZUS7SJLODr3JQy9a9i4C0vkvSyl-hCUsusEsVlHzxBEBbCs203KJ7iEoCAYA2itjWjFp6f-6rVjarEAUVsnoPRwBRbQXY2MyBZ2CHucyGRoHgGSIEFG_DVCeycc0P1G1Q1BpDZWIYPNTRkBCN2X0Y82FYE4UAA

Steps to Reproduce

Using example from official website Tree with polylines, set symbol parameter in the series to a callback:

symbol: (value: Array|number, params: Object) => 'rect',

Documentation reference: https://echarts.apache.org/en/option.html#series-tree.symbol

Current Behavior

The callback works but there is a typescript error :
image

Expected Behavior

The callback should be allowed in the type definition of series-tree.symbol and other items that accept callbacks.

Environment

- OS: macOS Monterey
- Browser: Chrome 107.0.5304.107
- Framework: Angular@14

Any additional comments?

No response

@theoarav theoarav added the bug label Nov 21, 2022
@echarts-bot echarts-bot bot added en This issue is in English pending We are not sure about whether this is a bug/new feature. labels Nov 21, 2022
@theoarav
Copy link
Author

Seems like the problems comes from the definition of the interface of TreeSeriesOption:

interface TreeSeriesOption extends SeriesOption<TreeSeriesStateOption, TreeStatesMixin>, TreeSeriesStateOption, SymbolOptionMixin, BoxLayoutOptionMixin, RoamOptionMixin {
    type?: 'tree';
    layout?: 'orthogonal' | 'radial';
    edgeShape?: 'polyline' | 'curve';
    /**
     * Available when edgeShape is polyline
     */
    edgeForkPosition?: string | number;
    nodeScaleRatio?: number;
    /**
     * The orient of orthoginal layout, can be setted to 'LR', 'TB', 'RL', 'BT'.
     * and the backward compatibility configuration 'horizontal = LR', 'vertical = TB'.
     */
    orient?: 'LR' | 'TB' | 'RL' | 'BT' | 'horizontal' | 'vertical';
    expandAndCollapse?: boolean;
    /**
     * The initial expanded depth of tree
     */
    initialTreeDepth?: number;
    leaves?: TreeSeriesLeavesOption;
    data?: TreeSeriesNodeItemOption[];
}

In the extends SymbolOptionMixin, there is no generic given to the interface.

interface SymbolOptionMixin<T = never> {
    /**
     * type of symbol, like `cirlce`, `rect`, or custom path and image.
     */
    symbol?: string | (T extends never ? never : SymbolCallback<T>);
    /**
     * Size of symbol.
     */
    symbolSize?: number | number[] | (T extends never ? never : SymbolSizeCallback<T>);
    symbolRotate?: number | (T extends never ? never : SymbolRotateCallback<T>);
    symbolKeepAspect?: boolean;
    symbolOffset?: string | number | (string | number)[] | (T extends never ? never : SymbolOffsetCallback<T>);
}

Maybe setting the extends SymbolOptionMixin to extends SymbolOptionMixin<CallbackDataParams> in the declaration of the interface CallbackDataParams, would solve this issue ?

@Ovilia
Copy link
Contributor

Ovilia commented Nov 23, 2022

It seems the callback function itself is working (symbol: () => 'triangle') but the type definition may be wrong. Are you interested in making a pull request?

@Ovilia Ovilia added typescript difficulty: easy Issues that can be fixed more easily than the average. and removed pending We are not sure about whether this is a bug/new feature. labels Nov 23, 2022
@echarts-bot
Copy link

echarts-bot bot commented Nov 23, 2022

This issue is labeled with difficulty: easy.
@theoarmengou Would you like to debug it by yourself? This is a quicker way to get your problem fixed. Or you may wait for the community to fix.

Please have a look at How to debug ECharts if you'd like to give a try. 🤓

@Ovilia Ovilia added this to the TBD milestone Nov 23, 2022
@Ovilia Ovilia closed this as completed in 4b4a732 Dec 16, 2022
Ovilia added a commit that referenced this issue Dec 16, 2022
fix(tree): change symbol type. close #17946
@Ovilia Ovilia removed this from the TBD milestone Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug difficulty: easy Issues that can be fixed more easily than the average. en This issue is in English typescript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants