docs: fix site docs (#5856)

* docs: fix cover image

* docs: correct custom edge example
This commit is contained in:
Aaron 2024-06-12 16:55:46 +08:00 committed by GitHub
parent 33a56144db
commit 343941bf2f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 30 additions and 23 deletions

View File

@ -235,16 +235,19 @@ import type { BaseNodeStyleProps } from '@antv/g6';
class ExtendBaseEdge extends BaseEdge { class ExtendBaseEdge extends BaseEdge {
// Override the getKeyStyle method // Override the getKeyStyle method
protected getKeyStyle(attributes: Required<BaseNodeStyleProps>) { protected getKeyStyle(attributes: Required<BaseNodeStyleProps>) {
const { sourceNode, targetNode } = attributes; return { ...super.getKeyStyle(attributes), lineWidth: 2, stroke: '#000' };
}
// Implement the getKeyPath method
protected getKeyPath(attributes) {
const { sourceNode, targetNode } = this;
const [x1, y1] = sourceNode.getPosition(); const [x1, y1] = sourceNode.getPosition();
const [x2, y2] = targetNode.getPosition(); const [x2, y2] = targetNode.getPosition();
return { ...super.getKeyStyle(attributes), x1, y1, x2, y2 }; return [
} ['M', x1, y1],
['L', x2, y2],
// Override the drawKeyShape method ];
protected drawKeyShape(attributes: Required<BaseNodeStyleProps>, container: Group) {
return this.upsert('key', Line, this.getKeyStyle(attributes), container);
} }
} }
``` ```

View File

@ -235,16 +235,19 @@ import type { BaseNodeStyleProps } from '@antv/g6';
class ExtendBaseEdge extends BaseEdge { class ExtendBaseEdge extends BaseEdge {
// 重写 getKeyStyle 方法 // 重写 getKeyStyle 方法
protected getKeyStyle(attributes: Required<BaseNodeStyleProps>) { protected getKeyStyle(attributes: Required<BaseNodeStyleProps>) {
const { sourceNode, targetNode } = attributes; return { ...super.getKeyStyle(attributes), lineWidth: 2, stroke: '#000' };
}
// 实现 getKeyPath 方法
protected getKeyPath(attributes) {
const { sourceNode, targetNode } = this;
const [x1, y1] = sourceNode.getPosition(); const [x1, y1] = sourceNode.getPosition();
const [x2, y2] = targetNode.getPosition(); const [x2, y2] = targetNode.getPosition();
return { ...super.getKeyStyle(attributes), x1, y1, x2, y2 }; return [
} ['M', x1, y1],
['L', x2, y2],
// 重写 drawKeyShape 方法 ];
protected drawKeyShape(attributes: Required<BaseNodeStyleProps>, container: Group) {
return this.upsert('key', Line, this.getKeyStyle(attributes), container);
} }
} }
``` ```

View File

@ -36,14 +36,7 @@
}, },
"screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*C9apQa9NioMAAAAAAAAAAAAADmJ7AQ/original" "screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*C9apQa9NioMAAAAAAAAAAAAADmJ7AQ/original"
}, },
{
"filename": "loop-polyline.js",
"title": {
"zh": "折线自环边",
"en": "Polyline Loop"
},
"screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*OReBSqIkp_cAAAAAAAAAAAAADmJ7AQ/original"
},
{ {
"filename": "quadratic.js", "filename": "quadratic.js",
"title": { "title": {
@ -76,13 +69,21 @@
}, },
"screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*6Gj2R50AJ8AAAAAAAAAAAAAADmJ7AQ/original" "screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*6Gj2R50AJ8AAAAAAAAAAAAAADmJ7AQ/original"
}, },
{
"filename": "loop-polyline.js",
"title": {
"zh": "折线自环边",
"en": "Polyline Loop"
},
"screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*eCLSSIiRDVEAAAAAAAAAAAAADmJ7AQ/original"
},
{ {
"filename": "loop-curve.js", "filename": "loop-curve.js",
"title": { "title": {
"zh": "曲线自环边", "zh": "曲线自环边",
"en": "Curve Loop" "en": "Curve Loop"
}, },
"screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*6Gj2R50AJ8AAAAAAAAAAAAAADmJ7AQ/original" "screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*OReBSqIkp_cAAAAAAAAAAAAADmJ7AQ/original"
}, },
{ {
"filename": "arrows.js", "filename": "arrows.js",