Vue.js 는 AntV X6 의 예제 절 차 를 사용 합 니 다.
프로젝트 는 프로 세 스 맵 을 사용 하고 수요 도 상세 하지 않 기 때문에 비교적 유연 한 x6 그래 픽 편집 기 를 프로 세 스 맵 편집기 로 선택 하 십시오.문 서 를 보면 복잡 하지 않 습 니 다.여 기 는 참고 튜 토리 얼 입 니 다.
Antv X6 문서
0x1 설치
튜 토리 얼 알림 에 따라 x6 의존 을 설치 한 다음 에 새 용 기 를 예화 합 니 다.
<div ref="containerRef" class="area-center-container" />
const data = {
//
nodes: [
{
id: 'node1', // String, ,
x: 40, // Number, , x
y: 40, // Number, , y
width: 80, // Number, , width
height: 40, // Number, , height
label: 'hello', // String,
},
{
id: 'node2', // String,
x: 160, // Number, , x
y: 180, // Number, , y
width: 80, // Number, , width
height: 40, // Number, , height
label: 'world', // String,
},
],
//
edges: [
{
source: 'node1', // String, , id
target: 'node2', // String, , id
},
],
}
function initGraph() {
const graph = new Graph({
container: this.$refs.containerRef,
grid: {
size: 10, // 10px
visible: true //
},
snapline: {
enabled: true, //
sharp: true
},
scroller: {
enabled: true,
pageVisible: false,
pageBreak: false,
pannable: true
}
})
//
graph.centerContent()
graph.fromJSON(data)
}
이렇게 가장 간단 한 예 가 실현 되 었 습 니 다.위의 서로 다른 매개 변 수 는 문서 에 대응 하 는 설명 을 참고 하 십시오.0x2 노드 사 이 드 바
문서 의stencil예 를 들 어 많은 코드 양 을 간소화 할 수 있 고 봉 인 된 업무 로 직접 하면 됩 니 다.위 와 같이 용기 의 실례 화 를 직접 쓰 면 됩 니 다.
<el-aside ref="stencilRef" class="area-left" />
this.stencil = new Stencil({
title: ' ',
target: graph,
search: false,
collapsable: true,
stencilGraphWidth: this.$refs.stencilRef.$el.clientWidth,
stencilGraphHeight: this.$refs.stencilRef.$el.clientHeight,
groups: [
{
name: 'group',
title: ' ',
collapsable: false
}
],
getDropNode: node => {
let cloneNode = node.clone()
switch (node.shape) {
case 'rect':
cloneNode = new RectShape()
break
case 'circle':
cloneNode = new CircleShape()
break
case 'polygon':
cloneNode = new PolylineShape()
break
}
cloneNode.updateInPorts(graph)
return cloneNode
}
})
//
this.stencil.load([new Rect(rectInfo), new Circle(circleInfo), new Polygon(polygonInfo)], 'group')
0x3 통합 예온라인:https://codesandbox.io/s/icy-meadow-rqihx
이상 은 Vue.js 가 Antv X6 를 사용 하 는 예제 절차 에 대한 상세 한 내용 입 니 다.Vue.js 가 Antv X6 를 사용 하 는 것 에 관 한 자 료 는 저희 의 다른 관련 글 을 주목 하 세 요!
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Vue Render 함수로 DOM 노드 코드 인스턴스 만들기render에서createElement 함수를 사용하여 DOM 노드를 만드는 것은 직관적이지 않지만 일부 독립 구성 요소의 디자인에서 특수한 수요를 충족시킬 수 있습니다.간단한 렌더링 예는 다음과 같습니다. 또한 v...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.