Skip to content

[feature] [transform] add new aggregate transform and id transform - #16903

Draft
pissang wants to merge 11 commits into
nextfrom
aggregate-transform
Draft

pissang wants to merge 11 commits into
nextfrom
aggregate-transform

Conversation

@pissang

@pissang pissang commented Apr 18, 2022

Copy link
Copy Markdown
Contributor

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others

What does this PR do?

This PR migrates the aggregate and id transform from echarts-simple-transform, which is a experiment repo maintained by one of our maintainers @100pah. The API design is mainly keeped same but code are refactored to be more clear and neater.

Also in this PR the old seriesLayoutBy option is renamed to sourceLayout to be more clear.

Details

Aggregate transform

const option = {
    dataset: [{
        source: [
            ['aa', 'bb', 'cc', 'tag'],
            [12, 0.33, 5200, 'AA'],
            [21, 0.65, 7100, 'AA'],
            [51, 0.15, 1100, 'BB'],
            [71, 0.75, 9100, 'BB'],
            ...
        ]
    }, {
        transform: {
            type: 'aggregate',
            config: {
                output: [
                    // by default, use the same name with `from`.
                    { from: 'aa', method: 'sum' },
                    { from: 'bb', method: 'count' },
                    { from: 'cc' }, // method by default: use the first value.
                    { from: 'dd', method: 'Q1' },
                    { from: 'tag' }
                ],
                groupBy: 'tag'
            }
        }
        // Then the result data will be:
        // [
        //     ['aa', 'bb', 'cc', 'tag'],
        //     [12, 0.33, 5200, 'AA'],
        //     [21, 0.65, 8100, 'BB'],
        //     ...
        // ]
    }],
    // ...
};

ID transform

const option = {
    dataset: [{
        source: [
            ['aa', 'bb', 'cc', 'tag'],
            [12, 0.33, 5200, 'AA'],
            [21, 0.65, 8100, 'AA'],
            ...
        ]
    }, {
        transform: {
            type: 'id',
            config: {
                dimensionIndex: 4,
                dimensionName: 'ID'
            }
        }
        // Then the result data will be:
        // [
        //     ['aa', 'bb', 'cc', 'tag', 'ID'],
        //     [12, 0.33, 5200, 'AA', 0],
        //     [21, 0.65, 8100, 'BB', 1],
        //     ...
        // ]
    }],
    // ...
};

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

N.A.

Others

Merging options

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

Other information

@echarts-bot

echarts-bot Bot commented Apr 18, 2022

Copy link
Copy Markdown

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.

The pull request is marked to be PR: author is committer because you are a committer of this project.

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.

@echarts-bot echarts-bot Bot added PR: author is committer PR: awaiting doc Document changes is required for this PR. PR: awaiting review labels Apr 18, 2022
@pissang
pissang marked this pull request as draft April 18, 2022 07:59
@pissang
pissang requested a review from 100pah April 18, 2022 07:59
@github-actions

github-actions Bot commented Jun 8, 2024

Copy link
Copy Markdown
Contributor

This PR has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this PR. We are sorry for this but 2 years is a long time and the code base has been changed a lot. Thanks for your contribution anyway.

@github-actions github-actions Bot added the stale Inactive for a long time. Will be closed in 7 days. label Jun 8, 2024
@plainheart plainheart added this to the TBD milestone Jun 11, 2024
@namannitr

Copy link
Copy Markdown

Thanks for landing the aggregate/id migration design here.

Two correctness items from the experimental plugin that are worth checking against this branch before it leaves draft (they are easy to miss because src and dist diverged):

Also, this PR’s aggregate still groups by one dimension. Long-format “one series per value of column X” is a reshape, not an aggregation — opened #21742 so that discussion does not block this migration.

I am not proposing extra API on this PR; just flagging the SUM seed/dist trap so core does not re-ship it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: author is committer PR: awaiting doc Document changes is required for this PR. size/XL stale Inactive for a long time. Will be closed in 7 days.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants