-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix(graph): fix some options not effect after setOptions * fix: fix issue that backgound cannot display * docs: add euro cup demo * fix: fix issue that html node cannot correct fit view * chore: add deps
- Loading branch information
Showing
14 changed files
with
508 additions
and
34 deletions.
There are no files selected for viewing
114 changes: 114 additions & 0 deletions
114
packages/g6-extension-react/__tests__/dataset/euro-cup.json
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,114 @@ | ||
{ | ||
"nodes": [ | ||
{ | ||
"id": "50251337", | ||
"x": 50, | ||
"y": 68, | ||
"isTeamA": "1", | ||
"player_id": "50251337", | ||
"player_shirtnumber": "19", | ||
"player_enName": "Justin Kluivert", | ||
"player_name": "尤斯廷-克鲁伊维特" | ||
}, | ||
{ | ||
"id": "50436685", | ||
"x": 25, | ||
"y": 68, | ||
"isTeamA": "1", | ||
"player_id": "50436685", | ||
"player_shirtnumber": "24", | ||
"player_enName": "Antoine Semenyo", | ||
"player_name": "塞门约" | ||
}, | ||
{ | ||
"id": "50204813", | ||
"x": 50, | ||
"y": 89, | ||
"isTeamA": "1", | ||
"player_id": "50204813", | ||
"player_shirtnumber": "9", | ||
"player_enName": "Dominic Solanke", | ||
"player_name": "索兰克" | ||
}, | ||
{ | ||
"id": "50250175", | ||
"x": 75, | ||
"y": 68, | ||
"isTeamA": "1", | ||
"player_id": "50250175", | ||
"player_shirtnumber": "16", | ||
"player_enName": "Marcus Tavernier", | ||
"player_name": "塔韦尼耶" | ||
}, | ||
{ | ||
"id": "50213675", | ||
"x": 65, | ||
"y": 48, | ||
"isTeamA": "1", | ||
"player_id": "50213675", | ||
"player_shirtnumber": "4", | ||
"player_enName": "Lewis Cook", | ||
"player_name": "刘易斯-库克" | ||
}, | ||
{ | ||
"id": "50186648", | ||
"x": 35, | ||
"y": 48, | ||
"isTeamA": "1", | ||
"player_id": "50186648", | ||
"player_shirtnumber": "10", | ||
"player_enName": "Ryan Christie", | ||
"player_name": "克里斯蒂" | ||
}, | ||
{ | ||
"id": "50279448", | ||
"x": 38, | ||
"y": 28, | ||
"isTeamA": "1", | ||
"player_id": "50279448", | ||
"player_shirtnumber": "6", | ||
"player_enName": "Chris Mepham", | ||
"player_name": "迈帕姆" | ||
}, | ||
{ | ||
"id": "50061646", | ||
"x": 15, | ||
"y": 28, | ||
"isTeamA": "1", | ||
"player_id": "50061646", | ||
"player_shirtnumber": "15", | ||
"player_enName": "Adam Smith", | ||
"player_name": "亚当-史密斯" | ||
}, | ||
{ | ||
"id": "50472140", | ||
"x": 62, | ||
"y": 28, | ||
"isTeamA": "1", | ||
"player_id": "50472140", | ||
"player_shirtnumber": "27", | ||
"player_enName": "Ilya Zabarnyi", | ||
"player_name": "扎巴尔尼" | ||
}, | ||
{ | ||
"id": "50544346", | ||
"x": 85, | ||
"y": 28, | ||
"isTeamA": "1", | ||
"player_id": "50544346", | ||
"player_shirtnumber": "3", | ||
"player_enName": "Milos Kerkez", | ||
"player_name": "科尔克兹" | ||
}, | ||
{ | ||
"id": "50062598", | ||
"x": 50, | ||
"y": 7, | ||
"isTeamA": "1", | ||
"player_id": "50062598", | ||
"player_shirtnumber": "1", | ||
"player_enName": "Neto", | ||
"player_name": "内托" | ||
} | ||
] | ||
} |
106 changes: 106 additions & 0 deletions
106
packages/g6-extension-react/__tests__/demos/euro-cup.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,106 @@ | ||
import { ExtensionCategory, register } from '@antv/g6'; | ||
import styled from 'styled-components'; | ||
import { ReactNode } from '../../src'; | ||
import { Graph } from '../../src/graph'; | ||
import data from '../dataset/euro-cup.json'; | ||
|
||
const Player = styled.div` | ||
width: 100%; | ||
height: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
`; | ||
|
||
const Shirt = styled.div` | ||
width: 40px; | ||
height: 40px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
position: relative; | ||
img { | ||
width: 40px; | ||
position: absolute; | ||
left: 0; | ||
top: 0; | ||
} | ||
`; | ||
|
||
const Number = styled.div` | ||
color: #fff; | ||
font-family: 'DingTalk-JinBuTi'; | ||
font-size: 10px; | ||
top: 20px; | ||
left: 15px; | ||
z-index: 1; | ||
margin-top: 16px; | ||
margin-left: -2px; | ||
`; | ||
|
||
const Label = styled.div` | ||
max-width: 120px; | ||
padding: 0 8px; | ||
color: #fff; | ||
font-size: 10px; | ||
background-image: url('https://mdn.alipayobjects.com/huamei_92awrc/afts/img/A*s2csQ48M0AkAAAAAAAAAAAAADsvfAQ/original'); | ||
background-repeat: no-repeat; | ||
background-size: cover; | ||
display: flex; | ||
justify-content: center; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
`; | ||
|
||
const PlayerNode = ({ playerInfo }: any) => { | ||
const { isTeamA, player_shirtnumber, player_name } = playerInfo; | ||
return ( | ||
<Player> | ||
<Shirt> | ||
<img | ||
src={ | ||
isTeamA | ||
? 'https://mdn.alipayobjects.com/huamei_92awrc/afts/img/A*0oAaS42vqWcAAAAAAAAAAAAADsvfAQ/original' | ||
: 'https://mdn.alipayobjects.com/huamei_92awrc/afts/img/A*BYH5SauBNecAAAAAAAAAAAAADsvfAQ/original' | ||
} | ||
/> | ||
<Number>{player_shirtnumber}</Number> | ||
</Shirt> | ||
<Label>{player_name}</Label> | ||
</Player> | ||
); | ||
}; | ||
|
||
register(ExtensionCategory.NODE, 'react', ReactNode); | ||
|
||
export const EuroCup = () => { | ||
return ( | ||
<div> | ||
<Graph | ||
options={{ | ||
data, | ||
animation: false, | ||
x: 10, | ||
y: 50, | ||
width: 480, | ||
height: 720, | ||
background: | ||
'url(https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*EmPXQLrX2xIAAAAAAAAAAAAADmJ7AQ/original)no-repeat', | ||
node: { | ||
type: 'react', | ||
style: { | ||
size: [100, 60], | ||
ports: [{ placement: 'center' }], | ||
x: (d: any) => d.x * 3.5, | ||
y: (d: any) => d.y * 3.5, | ||
fill: 'transparent', | ||
component: (data: any) => <PlayerNode playerInfo={data} />, | ||
}, | ||
}, | ||
}} | ||
/> | ||
</div> | ||
); | ||
}; |
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,3 +1,4 @@ | ||
export * from './euro-cup'; | ||
export * from './g-node'; | ||
export * from './graph'; | ||
export * from './react-node'; |
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
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.