@tuicomponents/sparkline 0.1.1 → 0.1.2
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.
- package/README.md +139 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# @tuicomponents/sparkline
|
|
2
|
+
|
|
3
|
+
Compact inline sparkline visualization using height block characters (▁▂▃▄▅▆▇)
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @tuicomponents/sparkline
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { createSparkline } from "@tuicomponents/sparkline";
|
|
17
|
+
import { createRenderContext } from "@tuicomponents/core";
|
|
18
|
+
|
|
19
|
+
const component = createSparkline();
|
|
20
|
+
const context = createRenderContext();
|
|
21
|
+
|
|
22
|
+
const result = component.render(
|
|
23
|
+
{
|
|
24
|
+
values: [4, 2, 8, 5, 9, 3, 7, 6, 1, 8],
|
|
25
|
+
},
|
|
26
|
+
context
|
|
27
|
+
);
|
|
28
|
+
console.log(result.output);
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Examples
|
|
32
|
+
|
|
33
|
+
### basic
|
|
34
|
+
|
|
35
|
+
Simple sparkline with default settings
|
|
36
|
+
|
|
37
|
+

|
|
38
|
+
|
|
39
|
+
<details>
|
|
40
|
+
<summary>Input</summary>
|
|
41
|
+
|
|
42
|
+
```json
|
|
43
|
+
{
|
|
44
|
+
"values": [4, 2, 8, 5, 9, 3, 7, 6, 1, 8]
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
</details>
|
|
49
|
+
|
|
50
|
+
### cpu-usage
|
|
51
|
+
|
|
52
|
+
CPU usage monitoring over time
|
|
53
|
+
|
|
54
|
+

|
|
55
|
+
|
|
56
|
+
<details>
|
|
57
|
+
<summary>Input</summary>
|
|
58
|
+
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"values": [45, 52, 48, 65, 72, 58, 63, 71, 68, 55, 48, 52],
|
|
62
|
+
"min": 0,
|
|
63
|
+
"max": 100
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
</details>
|
|
68
|
+
|
|
69
|
+
### with-label
|
|
70
|
+
|
|
71
|
+
Sparkline with label prefix
|
|
72
|
+
|
|
73
|
+

|
|
74
|
+
|
|
75
|
+
<details>
|
|
76
|
+
<summary>Input</summary>
|
|
77
|
+
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"values": [2.1, 2.3, 2.8, 3.2, 3.5, 3.1, 2.9, 3.4, 3.8, 4.1],
|
|
81
|
+
"label": "Memory: "
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
</details>
|
|
86
|
+
|
|
87
|
+
### stock-trend
|
|
88
|
+
|
|
89
|
+
Stock price trend
|
|
90
|
+
|
|
91
|
+

|
|
92
|
+
|
|
93
|
+
<details>
|
|
94
|
+
<summary>Input</summary>
|
|
95
|
+
|
|
96
|
+
```json
|
|
97
|
+
{
|
|
98
|
+
"values": [142, 145, 143, 148, 152, 149, 155, 158, 154, 160, 163, 159]
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
</details>
|
|
103
|
+
|
|
104
|
+
## Configuration Options
|
|
105
|
+
|
|
106
|
+
| Property | Type | Required | Default | Description |
|
|
107
|
+
| -------- | ---------- | -------- | ------- | ----------- |
|
|
108
|
+
| `values` | `number[]` | ✓ | - | - |
|
|
109
|
+
| `width` | `number` | | - | - |
|
|
110
|
+
| `min` | `number` | | - | - |
|
|
111
|
+
| `max` | `number` | | - | - |
|
|
112
|
+
| `label` | `string` | | - | - |
|
|
113
|
+
|
|
114
|
+
## Render Modes
|
|
115
|
+
|
|
116
|
+
The component supports two render modes:
|
|
117
|
+
|
|
118
|
+
- **ANSI**: Rich terminal output with colors and Unicode characters
|
|
119
|
+
- **Markdown**: Plain text suitable for AI assistants and documentation
|
|
120
|
+
|
|
121
|
+
You can specify the render mode when creating the context:
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
import { createRenderContext } from "@tuicomponents/core";
|
|
125
|
+
|
|
126
|
+
// ANSI mode (default)
|
|
127
|
+
const ansiContext = createRenderContext({ renderMode: "ansi" });
|
|
128
|
+
|
|
129
|
+
// Markdown mode
|
|
130
|
+
const mdContext = createRenderContext({ renderMode: "markdown" });
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## API
|
|
134
|
+
|
|
135
|
+
For detailed API documentation, see the [API docs](../../docs/sparkline.md).
|
|
136
|
+
|
|
137
|
+
## License
|
|
138
|
+
|
|
139
|
+
UNLICENSED
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuicomponents/sparkline",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Compact inline sparkline visualization using height blocks",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"zod": "^3.25.56",
|
|
34
34
|
"zod-to-json-schema": "^3.24.5",
|
|
35
|
-
"@tuicomponents/core": "0.1.
|
|
35
|
+
"@tuicomponents/core": "0.1.2"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/node": "^22.0.0"
|