a color type that actually works.

This commit is contained in:
Will Charczuk 2016-07-09 11:23:35 -07:00
parent 0da2b41a9d
commit 1357950324
10 changed files with 181 additions and 69 deletions

View file

@ -1,10 +1,10 @@
package chart
import (
"image/color"
"sync"
"github.com/golang/freetype/truetype"
"github.com/wcharczuk/go-chart/drawing"
)
const (
@ -47,44 +47,44 @@ const (
var (
// DefaultBackgroundColor is the default chart background color.
// It is equivalent to css color:white.
DefaultBackgroundColor = color.RGBA{R: 255, G: 255, B: 255, A: 255}
DefaultBackgroundColor = drawing.Color{R: 255, G: 255, B: 255, A: 255}
// DefaultBackgroundStrokeColor is the default chart border color.
// It is equivalent to color:white.
DefaultBackgroundStrokeColor = color.RGBA{R: 255, G: 255, B: 255, A: 255}
DefaultBackgroundStrokeColor = drawing.Color{R: 255, G: 255, B: 255, A: 255}
// DefaultCanvasColor is the default chart canvas color.
// It is equivalent to css color:white.
DefaultCanvasColor = color.RGBA{R: 255, G: 255, B: 255, A: 255}
DefaultCanvasColor = drawing.Color{R: 255, G: 255, B: 255, A: 255}
// DefaultCanvasStrokColor is the default chart canvas stroke color.
// It is equivalent to css color:white.
DefaultCanvasStrokColor = color.RGBA{R: 255, G: 255, B: 255, A: 255}
DefaultCanvasStrokColor = drawing.Color{R: 255, G: 255, B: 255, A: 255}
// DefaultTextColor is the default chart text color.
// It is equivalent to #333333.
DefaultTextColor = color.RGBA{R: 51, G: 51, B: 51, A: 255}
DefaultTextColor = drawing.Color{R: 51, G: 51, B: 51, A: 255}
// DefaultAxisColor is the default chart axis line color.
// It is equivalent to #333333.
DefaultAxisColor = color.RGBA{R: 51, G: 51, B: 51, A: 255}
DefaultAxisColor = drawing.Color{R: 51, G: 51, B: 51, A: 255}
// DefaultStrokeColor is the default chart border color.
// It is equivalent to #efefef.
DefaultStrokeColor = color.RGBA{R: 239, G: 239, B: 239, A: 255}
DefaultStrokeColor = drawing.Color{R: 239, G: 239, B: 239, A: 255}
// DefaultFillColor is the default fill color.
// It is equivalent to #0074d9.
DefaultFillColor = color.RGBA{R: 0, G: 217, B: 116, A: 255}
DefaultFillColor = drawing.Color{R: 0, G: 217, B: 116, A: 255}
// DefaultFinalLabelBackgroundColor is the default final label background color.
DefaultFinalLabelBackgroundColor = color.RGBA{R: 255, G: 255, B: 255, A: 255}
DefaultFinalLabelBackgroundColor = drawing.Color{R: 255, G: 255, B: 255, A: 255}
)
var (
// DefaultSeriesStrokeColors are a couple default series colors.
DefaultSeriesStrokeColors = []color.RGBA{
color.RGBA{R: 0, G: 116, B: 217, A: 255},
color.RGBA{R: 0, G: 217, B: 116, A: 255},
color.RGBA{R: 217, G: 0, B: 116, A: 255},
DefaultSeriesStrokeColors = []drawing.Color{
drawing.Color{R: 0, G: 116, B: 217, A: 255},
drawing.Color{R: 0, G: 217, B: 116, A: 255},
drawing.Color{R: 217, G: 0, B: 116, A: 255},
}
)
// GetDefaultSeriesStrokeColor returns a color from the default list by index.
// NOTE: the index will wrap around (using a modulo).g
func GetDefaultSeriesStrokeColor(index int) color.RGBA {
func GetDefaultSeriesStrokeColor(index int) drawing.Color {
finalIndex := index % len(DefaultSeriesStrokeColors)
return DefaultSeriesStrokeColors[finalIndex]
}