Coder Social home page Coder Social logo

stvis's Introduction

stvis

Re-usable d3 components for statistical visualizations.

This repository holds a number of reusable components for creating educational visualizations for statistics for the d3 visualization library. Each component is implemented using the general philosophy described here.

Examples can be viewed at [].

grid

Data

grid represents a set of square cells, typically used to construct a simulated spatial population. Provide data such that:

var cells = [
    {x: "23", y: "30", z: "0.22749336682146"},
    {x: "24", y: "30", z: "0.27311257527676"},
    {x: "25", y: "30", z: "0.147085050103258"},
    {x: "26", y: "30", z: "0.027998186023072"},
    {x: "27", y: "30", z: "0.299189645510937"},
    ...
    {x: "28", y: "30", z: "0.074517641137835"}
]

x refers to a column index and y refers to a row index and z refers to a population unit value. Such a configuration could be made from a csv file (see data/pop100.csv). Such a dataset might come from a simulated population from some other software. I used R, for example, but it is also possible to simply construct a JavaScript object natively.

Construction

Constructing a grid is straightforward, and mimics other d3 structures like axes, color scales, etc.

var myGrid = grid()
    .grid_width(100) // The number of cells on a side (this would be a 100x100 grid)
    .cell_width(8)   // The width of the cells in pixels
    .grid_buffer(2)  // The margin around the grid in pixels
    .between(1)      // The space between cells in pixels
    .color_scale(d3.scaleSequential() // The color scale specification for `z`
                    .domain([-0.3, 0.3])
                    .interpolator(d3.interpolateViridis))

Finally, append the data and call it on your selection.

mySelection
    .datum(cells)
    .call(myGrid)

stvis's People

Contributors

brycefrank avatar

Watchers

 avatar  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.