Separation of DotColorProvider and ColorProvider Interfaces (#34)

* fully functioning Viridis

* pure functions
This commit is contained in:
Chris Redford 2017-04-17 16:21:02 -07:00 committed by Will Charczuk
parent e53554fb04
commit b3dc3fef3c
7 changed files with 18 additions and 13 deletions

View file

@ -7,9 +7,15 @@ import (
_ "net/http/pprof"
"github.com/wcharczuk/go-chart"
"github.com/wcharczuk/go-chart/drawing"
)
func drawChart(res http.ResponseWriter, req *http.Request) {
viridisByY := func(xr, yr chart.Range, x, y float64) drawing.Color {
return chart.Viridis(y, yr.GetMin(), yr.GetMax())
}
graph := chart.Chart{
Series: []chart.Series{
chart.ContinuousSeries{
@ -17,7 +23,7 @@ func drawChart(res http.ResponseWriter, req *http.Request) {
Show: true,
StrokeWidth: chart.Disabled,
DotWidth: 5,
DotColorProvider: chart.Jet,
DotColorProvider: viridisByY,
},
XValues: chart.Sequence.Random(128, 1024),
YValues: chart.Sequence.Random(128, 1024),

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Before After
Before After