+1
日增长
15,773
stars
832
forks
303
watchers
98
prs
150
issues
0
releases
README
blessed-contrib
Build dashboards (or any other application) using ascii/ansi art and javascript.
Friendly to terminals, ssh and developers. Extends blessed with custom drawille and other widgets.
You should also check WOPR: a markup for creating terminal reports, presentations and infographics.
Contributors:
Yaron Naveh (@YaronNaveh)
Chris (@xcezzz)
Miguel Valadas (@mvaladas)
Liran Tal (@lirantal)
Demo (full size):
(source code)
Running the demo
git clone https://github.com/yaronn/blessed-contrib.git
cd blessed-contrib
npm install
node ./examples/dashboard.js
Works on Linux, OS X and Windows. For Windows follow the pre requisites.
Installation (to build custom projects)
Please use the latest stable version of Node.js LTS and install blessed-contrib and its peer dependency blessed as follows:
sh
npm install blessed blessed-contrib
Usage
You can use any of the default widgets of blessed (texts, lists and etc) or the widgets added in blessed-contrib (described below). A layout is optional but useful for dashboards. The widgets in blessed-contrib follow the same usage pattern:
javascript
var blessed = require('blessed')
, contrib = require('blessed-contrib')
, screen = blessed.screen()
, line = contrib.line(
{ style:
{ line: "yellow"
, text: "green"
, baseline: "black"}
, xLabelPadding: 3
, xPadding: 5
, label: 'Title'})
, data = {
x: ['t1', 't2', 't3', 't4'],
y: [5, 1, 7, 5]
}
screen.append(line) //must append before setting data
line.setData([data])
screen.key(['escape', 'q', 'C-c'], function(ch, key) {
return process.exit(0);
});
screen.render()
See below for a complete list of widgets.
Widgets
Line Chart
Bar Chart
Stacked Bar Chart
Map
Gauge
Stacked Gauge
Donut
LCD Display
Rolling Log
Picture
Sparkline
Table
Tree
Markdown
Line Chart
javascript
var line = contrib.line(
{ style:
{ line: "yellow"
, text: "green"
, baseline: "black"}
, xLabelPadding: 3
, xPadding: 5
, showLegend: true
, wholeNumbersOnly: false //true=do not show fraction in y axis
, label: 'Title'})
var series1 = {
title: 'apples',
x: ['t1', 't2', 't3', 't4'],
y: [5, 1, 7, 5]
}
var series2 = {
title: 'oranges',
x: ['t1', 't2', 't3', 't4'],
y: [2, 1, 4, 8]
}
screen.append(line) //must append before setting data
line.setData([series1, series2])
Examples: simple line chart, multiple lines, 256 colors
Bar Chart
javascript
var bar = contrib.bar(
{ label: 'Server Utilization (%)'
, barWidth: 4
, barSpacing: 6
, xOffset: 0
, maxHeight: 9})
screen.append(bar) //must append before setting data
bar.setData(
{ titles: ['bar1', 'bar2']
, data: [5, 10]})
Stacked BTop issues
#30Add option to remove borders on grid17 comments · 2015-02-15#192[Feature request] Use kenan238/reblessed15 comments · 2020-05-15#100Feature Request: scatter plots10 comments · 2017-02-19#36Table view with details10 comments · 2015-03-29#134Negative numbers in line graph9 comments · 2018-01-22#103Typedefinitions8 comments · 2017-04-04#14Font?8 comments · 2015-01-21#111Question marks are displayed in the world map7 comments · 2017-06-04