Giter VIP home page Giter VIP logo

examples-nodejs-energy-chart's Introduction

examples-nodejs-energy-chart

node.js application that fetches energy data and plot them on a color bar chart in the terminal.

It gets the data from Pulse Energy Platform

Usage: node chart.js <space_id>

Example

Output after running the app as follows:

node chart.js 388

week energy

Dependencies

This app depends on these node.js modules. Use npm to install them (npm install module_name):

  • async - asynchronous control flow (waterfall)
  • cli-chart - draw ansi color bar charts in a terminal
  • cli-spinner - display spinner when interacting with server
  • dateformat - show date in a readable format
  • request - simplied http request

Below are the config params to the PEChart class:

// from command line
var space_id = process.argv.splice(2)[0];

// config params
var url = 'https://api.pulseenergy.com/pulse';
var params = {
    // for detail info, see http://developer.pulseenergy.com/
         key: '9C3B13239D75E73FDE883C934FF647A1',
    resource: 'Total',
    interval: 'Week',
    quantity: 'Energy'
};
var graph = {
     interval: params.interval,
    // these ones below are optional parameters
       normal: { color: 'blue' },
    threshold: { percent: 2, color: 'yellow' }, // ie within 2% of max
          min: { color: 'green' },
          max: { color: 'red' }
};
var config = {
       params: params,
     data_url: url + '/1/spaces/'+space_id,
   spaces_url: url + '/1/spaces.json?key='+params.key,
        graph: graph
};

var pechart = new PEChart(config);
pechart.fetchDraw(space_id);

examples-nodejs-energy-chart's People

Contributors

carlos-edtech avatar developertogo avatar

Stargazers

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