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

@redsift/d3-rs-squares

v0.8.0

Published

Generates a co-occurrence matrix or a calendar chart using D3v4.

Downloads

7

Readme

d3-rs-squares

d3-rs-squares easily generate either a co-occurrence matrix or a calendar chart.

Builds

Circle CI npm MIT

Example

View @redsift/d3-rs-squares on Codepen

Matrix chart

Sample occurrence chart

Co occurrence chart

Sample occurrence chart

Calendar chart

Sample calendar chart

Usage

Browser

<script src="//static.redsift.io/reusable/d3-rs-squares/latest/d3-rs-squares.umd-es2015.min.js"></script>
<script>
	// for cooccurence view
	var squares = d3_rs_squares.html();
	...
	//or for calendar view
	var calendar = d3_rs_squares.html().type('calendar').lastWeeks(12);
</script>

ES6

import { chart } from "@redsift/d3-rs-squares";
let eml = chart.html();
...

Require

var chart = require("@redsift/d3-rs-squares");
var eml = chart.html();
...

Data layout

Both displays expect an Array with JSON objects.

var data = [{}, {}, ...];

Between the two types the layout of the object varies:

For the calendar view the expected JSON object should be:

{
	d: 1462057200000, // epoch timestamp in milliseconds 
	v: 10
}

For the co-occurrence matrix the expected JSON object should be:

{
	x: 'key1', 
	y: 'key2',
	z: 10 // number or object. To access object properties use zfield
}

Parameters

|Name|Used In|Description|Transition|Preview |----|--------|----------|----------|-------| |classed|* |SVG custom class|N| | |width, height|* | Integer Resize the chart height and width.|Y|Preview of width and heightExamples: Bricks / CodePen |size|* | Integer SVG container sizes|Y|Preview of sizeExamples: Bricks / CodePen |scale|* | Integer SVG container sizes|Y|Preview of scaleExamples: Bricks / CodePen |style|* | String Custom CSS to inject into chart|N| | |color|* | String, Array Color palette for the data. Available options from d3-rs-theme e.g. 'blue','green','aqua',... | Y| Preview of Color Examples: Bricks / CodePen |theme|* | String 'light' (default) or 'dark' as described in d3-rs-theme | | Preview of Theme Examples: Bricks / CodePen |inset|* | Integer, Object Provide additional margin for axis with long keys. Expected object structure {top: 0, bottom:10, left:10, right:0}| | Preview of InsetExamples: Bricks / CodePen |zfield| matrix.* |String When z field is an object this parameter gives you the ability to use the value under a different key e.g. for {x:'',y:'',z:{prop1:''}} to use the value of the prop1 key pass the name of the key 'prop1' to the parameter| | Example: CodePen |cellSize|* | Integer Get or override calculated size of cells | | Example: CodePen |type| |'calendar.days', 'calendar.hours', 'matrix.cooc', 'matrix'(default)| | Preview of typeExamples: Calendar Bricks / Matrix Bricks / Matrix CodePen / Calendar CodePen |minDate| 'calendar.days' | Timestamp Override the earliest day of the dataset | Y| Preview of minDate Examples: Bricks / CodePen |maxDate| 'calendar.days' | Timestamp Override the latest day of the dataset | Y | Preview of minDate Examples: Bricks / CodePen |nice | 'calendar.days' | Boolean (deault: yes) Extend range of calendar to display whole months | N | Example: CodePen |monthSeparation | 'calendar.days'| Boolean (deault: yes) Add extra space between months| N | Preview of monthSeparationExamples: Bricks / CodePen
|starting| calendar.* | String First day of the week. Default is 'timeSunday' Available options: ('timeMonday', 'timeTuesday', ...) or the utc counterparts: ('utcMonday', 'utcTuesday', ...) based on the d3-time package| | Preview of StartingExamples: Bricks / CodePen |rangeIndex, rangeValue| matrix | String, Function, Array ranges from d3-time#ranges (Milliseconds not supported) Custom ranges need to follow the d3-time#range paradigm. If an array is supplied first expected element is the range function and second a cardinality override of the range unit e.g. [d3.timeYear, 2] for a range of 2 years | | Preview of Index & Value RangeExamples: Bricks / CodePen |intervalIndex, intervalValue| matrix | String, Array intervals from d3-time#intervals (Milliseconds not supported). For custom intervals an array is expected with the interval and range functions following the paradigm in d3-time e.g. [timeHour, timeHours] | | Preview of Index and Value intervalsExamples: Bricks / CodePen |onClick| |Function handler for a click event on the data series| |

* In the default orientation *Index and *Value apply respectively to the the x and y axis