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

@terminus/ui-chart

v2.0.0

Published

<h1>Chart</h1>

Downloads

5

Readme

CI/CD Status Codecov MIT License
NPM version Github release Library size

Table of Contents

Installation

Packages to be installed

  • @amcharts/amcharts4
  • @amcharts/amcharts4-geodata
  • @terminus/design-tokens
  • @terminus/fe-utilities
  • @terminus/ui-utilities
  • @terminus/ui-chart
  • date-fns

Use the ng add command to quickly install all the needed dependencies:

ng add @terminus/ui-chart

Modules that need to be in NgModule

  • TsChartModule

CSS imports

In your top level stylesheet, add these imports:

@import '~@terminus/design-tokens/css/library-design-tokens.css';
@import '~@terminus/ui-styles/terminus-ui.css';

CSS resources

Load the needed font families by adding this link to the <head> of your application:

<link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;0,500;0,700;1,400&display=swap" rel="stylesheet">

Usage

Inject the needed libraries

Note: Since the end-user of this library is the one with the actual license to use amCharts, we let the consumer pass in the library.

Create a factory function to inject the needed libraries and plugins:

import { TS_AMCHARTS_TOKEN, TsAmChartsToken } from '@terminus/ui-chart';
import * as am4core from '@amcharts/amcharts4/core';
import * as am4charts from '@amcharts/amcharts4/charts';
import * as am4maps from '@amcharts/amcharts4/maps';
import am4themes_animated from '@amcharts/amcharts4/themes/animated';
import am4themes_material from '@amcharts/amcharts4/themes/animated';

// `core` and `charts` are always required.
// `maps` is required if using any map visualizations.
export function amChartsFactory(): TsAmChartsToken {
  return {
    core: am4core,
    charts: am4charts,
    maps: am4maps,
    themes: [am4themes_animated, am4themes_material],
  };
}

@NgModule({
  ...
  providers: [
    // Use the factory function to overwrite the `TS_AMCHARTS_TOKEN` injectable:
    {
      provide: TS_AMCHARTS_TOKEN,
      useFactory: amChartsFactory,
    },
  ],
  ...

NOTE: Themes will be applied in the order they are provided.

Set up the chart

Add the component and set up access to the generated chart:

<ts-chart (chartInitialized)="setUpChart($event)"></ts-chart>
setUpChart(chart: am4charts.Chart) {
  // Add axis' and series' etc...
}

See the demo app for concrete examples of the supported chart types.

Supported chart types

  • xy
  • pie
  • map
  • radar
  • tree
  • sankey
  • chord

See TsChartVisualizationOptions for all supported types.

Chart Type Coercion

The library exposes functions for coercing to specific chart types:

  • tsChartXYTypeCheck
  • tsChartPieTypeCheck
  • tsChartMapTypeCheck
  • tsChartRadarTypeCheck
  • tsChartTreeTypeCheck
  • tsChartSankeyTypeCheck
  • tsChartChordTypeCheck

Example:

if (tsChartXYTypeCheck(chart)) {
  // Now we know we are dealing with an XY chart type
}

amCharts documentation

See https://www.amcharts.com/docs/v4/ for full documentation.

Test Helpers

Some helpers are exposed to assist with testing. These are imported from @terminus/ui-chart/testing;

[source]

| Function | |------------------------| | getChartDebugElement | | getChartInstance |

| Chart service mock | |-------------------------| | AmChartsServiceMock |