Skip to content

Conversation

Ovilia
Copy link
Contributor

@Ovilia Ovilia commented Apr 9, 2024

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others

What does this PR do?

This PR introduces a new coordinate called "Matrix".

Matrix can serve as:

  • The layout system of data items of a series. The examples are listed as follows in this initial post.
  • The layout system of the box of a series/component, which enables tiny charts to lay out in a table, or CSS grid layout, or even a pure data table. Some subsequent definitions/examples are provided in comment feat(matrix): new matrix coordinate #19807 (comment)

The layout base of data items of a series

Multiple series like heatmap, pie, graph, custom can be used along with it.

FireShot Capture 002 -  - 127 0 0 1

More applications:

FireShot Capture 003 -  - 127 0 0 1

Fixed issues

Details

Before: What was the problem?

After: How does it behave after the fixing?

Document Info

One of the following should be checked.

The full document will be published when v6.0.0 is released.
Current doc for v6.0.0-beta:

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 Apr 9, 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.

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

⚠️ 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.

@echarts-bot echarts-bot bot added the PR: awaiting doc Document changes is required for this PR. label Apr 11, 2024
Copy link

echarts-bot bot commented Apr 11, 2024

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.

Copy link
Contributor

github-actions bot commented Apr 18, 2024

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

@Ovilia Ovilia marked this pull request as ready for review May 9, 2024 07:41
@Ovilia Ovilia added this to the 6.0.0 milestone May 9, 2024
@Ovilia Ovilia changed the title feat: init matrix coordinate feat: matrix coordinate May 9, 2024
@Ovilia Ovilia linked an issue May 10, 2024 that may be closed by this pull request
100pah and others added 11 commits June 9, 2025 21:00
…ct geo/insideDataZoom/treemap/sankey/graph roam)
…But it was based on canvas width/height, which is not reasonable - the unit may incorrect, and it is unpredictable if the `View['_rect']` is not calculated based on the current canvas rect. Therefore the percentage value is changed to based on `View['_rect'].width/height` since v6. Under this definition, users can use '0%' to map the top-left of `View['_rect']` to the center of `View['_viewRect']`.
…ectVerticalAlign` for series.map/geo/series.graph in box layout (lay out by left/right/top/bottom/width/height).

(2) Support `clip` on geo/series.map
(3) Support `roamTigger: 'global' | 'selfRect'` to switch roam area to global on only self bounding rect.
(4) Support cursor style change when hovering the roaming enabled area to hint users.
(5) Fix that center and zoom option does not work in series.sankey, and no relevant test case. (the roam is introduced in impl in #20321, due v6).
(6) Fix the percent base of `center` (such as `center: ['40%', '50%']`) for all View coord sys based components/series (geo/series.map/series.graph/series.tree/series.sankey). #16904 introcuded percentage string here, such as '33%'. But it was based on canvas width/height, which is not reasonable - the unit may incorrect, and it is unpredictable if the `View['_rect']` is not calculated based on the current canvas rect. Therefore the percentage value is changed to based on `View['_rect'].width/height` since v6. Under this definition, users can use '0%' to map the top-left of `View['_rect']` to the center of `View['_viewRect']`.
(7) Enhance the behavior for roaming area overlapping - the upper one has higher precedence.
(8) Fix some `scaleLimit` missing.
(9) Some refactor and clarification of `RoamController` and `roamHelper`.
@100pah
Copy link
Member

100pah commented Jun 15, 2025

Roaming Infrastructure Upgrade

Support preserveAspect

Support preserveAspect preserveAspectAlign preserveAspectVerticalAlign on series.map, geo, series.graph in box layout (lay out by left/right/top/bottom/width/height).

xx1

The new introduced echarts option is:

    // Suppose a "viewport" is decided by `left`/`right`/`top`/`bottom`/`width`/`height`,
    // - null/undefined/false (default): aspect ratio will not be preserved, but stretched to fill
    //   the "viewport".
    // - 'contain'/true: The aspect ratio is preserved; the viewRect is contained by the "viewport",
    //   and scaled up as much as possible to meet the "viewport".
    // - 'cover': The aspect ratio is preserved; the viewRect covers the "viewport", and scaled down
    //   as much as possible to meet the "viewport".
    preserveAspect?: boolean | 'contain' | 'cover';
    // By default 'center'
    preserveAspectAlign?: 'left' | 'right' | 'center';
    // By default 'middle'
    preserveAspectVerticalAlign?: 'top' | 'bottom' | 'middle';

For example:

chart.setOption({
    geo: [{
        left: 10,
        right: 10,
        top: 10,
        bottom: 10,
        preserveAspect: true,
        // ...
    }]
});
// or 
chart.setOption({
    series: [{
        type: 'graph',
        left: 10,
        right: 10,
        top: 10,
        bottom: 10,
        preserveAspect: true,
        // ...
    }]
});

Support clip

Support clip on geo component and series.map.

That is, if clip: true, hide the part that overflows the given layout rect defined by left/right/top/bottom/width/height.

xx2

For example:

chart.setOption({
    geo: [{
        clip: true, // default `false`
        // These props also defines the clip area.
        left: 20, 
        top: 50, 
        right: 50, 
        bottom: 50, 
        // ...
    }]
});
// or
chart.setOption({
    series: [{
        type: 'map',
        clip: true, // default `false`
        // These props also defines the clip area.
        left: 20, 
        top: 50, 
        right: 50, 
        bottom: 50, 
        // ...
    }]
});

Support cursor style change on roaming.

Support roamTigger: 'global' | 'selfRect' to switch roam area to global on only self bounding rect on geo, series.map, series.graph, series.tree, series.sankey, series.treemap.

Before:
bb2

After:

bb1

Support cursor style change when hovering the roaming enabled area to hint users.

Support roamTrigger: 'global' | 'selfRect'

xx3

    /**
     * Hover over an area where roaming is triggered.
     * - if `null`/`undefined`/`'selfRect'`, the trigger area is
     *   the intersection of "self bounding rect" and "clipping rect (if any)".
     * - if 'global', the trigger area is
     *   the intersection of "the entire canvas" and "clipping rect (if any)".
     * NOTE:
     *  The clipping rect, which can be enabled by `clip: true`, is typically the layout rect.
     *  The layout rect is typically determined by option `left`/`right`/`top`/`bottom`/`width`/`height`, some
     *  components/series, such as `geo` and `series.map` can also be determined by `layoutCenter`/`layoutSize`,
     *  and may modified by `preserveAspect`.
     */
    roamTrigger?: 'global' | 'selfRect' | NullUndefined

For example:

chart.setOption({
    geo: {
        roamTrigger: 'global', // by default 'selfRect' in geo component.
        // ...
    }
});

Fix the percent base of center for all coord/View coord sys based components/series

"View coord sys based components/series" is geo/series.map/series.graph/series.tree/series.sankey
Percent base of the center option is like:

chart.setOption({
    geo: {
        center: ['40%', '50%'],
        // ...
    }
});

Notice that historically the definition of this center option has always been irrelevant to some other series center like series[type='pie'].center - this center is a point on the raw data coord sys, rather than canvas viewport, and the unit is not necessarily pixel. For example, in geo component, the center option is [longitude, latitude]. This center option means that moving that center point to the center of the viewport.

#16904 introduced percentage string here, such as '33%'. But it was based on canvas width/height, which is not reasonable - the unit may incorrect, and it is unpredictable if the raw data coords are not calculated based on the current canvas rect. Therefore, the percentage value is changed to based on the raw data bounding rect since v6. Under this definition, users can use '0%' to move the top/left of the content to the center of the viewport, and use '100%' to move the bottom/right of the content to the center of the viewport.

This is a breaking change. To restore the previous behavior in v5:

chart.setOption({
    legacyViewCoordSysCenterBase: true,
    // ... 
});

Others

Enhance the behavior for roaming area overlapping

The upper one has higher precedence.

Fix some scaleLimit missing

Fix center and zoom option does not work in series.sankey.

And no relevant test case. (the roam is introduced in impl in #20321, due v6).

Some refactor and clarification of RoamController and roamHelper

@100pah 100pah merged commit e4c0eb8 into v6 Jun 20, 2025
0 of 2 checks passed
@github-project-automation github-project-automation bot moved this from In Review to Done in ECharts 6.0 Jun 20, 2025
Copy link

echarts-bot bot commented Jun 20, 2025

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

@Ovilia Ovilia changed the title feat: matrix coordinate feat(matrix): new matrix coordinate Jun 21, 2025
@Ovilia Ovilia deleted the feat-matrix branch June 21, 2025 00:49
@100pah
Copy link
Member

100pah commented Jun 27, 2025

Thumbnail

The final refactor of Thumbnail is make here.
The previous thumbnail related PR:
#17471
#18039

Thumbnail is finally designed as a component.
New echarts component option is introduced:

const option = {
    series: {
        type: 'graph',
        // ...
    },
    thumbnail: {
        // ...
        seriesId: 'xxx', // Optional, use the first series.graph by default.
        seriesIndex: 0, // Optional, use the first series.graph by default.
    }
}

Currently thumbnail only support series.graph.
More other base map, such as geo, series.tree, series.sankey, can be supported based on the current data structure.

The thumbnail options:

{
    type?: string;

    id?: OptionId;
    name?: OptionName;

    z?: number;
    zlevel?: number;

    coordinateSystem?: string
    coordinateSystemUsage?: CoordinateSystemUsageOption
    coord?: CoordinateSystemDataCoord
    width?: PositionSizeOption;
    height?: PositionSizeOption;
    top?: PositionSizeOption;
    right?: PositionSizeOption;
    bottom?: PositionSizeOption;
    left?: PositionSizeOption;

    show?: boolean

    itemStyle?: ItemStyleOption
    windowStyle?: ItemStyleOption

    seriesIndex?: number | number[]
    seriesId?: string | string[]
}

The example is test/graph-thumbnail.html.

The minimal echarts option to enable thumbnail on graph:

chart.setOption({
    series: {
        type: 'graph',
        data: [{
            itemStyle: null,
            name: 'DRD2',
            value: 40,
            symbolSize: 40
        }, {
            itemStyle: null,
            name: 'ADORA2A',
            value: 0,
            symbolSize: 20
        }],
        links: [],
    },
    thumbnail: {}, // declare a thumbnail component, use the first series.graph by default.
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[Feature] Matrix Coordinate
3 participants