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

fix(markArea): markArea background color disappeared. close #13647 #14343

Merged
merged 3 commits into from
Feb 25, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions src/component/marker/MarkAreaView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,22 +248,19 @@ class MarkAreaView extends MarkerView {
const points = map(dimPermutations, function (dim) {
return getSingleMarkerEndPoint(areaData, idx, dim, seriesModel, api);
});
const xScale = coordSys.getAxis('x').scale;
const yScale = coordSys.getAxis('y').scale;
const xAxis = xScale.getExtent();
Copy link
Contributor

Choose a reason for hiding this comment

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

Use a more specific name here. For example xAxisExtent, yAxisExtent

const yAxis = yScale.getExtent();
const xPoint = [xScale.parse(areaData.get('x0', idx)), xScale.parse(areaData.get('x1', idx))];
const yPoint = [yScale.parse(areaData.get('y0', idx)), yScale.parse(areaData.get('y1', idx))];
xPoint.sort();
yPoint.sort();
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a helper to sort an array to asc order. https://github.com/apache/echarts/blob/master/src/util/number.ts#L145

Default compare function in sort will convert the values to strings and use Unicode to compare. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#parameters

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for helping!

const overlapped = !(xAxis[0] > xPoint[1] || xAxis[1] < xPoint[0]
|| yAxis[0] > yPoint[1] || yAxis[1] < yPoint[0]);
// If none of the area is inside coordSys, allClipped is set to be true
// in layout so that label will not be displayed. See #12591
let allClipped = true;
each(dimPermutations, function (dim) {
if (!allClipped) {
return;
}
const xValue = areaData.get(dim[0], idx);
const yValue = areaData.get(dim[1], idx);
// If is infinity, the axis should be considered not clipped
if ((isInifinity(xValue) || coordSys.getAxis('x').containData(xValue))
&& (isInifinity(yValue) || coordSys.getAxis('y').containData(yValue))
) {
allClipped = false;
}
});
const allClipped = !overlapped;
areaData.setItemLayout(idx, {
points: points,
allClipped: allClipped
Expand Down Expand Up @@ -419,4 +416,4 @@ function createList(
return areaData;
}

export default MarkAreaView;
export default MarkAreaView;