Skip to content

Commit 57b04b2

Browse files
committed
Initial commit
0 parents  commit 57b04b2

File tree

577 files changed

+203828
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

577 files changed

+203828
-0
lines changed

.github/workflows/test.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Test
2+
on: [push, pull_request]
3+
jobs:
4+
test:
5+
name: Test
6+
runs-on: ubuntu-latest
7+
steps:
8+
- name: Install Go
9+
uses: actions/setup-go@v4
10+
- name: Checkout code
11+
uses: actions/checkout@v3
12+
- name: Test
13+
run: |
14+
CGO_ENABLED=0 TIMEOUT=10m go test -v -timeout=2h ./...

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/*.svg
2+
3+
*-orig.svg
4+
*.png
5+
*.jpg
6+
*.txt

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015-2024 Kenneth Shaw
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# echartsgoja
2+
3+
`echartsgoja` renders [Apache ECharts][echarts-examples] as SVGs using the
4+
[`goja`][goja] JavaScript runtime. Developed for use by [`usql`][usql] for
5+
rendering charts.
6+
7+
[Overview][] | [TODO][] | [About][]
8+
9+
[Overview]: #overview "Overview"
10+
[TODO]: #todo "TODO"
11+
[About]: #about "About"
12+
13+
[![Unit Tests][echartsgoja-ci-status]][echartsgoja-ci]
14+
[![Go Reference][goref-echartsgoja-status]][goref-echartsgoja]
15+
[![Discord Discussion][discord-status]][discord]
16+
17+
[echartsgoja-ci]: https://github.com/xo/echartsgoja/actions/workflows/test.yml
18+
[echartsgoja-ci-status]: https://github.com/xo/echartsgoja/actions/workflows/test.yml/badge.svg
19+
[goref-echartsgoja]: https://pkg.go.dev/github.com/xo/echartsgoja
20+
[goref-echartsgoja-status]: https://pkg.go.dev/badge/github.com/xo/echartsgoja.svg
21+
[discord]: https://discord.gg/yJKEzc7prt "Discord Discussion"
22+
[discord-status]: https://img.shields.io/discord/829150509658013727.svg?label=Discord&logo=Discord&colorB=7289da&style=flat-square "Discord Discussion"
23+
24+
## Overview
25+
26+
Install in the usual Go fashion:
27+
28+
```sh
29+
$ go get github.com/xo/echartsgoja@latest
30+
```
31+
32+
Then use like the following:
33+
34+
```go
35+
package echartsgoja_test
36+
37+
import (
38+
"context"
39+
"log"
40+
"os"
41+
42+
"github.com/xo/echartsgoja"
43+
)
44+
45+
func Example() {
46+
echarts := echartsgoja.New()
47+
svg, err := echarts.RenderOptions(context.Background(), simpleOpts)
48+
if err != nil {
49+
log.Fatal(err)
50+
}
51+
if err := os.WriteFile("simple.svg", []byte(svg), 0o644); err != nil {
52+
log.Fatal(err)
53+
}
54+
// Output:
55+
}
56+
57+
const simpleOpts = `{
58+
"xAxis": {
59+
"type": "category",
60+
"boundaryGap": false,
61+
"data": ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
62+
},
63+
"yAxis": {
64+
"type": "value"
65+
},
66+
"series": [{
67+
"data": [820, 932, 901, 934, 1290, 1330, 1320],
68+
"type": "line",
69+
"areaStyle": {}
70+
}]
71+
}`
72+
```
73+
74+
## TODO
75+
76+
- Rewrite as native Go
77+
78+
## About
79+
80+
`echartsgoja` was written primarily to support these projects:
81+
82+
- [usql][usql] - a universal command-line interface for SQL databases
83+
84+
Users of this package may find the [`github.com/xo/resvg`][resvg] package
85+
helpful in rendering generated SVGs.
86+
87+
[echarts-examples]: https://echarts.apache.org/examples/en/index.html
88+
[usql]: https://github.com/xo/usql
89+
[resvg]: https://github.com/xo/resvg
90+
[goja]: https://github.com/dop251/goja

echarts.min.js

Lines changed: 45 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)