main.go 413 B

123456789101112131415161718192021222324252627
  1. package main
  2. import (
  3. "os"
  4. "github.com/vicanso/go-charts"
  5. )
  6. func main() {
  7. buf, err := charts.RenderEChartsToPNG(`{
  8. "title": {
  9. "text": "Line"
  10. },
  11. "xAxis": {
  12. "type": "category",
  13. "data": ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
  14. },
  15. "series": [
  16. {
  17. "data": [150, 230, 224, 218, 135, 147, 260]
  18. }
  19. ]
  20. }`)
  21. if err != nil {
  22. panic(err)
  23. }
  24. os.WriteFile("output.png", buf, 0600)
  25. }