GithubHelp home page GithubHelp logo

scope's Introduction

Scope

Simple Realtime Charting

See examples in operation at http://simonswain.github.io/scope/

Get Scope on here or via bower install scope.

Built for modern browsers, uses HTML Canvas and has no dependencies.

Make a new chart and pass in values as they occur, or as an array of points to render. Scope takes care of the rest.

Usage

var values = new Scope({
  el: element selector (required),
  period: sampling period in ms (default 1000),
  points: how many points to record (default same as chart width),
  style: chart style, 'line' or 'bar',
  background: background color (default #111111),
  values: chart color (default #00ffff)
});
values.set(n); // Latch n on to sampler, to be charted next period.
values.set([...]); // Set array of values, trigger redraw and stop auto redraw. Use null to draw nothing on a point.
values.count(); // Add one to count of events to be charted next period.
values.count(n); // Count n events with one call.

Examples

Basics

<div class="scope sample"></div>

.scope {
    margin: 8px 0;
    width: 200px;
    height: 100px;
}

var sample = new Scope({
  el: '.values'
});

Simple value chart

var values = new Scope({
  el: '.values',
  period: 50,
  style: 'line'
});

setInterval(function(){
  var x = new Date().getTime();
  values.set(Math.round(Math.sin(x/5)*100, 2));
}, 250);

Count events per period

var counts = new Scope({
  el: '.counts',
  period: 50
});

setInterval(function(){
  var x = new Date().getTime();
  counts.count(Math.random());
}, 200);

Timeseries data from array

var timeseries = new Scope({
  el: '.timeseries',
  points: 50
});

setInterval(function(){
  var vals = [];
  for(var i = 0; i<50; i++){
    vals[i] = Math.floor(Math.random() * 10);
  }
  timeseries.set(vals);
}, 1000);

Sample values from mouse velocity

var last = false;
document.addEventListener(
  'mousemove',
  function(e){ 
    var z = e.screenX;
    if(!last){
      last = z;
    }
    samples.set(Math.abs(z - last));
    last = z;
  });

scope's People

Contributors

simonswain avatar modusoperator avatar

Stargazers

Michael Anthony avatar Zac Luzader avatar Dave Cooper avatar Dave Wongillies avatar

Watchers

James Cloos avatar Michael Anthony 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.