Skip to content

Commit

Permalink
feat: add axis innerOffset config
Browse files Browse the repository at this point in the history
  • Loading branch information
Rui-Sun committed Feb 2, 2024
1 parent dcec5d8 commit 05785b7
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 64 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@visactor/vtable",
"comment": "feat: add axis innerOffset config",
"type": "none"
}
],
"packageName": "@visactor/vtable"
}
98 changes: 49 additions & 49 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@visactor/vtable": "workspace:*",
"@visactor/vtable-editors": "workspace:*",
"@visactor/vtable-export": "workspace:*",
"@visactor/vchart": "1.9.0",
"@visactor/vchart": "1.9.1",
"markdown-it": "^13.0.0",
"highlight.js": "^11.8.0",
"axios": "^1.4.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/react-vtable/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"react-is": "^18.2.0"
},
"devDependencies": {
"@visactor/vchart": "1.9.0",
"@visactor/vchart": "1.9.1",
"@internal/bundler": "workspace:*",
"@internal/eslint-config": "workspace:*",
"@internal/ts-config": "workspace:*",
Expand Down Expand Up @@ -96,4 +96,4 @@
"axios": "^1.4.0",
"@types/react-is": "^17.0.3"
}
}
}
4 changes: 2 additions & 2 deletions packages/vtable-export/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"exceljs": "4.4.0"
},
"devDependencies": {
"@visactor/vchart": "1.9.0",
"@visactor/vchart": "1.9.1",
"@internal/bundler": "workspace:*",
"@internal/eslint-config": "workspace:*",
"@internal/ts-config": "workspace:*",
Expand Down Expand Up @@ -85,4 +85,4 @@
"@types/react-is": "^17.0.3",
"rollup-plugin-node-resolve": "5.2.0"
}
}
}
40 changes: 36 additions & 4 deletions packages/vtable/examples/pivot-chart/pivotChart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,25 @@ export function createTable() {
yField: '230417171050011',
seriesField: '230417171050030',
axes: [
{ orient: 'left', visible: true, label: { visible: true } },
{ orient: 'bottom', visible: true }
{
orient: 'left',
visible: true,
label: {
visible: true
},
innerOffset: {
top: 20,
bottom: 20
}
},
{
orient: 'bottom',
visible: true,
innerOffset: {
left: 20,
right: 20
}
}
],
bar: {
state: {
Expand Down Expand Up @@ -226,7 +243,15 @@ export function createTable() {
],
axes: [
{ orient: 'left', visible: true, label: { visible: true } },
{ orient: 'bottom', visible: true }

{
orient: 'bottom',
visible: true,
innerOffset: {
left: 20,
right: 20
}
}
],
theme: {
// axis: {
Expand Down Expand Up @@ -272,7 +297,14 @@ export function createTable() {
seriesField: '230417171050030',
axes: [
{ orient: 'left', visible: true, label: { visible: true } },
{ orient: 'bottom', visible: true }
{
orient: 'bottom',
visible: true,
innerOffset: {
left: 20,
right: 20
}
}
],
line: {
state: {
Expand Down
4 changes: 2 additions & 2 deletions packages/vtable/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
},
"devDependencies": {
"luxon": "*",
"@visactor/vchart": "1.9.0",
"@visactor/vchart": "1.9.1",
"@internal/bundler": "workspace:*",
"@internal/eslint-config": "workspace:*",
"@internal/ts-config": "workspace:*",
Expand Down Expand Up @@ -124,4 +124,4 @@
"url": "https://github.com/VisActor/VTable.git",
"directory": "packages/vtable"
}
}
}
12 changes: 8 additions & 4 deletions packages/vtable/src/components/axis/axis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,17 @@ export class CartesianAxis {
);

if (this.orient === 'left' || this.orient === 'right') {
const innerOffsetTop = this.option.innerOffset?.top ?? 0;
const innerOffsetBottom = this.option.innerOffset?.bottom ?? 0;
this.width = width;
this.height = height - padding[2];
this.y = padding[0];
this.height = height - padding[2] - innerOffsetBottom;
this.y = padding[0] + innerOffsetTop;
} else if (this.orient === 'top' || this.orient === 'bottom') {
this.width = width - padding[1];
const innerOffsetLeft = this.option.innerOffset?.left ?? 0;
const innerOffsetRight = this.option.innerOffset?.right ?? 0;
this.width = width - padding[1] - innerOffsetRight;
this.height = height;
this.x = padding[3];
this.x = padding[3] + innerOffsetLeft;
}

this.visible = option.visible ?? true;
Expand Down

0 comments on commit 05785b7

Please sign in to comment.