-
Notifications
You must be signed in to change notification settings - Fork 19.6k
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
Ovilia
wants to merge
20
commits into
next
Choose a base branch
from
feat-matrix
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: matrix coordinate #19807
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
ecd2ff0
feat: init matrix coordinate
Ovilia 780dd4b
feat: render a rect for matrix coordinate
Ovilia 3c1dcb4
feat(matrix): basic table labels
Ovilia ce4530f
feat(matrix): correct cell info and draw table borders
Ovilia 55883fc
feat(matrix): render cells border and text
Ovilia ef9c3bd
feat(matrix): matrix with heatmap
Ovilia 0b90a95
test(matrix): add test for pie
Ovilia ce5fa43
feat(matrix): pie series with matrix
Ovilia 9b1c9a0
test(matrix): test case for pie series
Ovilia 859ab1d
feat(matrix): graph, scatter, custom
Ovilia 0daaae1
test(matrix): update test cases
Ovilia e510f3e
fix(matrix): fix lint errors
Ovilia 0b3f14b
fix(matrix): fix import
Ovilia 9d1b48d
test(matrix): more applications
Ovilia 6e8c626
test(matrix): fix test cases
Ovilia b0529f9
feat(matrix): support convertToPixel and add a case for Periodic Table
Ovilia 8bedb78
feat(matrix): support darkMode, headers can be hidden
Ovilia ab3efd3
fix(matrix): remove unnecessary field
Ovilia 6fe5d69
fix(matrix): improve code
Ovilia 31295e1
chore(matrix): update package.json
Ovilia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { use } from '../extension'; | ||
import { install } from './matrix/install'; | ||
|
||
use(install); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,180 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import MatrixModel from '../../coord/matrix/MatrixModel'; | ||
import ComponentView from '../../view/Component'; | ||
import { createTextStyle } from '../../label/labelStyle'; | ||
import * as graphic from '../../util/graphic'; | ||
|
||
class MatrixView extends ComponentView { | ||
|
||
static type = 'matrix'; | ||
type = MatrixView.type; | ||
|
||
render(matrixModel: MatrixModel) { | ||
|
||
const group = this.group; | ||
|
||
group.removeAll(); | ||
|
||
this._renderTable(matrixModel); | ||
} | ||
|
||
protected _renderTable(matrixModel: MatrixModel) { | ||
const coordSys = matrixModel.coordinateSystem; | ||
const xDim = coordSys.getDim('x'); | ||
const yDim = coordSys.getDim('y'); | ||
const xModel = matrixModel.getModel('x'); | ||
const yModel = matrixModel.getModel('y'); | ||
const xLabelModel = xModel.getModel('label'); | ||
const yLabelModel = yModel.getModel('label'); | ||
const xItemStyle = xModel.getModel('itemStyle').getItemStyle(); | ||
const yItemStyle = yModel.getModel('itemStyle').getItemStyle(); | ||
|
||
const rect = coordSys.getRect(); | ||
const xLeavesCnt = xDim.getLeavesCount(); | ||
const yLeavesCnt = yDim.getLeavesCount(); | ||
const xCells = xDim.getCells(); | ||
const xHeight = xDim.getHeight(); | ||
const yCells = yDim.getCells(); | ||
const yHeight = yDim.getHeight(); | ||
const cellWidth = rect.width / (xLeavesCnt + yHeight); | ||
const cellHeight = rect.height / (yLeavesCnt + xHeight); | ||
|
||
const xLeft = rect.x + cellWidth * yHeight; | ||
if (xModel.get('show')) { | ||
for (let i = 0; i < xCells.length; i++) { | ||
const cell = xCells[i]; | ||
const width = cellWidth * cell.colSpan; | ||
const height = cellHeight * cell.rowSpan; | ||
const left = xLeft + cellWidth * cell.colId; | ||
const top = rect.y + cellHeight * cell.rowId; | ||
|
||
const cellRect = new graphic.Rect({ | ||
shape: { | ||
x: left, | ||
y: top, | ||
width: width, | ||
height: height | ||
}, | ||
style: xItemStyle | ||
}); | ||
this.group.add(cellRect); | ||
|
||
if (xLabelModel.get('show')) { | ||
cellRect.setTextConfig({ | ||
position: 'inside' | ||
}); | ||
cellRect.setTextContent( | ||
new graphic.Text({ | ||
style: createTextStyle(xLabelModel, { | ||
text: cell.value, | ||
verticalAlign: 'middle', | ||
align: 'center' | ||
}), | ||
silent: xLabelModel.get('silent') | ||
}) | ||
); | ||
} | ||
} | ||
} | ||
|
||
const yTop = rect.y + cellHeight * xHeight; | ||
if (yModel.get('show')) { | ||
for (let i = 0; i < yCells.length; i++) { | ||
const cell = yCells[i]; | ||
const width = cellWidth * cell.rowSpan; | ||
const height = cellHeight * cell.colSpan; | ||
const left = rect.x + cellWidth * cell.rowId; | ||
const top = yTop + cellHeight * cell.colId; | ||
|
||
this.group.add(new graphic.Rect({ | ||
shape: { | ||
x: left, | ||
y: top, | ||
width: width, | ||
height: height | ||
}, | ||
style: yItemStyle | ||
})); | ||
if (yLabelModel.get('show')) { | ||
this.group.add(new graphic.Text({ | ||
style: createTextStyle(yLabelModel, { | ||
text: cell.value, | ||
x: left + width / 2, | ||
y: top + height / 2, | ||
verticalAlign: 'middle', | ||
align: 'center' | ||
}) | ||
})); | ||
} | ||
} | ||
} | ||
|
||
// Inner cells | ||
const innerBackgroundStyle = matrixModel | ||
.getModel('innerBackgroundStyle') | ||
.getItemStyle(); | ||
for (let i = 0; i < xLeavesCnt; i++) { | ||
for (let j = 0; j < yLeavesCnt; j++) { | ||
const left = xLeft + cellWidth * i; | ||
const top = yTop + cellHeight * j; | ||
this.group.add(new graphic.Rect({ | ||
shape: { | ||
x: left, | ||
y: top, | ||
width: cellWidth, | ||
height: cellHeight | ||
}, | ||
style: innerBackgroundStyle | ||
})); | ||
} | ||
} | ||
|
||
// Outer border | ||
const backgroundStyle = matrixModel | ||
.getModel('backgroundStyle') | ||
.getItemStyle(); | ||
this.group.add(new graphic.Rect({ | ||
shape: rect, | ||
style: backgroundStyle | ||
})); | ||
// Header border | ||
this.group.add(new graphic.Line({ | ||
shape: { | ||
x1: rect.x, | ||
y1: yTop, | ||
x2: rect.x + rect.width, | ||
y2: yTop | ||
}, | ||
style: backgroundStyle | ||
})); | ||
this.group.add(new graphic.Line({ | ||
shape: { | ||
x1: xLeft, | ||
y1: rect.y, | ||
x2: xLeft, | ||
y2: rect.y + rect.height | ||
}, | ||
style: backgroundStyle | ||
})); | ||
} | ||
} | ||
|
||
export default MatrixView; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { EChartsExtensionInstallRegisters } from '../../extension'; | ||
import MatrixModel from '../../coord/matrix/MatrixModel'; | ||
import MatrixView from './MatrixView'; | ||
import Matrix from '../../coord/matrix/Matrix'; | ||
|
||
export function install(registers: EChartsExtensionInstallRegisters) { | ||
registers.registerComponentModel(MatrixModel); | ||
registers.registerComponentView(MatrixView); | ||
registers.registerCoordinateSystem('matrix', Matrix); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
.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 border won't be darker unless the opacity of borderColors are not 1. I personally think providing a
border-collapse
like mechanism is over-kill because then, we should also implement other features like border widths and colors being different values at four sides. This should bring much work to implement it robustly. The reason why I choose to render rectangles with background and border is that it would be more difficult to think which option controls which border line.The image you provided is as expected. You should add
x.itemStyle.borderWidth: 0
andy.itemStyle.borderWidth: 0
if you want to remove those rest borders.