@chartts/csv 0.1.3 → 0.1.4
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 +70 -0
- package/package.json +5 -4
package/README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://www.npmjs.com/package/@chartts/csv"><img src="https://img.shields.io/npm/v/@chartts/csv?color=06B6D4&label=npm" alt="npm version" /></a>
|
|
3
|
+
<a href="https://github.com/chartts/chartts/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-06B6D4" alt="MIT License" /></a>
|
|
4
|
+
<a href="https://chartts.com"><img src="https://img.shields.io/badge/docs-chartts.com-06B6D4" alt="Documentation" /></a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
# @chartts/csv
|
|
8
|
+
|
|
9
|
+
CSV/TSV adapter for Chartts. Parse and export chart data as CSV.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @chartts/csv @chartts/core
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Zero dependencies.
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { fromCSV, toCSV } from "@chartts/csv"
|
|
23
|
+
|
|
24
|
+
// CSV string -> ChartData
|
|
25
|
+
const data = fromCSV(`
|
|
26
|
+
Month,Sales,Costs
|
|
27
|
+
Jan,4200,3100
|
|
28
|
+
Feb,5800,3900
|
|
29
|
+
Mar,7100,4200
|
|
30
|
+
`)
|
|
31
|
+
|
|
32
|
+
chart.update(data)
|
|
33
|
+
|
|
34
|
+
// ChartData -> CSV string
|
|
35
|
+
const csv = toCSV(chart.data)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## API
|
|
39
|
+
|
|
40
|
+
### `fromCSV(text, options?)`
|
|
41
|
+
|
|
42
|
+
Parses a CSV or TSV string into `ChartData`.
|
|
43
|
+
|
|
44
|
+
| Option | Type | Default | Description |
|
|
45
|
+
|--------|------|---------|-------------|
|
|
46
|
+
| `delimiter` | `string` | auto-detect | Column delimiter (`,` or `\t`) |
|
|
47
|
+
| `headers` | `boolean` | `true` | First row contains column names |
|
|
48
|
+
| `labelColumn` | `number \| string` | first non-numeric | Column to use as labels |
|
|
49
|
+
| `seriesColumns` | `(number \| string)[]` | all numeric | Columns to use as series |
|
|
50
|
+
|
|
51
|
+
### `toCSV(data, options?)`
|
|
52
|
+
|
|
53
|
+
Converts `ChartData` to a CSV string.
|
|
54
|
+
|
|
55
|
+
| Option | Type | Default | Description |
|
|
56
|
+
|--------|------|---------|-------------|
|
|
57
|
+
| `delimiter` | `string` | `,` | Column delimiter |
|
|
58
|
+
| `headers` | `boolean` | `true` | Include header row |
|
|
59
|
+
|
|
60
|
+
## Part of Chartts
|
|
61
|
+
|
|
62
|
+
Beautiful charts. Tiny bundle. Every framework.
|
|
63
|
+
|
|
64
|
+
- [Documentation](https://chartts.com/docs)
|
|
65
|
+
- [GitHub](https://github.com/chartts/chartts)
|
|
66
|
+
- [All packages](https://www.npmjs.com/org/chartts)
|
|
67
|
+
|
|
68
|
+
## License
|
|
69
|
+
|
|
70
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chartts/csv",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "CSV/TSV
|
|
3
|
+
"version": "0.1.4",
|
|
4
|
+
"description": "CSV/TSV adapter for Chartts. Parse and export chart data as CSV.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -14,11 +14,12 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"files": [
|
|
17
|
-
"dist"
|
|
17
|
+
"dist",
|
|
18
|
+
"README.md"
|
|
18
19
|
],
|
|
19
20
|
"sideEffects": false,
|
|
20
21
|
"peerDependencies": {
|
|
21
|
-
"@chartts/core": "0.1.
|
|
22
|
+
"@chartts/core": "0.1.4"
|
|
22
23
|
},
|
|
23
24
|
"license": "MIT",
|
|
24
25
|
"repository": {
|