Coder Social home page Coder Social logo

rpasher1987 / array.visualize Goto Github PK

View Code? Open in Web Editor NEW

This project forked from altcademy/array.visualize

0.0 0.0 0.0 809 KB

Array visualizer

Home Page: https://altcademy.github.io/array.visualize/index.html

JavaScript 68.48% CSS 1.31% HTML 30.21%

array.visualize's Introduction

A practical library

Array visualize is a simple d3.js-based library with one purpose: to illustrate arrays.

It was made for the purpose of visualizing array functions for tutorials.

You can use this library for your demos, presentations and tutorials.

It is possible to set a few variables in options. However you can also use CSS and it is compatible, and usually better.

How to Use

illustrateArray(data,svg,options):ArrayVisualizer

This is the main function of the library. Creates an svg visualization based upon the data provided.

Also return an object you can use to manipulate the array visualization, much like manipulating an array itself.

Example
  var data = ['stark','lannister','targeryen'];
  var svg = d3.select('document').append('svg');
  var options = {fontsize:12}
  illustrateArray(data,svg,options)

ArrayVisualizer.push(entry)

Pushes another entry to the end of the array with an animation. If an index is provided, pushes the item to that index.

Useful for teaching someone what "push" does.

Example
  var v = illustrateArray( ['stark','lannister','targeryen'],svg)

v.push('baratheon'); v.push('tyrell',2);

ArrayVisualizer.splice(index,entry)

Removes an entry from the specified index. If a new entry is provided, puts that entry in the index.

Useful for teaching someone what "splice" does.

Example
  var v = illustrateArray( ['stark','lannister','targeryen'],svg)
  v.splice(2);
  v.splice(0,'bolton');

ArrayVisualizer.highlight(index):Highlight

Creates a highlight at the selected index. Can change colors and move.

Be sure to hold on to the reference. You can create multiple highlights and control them independently.

Good for highlighting stuff.

Example
  var v = illustrateArray( ["robb","rickon","bran"],svg)
  var highlight = v.highlight(0);
  var highlight2 = v.highlight(2);

highlight.goto(index)

Moves the highlight to the selected index, automatically resizing it.

Example
  var v = illustrateArray( ["cersei","tyrion","jaime"],svg)
  var highlight = v.highlight(0);
  highlight.goto(2);

highlight.color(color)

Changes the color of the referenced highlight.

Example
  var v = illustrateArray( ["drogon","rhaegal","viserion"],svg)
  var highlight = v.highlight(2);
  highlight.color('green');

array.visualize's People

Contributors

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