Giter Club home page Giter Club logo

graphin's Introduction

English | 简体中文

Graphin

A lighteight React toolkit for graph analysis based on G6.

Version NPM downloads Latest commit

✨ 功能特性

  • 🎨 轻量级:不做过度封装,尽量保持 G6 能力同步,尽量不新增概念,整体核心代码 <200 行。
  • 🎗️ React 风格:舒心的开发体验,符合 React 用户心智,基于 React 扩展组件更容易。
  • 🚀 丰富组件:丰富的组件,源于业务沉淀,让用户定制自己的图应用更快更容易。

component

🔨 快速使用

graphin 当作一个普通的 React 组件来使用即可,通过 NPM 或 Yarn 等包管理器来安装。

$ npm install @antv/graphin
$ yarn add @antv/graphin

成功安装之后,可以通过 import 导入 Graphin 组件。

import React from 'react';
import { Graphin } from '@antv/graphin';

export function Demo() {
  return (
    <Graphin
      id="my-graphin-demo"
      className="my-graphin-container"
      style={{ width: '100%', height: '100%' }}
      options={{
        data,
        node: {
          style: {
            labelText: (d) => d.id,
          },
          palette: {
            type: 'group',
            field: 'cluster',
          },
        },
        layout: {
          type: 'd3force',
          collide: {
            strength: 0.5,
          },
        },
        behaviors: ['zoom-canvas', 'drag-canvas'],
        animation: true,
      }}
    >
    </Graphin>
    />
  );
}

📖 API Reference

Property Description Type Default
id 设置图画布容器的 id 属性。 string -
className 设置图画布容器的 class 属性。 string -
style 设置图画布容器的 style 样式属性。 CSSProperties -
options 设置图画布的配置项,参考 G6 配置 文档,在 graph.setOptions(options) 中调用 GraphOptions | null -
onInit 当图实例初始化之后调用,在 new Graph() 之后。 (graph: Graph) => void -
onReady 当图实例渲染完成之后调用,在 graph.render() 之后。 (graph: Graph) => void -
onDestroy 当图实例被销毁的时候调用,在 graph.destroy() 之后。 () => {} -

🗂 Examples

📮 贡献

  • 问题反馈:使用过程遇到的 graphin 的问题,欢迎提交 Issue,并附上可以复现问题的最小案例代码。
  • 贡献指南:如何参与到 graphin开发和贡献
  • 想法讨论:在 GitHub Discussion 上或者钉钉群里面讨论。

📄 License

MIT.

graphin's People

Contributors

aarebecca avatar afc163 avatar baizn avatar blakko avatar brickmaker avatar budlion avatar codesarehonest avatar daniele-pini avatar dependabot-preview[bot] avatar dukesun99 avatar dulinrain avatar femiabdul avatar gazzamc avatar genert avatar jiangjun1994 avatar lloydzhou avatar niknbr avatar nwulqx avatar otto-j avatar pomelo-nwu avatar songhn233 avatar timlrx avatar v-jiepeng avatar xdddst avatar yangzy0603 avatar yanyan-wang avatar yjtm-1119 avatar yuiseki avatar yvonneyx avatar zxc0328 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

graphin's Issues

框选功能

你好,有没有框选多个节点或者边的功能,可以那道框选节点边的数据

添加事件双击节点连线, 单击空白处删除连线, 报错

Describe the bug
image
添加事件双击节点连线, 单击空白处删除连线, 报错

"edge:click": "_click"

// 报错行 \graphin\packages\graphin\src\behaviors\graphin-highlight.ts
if (id === sourceNode.get('id') || id === targetNode.get('id')) {

To Reproduce
@镜曦 https://codesandbox.io/s/nodeedgestyle-n0rl4

Expected behavior
A clear and concise description of what you expected to happen.

Desktop (please complete the following information):

  • OS: [windows]
  • Browser [chrome]
  • Version [ 78.0.3904.108]

Featrue : Need to support custom icons

Graphin needs a built-in icon library to help users set the icon for the node. There is also a need to support third-party icon libraries.

The method of extend.marker needs to be discarded,svg2marker seems to be a bit problem in rendering icons in @antv/g

--- zh-CN ---

Graphin需要一个内置的图标库,帮助用户设置节点的图标。同时也需要支持第三方图标库. Extend.marker_ 的方法需要废弃,svg2marker 在g中渲染图标似乎有点问题

内置的icon无法显示

我本地运行能正常显示节点里面的图标,然后编译发布到dev环境后图标就显示不出来了,是什么原因呢?

graphin-components 在 TS 项目中无法使用

Describe the bug
A clear and concise description of what the bug is.

使用 TS 的时候发现没有 types,看了一下 package.json 是指定了的,但是 types 在 ./dist/src/index.dsrc 被 .npmignore 忽略掉了。

"types": "./dist/src/index.d",

To Reproduce

// Add Code Sanbox reproduce link using this template: https://codesandbox.io/s/data-driven-3o71b

Expected behavior
A clear and concise description of what you expected to happen.

TS 项目能正常引入组件。

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

首页图片被压缩

Describe the bug

image

To Reproduce

https://graphin.antv.vision/zh

Expected behavior
A clear and concise description of what you expected to happen.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

ctrl+左键进行多选节点

如题,目前平台没有多选功能,期望能够增加节点多选。比如在多选操作之后,进行统一拖拽,统一扩展节点,统一合并到一个组等等的多节点操作。期望能够优先增强这些基础能力。

Sent with GitHawk

Feature:力导支持向心力配置

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

不渲染 ,控制台输出: effect did-mount

Describe the bug
不渲染 ,控制台输出: effect did-mount
To Reproduce

// Add Code Sanbox reproduce link using this template: https://codesandbox.io/s/data-driven-3o71b

Expected behavior
A clear and concise description of what you expected to happen.

Desktop (please complete the following information):

  • OS: [windows 10]
  • Browser [ chrome]
  • Version [1.0.0]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

G6的Option,传入没有效果

https://graphin.antv.vision/zh/docs/api/graphin#options
说,“另外,这个 props.options 也支持传入 G6 的 Options。详见 G6 Options。”
但是,g6的option,fitView,autoPaint:true传入没有效果。
<Graphin data={transform(import_data)}
options = {{pixelRatio :100, keyShapeZoom:0.001, fitView:true, autoPaint:true}}
layout={{
name: "dagre",
options: {
center: [window.innerWidth / 3, window.innerHeight / 3], // 可选,中心点坐标
nodeSize: [15, 15], // 可选,节点大小
nodesep: 12, // 可选, 节点水平间距(px)
ranksep: 15, // 可选, 每一层节点之间间距
align: "UL", // 可选, 放置位置
rankdir: 'LR',
}
}}>

SubLayout 子图布局

Graphin 通过数据和布局驱动,支持子图布局。

  • 1.支持稳定布局算法的子图布局,比如Graphin.Layout.circle + Graphin.Layput.radial
  • 2.支持力导布局算法的子图布局,比如Graphin.Layout.force + Graphin.Layput.circle

TypeError: Cannot read property 'Marker' of undefined

package.json
{
"name": "data-driven",
"version": "1.0.0",
"description": "",
"keywords": [],
"main": "src/index.js",
"dependencies": {
"@antv/graphin": "1.0.3",
"antd": "3.25.2",
"react": "16.12.0",
"react-dom": "16.12.0",
"react-scripts": "3.3.1"
},
"devDependencies": {
"typescript": "3.7.5"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}

版本1.0.3,1.0.2运行报错,把@antv/graphin版本降到1.0.1好了

支持vue吗

请问支持vue吗
具体怎么使用,谢谢

Graphin Gallery

We need a Graphin gallery to help users quickly understand what Graphin can do.
Currently, a demo of graphin-studio is not enough. Part of the gallery is used for the demonstration of our basic capabilities, and part of it is used for the demonstration of richer demos.

---- zh-CN ---
我们需要一个Graphin的画廊,帮助用户快速了解Graphin能做那些事情
目前仅graphin-studio一个demo是不够的,画廊一部分用于我们基础能力的演示,一部分用与于更丰富的demo的展示

网站菜单色彩问题

Describe the bug

image

To Reproduce

Visit:https://graphin.antv.vision/zh/examples/render/save

Expected behavior

应该和其他站点一样是紫色主色。

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

📝 图可视分析 参考案例

https://help.aliyun.com/video_detail/63227.html?spm=a2c4g.11186623.4.5.7b57af833Sm9xs
https://grapheco.github.io/InteractiveGraph/dist/examples/example1.html
国内一些不错的案例产品,可以参考一些功能和操作形态!
本热使用过一些开源的软件,cytoscape (客户端版本)针对图的操作还是不错的,和gephi各有千秋
而针对品质来讲cytoscape更胜一筹,但是cytoscape有点太专业,尤其是左侧的针对图的操作见仁见智。
综上,I+平台的针对国内可视化网络分析的使用习惯,还是有很多借鉴的意义的。

边优化

  • 边文字优化
    • 边文字背景
    • 自环边文字位置
  • 多边
  • 粗边
  • 边动画

基础功能建议

针对选中节点需要提供如下操作:
1、隐藏节点、显示隐藏的节点、删除节点,恢复隐藏;删除和隐藏节点后,将图形界面上的和选中节点的边也隐藏或删除。
2、可以针对选中的节点(可能是多个)设置:大小,高亮,填充、颜色,标签(可多值)、轮廓、背景图片等主要控制显示的属性。
3、针对选中节点可以合并成一个Group,并对Group名称,类型、样式等参数提供编辑、如:将N个对象合并成一个群体。合并之后,节点隐藏,组节点显示。
4、针对Group类型的节点,支持“展开”操作,节点的组合和展开可以执行多次,即节点之间、节点与组,组之间可以反复组合和展开。
组合后,组外其他关联组内节点的边需要和组发生链接。(需要平衡边的显示方式)

选中边:
1、可设置边的颜色、线条、方向(最好能够无向图和有向图的混合显示,即画布上一部分节点之间是无向关联的,一部分是有向关联)、边粗细(体现关系密切程度,可考虑权重)、边的Label(针对复杂多类型关系网络关系类型很重要)。
2、边需要提供事件响应,比如:点击或双击边之后,右侧显示关系构成的情况,时间,内容等。

暂时先梳理了一些最为基础的功能要求。希望官方能够仔细参考,完善。

节点类型声明

export interface Node {
    /** 节点源数据 */
    data: {
        /** 唯一标示ID,必选 */
        id: string;
        /** 节点数据类型 */
        type?: string;
        /** 节点文本 */
        label?: string;
        /** 节点属性 */
        properties?: any[]; // eslint-disable-line
    };
    /** 唯一标示ID,必选 */
    id: string;
    /** 节点类型 */
    shape?: string;
    /** 节点样式 */
    style?: Partial<NodeStyle>;
    /** 节点位置信息 */
    x?: number;
    y?: number;
    /** 内置的布局,追加的额外属性 */
    layout?: NodeLayoutType;
    /** 节点度数 */
    degree?: number;
    searchTypes?: string[];
}

想问一下,节点类型用string声明似乎不太方便,之后会调整吗?

Feature:Need to add a lock state to the node

Description: If the node is in the lock state, it will not participate in the layout. For example, in the force layout, the locked node will be fixed in place.

-- zh-CN --

功能描述:节点为lock状态,则不参与布局。比如在力导布局中,锁定的节点会固定在原处。

document typo of Graphin

https://graphin.antv.vision/zh/docs/manual/main-concepts/data

trasform

<Graphin data={transform.(data)} />;

const trasform = (data: { nodes: NodeData[]; edges: EdgeData[] }) => {
    const nodes = (nodes: NodeData[]) => {
        return nodes.map(node => {
            return {
                id: node.id,
                data: node,
                // 根据type来指定渲染的shape
                shape: node.type === 'phone' ? 'MyCustomNode' : 'CircleNode',
                // 根据数据的渲染样式
                style: {
                    nodeSize: node.weight > 20 ? 50 : 20,
                },
            };
        });
    };
    const edges = (edges: EdgeData[]) => {
        return edges;
    };
    return {
        nodes: transform.nodes(data.nodes),
        edges: transform.edges(data.edges),
    };
};

<Graphin data={transform.(data)} />;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.