go-chart
go-chart copied to clipboard
Spark lines
Spark lines are the first item featured in the Readme, but there isn't a shortcut for building them. Just wanted to point this out since they do seem handy enough that they might merit a quick example. Thanks for creating this library!
Hey @carbocation, you probably found the answer already. But I had the same question and came across this issue.
In case if somebody else is having the same question — the answer is pretty simple because the only code example in readme IS the sparkline. Sparkline is the line chart.
import (
...
"bytes"
...
"github.com/wcharczuk/go-chart" //exposes "chart"
)
graph := chart.Chart{
Series: []chart.Series{
chart.ContinuousSeries{
XValues: []float64{1.0, 2.0, 3.0, 4.0},
YValues: []float64{1.0, 2.0, 3.0, 4.0},
},
},
}
buffer := bytes.NewBuffer([]byte{})
err := graph.Render(chart.PNG, buffer)
Will generate this:
That obviously doesn't look like sparkline you expect, but here's what exactly the same code will do with real data: