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

Support using dataType param to specify edge highlighting #16243

Merged
merged 12 commits into from
Jan 5, 2022

Conversation

Dingzhaocheng
Copy link
Contributor

@Dingzhaocheng Dingzhaocheng commented Dec 19, 2021

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others

What does this PR do?

Added property configuration to specify edge highlighting

Fixed issues

Details

Before: What was the problem?

Source from this issue: #16134 (comment), need to solve the problem of highlighting on the specified side

After: How is it fixed in this PR?

According to the original method "highlight" of the highlighted node, pass in the dataType property in the payload

Misc

  • The API has been changed (apache/echarts-doc#xxx).
  • This PR depends on ZRender changes (ecomfe/zrender#xxx).

Related test cases or examples to use the new APIs

echartInstance.dispatchAction({ type: 'highlight', dataType: 'edge | node', dataIndex: number | number[] })

Others

Merging options

  • Please squash the commits into a single one when merging.

Other information

@echarts-bot
Copy link

echarts-bot bot commented Dec 19, 2021

Thanks for your contribution!
The community will review it ASAP. In the meanwhile, please checkout the coding standard and Wiki about How to make a pull request.

Document changes are required in this PR. Please also make a PR to apache/echarts-doc for document changes and update the issue id in the PR description. When the doc PR is merged, the maintainers will remove the PR: awaiting doc label.

src/view/Chart.ts Outdated Show resolved Hide resolved
@pissang
Copy link
Contributor

pissang commented Dec 19, 2021

Please dont commit yarn.lock

@pissang
Copy link
Contributor

pissang commented Dec 20, 2021

Please don't commit dist and i18n folder. Just the changed source code

src/view/Chart.ts Outdated Show resolved Hide resolved
.gitignore Outdated Show resolved Hide resolved
@pissang
Copy link
Contributor

pissang commented Dec 20, 2021

@Dingzhaocheng I didn't mean deleting these two folders. Just don't commit the change.

Make sure in the Files Changed tab only having the changed source code and added test files.

@Dingzhaocheng
Copy link
Contributor Author

@Dingzhaocheng I didn't mean deleting these two folders. Just don't commit the change.

Make sure in the Files Changed tab only having the changed source code and added test files.

I'm sorry, I didn't get it right earlier. 😊

src/view/Chart.ts Outdated Show resolved Hide resolved
@pissang
Copy link
Contributor

pissang commented Dec 20, 2021

I'm sorry, I didn't get it right earlier. 😊

Never mind. We are glad to having your contribution

@pissang pissang added this to the 5.3 milestone Dec 20, 2021
@plainheart plainheart linked an issue Dec 20, 2021 that may be closed by this pull request
@@ -152,7 +152,7 @@ class ChartView {
* Highlight series or specified data item.
*/
highlight(seriesModel: SeriesModel, ecModel: GlobalModel, api: ExtensionAPI, payload: Payload): void {
toggleHighlight(seriesModel.getData(), payload, 'emphasis');
toggleHighlight(seriesModel.getData(payload && payload.dataType), payload, 'emphasis');
Copy link
Contributor

Choose a reason for hiding this comment

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

Developers may give wrong dataType that is not supported in the echarts. It's better to check if data exists here.

Also downplay method should also add this change.

@@ -152,14 +152,14 @@ class ChartView {
* Highlight series or specified data item.
*/
highlight(seriesModel: SeriesModel, ecModel: GlobalModel, api: ExtensionAPI, payload: Payload): void {
toggleHighlight(seriesModel.getData(), payload, 'emphasis');
toggleHighlight(seriesModel.getData(payload && payload.dataType), payload, 'emphasis');
Copy link
Contributor

Choose a reason for hiding this comment

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

If we need to do null checking. We should always do it at the place where it is used. In this case is before we passing it as a parameter to toggleHighlight. What if seriesModel.getData() has other methods to fetch the data if you do null checking in the getLinkedData. ?

Here is an example:

const data = seriesModel.getData(payload && payload.dataType)
if (!data) {
    if (__DEV__) {
        error(`Unkown dataType ${dataType}`);
    }
    return;
}
toggleHighlight(data, payload, 'emphasis');

Null checking in the getLinkedData can be removed to simplify the code.

@pissang pissang changed the title Fix: Added property configuration to specify edge highlighting Support using dataType param to specify edge highlighting Jan 4, 2022
@pissang pissang merged commit 3731d5f into apache:master Jan 5, 2022
@echarts-bot
Copy link

echarts-bot bot commented Jan 5, 2022

Congratulations! Your PR has been merged. Thanks for your contribution! 👍

@maneetgoyal
Copy link

@Dingzhaocheng hi, how can we highlight both nodes and edges simultaneously?

@maneetgoyal
Copy link

@pissang please help

@Dingzhaocheng
Copy link
Contributor Author

@Dingzhaocheng hi, how can we highlight both nodes and edges simultaneously?

You can see the PR changes file, you can follow these changes to directly modify your local package, then you can use the new API on the proposal, the test case also has the usage, you can refer to it

@Dingzhaocheng
Copy link
Contributor Author

@Dingzhaocheng hi, how can we highlight both nodes and edges simultaneously?

You can see the PR changes file, you can follow these changes to directly modify your local package, then you can use the new API on the proposal, the test case also has the usage, you can refer to it

I'm not sure if the new version already has this method, you can check the documentation, if so, then just update to the new version

@maneetgoyal
Copy link

@Dingzhaocheng i am using the latest version. The "dataType" property is working but I want to highlight both nodes and edges at the same time.

Currently it is allowing me to highlight only one of them at a time.

Can you suggest something?

@Dingzhaocheng
Copy link
Contributor Author

@Dingzhaocheng i am using the latest version. The "dataType" property is working but I want to highlight both nodes (节点) and edges at the same time.

Currently it is allowing me to highlight only one of them at a time.

Can you suggest something?

Modify the local source code, change the dataType in the payload, pass in an array structure to indicate that the nodes and edges are highlighted together, and execute toggleHighlight in a loop based on the payload in the highlight method; not elegant, but effective

@maneetgoyal
Copy link

@pissang @Ovilia I can raise a PR if you guys or others from the Echarts team can review it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: awaiting doc Document changes is required for this PR. PR: first-time contributor size/S
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] graph highlight 如何高亮指定节点和边。
4 participants