Logo
  • Documentation
  • Components
  • New Component Request
GitHub
GitHub
    Treon Studio
    Discord
    Twitter

    Welcome

    Introduction
    Components
    Contributors
    Installation
    Roadmap
    Status - Beta

    Components

    Author TooltipCalendar Event CardCode BlockComponent Preview TooltipChat ComposerEmail Compose CardFile DropzoneFile PreviewGitHub Stars ButtonGoal CardHolo CardKnowledge GraphLink PreviewiOS Message BubblesModel SelectorNavbar MenuNested MenuNotification CardPricing CardRaised ButtonSearch Results TabsSlash Command DropdownTodo ItemTwitter CardWeather CardWorkflow Card

    Form Inputs

    Async Select
    Button
    Button Group
    Checkbox
    Color Picker
    Combobox
    Hierarchical Select
    Input
    Input Base
    Input O T P
    Mask Input
    Multi Select
    Number Input
    Radio Card Group
    Radio Group
    Range Slider
    Search Input
    Segmented Button
    Select
    Slider
    Switch
    Tag Input
    Textarea
    Voice Input

    Layout

    Aspect Ratio
    Card
    Card Icons
    Card Input
    Collapsible
    Divider
    Grid
    Island
    Panel
    Portal
    Resizable
    Scroll Area
    Scroll Shadow
    Separator
    Spacer
    Visually Hidden
    Visually Hidden Input

    Navigation

    Breadcrumb
    Context Menu
    Dropdown Menu
    Menu
    Navbar
    Pagination
    Sidebar
    Steps
    Tab Navigation
    Tabs

    Feedback

    Alert
    Banner
    Callout
    Circular Progress
    Empty State
    Error Message
    Error Page
    Loader Inline
    Loader Screen
    Progress
    Progress Bar
    Skeleton
    Spinner
    Status Dot
    Toast
    Toaster
    Tooltip
    Top Banner
    Tour

    Data Display

    Advanced Table
    Badge
    Badge Overflow
    Data Table
    Description List
    Listbox
    Table
    Tag
    Timeline
    Tree
    Virtualized

    Overlays

    Alert Dialog
    Dialog
    Dialog Stack
    Drawer
    Hover Card
    Popover

    Charts

    Area Chart
    Bar Chart
    Bar List
    Category Bar
    Combo Chart
    Comparison
    Conditional Bar Chart
    Contribution Graph
    Radar Chart

    Calendars

    Attendance Calendar
    Calendar
    Date Picker
    Date Time Field
    Full Calendar
    Gantt
    Mini Calendar
    Schedule
    Schedule Grid
    Time Field

    Typography

    Code
    Code Block
    Control Help
    Control Label
    Field
    Heading
    Kbd
    Label
    Link
    Markdown
    Rich Text Editor
    Snippet
    Text

    Media

    Avatar
    Avatar Group
    Deck
    Document Preview
    File List
    File Upload
    Glimpse
    Image
    Image Crop
    Image Zoom
    Photo Gallery
    Profile Picture
    Q R Code
    Q R Scanner

    User

    Discussion
    Rating
    Testimonial
    User
    User Card

    Interactive

    Accordion
    Action Bar
    Command
    Copy Button
    Cursor
    Emoji Picker
    Fade
    Inline Edit
    Kanban
    Marquee
    Orbit
    Ripple
    Sortable

    Specialized

    App Header
    Bulk Grade Input
    Credit Card
    Footer
    Level Picker
    Notification Card
    Password Strength
    Payment Method
    Pricing Table
    Sandbox
    Stat Card
    Ticker
    Usage Card
    Wizard
    DocsComponents

    Knowledge Graph

    An interactive D3.js-powered knowledge graph visualization with zoom, pan, drag, tooltips, and export functionality.

    Made with ❤️ byTreon Studio.Source code available onGitHub

    On This Page

    • Usage in Gaia
    • Installation
    • Usage
    • Features
    • Examples
    • With Ref for Export Controls
    • Minimal (No Legend, No Link Labels)
    • Custom Node Sizes and Colors
    • Props
    • Node Interface
    • Link Interface
    • Handle Methods
    Website screenshot
    Meet Bungas
    Your open-source, proactive personal AI assistant with 200+ integrations. Bungas combines todos, goals, calendar, and email into one system, turns tasks into automated workflows, and completes work instead of just tracking it. Open-source and self-hostable with support for custom automations and multi-step workflows.

    Knowledge Graph

    An interactive force-directed graph visualization powered by D3.js. Perfect for displaying relationships, knowledge bases, memory systems, mind maps, and entity connections.

    💡 Drag nodes to reposition • Scroll to zoom • Click nodes for details

    Usage in Gaia

    Visualizing the brain. Shows how Gaia connects entities and memories.

    Installation

    First, install the required D3.js dependency:

    npm install d3 @types/d3

    Then add the component:

    npx shadcn@latest add "https://ui.treonstudio.io/r/knowledge-graph"

    Usage

    import { KnowledgeGraph } from "@/components/ui/knowledge-graph";
     
    const nodes = [
      { id: "1", label: "React", type: "technology" },
      { id: "2", label: "TypeScript", type: "technology" },
      { id: "3", label: "User", type: "user", size: 30 },
    ];
     
    const links = [
      { source: "3", target: "1", label: "uses" },
      { source: "3", target: "2", label: "uses" },
      { source: "1", target: "2" },
    ];
     
    export default function Example() {
      return (
        <div className="h-[400px]">
          <KnowledgeGraph
            nodes={nodes}
            links={links}
            onNodeClick={(node) => console.log(node)}
          />
        </div>
      );
    }

    Features

    • Interactive: Drag nodes, zoom with scroll, pan the canvas
    • Automatic Layout: Force-directed simulation positions nodes optimally
    • Colored by Type: Each node type gets a unique, deterministic color
    • Legend: Optional legend showing all node types
    • Link Labels: Display relationship labels on edges
    • Tooltips: Hover for node information
    • Export: Export to SVG or PNG
    • Center Node: Optionally center a specific node

    Examples

    With Ref for Export Controls

    import { useRef } from "react";
    import { KnowledgeGraph, type KnowledgeGraphHandle } from "@/components/ui/knowledge-graph";
     
    export default function Example() {
      const graphRef = useRef<KnowledgeGraphHandle>(null);
     
      return (
        <div>
          <button onClick={() => graphRef.current?.exportAsPNG()}>
            Export as PNG
          </button>
          <button onClick={() => graphRef.current?.resetZoom()}>
            Reset Zoom
          </button>
          <KnowledgeGraph ref={graphRef} nodes={nodes} links={links} />
        </div>
      );
    }

    Minimal (No Legend, No Link Labels)

    <KnowledgeGraph
      nodes={nodes}
      links={links}
      showLegend={false}
      showLinkLabels={false}
    />

    Custom Node Sizes and Colors

    const nodes = [
      { id: "1", label: "Important", type: "main", size: 40, color: "#ff0000" },
      { id: "2", label: "Related", type: "secondary", size: 20 },
    ];

    Props

    PropTypeDefaultDescription
    nodesGraphNode[]RequiredArray of nodes to display
    linksGraphLink[]RequiredArray of links connecting nodes
    onNodeClick(node: GraphNode) => void-Callback when node is clicked
    onNodeHover(node: GraphNode | null) => void-Callback on node hover
    showLegendbooleantrueShow node type legend
    showLinkLabelsbooleantrueShow relationship labels on links
    centerNodeIdstring-Node ID to position in center
    classNamestring-Additional CSS classes

    Node Interface

    interface GraphNode {
      id: string;        // Unique identifier
      label: string;     // Display label
      type: string;      // Category (for coloring)
      size?: number;     // Node radius (default: 20)
      color?: string;    // Custom color override
      data?: unknown;    // Additional data
    }

    Link Interface

    interface GraphLink {
      source: string;      // Source node ID
      target: string;      // Target node ID
      label?: string;      // Relationship label
      strength?: number;   // Link strength (default: 0.8)
    }

    Handle Methods

    Access via ref:

    MethodDescription
    exportAsSVG()Download graph as SVG file
    exportAsPNG()Download graph as PNG file
    resetZoom()Reset zoom and pan to default