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

rms-sparkline-bar-chart

v0.0.1

Published

Sparkline Bar Chart Web Component

Downloads

8

Readme

<rms-sparkline-bar-chart>

Description

The rms-sparkline-bar-chart web component renders a sparkline including the following elements:

  • a collection of bars, one for each point

These sparkline can be styled. See the properties section for details

Usage

See examples of applications on the Angular web application, rms-sparklines-=styleguid.

Declare the component on the Angular application

The software engineer updates the host application's packages.json to include rms-sparkline-bar-chart:

    "rms-sparkline-bar-chart": "MAJOR.minor.patch",

As part of the development process the software engineer can simply symlink the component to app, as follows:

  • navigate to the rms-sparklines-=styleguid root folder: $ cd ~/rms-sparklines-styleguide
  • link to the component: $ nmp link ~/rms-sparklines/rms-sparkline-bar-chart

To remove the symlink simply:

  • navigate to the app root folder: $ cd ~/rms-sparklines-styleguide
  • link to the component: $ nmp unlink rms-sparkline-bar-chart

Import the web component into the Angular application, app:

// ...
import 'rms-sparkline-bar-chart';
// ...

Create app component(s) to host the web components

See the rms-sparkline-bar-chart Angular component used to render a simnple sparkline, and the the rms-sparkline-bar-chart Angular component used to render a sparkline with a drop dawn shade.

In our case the component selector is app-rms-sparkline-bar-chart

Configure the Angular Component to use the Web Component:

Edit rms-sparkline-bar-chart.component.html to use the web component, including its attributes. Note that the attributes are all lowercase, even thought they are bound to Angular properties with camel cased names.

<p>
  Simple inline:
  <span>
    <rms-sparkline-inline
      [barPoints] = "barPoints"
      [className] = "className"
      [fillColor] = "fillColor"
      [height] = "height"
      [lineColor] = "lineColor"
      [lineWidth] = "lineWidth"
      [toolTip] = "toolTip"
      [width] = "width"
    >
    </rms-sparkline-inline>
  </span>
</p>

Define the Angular Component properties

Edit rms-sparkline-bar-chart.component.ts to define the propoerties bound to the Web Component attributes. Note that the Angular properties are camel cased; be awere that this can be a source of confusion!

  // The sparkline data source
  barPoints: number[] = [4, 3, 7, 8, 1, 4, 9, 2, 5, 3, 5, 9];

  // Class(es) to be added to the canvas element.
  className = '';

  // A string giving the color to fill the bars; any valid CSS color. Default is red
  fillColor = 'red';

  // A number giving the height of the sparkline box in pixels. By default, uses the height of the Canvas element.
  height = 16;

  // A string giving the color of the sparkline. Any valid CSS color.
  lineColor = 'black';

  // A number giving the stroke of the line in pixels.
  lineWidth = 1.5;

  // Whether to show values the mouse glides over the sparkline
  toolTip = false;

  // A number giving the width of the sparkline box in pixels.
  width = 64;

Add the Angular component showing the web component to the view

Edit app.component.html:

    . . .
    <app-rms-sparkline-bar-chart></app-rms-sparkline-bar-chart>
     . . .

Properties

  • className:A string of space separated classe names to be added to the canvas element. Default is no classes.
  • barPoints: An array of numbers representing the sparkline data source. Default is empty array.
  • width: A number giving the width of the sparkline box in pixels. Default is 64.
  • height: A number giving the height of the sparkline box in pixels. Default is 16.
  • linecolor: A string giving the color of the sparkline; any valid CSS color. Default is black.
  • linewidth: A number giving the stroke of the line in pixels. Default is 1.
  • fillcolor: A string giving the color to fill the bars; any valid CSS color. Default value is blue
  • tooltip: Whether to show values the mouse glides over the sparkline. Default value is false;

Methods

The web element does not offer an API. It interactions are controlled by changing its attributes.

Events Received

none

Events Emitted

none

Development

 _   _                   _____            
| | | | __ ___   _____  |  ___|   _ _ __  
| |_| |/ _` \ \ / / _ \ | |_ | | | | '_ \ 
|  _  | (_| |\ V /  __/ |  _|| |_| | | | |
|_| |_|\__,_| \_/ \___| |_|   \__,_|_| |_|