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

feat: update gui and adapt to crossSize config #4949

Merged
merged 3 commits into from
May 9, 2023
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,4 @@ export async function populationIntervalRoseKeyframe(): Promise<G2Spec> {
}

populationIntervalRoseKeyframe.intervals = [false, false, [333, 666]];
populationIntervalRoseKeyframe.maxError = 100;
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export function aaplLineSliderFilterTranspose(): G2Spec {

aaplLineSliderFilterTranspose.maxError = 500;

aaplLineSliderFilterTranspose.skip = true;
Aarebecca marked this conversation as resolved.
Show resolved Hide resolved

aaplLineSliderFilterTranspose.steps = ({ canvas }) => {
const { document } = canvas;
const sliders = document.getElementsByClassName(SLIDER_CLASS_NAME);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"@antv/g": "^5.7.4",
"@antv/g-canvas": "^1.7.4",
"@antv/g-plugin-dragndrop": "^1.6.1",
"@antv/gui": "0.5.0-alpha.17",
"@antv/gui": "^0.5.0-alpha.18",
"@antv/path-util": "^3.0.1",
"@antv/scale": "^0.4.7",
"@antv/util": "^3.3.2",
Expand Down
73 changes: 41 additions & 32 deletions site/docs/spec/component/axis.zh.md

Large diffs are not rendered by default.

31 changes: 14 additions & 17 deletions src/component/axis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,34 +193,31 @@ function inferGridLength(position: GCP, coordinate: Coordinate) {
}

function inferLabelOverlap(transform = [], style: Record<string, any>) {
const {
labelAutoRotate = true,
labelAutoHide = false,
labelAutoEllipsis = false,
} = style;
if (transform.length > 0) return transform;
const { labelAutoRotate, labelAutoHide, labelAutoEllipsis, labelAutoWrap } =
style;

const finalTransforms = [...transform];
const finalTransforms = [];

const mutateLabelOverlap = (overlap, state) => {
const addToTransfroms = (overlap, state) => {
if (state) {
const index = finalTransforms.findIndex((t) => t.type === overlap.type);
if (index !== -1) finalTransforms[index] = overlap;
else finalTransforms.push(overlap);
} else {
const index = finalTransforms.findIndex((t) => t.type === overlap.type);
if (index !== -1) finalTransforms.splice(index, 1);
finalTransforms.push(overlap);
}
};

mutateLabelOverlap(
addToTransfroms(
{
type: 'rotate',
optionalAngles: [0, 15, 30, 45, 60, 90],
},
labelAutoRotate,
);
mutateLabelOverlap({ type: 'ellipsis', minLength: 20 }, labelAutoEllipsis);
mutateLabelOverlap({ type: 'hide' }, labelAutoHide);
addToTransfroms({ type: 'ellipsis', minLength: 20 }, labelAutoEllipsis);
addToTransfroms({ type: 'hide' }, labelAutoHide);
addToTransfroms(
{ type: 'wrap', wordWrapWidth: 100, maxLines: 3, recoveryWhenFail: true },
labelAutoWrap,
);
return finalTransforms;
}

Expand Down Expand Up @@ -503,7 +500,6 @@ const LinearAxisComponent: GCC<AxisOptions> = (options) => {
};

const gridLength = inferGridLength(position, coordinate);

const overrideStyle = inferAxisLinearOverrideStyle(
position,
orientation,
Expand All @@ -523,6 +519,7 @@ const LinearAxisComponent: GCC<AxisOptions> = (options) => {
position,
coordinate,
),
crossSize: size,
titleText: titleContent(title),
labelOverlap: inferLabelOverlap(transform, internalAxisStyle),
grid: inferGrid(internalAxisStyle.grid, coordinate, scale),
Expand Down
4 changes: 3 additions & 1 deletion src/component/axisX.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ export type AxisXOptions = AxisOptions;
* LinearAxis component bind to x scale.
*/
export const AxisX: GCC<AxisXOptions> = (options) => {
return LinearAxis(options);
return (...args) =>
// empirical value for crossPadding
LinearAxis(Object.assign({}, { crossPadding: 50 }, options))(...args);
};

AxisX.props = {
Expand Down
3 changes: 2 additions & 1 deletion src/component/axisY.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export type AxisYOptions = AxisOptions;
* LinearAxis component bind to y scale.
*/
export const AxisY: GCC<AxisYOptions> = (options) => {
return LinearAxis(options);
return (...args) =>
LinearAxis(Object.assign({}, { crossPadding: 10 }, options))(...args);
};

AxisY.props = {
Expand Down
2 changes: 2 additions & 0 deletions src/theme/classic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ export const Classic: TC<ClassicOptions> = (options) => {
gridDirection: 'negative',
labelDirection: 'positive',
labelSpacing: 12,
labelAutoRotate: true,
tickDirection: 'positive',
titlePosition: 'bottom',
titleSpacing: 10,
Expand All @@ -280,6 +281,7 @@ export const Classic: TC<ClassicOptions> = (options) => {
gridDirection: 'positive',
labelDirection: 'negative',
labelSpacing: 4,
labelAutoRotate: false,
tickDirection: 'negative',
titlePosition: 'right',
titleSpacing: 0,
Expand Down