搜尋套件、儲存庫與 APP 分類

flutter_graph_view 封面
套件詳情v2.1.0

flutter_graph_view

用於美觀的圖形資料結構的組件,例如力導向圖。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
3110
喜歡數
93
Pub 分數
160

安裝套件

flutter pub add flutter_graph_view

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

Flutter Graph View 是一個視覺化套件,可建立視覺上吸引人的圖資料結構,包含力導向圖。它提供可自訂的元件,用於呈現節點與邊,並支援順暢動畫與互動行為。非常適合顯示網路、樹狀結構或相依關係圖中的複雜關係,支援多個平台,包括行動裝置、Web 與桌面。此套件運用高效能的佈局演算法,即使面對大量資料也能確保快速回應的效能。其簡潔的 API 讓整合至需要動態視覺化的 Flutter 應用程式變得輕鬆簡單。

適用情境

  • 可視化網路拓撲
  • 顯示依賴關係圖
  • 建立互動式思維導圖
  • 渲染層次資料結構
  • 顯示即時資料流

主要特色

  • 力導向佈局演算法
  • 可自訂的節點和邊樣式
  • 互動式拖曳與放置支援
  • 流暢的動畫和過渡
  • 跨平台相容性(Android、iOS、Web、macOS、Windows、Linux)

適合對象

  • 資料視覺化應用
  • 教育工具
  • 網路分析軟體
  • 具有複雜資料關係的 UI
  • 需要動態圖形渲染的應用程式

使用建議

  • 效能可能會隨著非常大的圖而下降
  • 需要仔細調整佈局參數
  • 有限的內建互動功能,僅限基本拖曳
  • 可能需要額外的邏輯來處理進階事件
  • 未針對即時流資料更新進行優化

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Flutter Graph View

GitHub stars GitHub forks

Widgets for beautiful graphic data structures, such as force-oriented diagrams.

image image

image

https://github.com/graph-cn/flutter_graph_view/assets/15630211/a035cd7d-bdac-4ef6-8abf-74594e9d699b

Features

  • [x] Data converter: convert business data into graphic view data.

  • [x] Algorithm: calculate vertex layout.

    • [x] Force directed algorithm.
    • [x] Random algorithm (In example folder).
    • [x] Support algorithm decorator.
      • [x] Breathe decorator (optional).
      • [x] Provide decorators that follow Hooke's Law for related nodes
      • [x] Provide a decorator for Hooke's Law from the center outward for all nodes
      • [x] Provide mutually exclusive Coulomb's law decorators for subgraph root nodes
      • [x] Hooke's Law decorator that provides border buffering collisions for all nodes
      • [x] Add a counter decorator in the figure to convert node forces into motion
  • [x] Data panel embedding.

  • [x] Style configuration.

  • [ ] More graphical interactions.

Getting started

flutter pub add flutter_graph_view

Usage

// Copyright (c) 2023- All flutter_graph_view authors. All rights reserved.
//
// This source code is licensed under Apache 2.0 License.

import 'dart:math';

import 'package:flutter/material.dart';
import 'package:flutter_graph_view/flutter_graph_view.dart';

class DecoratorDemo extends StatelessWidget {
  const DecoratorDemo({super.key});

  @override
  Widget build(BuildContext context) {
    var vertexes = <Map>{};
    var r = Random();
    for (var i = 0; i < 150; i++) {
      vertexes.add(
        {
          'id': 'node$i',
          'tag': 'tag${r.nextInt(9)}',
          'tags': [
            'tag${r.nextInt(9)}',
            if (r.nextBool()) 'tag${r.nextInt(4)}',
            if (r.nextBool()) 'tag${r.nextInt(8)}'
          ],
        },
      );
    }
    var edges = <Map>{};

    for (var i = 0; i < 150; i++) {
      edges.add({
        'srcId': 'node${i % 8 + 8}',
        'dstId': 'node$i',
        'edgeName': 'edge${r.nextInt(3)}',
        'ranking': DateTime.now().millisecond,
      });
    }
    // for (var i = 0; i < 20; i++) {
    //   edges.add({
    //     'srcId': 'node${i % 8}',
    //     'dstId': 'node${r.nextInt(150)}',
    //     'edgeName': 'edge${r.nextInt(3)}',
    //     'ranking': DateTime.now().millisecond,
    //   });
    // }

    var data = {
      'vertexes': vertexes,
      'edges': edges,
    };
    return FlutterGraphWidget(
      data: data,
      algorithm: RandomAlgorithm(
        decorators: [
          CoulombDecorator(),
          // HookeBorderDecorator(),
          HookeDecorator(),
          CoulombCenterDecorator(),
          HookeCenterDecorator(),
          ForceDecorator(),
          ForceMotionDecorator(),
          TimeCounterDecorator(),
        ],
      ),
      convertor: MapConvertor(),
      options: Options()
        ..enableHit = false
        ..panelDelay = const Duration(milliseconds: 500)
        ..graphStyle = (GraphStyle()
          // tagColor is prior to tagColorByIndex. use vertex.tags to get color
          ..tagColor = {'tag8': Colors.orangeAccent.shade200}
          ..tagColorByIndex = [
            Colors.red.shade200,
            Colors.orange.shade200,
            Colors.yellow.shade200,
            Colors.green.shade200,
            Colors.blue.shade200,
            Colors.blueAccent.shade200,
            Colors.purple.shade200,
            Colors.pink.shade200,
            Colors.blueGrey.shade200,
            Colors.deepOrange.shade200,
          ])
        ..useLegend = true // default true
        ..edgePanelBuilder = edgePanelBuilder
        ..vertexPanelBuilder = vertexPanelBuilder
        ..edgeShape = EdgeLineShape() // default is EdgeLineShape.
        ..vertexShape = VertexCircleShape(), // default is VertexCircleShape.
    );
  }

  Widget edgePanelBuilder(Edge edge, Viewfinder viewfinder) {
    var c = viewfinder.localToGlobal(edge.position);

    return Stack(
      children: [
        Positioned(
          left: c.x + 5,
          top: c.y,
          child: SizedBox(
            width: 200,
            child: ColoredBox(
              color: Colors.grey.shade900.withAlpha(200),
              child: ListTile(
                title: Text(
                    '${edge.edgeName} @${edge.ranking}\nDelay controlled by \noptions.panelDelay\ndefault to 300ms'),
              ),
            ),
          ),
        )
      ],
    );
  }

  Widget vertexPanelBuilder(hoverVertex, Viewfinder viewfinder) {
    var c = viewfinder.localToGlobal(hoverVertex.cpn!.position);
    return Stack(
      children: [
        Positioned(
          left: c.x + hoverVertex.radius + 5,
          top: c.y - 20,
          child: SizedBox(
            width: 120,
            child: ColoredBox(
              color: Colors.grey.shade900.withAlpha(200),
              child: ListTile(
                title: Text(
                  'Id: ${hoverVertex.id}',
                ),
                subtitle: Text(
                    'Tag: ${hoverVertex.data['tag']}\nDegree: ${hoverVertex.degree} ${hoverVertex.prevVertex?.id}'),
              ),
            ),
          ),
        )
      ],
    );
  }
}

Licence

flutter_graph_view is under the Apache License, Version 2.0.

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。