Git Product home page Git Product logo

f6's Introduction

F6: A Mobile Graph Visualization Framework in TypeScript.

typescript MIT npm package NPM downloads Percentage of issues still open

English | 简体中文

What is F6

F6 is a mobile graph visualization engine, which provides a set of basic mechanisms, including rendering, layout, analysis, interaction, animation, and other auxiliary tools. F6 aims to simplify the relationships, and help people to obtain the insight of relational data.

Developers are able to build graph visualization analysis applications or graph visualization modeling applications easily.

Powerful Animation and Interactions

Features

  • Abundant Built-in Items: Nodes and edges with free configurations;
  • Steerable Interactions: More than 10 basic interaction behaviors ;
  • Powerful Layout: More than 10 layout algorithms;
  • Convenient Components: Outstanding ability and performance;
  • Friendly User Experience: Complete documents for different levels of user requirements. TypeScript supported.

F6 concentrates on the principle of 'good by default'. In addition, the custom mechanism of the item, interation behavior, and layout satisfies the customazation requirements.

Abundant Built-in Items

Installation

$ npm install @antv/f6

Usage

import F6 from "@antv/f6";
import graphData from "./data";
import dagreLayout from "@antv/f6/dist/extends/layout/dagreLayout";
import TreeGraph from "@antv/f6/dist/extends/graph/treeGraph";

F6.registerLayout("dagreLayout", dagreLayout);
F6.registerGraph("TreeGraph", TreeGraph);

Page({
  data: {
    width: 300,
    height: 400,
    pixelRatio: 1,
  },
  onLoad() {
    const { windowWidth, windowHeight, pixelRatio } = my.getSystemInfoSync();
    this.setData({
      width: windowWidth,
      height: windowHeight,
      pixelRatio: pixelRatio,
    });
  },
  onCanvasInit(ctx, rect, canvas, renderer) {
    this.graph = new F6.TreeGraph({
      context: ctx,
      renderer,
      width: this.data.width,
      height: this.data.height,
      linkCenter: true,
      modes: {
        default: ["drag-canvas", "zoom-canvas"],
      },
      defaultNode: {
        size: 40,
      },
      layout: {
        type: "compactBox",
        direction: "RL",
        getId: function getId(d) {
          return d.id;
        },
        getHeight: () => {
          return 26;
        },
        getWidth: () => {
          return 26;
        },
        getVGap: () => {
          return 20;
        },
        getHGap: () => {
          return 30;
        },
        radial: false,
      },
    });

    this.graph.node(function (node) {
      return {
        label: node.id,
      };
    });

    this.graph.data(graphData);
    this.graph.render();
    this.graph.fitView();
  },
  onTouch(e) {
    this.graph.emitEvent(e);
  },
  onUnload() {
    this.graph?.destroy();
  },
});

For more information of the usage, please refer to Getting Started.

Development

$ npm install -g @microsoft/rush

# update dependencies
$ rush update

# build the packages
$ rush build

# demo
$ cd packages/f6 && rushx storybook

Documents

How to Contribute

Please let us know what you are you going to help. Do check out issues for bug reports or suggestions first.

To become a contributor, please follow our contributing guide.

License

MIT license.

f6's People

Contributors

chenpeng-yiyu avatar chiaweilee avatar fantasista11 avatar hungwii avatar icmi avatar openwayne avatar tangying1027 avatar weiqingtangx 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

f6's Issues

force布局,小程序demo设置局部渲染,长时间不出图

力导布局,在支付宝小程序里。没有一开始的连续布局的动画效果,直到布局计算完成后最后一帧才会出图。表现就像是卡住白屏了。
设置非局部渲染graph.get('canvas').set('localRefresh', false)后,可以看到前面的动画效果。

目前排查到在drawRegion时,计算出来的脏区域总是null,导致总是跳出渲染。

调用链路:_drawRegion -> _getRefreshRegion -> getMergedRegion

getMergedRegion函数返回的区域不是很正常,如下图:
image

帧率(fps)插件

功能

通过帧率插件,在canvas上展示fps等内容

  • fps
  • 节点数量
  • 文本数量
  • etc

示例

TypeError: Bn.measureText is not a function

{
// 点集
nodes: [
{
id: "1",
label: "节点1"
// x: 100, // Number,可选,节点位置的 x 值
// y: 200 // Number,可选,节点位置的 y 值
},
{
id: "2",
label: "节点2"
// x: 300, // Number,可选,节点位置的 x 值
// y: 200 // Number,可选,节点位置的 y 值
}
],
// 边集
edges: [
{
source: "1", // String,必须,起始点 id
target: "2"
// label: "关系"
}
]
};

新能力讨论

  • webgl的渲染使用
  • rust模块改造
  • g以及f6核心引擎的优化,整体包大小控制在80k(zip)
  • 10+plugin能力支持
  • f6-ui的对外

还需什么额外的能力?

Plugin integration

目前 f6 没集成但 g6 已经集成的 plugin 包括:

  • Grid
  • Minimap
  • Bundling
  • Menu
  • Fisheye
  • ToolBar
  • Tooltip
  • TimeBar
  • ImageMinimap
  • EdgeFilterLens
  • SnapLine
  • Legend

需要根据移动端的特点决定是否集成、集成哪些?

BUG: 支付宝小程序, f6-alipay在页面的位置会导致点击位置不准确

Describe
支付宝小程序目前使用f6-alipay做了一层canvas的封装,如果该组件出现在页面顶部,一切工作正常。但是如果出现以下情况,会出现点击位置偏移,比如点击不到节点的情况。

  • f6-alipay 初始化后,位置发生变化,比如随着交互变化,隐藏了部分模块,canvas的位置自然上移
  • f6-alipay 的节点路径上,某个祖先节点高度100%并允许滚动的时候

初始化Graph实例报错,e.onTick is not a function

  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

Edit on CodeSandbox

Steps to reproduce

初始化的时候会报错,目前定位到报错行数,每帧都会调用,但是第一帧报错后,后续帧会停止调用,不影响出图,但是会有个报错。

Environment Info
f6 0.0.14
System -
Browser -

逐层展开插件

功能

通过设置展开节点数量,新展开节点,则关闭老节点

示例

待补充

BUG:微信端双击事件不触发

Describe

开发者发现微信端双击不触发,简单测试发现有触发,但是触发时机不对,可能点个5下触发一次。

其他端待测试

是否提供BOM和DOM操作

目前遇到的问题

  • 小程序中无BOM和DOM,那么一些container操作就无法正常使用

方案一

  • 使用canvas/webgl做全部元素的绘制,对container等做一层转换
    优势:
    全部环境都可以保持一致性
    缺点:
    开发成本会增加

方案二

  • 在小程序中增加一层wrapper,兼容有限的dom和bom操作,然后动态在模版中渲染
    优势:
    成本相对较低,可以便捷使用css和div等
    缺点:
    小程序内存在一些限制,再就是app中方案会更重

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.