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
base: next
Are you sure you want to change the base?
feat: matrix coordinate #19807
Conversation
Thanks for your contribution! The pull request is marked to be |
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 |
The changes brought by this PR can be previewed at: https://echarts.apache.org/examples/editor?version=PR-19807@ab3efd3 |
doc(matrix): add doc for apache/echarts#19807
@@ -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'; |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
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]); | ||
} |
There was a problem hiding this comment.
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') { |
There was a problem hiding this comment.
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.
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])); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the above.
this.group.add(new graphic.Text({ | ||
style: createTextStyle(xLabelModel, { | ||
text: cell.value, | ||
x: left + width / 2, | ||
y: top + height / 2, | ||
verticalAlign: 'middle', | ||
align: 'center' | ||
}) | ||
})); |
There was a problem hiding this comment.
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')
})
);
this.group.add(new graphic.Text({ | ||
style: createTextStyle(yLabelModel, { | ||
text: cell.value, | ||
x: left + width / 2, | ||
y: top + height / 2, | ||
verticalAlign: 'middle', | ||
align: 'center' | ||
}) | ||
})); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
}
There was a problem hiding this 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. 🤔
Line 172 in ab3efd3
"./lib/component/aria": "./lib/component/aria.js", |
Brief Information
This pull request is in the type of:
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.
More applications:
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
Related test cases or examples to use the new APIs
N.A.
Others
Merging options
Other information