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

clay-charts

v2.24.1

Published

Metal.js wrapper for D3 and billboard.js

Downloads

2,243

Readme

clay-charts

Metal.js wrapper for D3 and billboard.js

Setup

  1. Install NodeJS >= v0.12.0 and NPM >= v3.0.0, if you don't have it yet. You can find it here.

  2. Install local dependencies:

npm install
  1. Build the code:
npm run build

How to

Chart types:

clay-charts supports the following (billboard.js) charts:

  • LineChart
  • SplineChart
  • StepChart
  • AreaChart
  • AreaLineChart
  • AreaStepChart
  • BarChart
  • ScatterChart
  • PieChart
  • DonutChart
  • GaugeChart

Creating a chart

To create a chart, you will need to instantiate the type of chart you want to use, passing in the required options:

For example, to create a LineChart you could use the following code:

const lineChart = new metal.LineChart({
  columns: [
    {
      data: [30, 200, 100, 400, 150, 250],
      id: 'sample_data_1',
      name: 'Data 1',
    },
    {
      data: [50, 20, 10, 40, 15, 25],
      id: 'data2'
    },
    {
      data: [150, 90, 30, 400, 15, 205],
      id: 'data3'
    },
    {
      data: [10, 30, 130, 200, 50, 20],
      id: 'data4'
    }
  ]
});

As shown above, the only required option is to pass a columns array, which contains your datasets.

Each item in the columns array is an object which contains these fields:

{
  data: [10, 20, 30, 40, 50], // {!Array} The item's dataset
  id:   'data1',              // {!String} The item's ID (displayed in the chart's legend and tooltip)
  name: ''                    // {String} [optional] The item's name (If specified,
                              // will be displayed instead of the item's ID in the chart's legend and tooltip)
}

These options work with all supported chart types.

Please note that for DonutChart, GaugeChart and PieChart the column's items contain only one value in their data property:

const pieChart = new metal.PieChart({
  columns: [
    {
      data: [30],
      id: 'data1'
    },
    {
      data: [50],
      id: 'data2'
    },
    {
      data: [20],
      id: 'data3'
    }
  ]
});

More options

Additional options can be passed to the different chart constructors; these options will be passed to billboard.js.

For all available chart options, you might want to check billboard.js's available Options

These are the options available in clay-charts, some have slightly different names than the ones in billboard.js

+ area                      // Only for area type charts
+ axisRotated
+ axisX
+ axisY2
+ axisY
+ bar
+ color
+ colors
+ colorFormatter            // Set's billboard.js' data.color config
+ columns
+ donut                     // Only for DonutChart
+ emptyLabelText
+ gauge                     // Only for GaugeChart
+ grid
+ groups                    // Set's billboard.js' data.group config
+ hide                      // A boolean indicating if the chart should be hidden
+ intersection
+ json                      // Set's billboard.js' data.json config
+ keys                      // Set's billboard.js' data.keys config
+ labels                    // Set's billboard.js' data.labels config
+ legend                    // Set's billboard.js' data.labels config
+ line                      // Only for Line type charts
+ mimeType                  // Set's billboard.js' data.mimeType config
+ order                     // Set's billboard.js' data.order config
+ padding
+ pie                       // Only for PieChart
+ point
+ regions
+ resizeAuto
+ rows                       // Set's billboard.js' data.rows config
+ selection                  // Set's billboard.js' data.selection config
+ size                       // Set's the chart's size
+ splineInterpolationType    // For Spline type charts
+ subchart
+ svgClassName               // Set's the `svg` element's css class name
+ title
+ tooltip
+ transitionDuration
+ url
+ x                          // Set's billboard.js' data.x config
+ xFormat                    // Set's billboard.js' data.xFormat config
+ xLocaltime                 // Set's billboard.js' data.xLocaltime config
+ xSort                      // Set's billboard.js' data.xLocaltime config
+ zoom

All these options are commented and visible in ChartBase.js.

Contribute

We'd love to get contributions from you! Please, check our Contributing Guidelines to see how you can help us improve.