Skip to content

Commit

Permalink
fix: size鏀寔px
Browse files Browse the repository at this point in the history
  • Loading branch information
xuying.xu committed May 29, 2024
1 parent 736701d commit bc13fb4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
6 changes: 3 additions & 3 deletions packages/f2/src/components/interval/withInterval.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ export default (Views) => {

mapping() {
const records = super.mapping();

const { props } = this;
const { props, context } = this;
const { px2hd } = context;
const { coord, sizeZoom } = props;
const y0 = this.getY0Value();
const defaultSize = this.getDefaultSize();
Expand All @@ -95,7 +95,7 @@ export default (Views) => {
mix(child, coord.convertRect({ x, y, y0, size: size * zoomRatio }));
} else {
const { x, y } = child;
const rect = { size: mappedSize, x, y, y0 };
const rect = { size: px2hd(mappedSize), x, y, y0 };
mix(child, coord.transformToRect(rect));
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 21 additions & 1 deletion packages/f2/test/components/interval/interval.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { jsx } from '../../../src';
import { Canvas, Chart, Interval, Axis } from '../../../src';
import { Canvas, Chart, Interval, Axis, Point } from '../../../src';
import { createContext, delay } from '../../util';
const context = createContext();

Expand Down Expand Up @@ -43,6 +43,26 @@ describe('Interval', () => {
expect(context).toMatchImageSnapshot();
});

it('size 鏀寔px', async () => {
const ref = {};
const context = createContext('size 鏀寔px');
const { type, props } = (
<Canvas context={context} pixelRatio={1}>
<Chart data={data}>
<Axis field="genre" />
<Axis field="sold" min={0} />
<Interval x="genre" y="sold" size={'60px'}></Interval>
<Point x="genre" y="sold" size={'30px'}></Point>
</Chart>
</Canvas>
);

const canvas = new Canvas(props);
await canvas.render();

await delay(1000);
expect(context).toMatchImageSnapshot();
});
it('startOnZero', async () => {
const { props } = (
<Canvas context={context} pixelRatio={1}>
Expand Down

0 comments on commit bc13fb4

Please sign in to comment.