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

barchart

v0.6.1

Published

make some barcharts

Downloads

106

Readme

barchart

Usage

var BarChart = require('barchart');

var bc = new BarChart({
  barColors: ['#00AB8E', '#33CCDD'],
  labelInsideColors: ['#FFF', '#333'],
  autoScale: true,
  minimum: 0,
  maximum: 100,
  container: document.getElementById('chart-container')
});

bc.data([[
    {"name": "#1", "value": 12},
    {"name": "#2", "value": 20},
    {"name": "#3", "value": 30},
    {"name": "#4", "value": 70},
    {"name": "#5", "value": 63},
    {"name": "#6", "value": 35}
  ],[
    {"name": "#1'", "value": 2},
    {"name": "#2'", "value": 10},
    {"name": "#3'", "value": 3},
    {"name": "#4'", "value": 7},
    {"name": "#5'", "value": 6},
    {"name": "#6'", "value": 3}
  ]]
);

demo

Methods

data(data)

Update the chart's data. Triggers a rendering of the chart.

render()

Renders the chart. If there is no data, you will simply get an empty <div> with the class no-data.

Config Options

Set config options when constructing chart object:

var bc = new BarChart({
  //opts
});

container

DOM element to render the chart into (default: document.body).

isAnimated

Set to false if you don't want animation (default: true).

animationDuration

Animation duration in ms (default: 400).

autoScale

Whether or not BarChart should scale to the width of the container (default: false).

minimum

The value which would be displayed at the bottom of the chart (default: computed from data).

maximum

The value which would be displayed at the top of the chart (default: computed from data).

heightScaleType

Which of d3's scale types to use (default: 'linear').

barColors

Color(s) to fill the bars with (also accepts an array for multi-dataset support) (default: generated).

barSpacing

Distance between each bar in pixels (default: 20).

chartPadding

Padding around the outer edges of the chart in pixels (default: 10).

dataValueKey

The key to use when looking up a value on an item in the data array (default: 'value').

height

Height of the chart in pixels (default: 300).

width

Width of the chart if not using autoScale (default: 700).

labelTopColors

Text color of the top labels (also accepts an array for multi-dataset support) (default: #003D4C).

labelInsideColors

Text color of the labels inside the bars (also accepts an array for multi-dataset support) (default: generated to constrast with barColors).

labelInsideKey

Should usually be the same as the dataValueKey (default: dataValueKey).

labelPadding

Padding in pixels around each label (default: 3).

labelSize

font size of the label texts in pixels (default: 16).

labelTopKey

The key to use when looking up the top label on an item in the data array (default: 'name').