blessed-contrib
Advanced tools
Comparing version
@@ -98,7 +98,6 @@ 'use strict'; | ||
function drawDonut(label, percent, radius, width, cxx, middle, color){ | ||
function drawDonut(label, percent, radius, width, cxx, middle, color, percentAltNumber){ | ||
makeRound(100, radius, width, cxx, middle, remainColor ); | ||
makeRound(percent, radius, width, cxx, middle, color); | ||
var ptext = parseFloat(percent*100).toFixed(0) + '%'; | ||
var ptext = percentAltNumber ? percentAltNumber.toFixed(0) : parseFloat(percent*100).toFixed(0) + '%'; | ||
c.fillText(ptext, cxx - Math.round(parseFloat((c.measureText(ptext).width)/2)) + 3, middle); | ||
@@ -115,5 +114,6 @@ c.fillText(label, cxx - Math.round(parseFloat((c.measureText(label).width)/2)) + 3, (middle + radius) + 5); | ||
var label = stat.label; | ||
var percentAltNumber = stat.percentAltNumber; | ||
var color = stat.color || 'green'; | ||
var cxx = left; | ||
drawDonut(label, percent, radius, width, cxx, middle, color); | ||
drawDonut(label, percent, radius, width, cxx, middle, color, percentAltNumber); | ||
} | ||
@@ -120,0 +120,0 @@ function makeDonuts(stats){ |
{ | ||
"name": "blessed-contrib", | ||
"version": "4.9.0", | ||
"version": "4.10.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -239,3 +239,19 @@ ## blessed-contrib | ||
You can also hardcode a specific numeric into the donut's core display instead of the percentage by passing an `percentAltNumber` property to the data, such as: | ||
`````javascript | ||
var donut = contrib.donut({ | ||
label: 'Test', | ||
radius: 8, | ||
arcWidth: 3, | ||
remainColor: 'black', | ||
yPadding: 2, | ||
data: [ | ||
{percentAltNumber: 50, percent: 80, label: 'web1', color: 'green'} | ||
] | ||
}); | ||
````` | ||
See an example of this in one of the donuts settings on `./examples/donut.js`. | ||
### LCD Display | ||
@@ -242,0 +258,0 @@ |
Sorry, the diff of this file is not supported yet
112133
0.53%35444
22.2%2287
0.04%604
2.72%