@socketsecurity/cli-with-sentry 0.14.137 → 0.14.139

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/dist/blessed/LICENSE +20 -0
  2. package/dist/blessed/lib/alias.js +519 -0
  3. package/dist/blessed/lib/blessed.js +32 -0
  4. package/dist/blessed/lib/colors.js +490 -0
  5. package/dist/blessed/lib/events.js +195 -0
  6. package/dist/blessed/lib/gpmclient.js +245 -0
  7. package/dist/blessed/lib/helpers.js +170 -0
  8. package/dist/blessed/lib/keys.js +512 -0
  9. package/dist/blessed/lib/program.js +4530 -0
  10. package/dist/blessed/lib/tput.js +3111 -0
  11. package/dist/blessed/lib/unicode.js +912 -0
  12. package/dist/blessed/lib/widget.js +60 -0
  13. package/dist/blessed/lib/widgets/ansiimage.js +173 -0
  14. package/dist/blessed/lib/widgets/bigtext.js +170 -0
  15. package/dist/blessed/lib/widgets/box.js +34 -0
  16. package/dist/blessed/lib/widgets/button.js +62 -0
  17. package/dist/blessed/lib/widgets/checkbox.js +95 -0
  18. package/dist/blessed/lib/widgets/element.js +2871 -0
  19. package/dist/blessed/lib/widgets/filemanager.js +223 -0
  20. package/dist/blessed/lib/widgets/form.js +301 -0
  21. package/dist/blessed/lib/widgets/image.js +71 -0
  22. package/dist/blessed/lib/widgets/input.js +34 -0
  23. package/dist/blessed/lib/widgets/layout.js +249 -0
  24. package/dist/blessed/lib/widgets/line.js +59 -0
  25. package/dist/blessed/lib/widgets/list.js +652 -0
  26. package/dist/blessed/lib/widgets/listbar.js +452 -0
  27. package/dist/blessed/lib/widgets/listtable.js +265 -0
  28. package/dist/blessed/lib/widgets/loading.js +88 -0
  29. package/dist/blessed/lib/widgets/log.js +82 -0
  30. package/dist/blessed/lib/widgets/message.js +145 -0
  31. package/dist/blessed/lib/widgets/node.js +314 -0
  32. package/dist/blessed/lib/widgets/overlayimage.js +794 -0
  33. package/dist/blessed/lib/widgets/progressbar.js +166 -0
  34. package/dist/blessed/lib/widgets/prompt.js +127 -0
  35. package/dist/blessed/lib/widgets/question.js +129 -0
  36. package/dist/blessed/lib/widgets/radiobutton.js +62 -0
  37. package/dist/blessed/lib/widgets/radioset.js +36 -0
  38. package/dist/blessed/lib/widgets/screen.js +2485 -0
  39. package/dist/blessed/lib/widgets/scrollablebox.js +415 -0
  40. package/dist/blessed/lib/widgets/scrollabletext.js +35 -0
  41. package/dist/blessed/lib/widgets/table.js +383 -0
  42. package/dist/blessed/lib/widgets/terminal.js +452 -0
  43. package/dist/blessed/lib/widgets/text.js +35 -0
  44. package/dist/blessed/lib/widgets/textarea.js +376 -0
  45. package/dist/blessed/lib/widgets/textbox.js +79 -0
  46. package/dist/blessed/lib/widgets/video.js +130 -0
  47. package/dist/blessed/usr/fonts/AUTHORS +1 -0
  48. package/dist/blessed/usr/fonts/LICENSE +94 -0
  49. package/dist/blessed/usr/fonts/README +340 -0
  50. package/dist/blessed/usr/fonts/ter-u14b.json +17826 -0
  51. package/dist/blessed/usr/fonts/ter-u14n.json +17826 -0
  52. package/dist/blessed/usr/linux +0 -0
  53. package/dist/blessed/usr/windows-ansi +0 -0
  54. package/dist/blessed/usr/xterm +0 -0
  55. package/dist/blessed/usr/xterm-256color +0 -0
  56. package/dist/blessed/usr/xterm.termcap +243 -0
  57. package/dist/blessed/usr/xterm.terminfo +1977 -0
  58. package/dist/blessed/vendor/tng.js +1876 -0
  59. package/dist/blessed-contrib/LICENSE.md +21 -0
  60. package/dist/blessed-contrib/lib/layout/carousel.js +82 -0
  61. package/dist/blessed-contrib/lib/layout/grid.js +46 -0
  62. package/dist/blessed-contrib/lib/server-utils.js +83 -0
  63. package/dist/blessed-contrib/lib/utils.js +73 -0
  64. package/dist/blessed-contrib/lib/widget/canvas.js +52 -0
  65. package/dist/blessed-contrib/lib/widget/charts/bar.js +99 -0
  66. package/dist/blessed-contrib/lib/widget/charts/line.js +311 -0
  67. package/dist/blessed-contrib/lib/widget/charts/stacked-bar.js +245 -0
  68. package/dist/blessed-contrib/lib/widget/donut.js +183 -0
  69. package/dist/blessed-contrib/lib/widget/gauge-list.js +111 -0
  70. package/dist/blessed-contrib/lib/widget/gauge.js +127 -0
  71. package/dist/blessed-contrib/lib/widget/lcd.js +497 -0
  72. package/dist/blessed-contrib/lib/widget/log.js +32 -0
  73. package/dist/blessed-contrib/lib/widget/map.js +97 -0
  74. package/dist/blessed-contrib/lib/widget/markdown.js +68 -0
  75. package/dist/blessed-contrib/lib/widget/picture.js +61 -0
  76. package/dist/blessed-contrib/lib/widget/sparkline.js +66 -0
  77. package/dist/blessed-contrib/lib/widget/table.js +141 -0
  78. package/dist/blessed-contrib/lib/widget/tree.js +179 -0
  79. package/dist/blessed-contrib/node_modules/ansi-regex/index.js +6 -0
  80. package/dist/blessed-contrib/node_modules/ansi-regex/license +21 -0
  81. package/dist/blessed-contrib/node_modules/ansi-regex/package.json +64 -0
  82. package/dist/blessed-contrib/node_modules/ansi-regex/readme.md +39 -0
  83. package/dist/blessed-contrib/node_modules/ansi-styles/index.js +67 -0
  84. package/dist/blessed-contrib/node_modules/ansi-styles/license +21 -0
  85. package/dist/blessed-contrib/node_modules/ansi-styles/package.json +50 -0
  86. package/dist/blessed-contrib/node_modules/ansi-styles/readme.md +86 -0
  87. package/dist/blessed-contrib/node_modules/chalk/index.js +118 -0
  88. package/dist/blessed-contrib/node_modules/chalk/license +21 -0
  89. package/dist/blessed-contrib/node_modules/chalk/package.json +70 -0
  90. package/dist/blessed-contrib/node_modules/chalk/readme.md +213 -0
  91. package/dist/blessed-contrib/node_modules/escape-string-regexp/index.js +13 -0
  92. package/dist/blessed-contrib/node_modules/escape-string-regexp/license +21 -0
  93. package/dist/blessed-contrib/node_modules/escape-string-regexp/package.json +41 -0
  94. package/dist/blessed-contrib/node_modules/escape-string-regexp/readme.md +27 -0
  95. package/dist/blessed-contrib/node_modules/strip-ansi/index.js +8 -0
  96. package/dist/blessed-contrib/node_modules/strip-ansi/license +21 -0
  97. package/dist/blessed-contrib/node_modules/strip-ansi/package.json +57 -0
  98. package/dist/blessed-contrib/node_modules/strip-ansi/readme.md +33 -0
  99. package/dist/blessed-contrib/node_modules/supports-color/index.js +52 -0
  100. package/dist/blessed-contrib/node_modules/supports-color/license +21 -0
  101. package/dist/blessed-contrib/node_modules/supports-color/package.json +49 -0
  102. package/dist/blessed-contrib/node_modules/supports-color/readme.md +36 -0
  103. package/dist/cli.js +9 -8
  104. package/dist/cli.js.map +1 -1
  105. package/dist/instrument-with-sentry.js +2 -2
  106. package/dist/instrument-with-sentry.js.map +1 -1
  107. package/dist/shadow-npm-inject.js +2 -2
  108. package/dist/shadow-npm-inject.js.map +1 -1
  109. package/package.json +4 -4
@@ -0,0 +1,311 @@
1
+ 'use strict'
2
+ const Box = require('../../../../blessed/lib/widgets/box'),
3
+ Node = require('../../../../blessed/lib/widgets/node'),
4
+ Canvas = require('../canvas'),
5
+ utils = require('../../utils.js'),
6
+ _ = require('lodash')
7
+
8
+ function Line(options) {
9
+ if (!(this instanceof Node)) {
10
+ return new Line(options)
11
+ }
12
+
13
+ options.showNthLabel = options.showNthLabel || 1
14
+ options.style = options.style || {}
15
+ options.style.line = options.style.line || 'yellow'
16
+ options.style.text = options.style.text || 'green'
17
+ options.style.baseline = options.style.baseline || 'black'
18
+ options.xLabelPadding = options.xLabelPadding || 5
19
+ options.xPadding = options.xPadding || 10
20
+ options.numYLabels = options.numYLabels || 5
21
+ options.legend = options.legend || {}
22
+ options.wholeNumbersOnly = options.wholeNumbersOnly || false
23
+ options.minY = options.minY || 0
24
+
25
+ Canvas.call(this, options)
26
+ }
27
+
28
+ Line.prototype = Object.create(Canvas.prototype)
29
+
30
+ Line.prototype.calcSize = function () {
31
+ this.canvasSize = { width: this.width * 2 - 12, height: this.height * 4 - 8 }
32
+ }
33
+
34
+ Line.prototype.type = 'line'
35
+
36
+ Line.prototype.setData = function (data) {
37
+ if (!this.ctx) {
38
+ throw 'error: canvas context does not exist. setData() for line charts must be called after the chart has been added to the screen via screen.append()'
39
+ }
40
+
41
+ //compatability with older api
42
+ if (!Array.isArray(data)) {
43
+ data = [data]
44
+ }
45
+
46
+ const self = this
47
+ let xLabelPadding = this.options.xLabelPadding
48
+ const yLabelPadding = 3
49
+ let xPadding = this.options.xPadding
50
+ const yPadding = 11
51
+ const c = this.ctx
52
+ const labels = data[0].x
53
+
54
+ function addLegend() {
55
+ if (!self.options.showLegend) {
56
+ return
57
+ }
58
+ if (self.legend) {
59
+ self.remove(self.legend)
60
+ }
61
+ const legendWidth = self.options.legend.width || 15
62
+ self.legend = new Box({
63
+ height: data.length + 2,
64
+ top: 1,
65
+ width: legendWidth,
66
+ left: self.width - legendWidth - 3,
67
+ content: '',
68
+ fg: 'green',
69
+ tags: true,
70
+ border: {
71
+ type: 'line',
72
+ fg: 'black'
73
+ },
74
+ style: {
75
+ fg: 'blue'
76
+ },
77
+ screen: self.screen
78
+ })
79
+
80
+ let legandText = ''
81
+ const maxChars = legendWidth - 2
82
+ for (let i = 0; i < data.length; i++) {
83
+ const style = data[i].style || {}
84
+ const color = utils.getColorCode(style.line || self.options.style.line)
85
+ legandText +=
86
+ '{' +
87
+ color +
88
+ '-fg}' +
89
+ data[i].title.substring(0, maxChars) +
90
+ '{/' +
91
+ color +
92
+ '-fg}\r\n'
93
+ }
94
+ self.legend.setContent(legandText)
95
+ self.append(self.legend)
96
+ }
97
+
98
+ //iteratee for lodash _.max
99
+ function getMaxY() {
100
+ if (self.options.maxY) {
101
+ return self.options.maxY
102
+ }
103
+
104
+ let max = -Infinity
105
+
106
+ for (let i = 0; i < data.length; i++) {
107
+ if (data[i].y.length) {
108
+ const current = _.max(data[i].y, parseFloat)
109
+ if (current > max) {
110
+ max = current
111
+ }
112
+ }
113
+ }
114
+
115
+ return max + (max - self.options.minY) * 0.2
116
+ }
117
+
118
+ function formatYLabel(
119
+ value,
120
+ max,
121
+ min,
122
+ numLabels,
123
+ wholeNumbersOnly,
124
+ abbreviate
125
+ ) {
126
+ const fixed =
127
+ (max - min) / numLabels < 1 && value != 0 && !wholeNumbersOnly ? 2 : 0
128
+ const res = value.toFixed(fixed)
129
+ return abbreviate ? utils.abbreviateNumber(res) : res
130
+ }
131
+
132
+ function getMaxXLabelPadding(numLabels, wholeNumbersOnly, abbreviate, min) {
133
+ const max = getMaxY()
134
+
135
+ return (
136
+ formatYLabel(max, max, min, numLabels, wholeNumbersOnly, abbreviate)
137
+ .length * 2
138
+ )
139
+ }
140
+
141
+ const maxPadding = getMaxXLabelPadding(
142
+ this.options.numYLabels,
143
+ this.options.wholeNumbersOnly,
144
+ this.options.abbreviate,
145
+ this.options.minY
146
+ )
147
+ if (xLabelPadding < maxPadding) {
148
+ xLabelPadding = maxPadding
149
+ }
150
+
151
+ if (xPadding - xLabelPadding < 0) {
152
+ xPadding = xLabelPadding
153
+ }
154
+
155
+ function getMaxX() {
156
+ let maxLength = 0
157
+
158
+ for (let i = 0; i < labels.length; i++) {
159
+ if (labels[i] === undefined) {
160
+ // console.log("label[" + i + "] is undefined");
161
+ } else if (labels[i].length > maxLength) {
162
+ maxLength = labels[i].length
163
+ }
164
+ }
165
+
166
+ return maxLength
167
+ }
168
+
169
+ function getXPixel(val) {
170
+ return (
171
+ ((self.canvasSize.width - xPadding) / labels.length) * val +
172
+ xPadding * 1.0 +
173
+ 2
174
+ )
175
+ }
176
+
177
+ function getYPixel(val, minY) {
178
+ let res =
179
+ self.canvasSize.height -
180
+ yPadding -
181
+ ((self.canvasSize.height - yPadding) / (getMaxY() - minY)) * (val - minY)
182
+ res -= 2 //to separate the baseline and the data line to separate chars so canvas will show separate colors
183
+ return res
184
+ }
185
+
186
+ // Draw the line graph
187
+ function drawLine(values, style, minY) {
188
+ style = style || {}
189
+ const color = self.options.style.line
190
+ c.strokeStyle = style.line || color
191
+
192
+ c.moveTo(0, 0)
193
+ c.beginPath()
194
+ c.lineTo(getXPixel(0), getYPixel(values[0], minY))
195
+
196
+ for (let k = 1; k < values.length; k++) {
197
+ c.lineTo(getXPixel(k), getYPixel(values[k], minY))
198
+ }
199
+
200
+ c.stroke()
201
+ }
202
+
203
+ addLegend()
204
+
205
+ c.fillStyle = this.options.style.text
206
+
207
+ c.clearRect(0, 0, this.canvasSize.width, this.canvasSize.height)
208
+
209
+ let yLabelIncrement =
210
+ (getMaxY() - this.options.minY) / this.options.numYLabels
211
+ if (this.options.wholeNumbersOnly) {
212
+ yLabelIncrement = Math.floor(yLabelIncrement)
213
+ }
214
+ //if (getMaxY()>=10) {
215
+ // yLabelIncrement = yLabelIncrement + (10 - yLabelIncrement % 10)
216
+ //}
217
+
218
+ //yLabelIncrement = Math.max(yLabelIncrement, 1) // should not be zero
219
+
220
+ if (yLabelIncrement == 0) {
221
+ yLabelIncrement = 1
222
+ }
223
+
224
+ // Draw the Y value texts
225
+ const maxY = getMaxY()
226
+ for (let i = this.options.minY; i < maxY; i += yLabelIncrement) {
227
+ c.fillText(
228
+ formatYLabel(
229
+ i,
230
+ maxY,
231
+ this.options.minY,
232
+ this.options.numYLabels,
233
+ this.options.wholeNumbersOnly,
234
+ this.options.abbreviate
235
+ ),
236
+ xPadding - xLabelPadding,
237
+ getYPixel(i, this.options.minY)
238
+ )
239
+ }
240
+
241
+ for (let h = 0; h < data.length; h++) {
242
+ drawLine(data[h].y, data[h].style, this.options.minY)
243
+ }
244
+
245
+ c.strokeStyle = this.options.style.baseline
246
+
247
+ // Draw the axises
248
+ c.beginPath()
249
+
250
+ c.lineTo(xPadding, 0)
251
+ c.lineTo(xPadding, this.canvasSize.height - yPadding)
252
+ c.lineTo(this.canvasSize.width, this.canvasSize.height - yPadding)
253
+
254
+ c.stroke()
255
+
256
+ // Draw the X value texts
257
+ const charsAvailable = (this.canvasSize.width - xPadding) / 2
258
+ const maxLabelsPossible = charsAvailable / (getMaxX() + 2)
259
+ const pointsPerMaxLabel = Math.ceil(data[0].y.length / maxLabelsPossible)
260
+ let showNthLabel = this.options.showNthLabel
261
+ if (showNthLabel < pointsPerMaxLabel) {
262
+ showNthLabel = pointsPerMaxLabel
263
+ }
264
+
265
+ for (let i = 0; i < labels.length; i += showNthLabel) {
266
+ if (getXPixel(i) + labels[i].length * 2 <= this.canvasSize.width) {
267
+ c.fillText(
268
+ labels[i],
269
+ getXPixel(i),
270
+ this.canvasSize.height - yPadding + yLabelPadding
271
+ )
272
+ }
273
+ }
274
+ }
275
+
276
+ Line.prototype.getOptionsPrototype = function () {
277
+ return {
278
+ width: 80,
279
+ height: 30,
280
+ left: 15,
281
+ top: 12,
282
+ xPadding: 5,
283
+ label: 'Title',
284
+ showLegend: true,
285
+ legend: { width: 12 },
286
+ data: [
287
+ {
288
+ title: 'us-east',
289
+ x: ['t1', 't2', 't3', 't4'],
290
+ y: [5, 1, 7, 5],
291
+ style: {
292
+ line: 'red'
293
+ }
294
+ },
295
+ {
296
+ title: 'us-west',
297
+ x: ['t1', 't2', 't3', 't4'],
298
+ y: [2, 4, 9, 8],
299
+ style: { line: 'yellow' }
300
+ },
301
+ {
302
+ title: 'eu-north-with-some-long-string',
303
+ x: ['t1', 't2', 't3', 't4'],
304
+ y: [22, 7, 12, 1],
305
+ style: { line: 'blue' }
306
+ }
307
+ ]
308
+ }
309
+ }
310
+
311
+ module.exports = Line
@@ -0,0 +1,245 @@
1
+ 'use strict'
2
+ const Box = require('../../../../blessed/lib/widgets/box'),
3
+ Node = require('../../../../blessed/lib/widgets/node'),
4
+ Canvas = require('../canvas'),
5
+ utils = require('../../utils.js')
6
+
7
+ function StackedBar(options) {
8
+ if (!(this instanceof Node)) {
9
+ return new StackedBar(options)
10
+ }
11
+
12
+ const self = this
13
+ Canvas.call(this, options, require('ansi-term'))
14
+
15
+ this.options.barWidth = this.options.barWidth || 6
16
+ this.options.barSpacing = this.options.barSpacing || 9
17
+
18
+ if (this.options.barSpacing - this.options.barWidth < 3) {
19
+ this.options.barSpacing = this.options.barWidth + 3
20
+ }
21
+
22
+ this.options.xOffset = this.options.xOffset == null ? 5 : this.options.xOffset
23
+ if (this.options.showText === false) {
24
+ this.options.showText = false
25
+ } else {
26
+ this.options.showText = true
27
+ }
28
+
29
+ this.options.legend = this.options.legend || {}
30
+ if (this.options.showLegend === false) {
31
+ this.options.showLegend = false
32
+ } else {
33
+ this.options.showLegend = true
34
+ }
35
+
36
+ this.on('attach', function () {
37
+ if (self.options.data) {
38
+ self.setData(self.options.data)
39
+ }
40
+ })
41
+ }
42
+
43
+ StackedBar.prototype = Object.create(Canvas.prototype)
44
+
45
+ StackedBar.prototype.calcSize = function () {
46
+ this.canvasSize = { width: this.width - 2, height: this.height }
47
+ }
48
+
49
+ StackedBar.prototype.getSummedBars = function (bars) {
50
+ const res = []
51
+ bars.forEach(function (stackedValues) {
52
+ const sum = stackedValues.reduce(function (a, b) {
53
+ return a + b
54
+ }, 0)
55
+ res.push(sum)
56
+ })
57
+ return res
58
+ }
59
+
60
+ StackedBar.prototype.setData = function (bars) {
61
+ if (!this.ctx) {
62
+ throw 'error: canvas context does not exist. setData() for bar charts must be called after the chart has been added to the screen via screen.append()'
63
+ }
64
+
65
+ this.clear()
66
+
67
+ const summedBars = this.getSummedBars(bars.data)
68
+ let maxBarValue = Math.max.apply(Math, summedBars)
69
+ if (this.options.maxValue) {
70
+ maxBarValue = Math.max(maxBarValue, this.options.maxValue)
71
+ }
72
+ let x = this.options.xOffset
73
+ for (let i = 0; i < bars.data.length; i++) {
74
+ this.renderBar(
75
+ x,
76
+ bars.data[i],
77
+ summedBars[i],
78
+ maxBarValue,
79
+ bars.barCategory[i]
80
+ )
81
+ x += this.options.barSpacing
82
+ }
83
+
84
+ this.addLegend(bars, x)
85
+ }
86
+
87
+ StackedBar.prototype.renderBar = function (
88
+ x,
89
+ bar,
90
+ curBarSummedValue,
91
+ maxBarValue,
92
+ category
93
+ ) {
94
+ /*
95
+ var c = this.ctx
96
+ c.strokeStyle = 'red';
97
+ c.fillRect(0,7,4,0)
98
+ c.strokeStyle = 'blue';
99
+ c.fillRect(0,4,4,1)
100
+ c.strokeStyle = 'green';
101
+ c.fillRect(5,7,4,2)
102
+ return
103
+ */
104
+ //first line is for label
105
+ const BUFFER_FROM_TOP = 2
106
+ const BUFFER_FROM_BOTTOM =
107
+ (this.options.border ? 2 : 0) + (this.options.showText ? 1 : 0)
108
+
109
+ const c = this.ctx
110
+ c.strokeStyle = 'normal'
111
+ c.fillStyle = 'white'
112
+ if (this.options.labelColor) {
113
+ c.fillStyle = this.options.labelColor
114
+ }
115
+ if (this.options.showText) {
116
+ c.fillText(category, x + 1, this.canvasSize.height - BUFFER_FROM_BOTTOM)
117
+ }
118
+
119
+ if (curBarSummedValue < 0) {
120
+ return
121
+ }
122
+ const maxBarHeight =
123
+ this.canvasSize.height - BUFFER_FROM_TOP - BUFFER_FROM_BOTTOM
124
+ const currentBarHeight = Math.round(
125
+ maxBarHeight * (curBarSummedValue / maxBarValue)
126
+ )
127
+ //start painting from bottom of bar, section by section
128
+ let y = maxBarHeight + BUFFER_FROM_TOP
129
+ let availableBarHeight = currentBarHeight
130
+ for (let i = 0; i < bar.length; i++) {
131
+ const currStackHeight = this.renderBarSection(
132
+ x,
133
+ y,
134
+ bar[i],
135
+ curBarSummedValue,
136
+ currentBarHeight,
137
+ availableBarHeight,
138
+ this.options.barBgColor[i]
139
+ )
140
+ y -= currStackHeight
141
+ availableBarHeight -= currStackHeight
142
+ }
143
+ }
144
+
145
+ StackedBar.prototype.renderBarSection = function (
146
+ x,
147
+ y,
148
+ data,
149
+ curBarSummedValue,
150
+ currentBarHeight,
151
+ availableBarHeight,
152
+ bg
153
+ ) {
154
+ const c = this.ctx
155
+
156
+ const currStackHeight =
157
+ currentBarHeight <= 0
158
+ ? 0
159
+ : Math.min(
160
+ availableBarHeight, //round() can make total stacks excceed curr bar height so we limit it
161
+ Math.round(currentBarHeight * (data / curBarSummedValue))
162
+ )
163
+ c.strokeStyle = bg
164
+
165
+ if (currStackHeight > 0) {
166
+ const calcY = y - currStackHeight
167
+ /*fillRect starts from the point bottom of start point so we compensate*/
168
+ const calcHeight = Math.max(0, currStackHeight - 1)
169
+ c.fillRect(x, calcY, this.options.barWidth, calcHeight)
170
+
171
+ c.fillStyle = 'white'
172
+ if (this.options.barFgColor) {
173
+ c.fillStyle = this.options.barFgColor
174
+ }
175
+ if (this.options.showText) {
176
+ const str = utils.abbreviateNumber(data.toString())
177
+ c.fillText(
178
+ str,
179
+ Math.floor(x + this.options.barWidth / 2 + str.length / 2),
180
+ calcY + Math.round(calcHeight / 2)
181
+ )
182
+ }
183
+ }
184
+
185
+ return currStackHeight
186
+ }
187
+
188
+ StackedBar.prototype.getOptionsPrototype = function () {
189
+ return {
190
+ barWidth: 1,
191
+ barSpacing: 1,
192
+ xOffset: 1,
193
+ maxValue: 1,
194
+ barBgColor: 's',
195
+ data: { barCategory: ['s'], stackedCategory: ['s'], data: [[1]] }
196
+ }
197
+ }
198
+
199
+ StackedBar.prototype.addLegend = function (bars, x) {
200
+ const self = this
201
+ if (!self.options.showLegend) {
202
+ return
203
+ }
204
+ if (self.legend) {
205
+ self.remove(self.legend)
206
+ }
207
+ const legendWidth = self.options.legend.width || 15
208
+ self.legend = new Box({
209
+ height: bars.stackedCategory.length + 2,
210
+ top: 1,
211
+ width: legendWidth,
212
+ left: x,
213
+ content: '',
214
+ fg: 'green',
215
+ tags: true,
216
+ border: {
217
+ type: 'line',
218
+ fg: 'black'
219
+ },
220
+ style: {
221
+ fg: 'blue'
222
+ },
223
+ screen: self.screen
224
+ })
225
+
226
+ let legandText = ''
227
+ const maxChars = legendWidth - 2
228
+ for (let i = 0; i < bars.stackedCategory.length; i++) {
229
+ const color = utils.getColorCode(self.options.barBgColor[i])
230
+ legandText +=
231
+ '{' +
232
+ color +
233
+ '-fg}' +
234
+ bars.stackedCategory[i].substring(0, maxChars) +
235
+ '{/' +
236
+ color +
237
+ '-fg}\r\n'
238
+ }
239
+ self.legend.setContent(legandText)
240
+ self.append(self.legend)
241
+ }
242
+
243
+ StackedBar.prototype.type = 'bar'
244
+
245
+ module.exports = StackedBar