termchart 0.1.0 → 0.1.1
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.
- checksums.yaml +4 -4
- data/README.md +178 -0
- data/lib/termchart/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 66ec55314930e7c2c54652b8acac00c757c5e707ce56d407150af1dc452b089f
|
|
4
|
+
data.tar.gz: 4a70285ba3b7bf50b39cce857a54dbb05e913c070777e66e1f5247ac9a6b310a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6f48f4f24d481cde7647774a34992231bfabf8ae1839ff01967db03e428abb0c0179782ca3f7341accc36500cf15850376e736a43040c54d0636844dbb28f12a
|
|
7
|
+
data.tar.gz: 3fd672278e764531694fa78abcb71d86756c3f159077a1ebab81a423ff0c74dcfb8d4ca8e76d033349913a4c457bb9fd3418400dc140d7b0b6d2d5babe8c777c
|
data/README.md
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# Termchart - Terminal Charts with Unicode and ANSI Colors
|
|
2
|
+
|
|
3
|
+
 [](https://badge.fury.io/rb/termchart)  
|
|
4
|
+
|
|
5
|
+
<img src="img/logo.svg" align="left" width="150" alt="Termchart Logo">
|
|
6
|
+
|
|
7
|
+
Render sparklines, line charts, candlestick charts, and bar charts directly in the terminal. Pure Ruby, zero dependencies.
|
|
8
|
+
|
|
9
|
+
All chart types render to plain strings with ANSI color codes — composable with any TUI framework (rcurses, curses, or raw terminal output).
|
|
10
|
+
|
|
11
|
+
<br clear="left"/>
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- **Sparklines** — compact single-line charts using ▁▂▃▄▅▆▇█
|
|
16
|
+
- **Line charts** — high-resolution braille dot plotting (2×4 dots per cell)
|
|
17
|
+
- **Candlestick charts** — OHLC financial charts with green/red coloring
|
|
18
|
+
- **Bar charts** — horizontal and vertical with sub-cell precision
|
|
19
|
+
- **256-color and RGB** — supports integer color codes and hex strings
|
|
20
|
+
- **No dependencies** — pure Ruby, no native extensions
|
|
21
|
+
- **String output** — no direct terminal I/O, works anywhere
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
gem install termchart
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Or add to your Gemfile:
|
|
30
|
+
|
|
31
|
+
```ruby
|
|
32
|
+
gem 'termchart'
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Sparklines
|
|
36
|
+
|
|
37
|
+
Map values to 8 eighth-block characters on a single line.
|
|
38
|
+
|
|
39
|
+
```ruby
|
|
40
|
+
require 'termchart'
|
|
41
|
+
|
|
42
|
+
puts Termchart.spark([1, 3, 5, 2, 8, 4, 6])
|
|
43
|
+
# => ▁▃▅▂█▄▆
|
|
44
|
+
|
|
45
|
+
puts Termchart.spark([10, 20, 30, 25, 40], color: :green)
|
|
46
|
+
# => ▁▃▅▄█ (in green)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Supported color names: `:red`, `:green`, `:blue`, `:yellow`, `:cyan`, `:magenta`, `:white`, `:gray`, `:orange`
|
|
50
|
+
|
|
51
|
+
## Line Charts
|
|
52
|
+
|
|
53
|
+
Braille-dot line charts with Y-axis labels. Each terminal cell provides 2×4 sub-pixel resolution via Unicode braille patterns (U+2800–U+28FF).
|
|
54
|
+
|
|
55
|
+
```ruby
|
|
56
|
+
chart = Termchart::Line.new(width: 60, height: 20)
|
|
57
|
+
chart.add(prices, color: 82, label: "SPY")
|
|
58
|
+
chart.add(gold, color: 226, label: "GLD")
|
|
59
|
+
puts chart.render
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Output:
|
|
63
|
+
```
|
|
64
|
+
460┤⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠔⠊⠢⡀⠀⠀⠀⠀⠀⢀⡠⠊
|
|
65
|
+
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠔⠁⠀⠀⠀⠈⠢⡀⠀⢀⠔⠊
|
|
66
|
+
│⠀⠀⠀⠀⠀⠀⢀⡠⠤⠒⠢⡀⠀⠀⠀⣀⠔⠁⠀⠀⠀⠀⠀⠀⠀⠈⠔⠁
|
|
67
|
+
440┤⠀⠀⠀⢀⡠⠊⠁⠀⠀⠀⠀⠈⠢⡠⠊⠁
|
|
68
|
+
│⠀⠀⣀⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁
|
|
69
|
+
│⠀⡰⠁
|
|
70
|
+
420┤⡰⠁
|
|
71
|
+
━━ SPY
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Candlestick Charts
|
|
75
|
+
|
|
76
|
+
OHLC candlestick charts for financial data. Green for up candles, red for down.
|
|
77
|
+
|
|
78
|
+
```ruby
|
|
79
|
+
chart = Termchart::Candle.new(width: 60, height: 20)
|
|
80
|
+
chart.add([
|
|
81
|
+
{ o: 100, h: 105, l: 98, c: 103 },
|
|
82
|
+
{ o: 103, h: 107, l: 101, c: 99 },
|
|
83
|
+
{ o: 99, h: 104, l: 97, c: 102 },
|
|
84
|
+
{ o: 102, h: 108, l: 100, c: 106 },
|
|
85
|
+
])
|
|
86
|
+
puts chart.render
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Uses `│` for wicks and `█` for bodies. Y-axis labels on the left at 5 price levels.
|
|
90
|
+
|
|
91
|
+
## Bar Charts
|
|
92
|
+
|
|
93
|
+
Horizontal and vertical bar charts with sub-cell precision using eighth-block characters.
|
|
94
|
+
|
|
95
|
+
### Horizontal
|
|
96
|
+
|
|
97
|
+
```ruby
|
|
98
|
+
chart = Termchart::Bar.new(width: 40, orientation: :horizontal)
|
|
99
|
+
chart.add("GLD", 185.50, color: 226)
|
|
100
|
+
chart.add("SPY", 450.00, color: 82)
|
|
101
|
+
chart.add("SLV", 22.30, color: 245)
|
|
102
|
+
puts chart.render
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
GLD │███████████▏ 185.50
|
|
107
|
+
SPY │████████████████████████ 450
|
|
108
|
+
SLV │█▍ 22.30
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Vertical
|
|
112
|
+
|
|
113
|
+
```ruby
|
|
114
|
+
chart = Termchart::Bar.new(width: 30, height: 10, orientation: :vertical)
|
|
115
|
+
chart.add("Q1", 80, color: 82)
|
|
116
|
+
chart.add("Q2", 95, color: 82)
|
|
117
|
+
chart.add("Q3", 70, color: 196)
|
|
118
|
+
chart.add("Q4", 110, color: 82)
|
|
119
|
+
puts chart.render
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Colors
|
|
123
|
+
|
|
124
|
+
All chart types accept colors as:
|
|
125
|
+
|
|
126
|
+
| Format | Example | Description |
|
|
127
|
+
|--------|---------|-------------|
|
|
128
|
+
| Integer | `82` | 256-color palette index |
|
|
129
|
+
| Hex string | `"FF0000"` | RGB hex (with or without `#`) |
|
|
130
|
+
| Symbol | `:green` | Named color (sparklines only) |
|
|
131
|
+
|
|
132
|
+
## Canvas API
|
|
133
|
+
|
|
134
|
+
For custom visualizations, use the canvas classes directly.
|
|
135
|
+
|
|
136
|
+
### Canvas
|
|
137
|
+
|
|
138
|
+
Character grid where each cell holds a character, foreground color, and background color.
|
|
139
|
+
|
|
140
|
+
```ruby
|
|
141
|
+
canvas = Termchart::Canvas.new(40, 10)
|
|
142
|
+
canvas.set(5, 3, "█", fg: 196, bg: 233)
|
|
143
|
+
puts canvas.render
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### BrailleCanvas
|
|
147
|
+
|
|
148
|
+
Each cell maps to a 2×4 braille dot grid for sub-cell resolution.
|
|
149
|
+
|
|
150
|
+
```ruby
|
|
151
|
+
canvas = Termchart::BrailleCanvas.new(40, 10)
|
|
152
|
+
# Pixel space: 80×40
|
|
153
|
+
canvas.set_dot(15, 25, fg: 82)
|
|
154
|
+
puts canvas.render
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Use with rcurses
|
|
158
|
+
|
|
159
|
+
Termchart is designed to compose with [rcurses](https://github.com/isene/rcurses) panes:
|
|
160
|
+
|
|
161
|
+
```ruby
|
|
162
|
+
require 'rcurses'
|
|
163
|
+
require 'termchart'
|
|
164
|
+
|
|
165
|
+
pane = Rcurses::Pane.new(2, 2, 60, 20)
|
|
166
|
+
chart = Termchart::Line.new(width: 60, height: 20)
|
|
167
|
+
chart.add(data, color: 82, label: "Price")
|
|
168
|
+
pane.text = chart.render
|
|
169
|
+
pane.refresh
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## License
|
|
173
|
+
|
|
174
|
+
Unlicense — Public Domain
|
|
175
|
+
|
|
176
|
+
## Author
|
|
177
|
+
|
|
178
|
+
Geir Isene — https://isene.com
|
data/lib/termchart/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: termchart
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Geir Isene
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-03-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Render sparklines, line charts (braille), candlestick charts, and bar
|
|
14
14
|
charts as plain strings with ANSI color codes. Zero dependencies, pure Ruby.
|
|
@@ -17,6 +17,7 @@ executables: []
|
|
|
17
17
|
extensions: []
|
|
18
18
|
extra_rdoc_files: []
|
|
19
19
|
files:
|
|
20
|
+
- README.md
|
|
20
21
|
- lib/termchart.rb
|
|
21
22
|
- lib/termchart/bar.rb
|
|
22
23
|
- lib/termchart/candle.rb
|