Skip to content

Commit

Permalink
fix: graphScope add detail panel
Browse files Browse the repository at this point in the history
  • Loading branch information
baizn committed Feb 3, 2021
1 parent 77060d0 commit 7725c16
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 77 deletions.
1 change: 0 additions & 1 deletion packages/graphin-graphscope/docs/demo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export default () => {
<GraphScopeComponent
graphDOM={domRef.current}
data={data}
width={1000}
height={400}
neighbors={queryNeighbors}
hasContextMenu={true}
Expand Down
2 changes: 1 addition & 1 deletion packages/graphin-graphscope/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/graphin-graphscope",
"version": "0.0.18",
"version": "0.0.20",
"description": "An Example for GraphScope",
"main": "lib/index.js",
"module": "es/index.js",
Expand Down
1 change: 0 additions & 1 deletion packages/graphin-graphscope/src/detail.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.draggablePanel {
position: absolute !important;
z-index: 3;
width: 331px;
padding: 16px 24px;
Expand Down
4 changes: 2 additions & 2 deletions packages/graphin-graphscope/src/detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ const ElementDetailPanel: React.FC<DetailProps> = ({ close, type, itemId, data =
<Resizable
defaultSize={{
width: 331,
height: 'auto',
height: 350,
}}
className={styles.draggablePanel}
style={{ top: 40, right: 0 }}
style={{ overflow: 'auto' }}
>
<div style={{ height: '100%' }}>
<Row className={classNames(styles.header, 'handle')}>
Expand Down
1 change: 1 addition & 0 deletions packages/graphin-graphscope/src/events/click.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const ClickElement: React.FC<ClickElementProps> = ({ nodeClick }) => {
useEffect(() => {
graph.on('node:click', evt => {
const { item } = evt;
console.log('click node', item);
const model = item.getModel() as Graphin.NodeConfig;

if (nodeClick) {
Expand Down
26 changes: 14 additions & 12 deletions packages/graphin-graphscope/src/graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export interface GraphData {
interface GraphProps {
graphDOM: HTMLDivElement;
data: GraphData;
width: number;
width?: number;
height: number;
neighbors?: (nodeId: string, degree: number) => void;
hasMinimap?: boolean;
Expand Down Expand Up @@ -379,13 +379,13 @@ const GraphScope: React.FC<GraphProps> = ({
type: null,
});
const handleClickElement = (model: NodeConfig, type: string) => {
setDetailInfo({
visible: true,
data: model,
type,
});
if (nodeClick) {
nodeClick(model as NodeData, type);
setDetailInfo({
visible: true,
data: model,
type,
});
}
};

Expand Down Expand Up @@ -414,12 +414,14 @@ const GraphScope: React.FC<GraphProps> = ({
)}
{hasFishEye && <FishEye options={{ showLabel: false }} visible={visible} handleEscListener={handleClose} />}
{detailInfo.visible && (
<ElementDetailPanel
type={detailInfo.type}
data={detailInfo.data}
close={() => setDetailInfo({ visible: false, data: null, type: '' })}
itemId={detailInfo.data.id}
/>
<div style={{ position: 'absolute', top: 40, right: 0 }}>
<ElementDetailPanel
type={detailInfo.type}
data={detailInfo.data}
close={() => setDetailInfo({ visible: false, data: null, type: '' })}
itemId={detailInfo.data.id}
/>
</div>
)}
</Graphin>
</div>
Expand Down
Loading

0 comments on commit 7725c16

Please sign in to comment.