-
Notifications
You must be signed in to change notification settings - Fork 646
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
273 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
import { jsx } from '@ali/f2-jsx'; | ||
import Bottom from './bottom'; | ||
import Right from './right'; | ||
import Left from './left'; | ||
|
||
export default (props: any) => { | ||
const { position } = props; | ||
|
||
if (position === 'bottom') { | ||
return ( | ||
<Bottom { ...props } /> | ||
); | ||
switch (position) { | ||
case 'bottom': | ||
return <Bottom { ...props } /> | ||
case 'right': | ||
return <Right { ...props } /> | ||
default: | ||
return <Left { ...props } /> | ||
} | ||
return <Left { ...props } /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { jsx } from '@ali/f2-jsx'; | ||
|
||
export default (props: any) => { | ||
const { plot, labelOffset, ticks, line, label, tickLine, grid } = props; | ||
const { tl, tr, bl, br } = plot; | ||
|
||
return ( | ||
<group> | ||
{ | ||
line === false ? | ||
null | ||
: | ||
<line attrs={{ | ||
x1: tr.x, | ||
y1: tr.y, | ||
x2: br.x, | ||
y2: br.y, | ||
stroke: '#EDEDED', | ||
lineWidth: '1px', | ||
...line, | ||
}} /> | ||
} | ||
{ | ||
ticks.map((tick, index) => { | ||
const { x, y, text } = tick; | ||
return ( | ||
<group> | ||
{ | ||
label === false ? | ||
null | ||
: | ||
<text attrs={{ | ||
x: x + labelOffset, | ||
y, | ||
textAlign: 'left', | ||
textBaseline: 'middle', | ||
text, | ||
fill: '#CCCCCC', | ||
fontSize: '20px', | ||
...label, | ||
}} /> | ||
} | ||
{ | ||
grid === false ? | ||
null | ||
: | ||
<line attrs={{ | ||
x1: tl.x, | ||
y1: y, | ||
x2: tr.x, | ||
y2: y, | ||
stroke: '#EDEDED', | ||
lineWidth: '2px', | ||
...grid, | ||
}} /> | ||
} | ||
{ | ||
tickLine === false ? | ||
null | ||
: | ||
<line attrs={{ | ||
x1: x + (tickLine && tickLine.length || 0), | ||
y1: y, | ||
x2: x, | ||
y2: y, | ||
stroke: '#EDEDED', | ||
lineWidth: '2px', | ||
...tickLine, | ||
}} /> | ||
} | ||
</group> | ||
); | ||
}) | ||
} | ||
</group> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { map } from '@ali/f2x-util'; | ||
import ComboComponent from './comboComponent'; | ||
|
||
function createComponentTree(element: JSX.Element) { | ||
if (!element) return element; | ||
const { type, key, ref, props } = element; | ||
const { children } = props; | ||
|
||
// 如果有children, 统一处理成 ComboComponent | ||
if (type === 'fragment' && children) { | ||
props.children = map(children, (child: JSX.Element) => { | ||
return createComponentTree(child); | ||
}); | ||
return { | ||
type: ComboComponent, | ||
key, | ||
ref, | ||
props, | ||
} | ||
} | ||
// 其他标签都不处理 | ||
if (typeof type !== 'function') { | ||
return null; | ||
} | ||
// 如果已经是F2 component了,直接返回 | ||
if (type.prototype && type.prototype.isF2Component) { | ||
return element; | ||
} | ||
// 其他情况 说明是 function component, 直接执行 | ||
const newElement = type(element.props); | ||
return createComponentTree(newElement); | ||
} | ||
|
||
export default (children: JSX.Element[]) => { | ||
return map(children, (child: JSX.Element) => { | ||
return createComponentTree(child); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.