Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-red-contrib-chartjs

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-red-contrib-chartjs - npm Package Compare versions

Comparing version 0.3.1 to 0.4.0

13

CHANGELOG.md

@@ -17,2 +17,13 @@ ### 0.2.6: First Release

- Add Bootstrap to manage the export chart in image png or pdf format
- Add Bootstrap to manage the export chart in image png or pdf format
### 0.4.0: Second Release
**Fixes**
- Refactor the code to manage socket.io server better. Now each node is responsible to create
the socket.io server if not exist in the node-RED instance. The node save the socket.io server instance in the node-RED global context **io** variable. This new way to manage the socket-io server permit resolve two problems:
* The initial configuration of each template node will be load the first time.
* The node will be able to work with other nodes that use socket.io server too, Of course the global context **io** variable will be reserver by me.
**Enhancements**

337

chartjs/chartjs.js

@@ -16,13 +16,2 @@ var fs = require('fs');

// configure socket.io server
var io = require('socket.io')(server);
io.on('connection', function(socket){
console.log('a user connected');
socket.on('disconnect', function(){
console.log('user disconnected');
});
});
// add static folders

@@ -103,3 +92,36 @@ app.use('/', serveStatic(path.join(__dirname, "css")));

var node = this;
var conf = config;
var globalContext = node.context().global;
var io;
// configure socket.io server
if (globalContext.io)
io = globalContext.io;
else {
io = require('socket.io')(server);
globalContext.io = io;
}
io.on('connection', function(socket) {
// get topic from client conenction
var topic = socket.handshake.query.topic;
if (conf.path == topic) {
console.log('a socket connection with id: ' + socket.conn.id + ' from host: ' + socket.conn.remoteAddress + ' and topic:' + topic + ' is created at ' + new Date());
// publish chart configurations
var config = {title: conf.charttitle, xaxis: conf.xaxis, yaxis : conf.yaxis};
var red = {config: config};
var item = getPath(node.id);
io.emit(item.path, red);
socket.on('disconnect', function(){
console.log('user disconnected');
});
}
});
// load default template

@@ -128,9 +150,2 @@ var template = fs.readFileSync(__dirname + '/templates/line-chart.html', 'utf8');

// publish chart configurations
var config = {title: config.charttitle, xaxis: config.xaxis, yaxis : config.yaxis};
var red = {config: config};
var item = getPath(node.id);
io.emit(item.path, red);
// trigger on flow input

@@ -154,3 +169,36 @@ node.on('input', function(msg) {

var node = this;
var conf = config;
var globalContext = node.context().global;
var io;
// configure socket.io server
if (globalContext.io)
io = globalContext.io;
else {
io = require('socket.io')(server);
globalContext.io = io;
}
io.on('connection', function(socket){
// get topic from client connection
var topic = socket.handshake.query.topic;
if (conf.path == topic) {
console.log('a socket connection with id: ' + socket.conn.id + ' from host: ' + socket.conn.remoteAddress + ' and topic:' + topic + ' is created at ' + new Date());
// publish chart configurations
var config = {title: conf.charttitle, xaxis: conf.xaxis, yaxis : conf.yaxis};
var red = {config: config};
var item = getPath(node.id);
io.emit(item.path, red);
socket.on('disconnect', function(){
console.log('user disconnected');
});
}
});
// load default template

@@ -179,9 +227,2 @@ var template = fs.readFileSync(__dirname + '/templates/vertical-bar-chart.html', 'utf8');

// publish chart configurations
var config = {title: config.charttitle, xaxis: config.xaxis, yaxis : config.yaxis};
var red = {config: config};
var item = getPath(node.id);
io.emit(item.path, red);
// trigger on flow input

@@ -205,3 +246,36 @@ node.on('input', function(msg) {

var node = this;
var conf = config;
var globalContext = node.context().global;
var io;
// configure socket.io server
if (globalContext.io)
io = globalContext.io;
else {
io = require('socket.io')(server);
globalContext.io = io;
}
io.on('connection', function(socket){
// get topic from client connection
var topic = socket.handshake.query.topic;
if (conf.path == topic) {
console.log('a socket connection with id: ' + socket.conn.id + ' from host: ' + socket.conn.remoteAddress + ' and topic:' + topic + ' is created at ' + new Date());
// publish chart configurations
var config = {title: conf.charttitle, xaxis: conf.xaxis, yaxis : conf.yaxis};
var red = {config: config};
var item = getPath(node.id);
io.emit(item.path, red);
socket.on('disconnect', function(){
console.log('user disconnected');
});
}
});
// load default template

@@ -230,9 +304,2 @@ var template = fs.readFileSync(__dirname + '/templates/horizontal-bar-chart.html', 'utf8');

// publish chart configurations
var config = {title: config.charttitle, xaxis: config.xaxis, yaxis : config.yaxis};
var red = {config: config};
var item = getPath(node.id);
io.emit(item.path, red);
// trigger on flow input

@@ -256,3 +323,36 @@ node.on('input', function(msg) {

var node = this;
var conf = config;
var globalContext = node.context().global;
var io;
// configure socket.io server
if (globalContext.io)
io = globalContext.io;
else {
io = require('socket.io')(server);
globalContext.io = io;
}
io.on('connection', function(socket){
// get topic from client connection
var topic = socket.handshake.query.topic;
if (conf.path == topic) {
console.log('a socket connection with id: ' + socket.conn.id + ' from host: ' + socket.conn.remoteAddress + ' and topic:' + topic + ' is created at ' + new Date());
// publish chart configurations
var config = {title: conf.charttitle, xaxis: conf.xaxis, yaxis : conf.yaxis};
var red = {config: config};
var item = getPath(node.id);
io.emit(item.path, red);
socket.on('disconnect', function(){
console.log('user disconnected');
});
}
});
// load default template

@@ -281,9 +381,2 @@ var template = fs.readFileSync(__dirname + '/templates/pie-chart.html', 'utf8');

// publish chart configurations
var config = {type: config.charttype, title: config.charttitle, xaxis: config.xaxis, yaxis : config.yaxis};
var red = {config: config};
var item = getPath(node.id);
io.emit(item.path, red);
// trigger on flow input

@@ -304,6 +397,37 @@ node.on('input', function(msg) {

function chartjsDoughnut(config) {
RED.nodes.createNode(this, config);
var node = this;
var conf = config;
var globalContext = node.context().global;
var io;
// configure socket.io server
if (globalContext.io)
io = globalContext.io;
else {
io = require('socket.io')(server);
globalContext.io = io;
}
io.on('connection', function(socket) {
// get topic from client connection
var topic = socket.handshake.query.topic;
if (conf.path == topic) {
console.log('a socket connection with id: ' + socket.conn.id + ' from host: ' + socket.conn.remoteAddress + ' and topic:' + topic + ' is created at ' + new Date());
// publish chart configurations
var config = {title: conf.charttitle, xaxis: conf.xaxis, yaxis : conf.yaxis};
var red = {config: config};
var item = getPath(node.id);
io.emit(item.path, red);
socket.on('disconnect', function(){
console.log('user disconnected');
});
}
});
// load default template

@@ -332,9 +456,2 @@ var template = fs.readFileSync(__dirname + '/templates/doughnut-chart.html', 'utf8');

// publish chart configurations
var config = {type: config.charttype, title: config.charttitle, xaxis: config.xaxis, yaxis : config.yaxis};
var red = {config: config};
var item = getPath(node.id);
io.emit(item.path, red);
// trigger on flow input

@@ -355,6 +472,37 @@ node.on('input', function(msg) {

function chartjsPolar(config) {
RED.nodes.createNode(this, config);
var node = this;
var conf = config;
var globalContext = node.context().global;
var io;
// configure socket.io server
if (globalContext.io)
io = globalContext.io;
else {
io = require('socket.io')(server);
globalContext.io = io;
}
io.on('connection', function(socket){
// get topic from client connection
var topic = socket.handshake.query.topic;
if (conf.path == topic) {
console.log('a socket connection with id: ' + socket.conn.id + ' from host: ' + socket.conn.remoteAddress + ' and topic:' + topic + ' is created at ' + new Date());
// publish chart configurations
var config = {title: conf.charttitle, xaxis: conf.xaxis, yaxis : conf.yaxis};
var red = {config: config};
var item = getPath(node.id);
io.emit(item.path, red);
socket.on('disconnect', function(){
console.log('user disconnected');
});
}
});
// load default template

@@ -383,9 +531,2 @@ var template = fs.readFileSync(__dirname + '/templates/polar-chart.html', 'utf8');

// publish chart configurations
var config = {type: config.charttype, title: config.charttitle, xaxis: config.xaxis, yaxis : config.yaxis};
var red = {config: config};
var item = getPath(node.id);
io.emit(item.path, red);
// trigger on flow input

@@ -406,6 +547,37 @@ node.on('input', function(msg) {

function chartjsBubble(config) {
RED.nodes.createNode(this, config);
var node = this;
var conf = config;
var globalContext = node.context().global;
var io;
// configure socket.io server
if (globalContext.io)
io = globalContext.io;
else {
io = require('socket.io')(server);
globalContext.io = io;
}
io.on('connection', function(socket) {
// get topic from client connection
var topic = socket.handshake.query.topic;
if (conf.path == topic) {
console.log('a socket connection with id: ' + socket.conn.id + ' from host: ' + socket.conn.remoteAddress + ' and topic:' + topic + ' is created at ' + new Date());
// publish chart configurations
var config = {title: conf.charttitle, xaxis: conf.xaxis, yaxis : conf.yaxis};
var red = {config: config};
var item = getPath(node.id);
io.emit(item.path, red);
socket.on('disconnect', function(){
console.log('user disconnected');
});
}
});
// load default template

@@ -434,9 +606,2 @@ var template = fs.readFileSync(__dirname + '/templates/bubble-chart.html', 'utf8');

// publish chart configurations
var config = {type: config.charttype, title: config.charttitle, xaxis: config.xaxis, yaxis : config.yaxis};
var red = {config: config};
var item = getPath(node.id);
io.emit(item.path, red);
// trigger on flow input

@@ -460,3 +625,36 @@ node.on('input', function(msg) {

var node = this;
var conf = config;
var globalContext = node.context().global;
var io;
// configure socket.io server
if (globalContext.io)
io = globalContext.io;
else {
io = require('socket.io')(server);
globalContext.io = io;
}
io.on('connection', function(socket){
// get topic from client connection
var topic = socket.handshake.query.topic;
if (conf.path == topic) {
console.log('a socket connection with id: ' + socket.conn.id + ' from host: ' + socket.conn.remoteAddress + ' and topic:' + topic + ' is created at ' + new Date());
// publish chart configurations
var config = {title: conf.charttitle, xaxis: conf.xaxis, yaxis : conf.yaxis};
var red = {config: config};
var item = getPath(node.id);
io.emit(item.path, red);
socket.on('disconnect', function(){
console.log('user disconnected');
});
}
});
// load default template: line.chart

@@ -485,9 +683,2 @@ var template = fs.readFileSync(__dirname + '/templates/radar-chart.html', 'utf8');

// publish chart configurations
var config = {title: config.charttitle, xaxis: config.xaxis, yaxis : config.yaxis};
var red = {config: config};
var item = getPath(node.id);
io.emit(item.path, red);
// trigger on flow input

@@ -494,0 +685,0 @@ node.on('input', function(msg) {

@@ -19,3 +19,4 @@ document.addEventListener("DOMContentLoaded", function(event) {

var socket = io();
// connect to socket.io server
var socket = io.connect(window.location.origin, {query:'topic=' + topic});

@@ -22,0 +23,0 @@ socket.on(topic, function(red){

@@ -19,3 +19,4 @@ document.addEventListener("DOMContentLoaded", function(event) {

var socket = io();
// connect to socket.io server
var socket = io.connect(window.location.origin, {query:'topic=' + topic});

@@ -22,0 +23,0 @@ socket.on(topic, function(red){

@@ -19,4 +19,5 @@ document.addEventListener("DOMContentLoaded", function(event) {

var socket = io();
// connect to socket.io server
var socket = io.connect(window.location.origin, {query:'topic=' + topic});
socket.on(topic, function(red){

@@ -23,0 +24,0 @@ console.log(red);

@@ -19,3 +19,4 @@ document.addEventListener("DOMContentLoaded", function(event) {

var socket = io();
// connect to socket.io server
var socket = io.connect(window.location.origin, {query:'topic=' + topic});

@@ -22,0 +23,0 @@ socket.on(topic, function(red){

@@ -19,3 +19,4 @@ document.addEventListener("DOMContentLoaded", function(event) {

var socket = io();
// connect to socket.io server
var socket = io.connect(window.location.origin, {query:'topic=' + topic});

@@ -22,0 +23,0 @@ socket.on(topic, function(red){

@@ -19,3 +19,4 @@ document.addEventListener("DOMContentLoaded", function(event) {

var socket = io();
// connect to socket.io server
var socket = io.connect(window.location.origin, {query:'topic=' + topic});

@@ -22,0 +23,0 @@ socket.on(topic, function(red){

@@ -18,3 +18,4 @@ document.addEventListener("DOMContentLoaded", function(event) {

var socket = io();
// connect to socket.io server
var socket = io.connect(window.location.origin, {query:'topic=' + topic});

@@ -21,0 +22,0 @@ socket.on(topic, function(red){

@@ -16,7 +16,8 @@ document.addEventListener("DOMContentLoaded", function(event) {

// implement message topic event
// connect to socket.io server
var topic = window.location.pathname.replace('/', '');
var socket = io();
//var socket = io();
var socket = io.connect(window.location.origin, {query:'topic=' + topic});
socket.on(topic, function(red){

@@ -23,0 +24,0 @@ console.log(red);

{
"name": "node-red-contrib-chartjs",
"version": "0.3.1",
"version": "0.4.0",
"description": "Node-RED Chart.js node",

@@ -5,0 +5,0 @@ "scripts": {

# node-red-contrib-chartjs
Chart.js Node-RED nodes
A Node-RED node to provide charts for plotting things on. Implemented by Chart.js

@@ -4,0 +4,0 @@ ![Charts RED Dashboards](https://user-images.githubusercontent.com/1216181/52432061-cddca400-2b09-11e9-9b83-f6cdae1a75b5.png)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc