百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
S

spark

> 编程语言
开源

Go 中的 sparkline 克隆

182 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

Go 中的 sparkline 克隆

spark

Cloning holman/spark for Go

A quick example:

go
import (
  "fmt"
  "github.com/joliv/spark"
)

boring_data := []float64{1, 2, 3, 4, 5, 6, 7, 8}

sparkline := spark.Line(boring_data)

fmt.Println(sparkline)

> "▁▂▃▄▅▆▇█"

Grab it with go get github.com/joliv/spark.

Now some more interesting examples.

Nats season batting averages at a certain point in their 2014 season:

go
avgs := []float64{.270, .272, .293, .310, .274, .239, .237, .238, .111}
spark.Line(avgs)

> "▇▇██▇▆▆▆▁"

Not too cool, but it is easy to see where the problem is in this lineup. You'll have to blame the National League's rules though, not Treinen. Anyway, have a look at average monthly highs in Phoenix:

go
temps := []float64{67, 71, 77, 85, 95, 104, 106, 105, 100, 89, 76, 66}
spark.Line(temps)

> "▁▂▃▄▆███▇▅▃▁"

Doesn't say much without knowing the min and max there (about 65° and 105°—why do people live there, again?) but you can clearly see the seasonal trend.

  • Zach Holman does a great sell too, and this is really just a port of his neat tool. There are some cool examples there.
  • @tv added a main() with arg parsing so you can use it in your terminal. You can find that here.
  • Oh, and if you really want, you can pore over the full docs at godoc.org.

Licensed under GPLv3.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Go

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言