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

ngx-object-diagram

v2.2.0

Published

## About this project

Downloads

28

Readme

ngx-object-diagram

About this project

This angular library lets you generate object-diagrams from typescript objects. Please note, that it is not a target or intention of it to reach uml conformity.

Usage

<ngx-object-diagram [objs]="simpleObjs"></ngx-object-diagram>

Features

  • customize color, font-family and sizes via css-variables
  • Entities can be dragged
  • Support for simple entities as well as overrides for more complex objects with associations
  • Supports interactions with two buttons: One in the header of an entity (ex. for reloading) and one for adding more associations

Documentation

API

The ngx-object-diagram component can be configured with the following properties.

    @Input() // key of the identifier property which every entity must have
    public guidProp = 'guid';

    @Input() // key of the type property, which value is used in the entity header
    public typeNameProp = 'typeName';

    @Input() // key of the displayname property, which value is used in the entity header
    public displayNameProp = 'displayName';

    @Input() // a function to filter the fields of provided entities, must return NgxObjectDiagramEntityField[]
    public trackFields: (entity: Record<string, unknown>) => NgxObjectDiagramEntityField[] = entity => {
        return Object.keys(entity)
            .filter(key => key !== this.typeNameProp && key !== this.displayNameProp)
            .map(key => {
                return {
                    fieldName: key,
                    fieldKey: key,
                    value: entity[key],
                    isAssoc: entity[key] instanceof Array,
                };
            });
    };

    @Input() // an array of objects, which are to be displayed as object diagram
    public entities: Record<string, unknown>[];

    @Input() // an optional array of NgxObjectDiagramAssoc, to provide connecting lines between objects
    public assocs?: NgxObjectDiagramAssoc[];

    @Input() // maximal amount of chars to be displayed within an object (header and field), the rest will be truncated with ellipsis
    public maxTextLength = 20;

    @Output() // an action handler which is emmitted when clicking on the entity-header button
    public executeAction = new EventEmitter<{ guid: unknown }>();

    @Output() // an action handler, which is emitted when clicking on an associations field button
    public addAssoc = new EventEmitter<{ guid: unknown; assocKey: string }>();

Model of NgxObjectDiagramAssoc

export interface NgxObjectDiagramAssoc {
    guidA: string;
    guidB: string;
    fieldA: string;
    fieldB: string;
}

Model of NgxObjectDiagramEntityField

export interface NgxObjectDiagramEntityField {
    fieldName: string;
    fieldKey: string;
    value: unknown;
    isAssoc: boolean;
}

Usage

Please see the demo-app for how a possible implementation with associations could look like.

Theming

You can override colors, fonts and other styles using css-3 variables.

In your component.html

<ngx-object-diagram class="my-diagram" [objs]="simpleObjs"></ngx-object-diagram>

In your component.scss

.my-diagram {
    --ngx-obj-diagram-height: 600px;
    --ngx-obj-diagram-width: 800px;
    --ngx-obj-diagram-stroke-color: red;
}

Available variables: | CSS variable | Default | |-------------------------------------------|-------------------------------------------------| | --ngx-obj-diagram-height | 600px | | --ngx-obj-diagram-width | 800px | | --ngx-obj-diagram-font-family | 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif | | --ngx-obj-diagram-font-size | 16px | | --ngx-obj-diagram-entity-background-color | #fff | | --ngx-obj-diagram-entity-min-height | 300px | | --ngx-obj-diagram-entity-min-width | 225px | | --ngx-obj-diagram-header-font-size | 16px | | --ngx-obj-diagram-header-font-color | #000 | | --ngx-obj-diagram-header-background-color | #fff | | --ngx-obj-diagram-stroke-color | #000 | | --ngx-obj-diagram-line-stroke-color | #000 | | --ngx-obj-diagram-line-stroke-width | 2px | | --ngx-obj-diagram-button-font-size | 19px |

Status

This project is heavy work in progress and it is likely to change and or break. You are welcome to send pullrequests for improvements or new features.