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

@morphatic/charts

v0.1.3

Published

A charting library for Angular 5+ that uses d3 and d3kit.

Downloads

4

Readme

Morphatic Charts

This is a library of Angular components that can create data visualizations using the powerful d3 framework, and the d3Kit library, which is designed to make it easier to create reusable d3 code. These charts should also work within Ionic projects, as well.

Installation

To install, from the root directory of your project type:

npm i -S d3 d3kit @morphatic/charts

The d3 and d3Kit libraries are listed as peerDependencies so you have to explicitly install them separately.

Then in the app.module.ts file in your project, import the MorphaticChartsModule and add it to the imports array of your @NgModule decorator as follows:

import { BrowserModule         } from '@angular/platform-browser';
import { NgModule              } from '@angular/core';
import { AppComponent          } from './app.component';
import { MorphaticChartsModule } from '@morphatic/charts';

@NgModule({
  declarations: [ AppComponent ],
  imports: [
    BrowserModule,
    MorphaticChartsModule
  ],
  providers: [],
  bootstrap: [ AppComponent ]
})
export class AppModule {}

At this point, the various different chart components will be available to your templates.

Using the Chart Components

To use the chart components, all you need to do is add the right tag to the appropriate template, and provide it with data in the correct format. The format of the expected data will differ for each type of chart and will be explained below.

Bar Charts

Bar charts consist of vertical bars representing the numeric values of a collection of categories or dates.

Example Bar Chart created with Morphatic Charts

In your template you should add a tag as follows:

<bar-chart [data]="barData"></bar-chart>

The variable barData is an array of BarDatum objects which have a pre-defined signature. In your component's .ts file, you should have something like:

import { Component } from '@angular/core';
import { BarDatum  } from '@morphatic/charts';

@Component({
  selector: 'home-page',
  templateUrl: './home.html'
})
export class HomePage {

  barData: BarDatum[];

  constructor() {
    this.barData = [
      {
        category: "apples",
        value: 12
      },
      {
        category: "oranges",
        value: 7
      },
      {
        category: "pears",
        value: 15
      }
    ];
  }
}

This code would generate a bar chart with three bars with the labels shown in the categories. Of course, data can be generated any way you like, e.g. retrieved from a database, pulled from a REST API, etc. It's also possible to change the chart, just by changing the data. The charts are fully styleable with CSS.