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(axis): axis pos when update #5275

Merged
merged 1 commit into from
Jul 6, 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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion __tests__/plots/interaction/appl-line-slider-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function dispatchValueChange(slider, values = [0.25, 0.75]) {
);
}

aaplLineSliderFilter.maxError = 500;
aaplLineSliderFilter.maxError = 600;

aaplLineSliderFilter.steps = ({ canvas }) => {
const { document } = canvas;
Expand Down
3 changes: 0 additions & 3 deletions __tests__/plots/static/github-star-interval-theme-academy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import { githubStar } from '../../data/github-star';
export function githubStarIntervalThemeAcademy(): G2Spec {
return {
type: 'interval',
width: 1000,
paddingBottom: 100,
paddingLeft: 160,
data: {
value: githubStar,
transform: [{ type: 'sortBy', fields: [['star', true]] }],
Expand Down
6 changes: 5 additions & 1 deletion src/runtime/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -921,8 +921,12 @@ export function computeTitleBBox(
const { title: styleTitle } = style;
if (isFalsy(title) || isFalsy(styleTitle) || title === undefined) return null;
const titleStyle = subObject(style, 'title');
const { direction, transform } = titleStyle;
const titleText = Array.isArray(title) ? title.join(',') : title;
const titleBBox = computeLabelSize(titleText, titleStyle);
const titleBBox = computeLabelSize(titleText, {
...titleStyle,
transform: transform || direction === 'vertical' ? 'rotate(-90)' : '',
});
return titleBBox;
}

Expand Down
10 changes: 8 additions & 2 deletions src/runtime/plot.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Vector2 } from '@antv/coord';
import { DisplayObject, IAnimation as GAnimation, Rect } from '@antv/g';
import { deepMix, upperFirst } from '@antv/util';
import { group } from 'd3-array';
import { group, groups } from 'd3-array';
import { format } from 'd3-format';
import { mapObject } from '../utils/array';
import { ChartEvent } from '../utils/event';
Expand Down Expand Up @@ -799,9 +799,15 @@ async function plotView(

// Render components.
// @todo renderComponent return ctor and options.
// Key for each type of component.
// Index them grouped by position.
for (const [, C] of groups(components, (d) => `${d.type}-${d.position}`)) {
C.forEach((d, i) => (d.index = i));
}

const componentsTransitions = selection
.selectAll(className(COMPONENT_CLASS_NAME))
.data(components, (d, i) => `${d.type}-${i}`)
.data(components, (d) => `${d.type}-${d.position}-${d.index}`)
.join(
(enter) =>
enter
Expand Down
4 changes: 2 additions & 2 deletions src/theme/academy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ export const Academy: TC<AcademyOptions> = (options) => {
titlePosition: 'left',
titleSpacing: 4,
titleTextBaseline: 'middle',
titleTransform: `translate(50%, 0) rotate(-90) translate(0, -50%)`,
titleDirection: 'vertical',
titleTransformOrigin: 'center',
},
axisRight: {
Expand All @@ -283,7 +283,7 @@ export const Academy: TC<AcademyOptions> = (options) => {
titlePosition: 'right',
titleSpacing: 0,
titleTextBaseline: 'top',
titleTransform: `translate(-50%, 0) rotate(-90)`,
titleDirection: 'vertical',
titleTransformOrigin: 'center',
},
axisLinear: {
Expand Down
4 changes: 2 additions & 2 deletions src/theme/classic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ export const Classic: TC<ClassicOptions> = (options) => {
titlePosition: 'left',
titleSpacing: 10,
titleTextBaseline: 'middle',
titleTransform: `translate(50%, 0) rotate(-90)`,
titleDirection: 'vertical',
titleTransformOrigin: 'center',
},
axisRight: {
Expand All @@ -286,7 +286,7 @@ export const Classic: TC<ClassicOptions> = (options) => {
titlePosition: 'right',
titleSpacing: 0,
titleTextBaseline: 'top',
titleTransform: `translate(-50%, 0) rotate(-90)`,
titleDirection: 'vertical',
titleTransformOrigin: 'center',
},
axisLinear: {
Expand Down
4 changes: 2 additions & 2 deletions src/theme/classicDark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ export const ClassicDark: TC<ClassicDarkOptions> = (options) => {
titlePosition: 'left',
titleSpacing: 10,
titleTextBaseline: 'middle',
titleTransform: `translate(50%, 0) rotate(-90)`,
titleDirection: 'vertical',
titleTransformOrigin: 'center',
},
axisRight: {
Expand All @@ -283,7 +283,7 @@ export const ClassicDark: TC<ClassicDarkOptions> = (options) => {
titlePosition: 'right',
titleSpacing: 0,
titleTextBaseline: 'top',
titleTransform: `translate(-50%, 0) rotate(-90)`,
titleDirection: 'vertical',
titleTransformOrigin: 'center',
},
axisLinear: {
Expand Down