GithubHelp home page GithubHelp logo

hgalindo / pubnub-smoothy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from stephenlb/pubnub-smoothy

0.0 2.0 0.0 1.24 MB

Smoothy.js Charts with PubNub Wrapper for Easy Use

Home Page: http://stephenlb.github.io/pubnub-smoothy/

HTML 44.27% JavaScript 55.73%

pubnub-smoothy's Introduction

PubNub Smoothy Stream Add-on

Data streamed to your screen using PubNub Data Stream Network and painted in smoothy.js canvas. Smoothie Charts: A JavaScript Charting Library for Streaming Data can receive live updates in realtime using the Smoothy Stream library add-on.

Stream Live Data to Smoothy.js Chart

Originally the need for this library was requested on StackOverflow for Creating a line chart with smoothie graphs from a PubNub Stream.

You should also check out the live PubNub Smoothy Stream Add-on Live Demo to see this in action. But don't skip the usage example below.

Usage Example - Smoothy.js Data Stream Demo

Start a smoothy stream using a PubNub Data Channel. You can receive mouse coordinates or stock prices or server cpu usage in realtime from a remote source anywhere on the internet. The following example will receive stock prices from a live data stream feed Streaming JavaScript Market Orders on PubNub DSN (Data Stream Network).

<canvas id="chart1" width="400" height="100"></canvas>

<script src="https://cdn.pubnub.com/pubnub.min.js"></script>
<script src="js/smoothy.min.js"></script>
<script src="js/smoothstream.js"></script>
<script>(function(){

    // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    // Start Smooth Stream
    // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    var stream = smoothstream({
        channel       : "pubnub-market-orders",
        subscribe_key : "sub-c-4377ab04-f100-11e3-bffd-02ee2ddab7fe",
        x             : function (message) { return new Date().getTime() },
        y             : function (message) { return message.bid_price    },
        chart         : 'chart1',
        strokeStyle   : 'rgba(185,230,199,1)',
        fillStyle     : 'rgba(222,238,191,0.7)',
        lineWidth     : 5
    });

})();</script>

Stopping a Smoothy Stream

You can also stop a stream using the .stop(); method.

stream.stop();

pubnub-smoothy's People

Contributors

stephenlb avatar

Watchers

James Cloos 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.