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

angular-mindmapping

v1.0.6

Published

Enhanced english version for angular-mindmap

Downloads

13

Readme

Mind Map

Notice

This repo that convert original lib to typescript lib, then, add some feature, hope you like this feature.

Original

jsMind is a pure javascript library for mindmap, it base on html5 canvas. jsMind was released under BSD license, you can embed it in any project, if only you observe the license.

Install

npm i angular-mindmapping

Feature

nodeMoving event

we can handle "nodeMoving" event to catch the current, source and destination node during a drag/drop move and even cancel the move using "event.preventDefault()"

Configurable node tree depth etc.

we can add property depth of option parameter to control this mind map depth, it will throw exception when add node greater the depth.

const option = {
  ...
  depth: 5,
  hasInteraction: true,
  enableDraggable: true,
}

const mindMap = MindMapMain.show(option, mind);
  • hasInteraction(boolean): define this mind map whether need interaction, if true, we can use some utils like reporter and receiver to control yourself interaction
  • enableDraggable(boolean): enable node draggable, default is false

Configurable node select type.

we can add property hierarchy_rule of option parameter to control this mind map select type and node background color and font color.

const HIERARCHY_RULES = {
  ROOT: {
    name: 'Company',
    backgroundColor: '#7EC6E1',
    getChildren: () => [
      HIERARCHY_RULES.SALES_MANAGER,
      HIERARCHY_RULES.SHOW_ROOM,
      HIERARCHY_RULES.SALES_TEAM
    ]
  },
  SALES_MANAGER: {
    name: 'Work Plan',
    color: '#fff',
    backgroundColor: '#616161',
    getChildren: () => [
      HIERARCHY_RULES.SHOW_ROOM,
      HIERARCHY_RULES.SALES_TEAM
    ]
  },
  SHOW_ROOM: {
    name: 'Job',
    color: '#fff',
    backgroundColor: '#989898',
    getChildren: () => [
      HIERARCHY_RULES.SALES_TEAM
    ]
  },
  SALES_TEAM: {
    name: 'Task',
    color: '#fff',
    backgroundColor: '#C6C6C6',
    getChildren: () => []
  }
};

By above example, we can configurate the mind map hierarchical relationship.

  • name(string): display in node text
  • color(string): node font color
  • backgroundColor(string): node background color
  • getChildren(function): get can select node type in selector

Usage

--In angular

import { MindMapMain } from "angular-mindmapping";

const HIERARCHY_RULES = {
  ROOT: {
    name: 'Company',
    backgroundColor: '#7EC6E1',
    getChildren: () => [
      HIERARCHY_RULES.SALES_MANAGER,
      HIERARCHY_RULES.SHOW_ROOM,
      HIERARCHY_RULES.SALES_TEAM
    ]
  },
  SALES_MANAGER: {
    name: 'Work Plan',
    color: '#fff',
    backgroundColor: '#616161',
    getChildren: () => [
      HIERARCHY_RULES.SHOW_ROOM,
      HIERARCHY_RULES.SALES_TEAM
    ]
  },
  SHOW_ROOM: {
    name: 'Job',
    color: '#fff',
    backgroundColor: '#989898',
    getChildren: () => [
      HIERARCHY_RULES.SALES_TEAM
    ]
  },
  SALES_TEAM: {
    name: 'Task',
    color: '#fff',
    backgroundColor: '#C6C6C6',
    getChildren: () => []
  }
};

const option = {
  container: 'jsmind_container',
  theme: 'normal',
  editable: true,
  selectable: false,
  depth: 4,
  hierarchyRule: HIERARCHY_RULES,
  enableDraggable: true,
};

const mind = {
  format: 'nodeTree',
  data: {
    id: 43,
    topic: 'EiBP',
    selectedType: false,
    backgroundColor: '#7EC6E1',
    children: [
      {
        id: 80,
        color: '#fff',
        topic: 'Work Plan No.1',
        direction: 'right',
        selectedType: 'Work Plan',
        backgroundColor: '#616161',
        children: []
      },
      {
        id: 44,
        color: '#fff',
        topic: 'Work Plan No.2',
        direction: 'right',
        selectedType: 'Work Plan',
        backgroundColor: '#616161',
        children: [
          {
            id: 46,
            color: '#fff',
            topic: 'Job No.1',
            direction: 'right',
            selectedType: 'Job',
            backgroundColor: '#989898',
            children: [
              {
                id: 49,
                color: '#fff',
                topic: 'Task No.1',
                direction: 'right',
                selectedType: 'Task',
                backgroundColor: '#C6C6C6',
                children: []
              },
              {
                id: 51,
                color: '#fff',
                topic: 'Task No.2',
                direction: 'right',
                selectedType: 'Task',
                backgroundColor: '#C6C6C6',
                children: []
              },
              {
                id: 47,
                color: '#fff',
                topic: 'Task No.3',
                direction: 'right',
                selectedType: 'Task',
                backgroundColor: '#C6C6C6',
                children: []
              },
              {
                id: 48,
                color: '#fff',
                topic: 'Task No.4',
                direction: 'right',
                selectedType: 'Task',
                backgroundColor: '#C6C6C6',
                children: []
              },
              {
                id: 50,
                color: '#fff',
                topic: 'Task No.5',
                direction: 'right',
                selectedType: 'Task',
                backgroundColor: '#C6C6C6',
                children: []
              }
            ]
          }
        ]
      },
      {
        id: 45,
        color: '#fff',
        topic: 'Work Plan No.3',
        direction: 'right',
        selectedType: 'Work Plan',
        backgroundColor: '#616161',
        children: []
      }
    ]
  }
};

@Component(
  ...
)
class MindMapComponent implements OnInit {

  mindMap;

  constructor() {

  }

  ngOnInit() {
    this.mindMap = MindMapMain.show(option, mind);
  }

  removeNode() {
    const selectedNode = this.mindMap.getSelectedNode();
    const selectedId = selectedNode && selectedNode.id;

    if (!selectedId) {
      return;
    }
    this.mindMap.removeNode(selectedId);
  }

  addNode() {
    const selectedNode = this.mindMap.getSelectedNode();
    if (!selectedNode) {
      return;
    }

    const nodeId = customizeUtil.uuid.newid();
    this.mindMap.addNode(selectedNode, nodeId);
  }

  getMindMapData() {
    const data = this.mindMap.getData().data;
    console.log('data: ', data);
  }
}