# node-chart **Repository Path**: mirrors_andyperlitch/node-chart ## Basic Information - **Project Name**: node-chart - **Description**: Event-based Charting Canvas API - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-08 - **Last Updated**: 2026-11-21 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README node-chart ========== Time Series Charting Canvas API Use === var Chart = require('chart'); var chart = new Chart; var ee = require('events').EventEmitter; var datasource = new ee; chart.series(datasource); chart.to(document.getElementById('mychart')); setInterval(function() { var random = Math.floor(Math.random()*100); datasource.emit('data',{y:random}); },1000); Multiple Data sources ===================== var d1 = new ee; var d2 = new ee; chart.series(d1); chart.series(d2); // or chart.series([d1,d2]) // or chart.series(d1,d2); Multiple Y-Axises ================= To have the data you emit treated as separate y-axises with different scaling, simply pass a second object {multiple:true} in your emit datasource.emit('data',{stockPrice:235,temperature:88},{multiple:true}); chart.series ============ Event types that chart.series responds to are 'data' - provides data for timeseries and optional labels 'stop' - stops the timeseries for that datastream chart.legend ============
chart.legend(document.getElementById('legend')); Legend is automatically created with the data that is sent. To visualize and interact with a legend, use the .legend callback legend.css ========== Also in the root directory of this package is a file called legend.css that you should include. Labels go with the value ------------------------ datasorce.emit('data',{'units sold':9.2}) You can supply multiple labels ------------------------------ datasorce1.emit('data',{'units sold':9.2}) datasorce2.emit('data',{'current energy consumption':30}) Colors ====== You can set the following colors. Defaults to below. chart.color.grid = '#c9d6de'; chart.color.gridbg = '#FFF'; chart.color.gridxlabel = '#000'; chart.color.gridxline = '#000'; chart.color.gridylabel = '#000' chart.color.gridyline = '#000'; chart.color.grid.interactionline = '#000'; You can also create a preferred ordered set of colors for the lines. You must supply the lines in six digit RGB hexadecimal like so: chart.color.line = ['#FF0000','#00FF']; Any colors you do not supply will be provided for. chart.color.line = ['#FF0000',undefined,'#00FF']; // will choose '#FFFF00' for the second element automatically. Render Modes ============ You can set the render modes any time, change them at any time like so: chart.rendermode = "line"; // defaults to line, also can use "linefill", "bar" You can also set the rendermode from a specific event and it will take precedence. You can switch this at will. datasource.rendermode = "linefill"; Tests ===== // to install tap, simply npm install tap tap ./test MISC ==== Author: David Wee