-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
1 parent
fb084c2
commit 96fd489
Showing
31 changed files
with
2,417 additions
and
52 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,6 +1,6 @@ | ||
--- | ||
title: 属性 | ||
order: 11 | ||
order: 13 | ||
redirect_from: | ||
- /zh/docs | ||
- /zh/docs/api | ||
|
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,6 +1,6 @@ | ||
--- | ||
title: 滤镜 | ||
order: 12 | ||
order: 15 | ||
redirect_from: | ||
- /zh/docs | ||
- /zh/docs/api | ||
|
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,6 +1,6 @@ | ||
--- | ||
title: 高亮器 | ||
order: 11 | ||
order: 14 | ||
redirect_from: | ||
- /zh/docs | ||
- /zh/docs/api | ||
|
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,6 +1,6 @@ | ||
--- | ||
title: PortLabelLayout | ||
order: 14 | ||
order: 12 | ||
redirect_from: | ||
- /zh/docs | ||
- /zh/docs/api | ||
|
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
42 changes: 42 additions & 0 deletions
42
sites/x6-sites/src/api/port-label-layout/inside-outside/index.less
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,42 @@ | ||
.port-label-inside-outside-app { | ||
display: flex; | ||
padding: 0; | ||
padding: 16px 8px; | ||
font-family: sans-serif; | ||
|
||
.app-side { | ||
bottom: 0; | ||
padding: 0 8px; | ||
} | ||
|
||
.app-content { | ||
flex: 1; | ||
margin-right: 8px; | ||
margin-left: 8px; | ||
box-shadow: 0 0 10px 1px #e9e9e9; | ||
} | ||
|
||
.ant-card { | ||
box-shadow: 0 0 10px 1px #e9e9e9; | ||
} | ||
|
||
.ant-card-head-title { | ||
text-align: center; | ||
} | ||
|
||
.ant-row { | ||
margin: 16px 0; | ||
text-align: left; | ||
} | ||
|
||
.slider-value { | ||
display: inline-block; | ||
margin-left: 8px; | ||
padding: 3px 7px; | ||
color: #333; | ||
font-size: 12px; | ||
line-height: 1.25; | ||
background: #eee; | ||
border-radius: 10px; | ||
} | ||
} |
98 changes: 98 additions & 0 deletions
98
sites/x6-sites/src/api/port-label-layout/inside-outside/index.tsx
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,98 @@ | ||
import React from 'react' | ||
import { Graph, Node } from '@antv/x6' | ||
import { Settings, State } from './settings' | ||
import './index.less' | ||
|
||
export default class Example extends React.Component { | ||
private container: HTMLDivElement | ||
private node: Node | ||
|
||
componentDidMount() { | ||
const graph = new Graph({ | ||
container: this.container, | ||
background: { | ||
color: '#F2F7FA', | ||
}, | ||
}) | ||
|
||
this.node = graph.addNode({ | ||
shape: 'ellipse', | ||
x: 70, | ||
y: 85, | ||
width: 260, | ||
height: 100, | ||
attrs: { | ||
label: { | ||
text: 'outside', | ||
fill: '#888', | ||
fontSize: 12, | ||
}, | ||
body: { | ||
stroke: '#8f8f8f', | ||
strokeWidth: 1, | ||
fill: '#fff', | ||
rx: 6, | ||
ry: 6, | ||
}, | ||
}, | ||
ports: { | ||
groups: { | ||
a: { | ||
position: { | ||
name: 'ellipseSpread', | ||
args: { | ||
compensateRotate: true, | ||
}, | ||
}, | ||
label: { | ||
position: { | ||
name: 'outside', | ||
}, | ||
}, | ||
attrs: { | ||
circle: { | ||
fill: '#ffffff', | ||
stroke: '#8f8f8f', | ||
strokeWidth: 1, | ||
r: 10, | ||
magnet: true, | ||
}, | ||
text: { | ||
fill: '#6a6c8a', | ||
fontSize: 12, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}) | ||
|
||
Array.from({ length: 10 }).forEach((_, index) => { | ||
this.node.addPort({ attrs: { text: { text: `P ${index}` } }, group: 'a' }) | ||
}) | ||
} | ||
|
||
onAttrsChanged = ({ position, offset }: State) => { | ||
this.node.prop('ports/groups/a/label/position', { | ||
name: position, | ||
args: { offset }, | ||
}) | ||
|
||
this.node.attr('label/text', position) | ||
} | ||
|
||
refContainer = (container: HTMLDivElement) => { | ||
this.container = container | ||
} | ||
|
||
render() { | ||
return ( | ||
<div className="port-label-inside-outside-app"> | ||
<div className="app-side"> | ||
<Settings onChange={this.onAttrsChanged} /> | ||
</div> | ||
<div className="app-content" ref={this.refContainer} /> | ||
</div> | ||
) | ||
} | ||
} |
103 changes: 103 additions & 0 deletions
103
sites/x6-sites/src/api/port-label-layout/inside-outside/settings.tsx
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,103 @@ | ||
import React from 'react' | ||
import { Radio, Slider, Card, Row, Col } from 'antd' | ||
|
||
export interface Props { | ||
onChange: (state: State) => void | ||
} | ||
|
||
export interface State { | ||
position: string | ||
offset: number | ||
} | ||
|
||
export class Settings extends React.Component<Props, State> { | ||
state: State = { | ||
position: 'outside', | ||
offset: 15, | ||
} | ||
|
||
notifyChange() { | ||
this.props.onChange(this.state) | ||
} | ||
|
||
onOffsetChanged = (offset: number) => { | ||
this.setState({ offset }, () => { | ||
this.notifyChange() | ||
}) | ||
} | ||
|
||
onPositionChange = (e: any) => { | ||
this.setState( | ||
{ | ||
position: e.target.value, | ||
}, | ||
() => { | ||
this.notifyChange() | ||
}, | ||
) | ||
} | ||
|
||
render() { | ||
const radioStyle = { | ||
display: 'block', | ||
height: '36px', | ||
lineHeight: '36px', | ||
} | ||
|
||
return ( | ||
<Card | ||
title="Port Label Position" | ||
size="small" | ||
bordered={false} | ||
style={{ width: 240 }} | ||
> | ||
<Row | ||
align="middle" | ||
justify="center" | ||
style={{ | ||
borderBottom: '1px solid #f0f0f0', | ||
paddingBottom: 16, | ||
marginBottom: 16, | ||
}} | ||
> | ||
<Col> | ||
<Radio.Group | ||
value={this.state.position} | ||
onChange={this.onPositionChange} | ||
> | ||
<Radio style={radioStyle} value={'inside'}> | ||
inside | ||
</Radio> | ||
<Radio style={radioStyle} value={'outside'}> | ||
outside | ||
</Radio> | ||
<Radio style={radioStyle} value={'insideOriented'}> | ||
insideOriented | ||
</Radio> | ||
<Radio style={radioStyle} value={'outsideOriented'}> | ||
outsideOriented | ||
</Radio> | ||
</Radio.Group> | ||
</Col> | ||
</Row> | ||
<Row align="middle"> | ||
<Col span={5} style={{ textAlign: 'right', paddingRight: 16 }}> | ||
offset | ||
</Col> | ||
<Col span={14}> | ||
<Slider | ||
min={-30} | ||
max={30} | ||
step={1} | ||
value={this.state.offset} | ||
onChange={this.onOffsetChanged} | ||
/> | ||
</Col> | ||
<Col span={1} offset={1}> | ||
<div className="slider-value">{this.state.offset}</div> | ||
</Col> | ||
</Row> | ||
</Card> | ||
) | ||
} | ||
} |
Oops, something went wrong.