8000 fix: revert indent of region by xuefei1313 · Pull Request #2091 · VisActor/VChart · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: revert indent of region #2091

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

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 4 additions & 4 deletions packages/vchart/src/component/axis/cartesian/axis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -644,13 +644,13 @@ export abstract class CartesianAxis<T extends ICartesianAxisCommonSpec = ICartes
if (!ignoreGrid) {
const regions = this.getRegions();
let { x: minX, y: minY } = regions[0].getLayoutStartPoint();
let maxX = minX + regions[0].getLayoutRectExcludeIndent().width;
let maxY = minY + regions[0].getLayoutRectExcludeIndent().height;
let maxX = minX + regions[0].getLayoutRect().width;
let maxY = minY + regions[0].getLayoutRect().height;

for (let index = 1; index < regions.length; index++) {
const region = regions[index];
const { x, y } = region.getLayoutPositionExcludeIndent();
const { width, height } = region.getLayoutRectExcludeIndent();
const { x, y } = region.getLayoutStartPoint();
const { width, height } = region.getLayoutRect();

minX = Math.min(minX, x);
maxX = Math.max(maxX, width + x); 10000
Expand Down
4 changes: 2 additions & 2 deletions packages/vchart/src/component/axis/polar/axis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export abstract class PolarAxis<T extends IPolarAxisCommonSpec = IPolarAxisCommo

_transformLayoutPosition = (pos: Partial<IPoint>) => {
const region = this.getRegions()?.[0];
return region ? region.getLayoutPositionExcludeIndent() : pos;
return region ? region.getLayoutStartPoint() : pos;
};

onLayoutEnd(ctx: any): void {
Expand Down Expand Up @@ -570,7 +570,7 @@ export abstract class PolarAxis<T extends IPolarAxisCommonSpec = IPolarAxisCommo
}

private getRefLayoutRect() {
return this.getRegions()[0].getLayoutRectExcludeIndent();
return this.getRegions()[0].getLayoutRect();
}

private getRefSeriesRadius() {
Expand Down
8 changes: 4 additions & 4 deletions packages/vchart/src/component/brush/brush.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ export class Brush<T extends IBrushSpec = IBrushSpec> extends BaseComponent<T> i
}

protected _getBrushInteractiveAttr(region: IRegion) {
const regionLayoutPosition = region.getLayoutPositionExcludeIndent();
const regionLayoutRect = region.getLayoutRectExcludeIndent();
const regionLayoutPosition = region.getLayoutStartPoint();
const regionLayoutRect = region.getLayoutRect();
const seriesRegionStartX = regionLayoutPosition.x;
const seriesRegionEndX = seriesRegionStartX + regionLayoutRect.width;
const seriesRegionStartY = regionLayoutPosition.y;
Expand Down Expand Up @@ -322,11 +322,11 @@ export class Brush<T extends IBrushSpec = IBrushSpec> extends BaseComponent<T> i
}

private _reconfigLinkedItem(operateMask: IPolygon, region: IRegion) {
const regionLayoutPos = region.getLayoutPositionExcludeIndent();
const regionLayoutPos = region.getLayoutStartPoint();
const seriesId = region.getSeries().map(s => s.id);
this._linkedSeries.forEach((s: ISeries) => {
if (!seriesId.includes(s.id)) {
const sRegionLayoutPos = s.getRegion().getLayoutPositionExcludeIndent();
const sRegionLayoutPos = s.getRegion().getLayoutStartPoint();

const regionOffsetX = sRegionLayoutPos.x - regionLayoutPos.x;
const regionOffsetY = sRegionLayoutPos.y - regionLayoutPos.y;
Expand Down
10 changes: 5 additions & 5 deletions packages/vchart/src/component/crosshair/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,11 @@ export abstract class BaseCrossHair<T extends ICartesianCrosshairSpec | IPolarCr
}
const regions = axis.getRegions();
regions.forEach(r => {
const { x: regionStartX, y: regionStartY } = r.getLayoutPositionExcludeIndent();
const { x: regionStartX, y: regionStartY } = r.getLayoutStartPoint();
x1 = Math.min(x1, regionStartX - sx);
y1 = Math.min(y1, regionStartY - sy);
x2 = Math.max(x2, regionStartX + r.getLayoutRectExcludeIndent().width - sx);
y2 = Math.max(y2, regionStartY + r.getLayoutRectExcludeIndent().height - sy);
x2 = Math.max(x2, regionStartX + r.getLayoutRect().width - sx);
y2 = Math.max(y2, regionStartY + r.getLayoutRect().height - sy);
});
map.set(idx, { x1, y1, x2, y2, axis: axis as unknown as T });
});
Expand All @@ -254,8 +254,8 @@ export abstract class BaseCrossHair<T extends ICartesianCrosshairSpec | IPolarCr

onLayoutEnd(ctx: IModelLayoutOption): void {
const region = this._regions[0];
this.setLayoutRect(region.getLayoutRectExcludeIndent());
this.setLayoutStartPosition(region.getLayoutPositionExcludeIndent());
this.setLayoutRect(region.getLayoutRect());
this.setLayoutStartPosition(region.getLayoutStartPoint());

super.onLayoutEnd(ctx);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ export abstract class DataFilterBaseComponent<T extends IDataFilterComponentSpec

const { zoomDelta, zoomX, zoomY } = params;
const { x, y } = this._regions[0].getLayoutStartPoint();
const { width, height } = this._regions[0].getLayoutRectExcludeIndent();
const { width, height } = this._regions[0].getLayoutRect();

const delta = Math.abs(this._start - this._end);
const zoomRate = (this._spec.roamZoom as IRoamZoomSpec)?.rate ?? 1;
Expand Down
4 changes: 2 additions & 2 deletions packages/vchart/src/component/geo/geo-coordinate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ export class GeoCoordinate extends BaseComponent<IGeoRegionSpec> implements IGeo
}

onLayoutEnd(ctx: IModelLayoutOption) {
this.setLayoutRect(this._regions[0].getLayoutRectExcludeIndent());
this.setLayoutStartPosition(this._regions[0].getLayoutPositionExcludeIndent());
this.setLayoutRect(this._regions[0].getLayoutRect());
this.setLayoutStartPosition(this._regions[0].getLayoutStartPoint());
const { width, height } = this.getLayoutRect();
const { translate, scale, center } = this.evaluateProjection([0, 0], [width, height]);
translate && this._projection.translate(translate);
Expand Down
6 changes: 3 additions & 3 deletions packages/vchart/src/component/indicator/indicator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ export class Indicator<T extends IIndicatorSpec> extends BaseComponent<T> implem

private _getIndicatorAttrs() {
const region = this._regions[0];
const { width, height } = region.getLayoutRectExcludeIndent();
const { x, y } = region.getLayoutPositionExcludeIndent();
const { width, height } = region.getLayoutRect();
const { x, y } = region.getLayoutStartPoint();

const contentComponentSpec: IIndicatorItemSpec[] = [];
array(this._spec.content).forEach((eachItem: IIndicatorItemSpec) => {
Expand Down Expand Up @@ -261,7 +261,7 @@ export class Indicator<T extends IIndicatorSpec> extends BaseComponent<T> implem

private _computeLayoutRadius() {
const region = this._regions[0];
const { width, height } = region.getLayoutRectExcludeIndent();
const { width, height } = region.getLayoutRect();
return Math.min(width / 2, height / 2);
}

Expand Down
6 changes: 3 additions & 3 deletions packages/vchart/src/component/label/label.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@ export class Label<T extends IChartSpec = any> extends BaseLabelComponent<T> {
.filter(cmp => cmp.type === 'totalLabel')
.map(cmp => cmp.getMarks()[0].getProductId())
},
x: labelInfos[0].series.getRegion().layout.indent.left,
y: labelInfos[0].series.getRegion().layout.indent.top
x: 0,
y: 0
},
defaultLabelConfig(rule, labelInfo),
{
Expand All @@ -330,7 +330,7 @@ export class Label<T extends IChartSpec = any> extends BaseLabelComponent<T> {
: textAttribute(labelInfos[params.labelIndex], datum, labelSpec.formatMethod, labelSpec.formatter);
}
})
.size(() => labelInfos[0].series.getRegion().getLayoutRectExcludeIndent());
.size(() => labelInfos[0].series.getRegion().getLayoutRect());
}

compileMarks() {
Expand Down
6 changes: 3 additions & 3 deletions packages/vchart/src/component/label/total-label.ts
56D8
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ export class TotalLabel extends BaseLabelComponent {
{
textStyle: { pickable: this._spec.interactive === true },
position: totalLabelPosition(series, this._baseMark.type),
x: series.getRegion().layout.indent.left,
y: series.getRegion().layout.indent.top
x: 0,
y: 0
},
{
offset,
Expand All @@ -140,7 +140,7 @@ export class TotalLabel extends BaseLabelComponent {
this._spec.formatMethod
);
})
.size(() => this._regions[0].getLayoutRectExcludeIndent());
.size(() => this._regions[0].getLayoutRect());
});
}

Expand Down
2 changes: 1 addition & 1 deletion packages/vchart/src/component/map-label/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ export class MapLabelComponent extends BaseComponent<IMapLabelSpec> {
});
const datum = this._data.getLatestData()[i];
const anchor = this.dataToPosition(datum);
const regionPos = this.getRegions()[0].getLayoutPositionExcludeIndent();
const regionPos = this.getRegions()[0].getLayoutStartPoint();
const showLeader = !!(this._spec.leader?.visible && (icon || nameLabel || valueLabel));
this._markerComponents[i].setAttributes({
x: regionPos.x,
Expand Down
12 changes: 6 additions & 6 deletions packages/vchart/src/component/marker/mark-line/mark-line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,25 +182,25 @@ export class MarkLine extends BaseMarker<IMarkLineSpec> implements IMarkLine {
let expandDistanceValue: number;
if (isPercent(expandDistance)) {
const regionStart = startRelativeSeries.getRegion();
const regionStartLayoutStartPoint = regionStart.getLayoutPositionExcludeIndent();
const regionStartLayoutStartPoint = regionStart.getLayoutStartPoint();
const regionEnd = endRelativeSeries.getRegion();
const regionEndLayoutStartPoint = regionEnd.getLayoutPositionExcludeIndent();
const regionEndLayoutStartPoint = regionEnd.getLayoutStartPoint();

if (connectDirection === 'bottom' || connectDirection === 'top') {
const regionHeight = Math.abs(
Math.min(regionStartLayoutStartPoint.y, regionEndLayoutStartPoint.y) -
Math.max(
regionStartLayoutStartPoint.y + regionStart.getLayoutRectExcludeIndent().height,
regionEndLayoutStartPoint.y + regionEnd.getLayoutRectExcludeIndent().height
regionStartLayoutStartPoint.y + regionStart.getLayoutRect().height,
regionEndLayoutStartPoint.y + regionEnd.getLayoutRect().height
)
);
expandDistanceValue = (Number(expandDistance.substring(0, expandDistance.length - 1)) * regionHeight) / 100;
} else {
const regionWidth = Math.abs(
Math.min(regionStartLayoutStartPoint.x, regionEndLayoutStartPoint.x) -
Math.max(
regionStartLayoutStartPoint.x + regionStart.getLayoutRectExcludeIndent().width,
regionEndLayoutStartPoint.x + regionEnd.getLayoutRectExcludeIndent().width
regionStartLayoutStartPoint.x + regionStart.getLayoutRect().width,
regionEndLayoutStartPoint.x + regionEnd.getLayoutRect().width
)
);
expandDistanceValue = (Number(expandDistance.substring(0, expandDistance.length - 1)) * regionWidth) / 100;
Expand Down
32 changes: 16 additions & 16 deletions packages/vchart/src/component/marker/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,22 @@ export function xyLayout(
autoRange: boolean
) {
const regionStart = startRelativeSeries.getRegion();
const regionStartLayoutStartPoint = regionStart.getLayoutPositionExcludeIndent();
const regionStartLayoutStartPoint = regionStart.getLayoutStartPoint();
const regionEnd = endRelativeSeries.getRegion();
const regionEndLayoutStartPoint = regionEnd.getLayoutPositionExcludeIndent();
const regionEndLayoutStartPoint = regionEnd.getLayoutStartPoint();

const regionWidth = Math.abs(
Math.min(regionStartLayoutStartPoint.x, regionEndLayoutStartPoint.x) -
Math.max(
regionStartLayoutStartPoint.x + regionStart.getLayoutRectExcludeIndent().width,
regionEndLayoutStartPoint.x + regionEnd.getLayoutRectExcludeIndent().width
regionStartLayoutStartPoint.x + regionStart.getLayoutRect().width,
regionEndLayoutStartPoint.x + regionEnd.getLayoutRect().width
)
);
const regionHeight = Math.abs(
Math.min(regionStartLayoutStartPoint.y, regionEndLayoutStartPoint.y) -
Math.max(
regionStartLayoutStartPoint.y + regionStart.getLayoutRectExcludeIndent().height,
regionEndLayoutStartPoint.y + regionEnd.getLayoutRectExcludeIndent().height
regionStartLayoutStartPoint.y + regionStart.getLayoutRect().height,
regionEndLayoutStartPoint.y + regionEnd.getLayoutRect().height
)
);

Expand All @@ -121,8 +121,8 @@ export function xyLayout(
} else if (isValid(datum.x)) {
const x = getXValue(datum, xDomain, autoRange, refSeries, regionWidth, regionStartLayoutStartPoint);
const y = Math.max(
regionStartLayoutStartPoint.y + regionStart.getLayoutRectExcludeIndent().height,
regionEndLayoutStartPoint.y + regionEnd.getLayoutRectExcludeIndent().height
regionStartLayoutStartPoint.y + regionStart.getLayoutRect().height,
regionEndLayoutStartPoint.y + regionEnd.getLayoutRect().height
);
const y1 = Math.min(regionStartLayoutStartPoint.y, regionEndLayoutStartPoint.y);
lines.push([
Expand All @@ -139,8 +139,8 @@ export function xyLayout(
const x = Math.min(regionStartLayoutStartPoint.x, regionEndLayoutStartPoint.x);
const y = getYValue(datum, yDomain, autoRange, refSeries, regionHeight, regionStartLayoutStartPoint);
const x1 = Math.max(
regionStartLayoutStartPoint.x + regionStart.getLayoutRectExcludeIndent().width,
regionEndLayoutStartPoint.x + regionEnd.getLayoutRectExcludeIndent().width
regionStartLayoutStartPoint.x + regionStart.getLayoutRect().width,
regionEndLayoutStartPoint.x + regionEnd.getLayoutRect().width
);
lines.push([
{
Expand Down Expand Up @@ -178,9 +178,9 @@ export function coordinateLayout(
) => {
const refRelativeSeries = datum?.getRefRelativeSeries ? datum.getRefRelativeSeries() : relativeSeries;
const regionStart = refRelativeSeries.getRegion();
const regionStartLayoutStartPoint = regionStart.getLayoutPositionExcludeIndent();
const regionStartLayoutStartPoint = regionStart.getLayoutStartPoint();

const { width: regionWidth, height: regionHeight } = regionStart.getLayoutRectExcludeIndent();
const { width: regionWidth, height: regionHeight } = regionStart.getLayoutRect();

let offsetX = 0;
let offsetY = 0;
Expand Down Expand Up @@ -222,8 +222,8 @@ export function coordinateLayout(
export function positionLayout(positions: MarkerPositionPoint[], series: ISeries, regionRelative: boolean): IPoint[] {
if (regionRelative) {
const region = series.getRegion();
const { x: regionStartX, y: regionStartY } = region.getLayoutPositionExcludeIndent();
const { width: regionWidth, height: regionHeight } = region.getLayoutRectExcludeIndent();
const { x: regionStartX, y: regionStartY } = region.getLayoutStartPoint();
const { width: regionWidth, height: regionHeight } = region.getLayoutRect();
return positions.map(position => {
let { x, y } = position;
if (isPercent(x)) {
Expand Down Expand Up @@ -264,8 +264,8 @@ export function computeClipRange(regions: IRegion[]) {
let minY = Infinity;
let maxY = -Infinity;
regions.forEach((region: IRegion) => {
const regionPos = region.getLayoutPositionExcludeIndent();
const regionRect = region.getLayoutRectExcludeIndent();
const regionPos = region.getLayoutStartPoint();
const regionRect = region.getLayoutRect();
if (regionPos.x < minX) {
minX = regionPos.x;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/vchart/src/component/tooltip/utils/show-tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ export function showTooltip(

// 组织数据
const activeType = opt.activeType ?? (markInfoList.length > 1 ? 'dimension' : 'mark');
const regionPos = region.getLayoutPositionExcludeIndent();
const regionRect = region.getLayoutRectExcludeIndent();
const regionPos = region.getLayoutStartPoint();
const regionRect = region.getLayoutRect();
const container = componentOptions.globalInstance.getContainer();
const containerPos = {
x: 0,
Expand Down
2 changes: 1 addition & 1 deletion packages/vchart/src/core/vchart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1748,7 +1748,7 @@ export class VChart implements IVChart {
.getViewData()
// eslint-disable-next-line eqeqeq
.latestData.find((viewDatum: Datum) => keys.every(k => viewDatum[k] == datum[k]));
const seriesLayoutStartPoint = series.getRegion().getLayoutPositionExcludeIndent();
const seriesLayoutStartPoint = series.getRegion().getLayoutStartPoint();
let point: IPoint;
if (handledDatum) {
point = series.dataToPosition(handledDatum);
Expand Down
8 changes: 4 additions & 4 deletions packages/vchart/src/layout/base-layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,10 @@ export class Layout implements IBaseLayout {
const relativeRegion = this.filterRegionsWithID(regionItems, item.layoutBindRegionID[0]);

item.setLayoutRect({
height: relativeRegion.layoutExcludeIndent.height
height: relativeRegion.getLayoutRect().height
});
item.setLayoutStartPosition({
y: relativeRegion.layoutExcludeIndent.y + item.layoutOffsetY + item.layoutPaddingTop
y: relativeRegion.getLayoutStartPoint().y + item.layoutOffsetY + item.layoutPaddingTop
});

if (item.layoutOrient === 'right') {
Expand All @@ -377,11 +377,11 @@ export class Layout implements IBaseLayout {
const relativeRegion = this.filterRegionsWithID(regionItems, item.layoutBindRegionID[0]);

item.setLayoutRect({
width: relativeRegion.layoutExcludeIndent.width
width: relativeRegion.getLayoutRect().width
});

item.setLayoutStartPosition({
x: relativeRegion.layoutExcludeIndent.x + item.layoutOffsetX + item.layoutPaddingLeft
x: relativeRegion.getLayoutStartPoint().x + item.layoutOffsetX + item.layoutPaddingLeft
});

if (item.layoutOrient === 'bottom') {
Expand Down
7 changes: 1 addition & 6 deletions packages/vchart/src/layout/interface.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IBoundsLike } from '@visactor/vutils';
import type { StringOrNumber } from '../typings/common';
import type { IOrientType, IPadding, IRect } from '../typings/space';
import type { IOrientType, IRect } from '../typings/space';
import type { IPoint } from '../typings/coordinate';
import type { ILayoutNumber, ILayoutPaddingSpec, ILayoutPoint, ILayoutRect, ILayoutType } from '../typings/layout';
import type { ILayoutModel } from '../model/interface';
Expand Down Expand Up @@ -91,11 +91,6 @@ export interface ILayoutItem {
layoutPaddingRight: number;
layoutPaddingBottom: number;

// 锁进 概念上等同于 padding
indent: IPadding;
// 锁进后的布局属性
layoutExcludeIndent: IRect;

layoutOffsetX: number;
layoutOffsetY: number;

Expand Down
Loading
0