8000 fix: fix issue with 3d chart grid by neuqzxy · Pull Request #4049 · VisActor/VChart · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: fix issue with 3d chart grid #4049

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
Jun 20, 2025
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@visactor/vchart",
"comment": "fix: fix issue with 3d chart grid",
"type": "none"
}
],
"packageName": "@visactor/vchart"
}
59 changes: 58 additions & 1 deletion packages/vchart-extension/src/charts/axis-3d/axis-3d-mixin.ts
103D4
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { IAxis } from '@visactor/vchart';
import { isZAxis } from '@visactor/vchart';
import { isXAxis, isYAxis, isZAxis } from '@visactor/vchart';
import { getUpdateAttributeOfZAxis } from './util';

export class Axis3dMixin {
Expand All @@ -11,8 +11,65 @@ export class Axis3dMixin {

protected _afterUpdateAttribute(attrs: any, ignoreGrid: boolean) {
const isZ = isZAxis((this as any)._orient);
const isX = isXAxis((this as any)._orient);
const isY = isYAxis((this as any)._orient);

// 获取更新的坐标轴属性
let regionHeight = 0;
let regionWidth = 0;

if (!ignoreGrid) {
const regions = (this as any).getRegions();
let { x: minX, y: minY } = regions[0].getLayoutStartPoint();
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.getLayoutStartPoint();
const { width, height } = region.getLayoutRect();
minX = Math.min(minX, x);
maxX = Math.max(maxX, width + x);
minY = Math.min(minY, y);
maxY = Math.max(maxY, height + y);
}
regionHeight = Math.abs(maxY - minY);
regionWidth = Math.abs(maxX - minX);
}

let gridLength = 0;
let axisLength = 0;
const { width, height } = (this as any).getLayoutRect();
let end = { x: 0, y: 0 };

if (isX) {
end = { x: width, y: 0 };
gridLength = regionHeight;
axisLength = width;
} else if (isY) {
end = { x: 0, y: height };
gridLength = regionWidth;
axisLength = height;
}

const depth = (this as any).layout3dBox ? (this as any).layout3dBox.length : 0;

if (!isZ) {
const items = (this as any).getLabelItems(axisLength);
attrs.grid = {
length: gridLength
};
attrs.start = { x: 0, y: 0 };
attrs.text = (this as any)._spec.title.text || (this as any)._dataFieldText;
attrs.maxWidth = (this as any)._getTitleLimit(isX);
attrs.items = items;
attrs.grid = {
type: 'line',
start: { x: 0, y: 0 },
end,
items: items[0],
depth,
length: gridLength
};
return attrs;
}

Expand Down
25 changes: 14 additions & 11 deletions packages/vchart-extension/src/charts/axis-3d/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,6 @@ export const getUpdateAttributeOfZAxis = (axis: IAxis, ignoreGrid: boolean) => {
items,
scale: (axis as any)._scale.clone()
};
if (!ignoreGrid) {
attrs.grid = {
type: 'line',
start: { x: 0, y: 0 },
end,
items: items[0],
verticalFactor: (axis as any)._axisStyle.verticalFactor,
depth: depthZ,
length: !ignoreGrid ? regionSize.height : 0
};
}

const directionStr = (axis as any).directionStr ?? 'r2l';
let anchor3d = [0, 0];
Expand All @@ -44,5 +33,19 @@ export const getUpdateAttributeOfZAxis = (axis: IAxis, ignoreGrid: boolean) => {
attrs.alpha = alpha;
attrs.anchor3d = anchor3d;

if (!ignoreGrid) {
attrs.grid = {
type: 'line',
start: { x: 0, y: 0 },
end,
items: items[0],
verticalFactor: (axis as any)._axisStyle.verticalFactor,
depth: depthZ,
length: !ignoreGrid ? regionSize.height : 0,
alpha,
z,
anchor3d
};
}
return attrs;
};
Loading
0