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

kt-hierarch

v0.0.3

Published

## Overview

Downloads

206

Readme

kt-hierarch

Overview

kt-hierarch is an Angular module designed to create and manage hierarchical structures in your Angular applications. It provides a flexible way to display and manipulate hierarchical data, making it ideal for applications that require tree views or nested structures.

Minimum Angular Version

  • Angular 12

Installation

To install the kt-hierarch module, you can use npm:

npm install kt-hierarch

Importing the Module

After installation, import the KtHierarchModule into your Angular application module:

import { KtHierarchModule } from 'kt-hierarch';

@NgModule({
  declarations: [
    // your components
  ],
  imports: [
    KtHierarchModule,
    // other modules
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Jump To Examples

Default Vertical Orientation chart

example1

Default Horizontal Orientation chart

example2

Custom Vertical Orientation chart

example3

Usage

Component Setup

To use the hierarchy component, add the following in your template:

<kt-hierarch [data]="hierarchicalData" [config]="hierarchyConfig" (nodeClick)="onnodeClick($event)"></kt-hierarch>

Input Properties

  • data: An array of objects representing the hierarchical structure. Each object can have the following properties:

    • title: The title of the node.
    • subTitle: A subtitle for additional information.
    • image: A URL for an image associated with the node.
    • customContent: Any custom HTML content to display within the node.
    • childs: An array of child nodes, structured similarly.
  • config: An object for configuring the hierarchy display.

    • orientation: Specifies the layout orientation. Options are vertical or horizontal.
    • connector: Styles for the connectors between nodes.
      • borderWidth: Width of the connector line (e.g., '1px').
      • borderStyle: Style of the connector line (e.g., 'solid').
      • borderColor: Color of the connector line (e.g., '#d2d1d1').
    • node: Styles for the nodes.
      • backgroundColor: Background color of the node (e.g., '#ffffff').
      • borderWidth: Width of the node border (e.g., '1px').
      • borderStyle: Style of the node border (e.g., 'solid').
      • borderColor: Color of the node border (e.g., '#E8E8E8').

Output Properties

  • nodeClick: An event emitted when a node is selected. The event payload will include the selected node's data.

Example

Here's a simple example of how to use the kt-hierarch component:

Component Code

import { Component } from '@angular/core';

@Component({
  selector: 'app-hierarchy-example',
  templateUrl: './hierarchy-example.component.html'
})
export class HierarchyExampleComponent {
  hierarchicalData = [
    {
      title: 'Node 1',
      subTitle: 'This is Node 1',
      image: 'path/to/image1.png',
      customContent: '<p>Custom Content for Node 1</p>',
      childs: [
        {
          title: 'Node 1.1',
          subTitle: 'This is Node 1.1',
          image: 'path/to/image1.1.png',
          customContent: '<p>Custom Content for Node 1.1</p>',
          childs: []
        },
        {
          title: 'Node 1.2',
          subTitle: 'This is Node 1.2',
          image: 'path/to/image1.2.png',
          customContent: '<p>Custom Content for Node 1.2</p>',
          childs: []
        }
      ]
    },
    {
      title: 'Node 2',
      subTitle: 'This is Node 2',
      image: 'path/to/image2.png',
      customContent: '<p>Custom Content for Node 2</p>',
      childs: []
    }
  ];

  hierarchyConfig = {
    orientation: 'vertical',
    connector: {
      borderWidth: '1px',
      borderStyle: 'solid',
      borderColor: '#d2d1d1',
    },
    node: {
      backgroundColor: '#ffffff',
      borderWidth: '1px',
      borderStyle: 'solid',
      borderColor: '#E8E8E8',
    }
  };

  onnodeClick(item: any) {
    console.log('Selected Item:', item);
  }
}

Template Code

<kt-hierarch [data]="hierarchicalData" [config]="hierarchyConfig" (nodeClick)="onnodeClick($event)"></kt-hierarch>

API Reference

KtHierarchComponent

  • Inputs:

    • data: any[]: The hierarchical data to display.
    • config: { orientation: string; connector: { borderWidth: string; borderStyle: string; borderColor: string; }; node: { backgroundColor: string; borderWidth: string; borderStyle: string; borderColor: string; }; }: Configuration settings for the hierarchy display.
  • Outputs:

    • nodeClick: EventEmitter<any>: Emits the selected node.

Conclusion

The kt-hierarch module provides a straightforward way to manage and display hierarchical data in Angular applications. Customize it further to fit your application's needs by leveraging the available input and output properties. For additional features and updates, refer to the official repository or the project's documentation.

License

This module is licensed under the MIT License.