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: matrix coordinate #19807

Open
wants to merge 18 commits into
base: next
Choose a base branch
from
Open

feat: matrix coordinate #19807

wants to merge 18 commits into from

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".

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.

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@ab3efd3

@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
Ovilia added a commit to apache/echarts-examples that referenced this pull request May 15, 2024
@Ovilia Ovilia changed the base branch from master to v6 May 15, 2024 07:31
@Ovilia Ovilia requested a review from plainheart May 16, 2024 02:12
Ovilia added a commit to apache/echarts-doc that referenced this pull request May 16, 2024
Ovilia added a commit to apache/echarts-doc that referenced this pull request May 16, 2024
@Ovilia Ovilia changed the base branch from v6 to next May 16, 2024 06:50
@@ -34,6 +34,7 @@ import type Cartesian2D from '../../coord/cartesian/Cartesian2D';
import type Calendar from '../../coord/calendar/Calendar';
import { setLabelStyle, getLabelStatesModels } from '../../label/labelStyle';
import type Element from 'zrender/src/Element';
import Matrix from '../../coord/matrix/Matrix';
Copy link
Member

Choose a reason for hiding this comment

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

Always good to import type explicitly.

static type = 'matrix';
type = MatrixView.type;

render(matrixModel: MatrixModel, ecModel: GlobalModel, api: ExtensionAPI) {
Copy link
Member

Choose a reason for hiding this comment

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

The latter two parameters are unused, just remove them and relative imports.

Comment on lines +65 to +76
if (!this._option.data) {
this._leavesCount = 0;
return 0;
}
if (typeof this._option.data === 'string') {
this._leavesCount = 1;
return 1;
}
let cnt = 0;
for (let i = 0; i < this._option.data.length; i++) {
cnt += this._countLeaves(this._option.data[i]);
}
Copy link
Member

Choose a reason for hiding this comment

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

Extract this._option.data to a local constant for reducing several characters.

this._leavesCount = 0;
return 0;
}
if (typeof this._option.data === 'string') {
Copy link
Member

Choose a reason for hiding this comment

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

Consider using the isString helper.

Comment on lines +88 to +97
if (!this._option.data) {
return 0;
}
if (typeof this._option.data === 'string') {
return 1;
}
let height = 0;
for (let i = 0; i < this._option.data.length; i++) {
height = Math.max(height, this._countHeight(this._option.data[i]));
}
Copy link
Member

Choose a reason for hiding this comment

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

Similar to the above.

Comment on lines +80 to +88
this.group.add(new graphic.Text({
style: createTextStyle(xLabelModel, {
text: cell.value,
x: left + width / 2,
y: top + height / 2,
verticalAlign: 'middle',
align: 'center'
})
}));
Copy link
Member

Choose a reason for hiding this comment

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

It would be better to use the new API setTextConfig & setTextContent added since v5. We also should support silent option to allow disabling mouse events.

cellRect.setTextConfig({
    position: 'inside'
});
cellRect.setTextContent(
    new graphic.Text({
        style: createTextStyle(xLabelModel, {
            text: cell.value,
            verticalAlign: 'middle',
            align: 'center',
        }),
        silent: xLabelModel.get('silent')
    })
);

Comment on lines +110 to +118
this.group.add(new graphic.Text({
style: createTextStyle(yLabelModel, {
text: cell.value,
x: left + width / 2,
y: top + height / 2,
verticalAlign: 'middle',
align: 'center'
})
}));
Copy link
Member

Choose a reason for hiding this comment

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

Similar to the above.

}

// Outer border
const backgroundStyle = matrixModel
Copy link
Member

Choose a reason for hiding this comment

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

These borders may overlap and cause a darker border color. I'm not sure if we should provide a similar ability like the CSS table property border-collapse. It looks not easy to implement that feature.

And the chart seems rendering unexpectedly if I set the width of both the outer border and inner border to 0.

backgroundStyle: {
    borderWidth: 0
},
innerBackgroundStyle: {
    borderWidth: 0
}

Copy link
Member

@plainheart plainheart left a comment

Choose a reason for hiding this comment

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

The package.json may need to be updated as well. 🤔

"./lib/component/aria": "./lib/component/aria.js",

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.

[Feature] Matrix Coordinate
2 participants