feat: support table redner

This commit is contained in:
vicanso 2022-06-25 08:21:27 +08:00
parent 2fb0ebcbf7
commit b3a3018ea2
8 changed files with 433 additions and 116 deletions

View file

@ -15,6 +15,9 @@ Screenshot of common charts, the left part is light theme, the right part is gra
<img src="./assets/go-charts.png" alt="go-charts">
</p>
<p align="center">
<img src="./assets/go-table.png" alt="go-table">
</p>
## Chart Type
These chart types are supported: `line`, `bar`, `pie`, `radar` or `funnel`.
@ -374,6 +377,71 @@ func main() {
}
```
### Table
```go
package main
import (
"github.com/vicanso/go-charts/v2"
)
func main() {
header := []string{
"Name",
"Age",
"Address",
"Tag",
"Action",
}
data := [][]string{
{
"John Brown",
"32",
"New York No. 1 Lake Park",
"nice, developer",
"Send Mail",
},
{
"Jim Green ",
"42",
"London No. 1 Lake Park",
"wow",
"Send Mail",
},
{
"Joe Black ",
"32",
"Sidney No. 1 Lake Park",
"cool, teacher",
"Send Mail",
},
}
spans := map[int]int{
0: 2,
1: 1,
// 设置第三列的span
2: 3,
3: 2,
4: 2,
}
p, err := charts.TableRender(
header,
data,
spans,
)
if err != nil {
panic(err)
}
buf, err := p.Bytes()
if err != nil {
panic(err)
}
// snip...
}
```
### ECharts Render
```go