https://github.com/xo/echartsgoja
Go package to render Apache ECharts as SVG
https://github.com/xo/echartsgoja
apache-echarts charts echarts go goja golang svg visualization
Last synced: 11 months ago
JSON representation
Go package to render Apache ECharts as SVG
- Host: GitHub
- URL: https://github.com/xo/echartsgoja
- Owner: xo
- License: mit
- Created: 2024-01-20T03:33:58.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-06-09T23:10:47.000Z (over 1 year ago)
- Last Synced: 2025-01-08T08:42:51.679Z (about 1 year ago)
- Topics: apache-echarts, charts, echarts, go, goja, golang, svg, visualization
- Language: Go
- Homepage:
- Size: 2.67 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# echartsgoja
`echartsgoja` renders [Apache ECharts][echarts-examples] as SVGs using the
[`goja`][goja] JavaScript runtime. Developed for use by [`usql`][usql] for
rendering charts.
[Overview][] | [TODO][] | [About][]
[Overview]: #overview "Overview"
[TODO]: #todo "TODO"
[About]: #about "About"
[![Unit Tests][echartsgoja-ci-status]][echartsgoja-ci]
[![Go Reference][goref-echartsgoja-status]][goref-echartsgoja]
[![Discord Discussion][discord-status]][discord]
[echartsgoja-ci]: https://github.com/xo/echartsgoja/actions/workflows/test.yml
[echartsgoja-ci-status]: https://github.com/xo/echartsgoja/actions/workflows/test.yml/badge.svg
[goref-echartsgoja]: https://pkg.go.dev/github.com/xo/echartsgoja
[goref-echartsgoja-status]: https://pkg.go.dev/badge/github.com/xo/echartsgoja.svg
[discord]: https://discord.gg/yJKEzc7prt "Discord Discussion"
[discord-status]: https://img.shields.io/discord/829150509658013727.svg?label=Discord&logo=Discord&colorB=7289da&style=flat-square "Discord Discussion"
## Overview
Install in the usual Go fashion:
```sh
$ go get github.com/xo/echartsgoja@latest
```
Then use like the following:
```go
package echartsgoja_test
import (
"context"
"log"
"os"
"github.com/xo/echartsgoja"
)
func Example() {
echarts := echartsgoja.New()
svg, err := echarts.RenderOptions(context.Background(), simpleOpts)
if err != nil {
log.Fatal(err)
}
if err := os.WriteFile("simple.svg", []byte(svg), 0o644); err != nil {
log.Fatal(err)
}
// Output:
}
const simpleOpts = `{
"xAxis": {
"type": "category",
"boundaryGap": false,
"data": ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
},
"yAxis": {
"type": "value"
},
"series": [{
"data": [820, 932, 901, 934, 1290, 1330, 1320],
"type": "line",
"areaStyle": {}
}]
}`
```
## TODO
- Rewrite as native Go
## About
`echartsgoja` was written primarily to support these projects:
- [usql][usql] - a universal command-line interface for SQL databases
Users of this package may find the [`github.com/xo/resvg`][resvg] package
helpful in rendering generated SVGs.
[echarts-examples]: https://echarts.apache.org/examples/en/index.html
[usql]: https://github.com/xo/usql
[resvg]: https://github.com/xo/resvg
[goja]: https://github.com/dop251/goja