Skip to content

Commit

Permalink
fix: 修改 FEngine layout 的命名 (#1647)
Browse files Browse the repository at this point in the history
  • Loading branch information
zengyue committed Nov 16, 2022
1 parent 2a5fa21 commit ec28248
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 33 deletions.
4 changes: 2 additions & 2 deletions packages/f2/src/chart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ class Chart extends Component<ChartProps, ChartState> {
}

private getStyle(props: ChartProps) {
const { context, style } = this;
const { context, layout } = this;
const { theme, px2hd } = context;
const { left, top, width, height } = style;
const { left, top, width, height } = layout;
const { style: customStyle } = props;
return px2hd({
left,
Expand Down
2 changes: 1 addition & 1 deletion packages/f2/src/components/area/withArea.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import withLine from '../line/withLine';

export default (View) => {
export default (View): any => {
return class Area extends withLine(View) {
getDefaultCfg() {
return {
Expand Down
8 changes: 5 additions & 3 deletions packages/f2/src/components/gauge/withGauge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ export interface GuageProps {
startAngle?: number;
endAngle?: number;
tickCount?: number;
tickOffset?: number;
tickLength?: number;
r?: number;
tickOffset?: number | string;
tickLength?: number | string;
r?: number | string;
r0?: number | string;
center?: { x: number; y: number };
percent?: number;
}

export default (View: ComponentType): ClassComponent<GuageProps> => {
Expand Down
7 changes: 3 additions & 4 deletions packages/f2/src/components/sunburst/withSunburst.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,16 @@ export default (View): ClassComponent<any> => {
}

willMount() {
const { props, coord, style } = this;
const { props, coord, layout } = this;
const { coord: coordOption } = props;
coord.updateLayout(style);
coord.updateLayout(layout);

coord.create(coordOption);
}

didMount() {
const { props, container, context } = this;
const { props, context } = this;
const { onClick } = props;
const { canvas } = context;
this.triggerRef = [];

context.gesture.on('click', (ev) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/f2/src/components/treemap/withTreemap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export default (View): ClassComponent<any> => {
}

willMount() {
const { props, coord, style } = this;
const { props, coord, layout } = this;
const { coord: coordOption } = props;
coord.updateLayout(style);
coord.updateLayout(layout);

coord.create(coordOption);
}
Expand Down
19 changes: 13 additions & 6 deletions packages/f2/src/coord/base.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Layout } from '../index';
import { Range, Point, Option } from './types';
import { isArray } from '@antv/util';
import { isArray, mix } from '@antv/util';

function transposedRect({ xMin, xMax, yMin, yMax }) {
return { xMin: yMin, xMax: yMax, yMin: xMin, yMax: xMax };
Expand Down Expand Up @@ -55,7 +54,14 @@ interface Rect {
* convert相关的方法,涉及将标准坐标系映射到实际坐标系内
* transform相关的方法,是仅将某一种关键点转换成另一种关键点 (比如将x/y/size/y0转换成yMin/yMax/..)
*/
class Base extends Layout {
class Base {
left = 0;
top = 0;
width = 0;
height = 0;
right: number;
bottom: number;

type: string;
// 用来特殊标识是否是极坐标
isPolar: boolean;
Expand All @@ -70,14 +76,15 @@ class Base extends Layout {
y: Range = [0, 1];

constructor(option: Option) {
super(option);
this.update(option);
}

update(option: Option) {
super.update(option);

mix(this, option);
const { left, top, width, height } = this;

this.right = left + width;
this.bottom = top + height;
this.center = {
x: left + width / 2,
y: top + height / 2,
Expand Down
11 changes: 0 additions & 11 deletions packages/f2/src/deps/f2-scale/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,6 @@ import Identity from './identity/index';
import { getTickMethod, registerTickMethod } from './tick-method/index';
import { ScaleConfig, Tick } from './types';

registerScale('cat', Category);
registerScale('category', Category);
registerScale('identity', Identity);
registerScale('linear', Linear);
registerScale('log', Log);
registerScale('pow', Pow);
registerScale('time', Time);
registerScale('timeCat', TimeCat);
registerScale('quantize', Quantize);
registerScale('quantile', Quantile);

export {
Category,
Identity,
Expand Down
4 changes: 0 additions & 4 deletions packages/f2/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import {
createRef,
Component,
Children,
Layout,
LayoutProps,
computeLayout,
Theme,
} from '@antv/f-engine';
Expand All @@ -31,8 +29,6 @@ export {
Component,
Timeline,
Chart,
Layout,
LayoutProps,
computeLayout,
CanvasRenderer,
};
Expand Down

0 comments on commit ec28248

Please sign in to comment.