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

@slashd/alpha

v0.0.7

Published

The Slashd chart library

Downloads

5

Readme

Slashd

Slashd is a javascript library built on top of D3.js. It helps to create modern interactive dashboard.

It's powerful and easy to use. It brings automatic cross-linking between charts.

Install

With UnPkg CDN:

<script src="https://unpkg.com/@slashd/core"></script>

With SkyPack CDN:

<script type="module">
import SlashdRun from 'https://cdn.skypack.dev/@slashd/core'
// your code
</script>

With a package manager:

npm install @slashd/core

Then, include it in the browser:

<script src="node_modules/@slashd/core/dist/slashd-core.min.js"></script>

or with ES6 in a module with a bundler:

import Slashd from '@slashd/core'

How to use

How to create a chart:

new Slashd(wrapper, config, data)

Wrapper

The wrapper can be both an HTML element or a CSS selector as well, so the following are equivalent:

const chart1 = new Slashd('#chart1', config, data)
const chart2 = new Slashd(document.querySelector('#chart1'), config, data)

Config

The config is the object containing all the required configuration in order to build a chart.

Data

The data parameter is the dataset (array of objects) that will be used across all the charts.

How the cross-linking works

The cross-link capability works on top of a simple principle: every chart is a view of the same dataset. By selecting a mark, you are selecting a subset of the dataset that is sent to the other charts automatically.

Charts

Proper documentation is in progress. In the meantime, learn from the following examples on Codepen:

  • A minimal example for size-based charts (pack, tree, pie, bar) with an inline data sample
  • A minimal example for plot chart with an inline data sample

Required Encoders

Alongside type, the other required options to see something on screen are the marker encoders. They allow to convert data columns (dimensions) into visual properties in order to draw markers properly.

They can be configured and they are required according to the type. For instance, the pack requires size while the plot requires both x and y.

The library comes with the following properties:

  • size (required by pack, tree, pie, bar)
  • x (required by plot, line, map, maplot)
  • y (required by plot, line, map, maplot)

Every property can be configured with the following options:

size
{
  size:{
    key:'age', // column field
    op: 'sum', // sum|mean|min|max, default: sum
    ordinal: false,
    template: null,
      
    domain:'',
    range:''
    scale:'' // linear, ordinal, time, log
  }
}
x
{
  x:{
    key:'age', // column field
    op: 'sum', // sum|mean|min|max, default: sum
    ordinal: false,
    template: null
  }
}
y
{
  y:{
    key:'age', // column field
    op: 'sum', // sum|mean|min|max, default: sum
    ordinal: false,
    template: null
  }
}

color & opacity

{
  color:{
    key:'age', // column field
    value: '', // the colors source, multiple types of value
    template: 'index % 2 === 0 ? "red" : "blue"' // js
  }
}

Opacity

{
  opacity:{
    key:'age', // column field
    template: 0.5 // or expression
  }
}

Transformers

Transformers are data transformation functions that are meant to transform the incoming data-source to a proper structure before feeding it to the chart builder.

90% of the time you only need group transformer but further capabilities are present to solve more edge cases.

Now, a question might be relevant: Why not transforming the data before using it with the chart library? This is what almost all other chart libraries do actually.

The answer is: the whole concept of Slashd connected capability is based on one single requirement: All charts share the same original data source and each instance apply specific per-chart data transformation in order to build the visualization.

group

{
  group: 'age'
}

sort

{
  sort: 'age' // default ascending
}
{
  sort:{
    key: 'age', // column field, default: null
    dir: 'desc' // asc|desc, default: desc
  }
}

filter

You can use datum and index in the filter statement:

{
  filter: 'datum.age < 22'
}

Special calculations

Geo

If the dataset contains column containing the country value, it's possible to derive the geo location coordinates of it:

{
  geo: 'country'
}

Time

In the same way, a column with a time information can be parsed and converted properly:

{
  time: 'timestamp'
}

Components

Built-in components are common components that can be used in, almost, any chart types. They can be enabled and configured. Some chart types override some of component' properties for obvious reasons (i.e. axis don't make sense in Pie chart).

  • title
  • labels
  • ax (x axis)
  • ay (y axis)
  • tooltip
  • toolbar
  • legend
  • regression

Cross communication

Contribute

Clone the repo and install the dependencies:

npm i

Start the watcher

npm start