npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

graph-board

v1.1.25

Published

Một thư viện vẽ đồ thị bằng Javascript

Downloads

3

Readme

graph-board

Codacy Badge

Một Thư Viện Vẽ Đồ Thị Bằng Javascript.

A Draw Graph Javascript Library.

Xem demo

Cách dùng cơ bản

Basic Usage

index.html

...
<div id="graph"></div>
...
import Graph from "graph-board";

// Khởi tạo đối tượng Graph
const graph = new Graph();

// Mount đồ thị vào một phần tử
graph.appendTo("#graph");

Tùy chọn

Options

Bạn có thêm một số tham số khi khởi tạo đồi tượng

| Tham số | Kiểu dữ liệu | Mặc định | Mô tả | | ------------ | ------------ | -------- | ------------------------------------- | | directed | boolean | false | Tùy chọn đồ thị có hướng hay vô hướng | | showGrid | boolean | false | Tùy chọn hiện hay ẩn lưới | | showDistance | boolean | false | Hiển thị khoảng các giữa các đỉnh | | radius | number | 20 | Bán kính của đỉnh |

Ví dụ

Example

...

const options = {
    directed: true,
    showGrid: true,
    showDistance: true,
    radius: 35,
}

const graph = new Graph(options)
graph.appendTo('#graph')

...

Thuộc tính

Properties

| Tên thuộc tính | Giá trị | Cấu trúc | | -------------- | ------------------------------------------------------- | ----------------------------------------------- | | nodes | Danh sách chứa các đỉnh và vị trí của nó trên hệ tọa độ | nodes: {label:number, x: number, y: number}[] | | edges | Danh sách các cung của đồ thị | edges: {from:number, to: number}[] |

Phương thức

Methods

| Tên phương thức | Tham số | Mô tả | | ------------------------------------ | ----------------------------------------------------------- | ---------------------------------------------------------- | | addNode(label:number) | label: nhãn của nút | Thêm một nút vào đồ thị | | addEdge(from:number, to:number) | from: đỉnh bắt đầu của cung, to: đỉnh kết thúc của cung | Thêm một cung vào đồ thị | | appendTo(selector: string) | selector: css-selector | Chèn giao diện đồ họa của đồ thị vào một đối tượng DOM | | setDirected(directed: boolean) | directed: boolean | Đặt giá trị cho việc hiện hay ẩn hướng của đồ thị | | setShowDistance(distance: boolean) | distance: boolean | Đặt giá trị cho việc hiện hay ẩn khoảng cách giữa các đỉnh | | setShowGrid(showGrid: boolean) | showGrid: boolean | Đặt giá trị cho việc hiện hay ẩn lưới | | exportMatrix(): number[][] | Không có tham số | Trả về ma trận kề của đồ thị | | removeNode(label:number) | label: nhãn | Xóa một nút có nhãn label | | removeEdge(from: number, to: number) | from: đỉnh bắt đầu của cung, to: đỉnh kết thúc của cung | Xóa một cung khỏi đồ thị |

Donation