Giter VIP home page Giter VIP logo

d3-spiral-heatmap's Introduction

d3-spiral-heatmap

A reusable D3 chart for creating SVG spiral heatmaps.

The chart was based on the answer given to an R Stack Overflow question.

A spiral heatmap is useful for displaying periodic datasets, and you want a continuous series without visual breaks at certain points (for example at the end and beginning of the calendar year).

Example

Spiral heatmap


Usage

Pre-requesisites

The chart uses version 4 of D3.js, which must be loaded.

The dataset must be sorted before calling the chart. The heatmap will be created from the centre of the spiral, circling outwards.

API

var chart = spiralHeatmap()

Creates a new instance of the spiral heatmap with default settings.

When the chart is called on a selection with data attached, a spiral heatmap is created within a "g" element with the class ".spiral-heatmap".

selection.datum(data).call(chart)

Each arc of the spiral is path element contained within a "g" element with the class ".arc", which can be selected and styled after it is created. For example:

g.selectAll(".arc")
    .selectAll("path")
    .style("fill", function (d) { return colour(d.value); })

chart.radius(r)

The radius (r) of the spiral chart. The radius is from the centre of the chart to the widest point of the spiral. Default is 250.

chart.holeRadiusProportion(p)

The proportion (p) of the radius which will be left as a hole in the centre of the chart. Must be between 0 and 1.

0 will mean the spiral starts at the centre of the chart, which produces pointed arcs at the centre. Default is 0.3.

chart.arcsPerCoil(s)

The number of arcs per coil of the spiral. Usually this is set to match the number of intervals in the period you are charting, eg 12 months per year, 24 hours per day, etc. Default is 12.

chart.coilPadding(p)

The proportion (0 to 1) of the coil width that will be used as padding between coils. Padding is useful if you want to highlight the spiral rather than the segments of arcs. Must be between 0 and 1. Default is 0 (no padding).

chart.arcLabel(fieldname)

The field in the data that will label each segment of arcs in the spiral. The label will have the class ".arc-label" for selection and styling. Defaults to no field (no labels).

chart.coilLabel(fieldname)

The field in the data that will label each coil. The label will have the class ".coil-label" for selection and styling. Defaults to no field (no labels).

chart.startAngle(int)

The angle, in degrees starting from the 12 o'clock position, from which the first segment will be drawn. Defaults to 0.

d3-spiral-heatmap's People

Contributors

tomshanley avatar bastitee avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.