parameterize by index.

This commit is contained in:
Will Charczuk 2017-04-19 15:27:31 -07:00
parent cee1a66a50
commit 0cbbd0887a
3 changed files with 5 additions and 5 deletions

View file

@ -12,7 +12,7 @@ import (
func drawChart(res http.ResponseWriter, req *http.Request) { func drawChart(res http.ResponseWriter, req *http.Request) {
viridisByY := func(xr, yr chart.Range, x, y float64) drawing.Color { viridisByY := func(xr, yr chart.Range, index int, x, y float64) drawing.Color {
return chart.Viridis(y, yr.GetMin(), yr.GetMax()) return chart.Viridis(y, yr.GetMin(), yr.GetMax())
} }

View file

@ -66,11 +66,11 @@ func (d draw) LineSeries(r Renderer, canvasBox Box, xrange, yrange Range, style
dotWidth := defaultDotWidth dotWidth := defaultDotWidth
if style.DotWidthProvider != nil { if style.DotWidthProvider != nil {
dotWidth = style.DotWidthProvider(xrange, yrange, vx, vy) dotWidth = style.DotWidthProvider(xrange, yrange, i, vx, vy)
} }
if style.DotColorProvider != nil { if style.DotColorProvider != nil {
dotColor := style.DotColorProvider(xrange, yrange, vx, vy) dotColor := style.DotColorProvider(xrange, yrange, i, vx, vy)
r.SetFillColor(dotColor) r.SetFillColor(dotColor)
r.SetStrokeColor(dotColor) r.SetStrokeColor(dotColor)

View file

@ -37,10 +37,10 @@ type FullBoundedValueProvider interface {
} }
// SizeProvider is a provider for integer size. // SizeProvider is a provider for integer size.
type SizeProvider func(xrange, yrange Range, x, y float64) float64 type SizeProvider func(xrange, yrange Range, index int, x, y float64) float64
// ColorProvider is a general provider for color ranges based on values. // ColorProvider is a general provider for color ranges based on values.
type ColorProvider func(v, vmin, vmax float64) drawing.Color type ColorProvider func(v, vmin, vmax float64) drawing.Color
// DotColorProvider is a provider for dot color. // DotColorProvider is a provider for dot color.
type DotColorProvider func(xrange, yrange Range, x, y float64) drawing.Color type DotColorProvider func(xrange, yrange Range, index int, x, y float64) drawing.Color