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

feat(sankey): Add sankey chart dataset support. #19519

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

zhaxnb
Copy link
Contributor

@zhaxnb zhaxnb commented Jan 17, 2024

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others

What does this PR do?

Add sankey chart dataset support.

Fixed issues

Details

Before: What was the problem?

After: How does it behave after the fixing?

image

Document Info

One of the following should be checked.

  • This PR doesn't relate to document changes
  • The document should be updated later
  • The document changes have been made in apache/echarts-doc#xxx

Misc

ZRender Changes

  • This PR depends on ZRender changes (ecomfe/zrender#xxx).

Related test cases or examples to use the new APIs

N.A.

Others

Merging options

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

Other information

Copy link

echarts-bot bot commented Jan 17, 2024

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.

⚠️ MISSING DOCUMENT INFO: Please make sure one of the document options are checked in this PR's description. Search "Document Info" in the description of this PR. This should be done either by the author or the reviewers of the PR.

Copy link
Contributor

The changes brought by this PR can be previewed at: https://echarts.apache.org/examples/editor?version=PR-19519@5b19300

@admsev
Copy link

admsev commented May 25, 2024

@gooroodev review

@gooroodev
Copy link

1. Summary of Changes

The pull request introduces support for Sankey chart datasets in the Apache ECharts library. The changes include:

  • A new helper function createGraphDataFromDataset to create graph data from datasets.
  • Modifications in SankeySeries to support the new dataset-based graph creation.
  • A new test file dataset-sankey.html to test the Sankey chart with different dataset formats.

2. Issues, Bugs, or Typos

Issue 1: Unnecessary Concatenation in prepareSeriesDataSchema

  • Code:
    if (zrUtil.indexOf(coordDimensions, 'value') < 0) {
        coordDimensions.concat(['value']);
    }
  • Improvement:
    if (zrUtil.indexOf(coordDimensions, 'value') < 0) {
        coordDimensions.push('value');
    }
  • Reason: concat does not modify the original array but returns a new one. Use push to directly modify the array.

Issue 2: Inconsistent Formatting in Import Statements

  • Code:
    import {LayoutRect} from '../../util/layout';
    import {createTooltipMarkup} from '../../component/tooltip/tooltipMarkup';
  • Improvement:
    import { LayoutRect } from '../../util/layout';
    import { createTooltipMarkup } from '../../component/tooltip/tooltipMarkup';
  • Reason: Maintain consistent spacing for better readability.

3. General Review of Code Quality and Style

Code Quality

  • Modularity: The code is well-modularized, with the new functionality encapsulated in the createGraphDataFromDataset function.
  • Error Handling: The function throwError is used to handle unsupported dataset formats, which is good practice.
  • TypeScript: Proper TypeScript types and interfaces are used, enhancing code clarity and type safety.

Code Style

  • Consistency: The code generally follows consistent formatting and naming conventions.
  • Documentation: The new function createGraphDataFromDataset is not documented. Adding a JSDoc comment would improve code maintainability.
  • Test Coverage: The new test file dataset-sankey.html is comprehensive, covering various dataset formats.

Summary

Overall, the code quality is good, with minor improvements suggested for better performance and readability. The new functionality is well-integrated and thoroughly tested.

Yours, Gooroo.dev. To receive reviews automatically, install Github App

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.

None yet

3 participants