Documentation ¶
Index ¶
- Constants
- Variables
- func ColorIsZero(c color.Color) bool
- func ColorToString(c color.Color) string
- func ColorWithAlpha(c color.RGBA, a uint8) color.Color
- func GetAlternateColor(index int) color.Color
- func GetDefaultColor(index int) color.Color
- func Jet(v, vmin, vmax float64) color.Color
- func Viridis(v, vmin, vmax float64) color.Color
- type Box
- func (b Box) AspectRatio() float64
- func (b Box) Center() (x, y int)
- func (b Box) Clone() Box
- func (b Box) Constrain(other Box) Box
- func (b Box) Corners() BoxCorners
- func (b Box) Draw(r Renderer, s Style)
- func (b Box) DrawRotated(r Renderer, thetaDegrees float64, s Style)
- func (b Box) Equals(other Box) bool
- func (b Box) Fit(other Box) Box
- func (b Box) GetBottom(defaults ...int) int
- func (b Box) GetLeft(defaults ...int) int
- func (b Box) GetRight(defaults ...int) int
- func (b Box) GetTop(defaults ...int) int
- func (b Box) Grow(other Box) Box
- func (b Box) Height() int
- func (b Box) IsBiggerThan(other Box) bool
- func (b Box) IsSmallerThan(other Box) bool
- func (b Box) IsZero() bool
- func (b Box) OuterConstrain(bounds, other Box) Box
- func (b Box) Shift(x, y int) Box
- func (b Box) String() string
- func (b Box) Width() int
- type BoxCorners
- func (bc BoxCorners) Box() Box
- func (bc BoxCorners) Center() (x, y int)
- func (bc BoxCorners) Draw(r Renderer, s Style)
- func (bc BoxCorners) Equals(other BoxCorners) bool
- func (bc BoxCorners) Height() int
- func (bc BoxCorners) Rotate(thetaDegrees float64) BoxCorners
- func (bc BoxCorners) String() string
- func (bc BoxCorners) Width() int
- type ChartRenderable
- type ColorPalette
- type ColorProvider
- type DotColorProvider
- type Font
- type Point
- type Renderable
- type Renderer
- type RendererProvider
- type SizeProvider
- type Style
- func (s Style) GetClassName(defaults ...string) string
- func (s Style) GetDotColor(defaults ...color.Color) color.Color
- func (s Style) GetDotOptions() Style
- func (s Style) GetDotWidth(defaults ...float64) float64
- func (s Style) GetFillAndStrokeOptions() Style
- func (s Style) GetFillColor(defaults ...color.Color) color.Color
- func (s Style) GetFillOptions() Style
- func (s Style) GetFont(defaults ...Font) Font
- func (s Style) GetFontColor(defaults ...color.Color) color.Color
- func (s Style) GetFontSize(defaults ...float64) float64
- func (s Style) GetPadding(defaults ...Box) Box
- func (s Style) GetStrokeColor(defaults ...color.Color) color.Color
- func (s Style) GetStrokeDashArray(defaults ...[]float64) []float64
- func (s Style) GetStrokeOptions() Style
- func (s Style) GetStrokeWidth(defaults ...float64) float64
- func (s Style) GetTextHorizontalAlign(defaults ...TextHorizontalAlign) TextHorizontalAlign
- func (s Style) GetTextLineSpacing(defaults ...int) int
- func (s Style) GetTextOptions() Style
- func (s Style) GetTextRotationDegrees(defaults ...float64) float64
- func (s Style) GetTextVerticalAlign(defaults ...TextVerticalAlign) TextVerticalAlign
- func (s Style) GetTextWrap(defaults ...TextWrap) TextWrap
- func (s Style) InheritFrom(defaults Style) (final Style)
- func (s Style) IsZero() bool
- func (s Style) ShouldDrawDot() bool
- func (s Style) ShouldDrawFill() bool
- func (s Style) ShouldDrawStroke() bool
- func (s Style) String() string
- func (s Style) WriteDrawingOptionsToRenderer(r Renderer)
- func (s Style) WriteTextOptionsToRenderer(r Renderer)
- func (s Style) WriteToRenderer(r Renderer)
- type TextHorizontalAlign
- type TextStyle
- type TextVerticalAlign
- type TextWrap
Constants ¶
const ( // DefaultStrokeWidth is the default chart stroke width. DefaultStrokeWidth = 0.0 // DefaultDotWidth is the default chart dot width. DefaultDotWidth = 0.0 // DefaultFontSize is the default font size. DefaultFontSize = 10.0 // DefaultLineSpacing is the default vertical distance between text lines. DefaultLineSpacing = 5 )
Variables ¶
var ( // ColorTransparent is a transparent (alpha zero) color. ColorTransparent = color.RGBA{R: 255, G: 255, B: 255, A: 0} // ColorWhite is white. ColorWhite = color.RGBA{R: 255, G: 255, B: 255, A: 255} // ColorBlue is the basic theme blue color. ColorBlue = color.RGBA{R: 0, G: 116, B: 217, A: 255} // ColorCyan is the basic theme cyan color. ColorCyan = color.RGBA{R: 0, G: 217, B: 210, A: 255} // ColorGreen is the basic theme green color. ColorGreen = color.RGBA{R: 0, G: 217, B: 101, A: 255} // ColorRed is the basic theme red color. ColorRed = color.RGBA{R: 217, G: 0, B: 116, A: 255} // ColorOrange is the basic theme orange color. ColorOrange = color.RGBA{R: 217, G: 101, B: 0, A: 255} // ColorYellow is the basic theme yellow color. ColorYellow = color.RGBA{R: 217, G: 210, B: 0, A: 255} // ColorBlack is the basic theme black color. ColorBlack = color.RGBA{R: 51, G: 51, B: 51, A: 255} // ColorLightGray is the basic theme light gray color. ColorLightGray = color.RGBA{R: 239, G: 239, B: 239, A: 255} // ColorAlternateBlue is a alternate theme color. ColorAlternateBlue = color.RGBA{R: 106, G: 195, B: 203, A: 255} // ColorAlternateGreen is a alternate theme color. ColorAlternateGreen = color.RGBA{R: 42, G: 190, B: 137, A: 255} // ColorAlternateGray is a alternate theme color. ColorAlternateGray = color.RGBA{R: 110, G: 128, B: 139, A: 255} // ColorAlternateYellow is a alternate theme color. ColorAlternateYellow = color.RGBA{R: 240, G: 174, B: 90, A: 255} // ColorAlternateLightGray is a alternate theme color. ColorAlternateLightGray = color.RGBA{R: 187, G: 190, B: 191, A: 255} )
var ( // DefaultTextColor is the default text color. DefaultTextColor = ColorBlack // DefaultLineColor is the default line color. DefaultLineColor = ColorBlack )
var AlternateColorPalette alternateColorPalette
AlternateColorPalette is an alternate color palatte.
var DefaultColorPalette defaultColorPalette
DefaultColorPalette is the default color palatte.
var (
// Text contains utilities for text.
Text = &text{}
)
Functions ¶
func ColorIsZero ¶
ColorIsZero returns true if the all the color components are zero.
func ColorToString ¶
ColorToString returns a string representation of the color.
func ColorWithAlpha ¶
ColorWithAlpha returns a copy of the color with a given alpha.
func GetAlternateColor ¶
GetAlternateColor returns a color from the default list by index. NOTE: the index will wrap around (using a modulo).
func GetDefaultColor ¶
GetDefaultColor returns a color from the default list by index. NOTE: the index will wrap around (using a modulo).
Types ¶
type Box ¶
Box represents the main 4 dimensions of a box.
func (Box) AspectRatio ¶
AspectRatio returns the aspect ratio of the box.
func (Box) Constrain ¶
Constrain is similar to `Fit` except that it will work more literally like the opposite of grow.
func (Box) DrawRotated ¶
DrawRotated draws the box with the provided style, rotated by the specified degrees.
func (Box) Fit ¶
Fit is functionally the inverse of grow. Fit maintains the original aspect ratio of the `other` box, but constrains it to the bounds of the target box.
func (Box) IsBiggerThan ¶
IsBiggerThan returns if a box is bigger than another box.
func (Box) IsSmallerThan ¶
IsSmallerThan returns if a box is smaller than another box.
func (Box) OuterConstrain ¶
OuterConstrain is similar to `Constraint` with the difference that it applies corrections.
type BoxCorners ¶
type BoxCorners struct {
TopLeft, TopRight, BottomRight, BottomLeft Point
}
BoxCorners is a box with independent corners.
func (BoxCorners) Center ¶
func (bc BoxCorners) Center() (x, y int)
Center returns the center of the box.
func (BoxCorners) Draw ¶
func (bc BoxCorners) Draw(r Renderer, s Style)
Draw draws the box corners using the specified style.
func (BoxCorners) Equals ¶
func (bc BoxCorners) Equals(other BoxCorners) bool
Equals returns if the box equals another box.
func (BoxCorners) Rotate ¶
func (bc BoxCorners) Rotate(thetaDegrees float64) BoxCorners
Rotate rotates the box.
func (BoxCorners) String ¶
func (bc BoxCorners) String() string
type ChartRenderable ¶
type ChartRenderable interface { Width() int SetWidth(width int) Height() int SetHeight(height int) Render(rp RendererProvider, w io.Writer) error }
ChartRenderable represents a chart renderable component.
type ColorPalette ¶
type ColorPalette interface { BackgroundColor() color.Color BackgroundStrokeColor() color.Color CanvasColor() color.Color CanvasStrokeColor() color.Color AxisStrokeColor() color.Color TextColor() color.Color GetSeriesColor(index int) color.Color }
ColorPalette is a set of colors that.
type ColorProvider ¶
ColorProvider is a general provider for color ranges based on values.
type DotColorProvider ¶
DotColorProvider is a provider for dot color.
type Point ¶
type Point struct {
X, Y int
}
Point is an X, Y pair.
func (Point) DistanceTo ¶
DistanceTo calculates the distance to another point.
type Renderable ¶
Renderable is a function that can be called to render custom elements on the chart.
type Renderer ¶
type Renderer interface { // ResetStyle resets all the style related settings of the renderer. ResetStyle() // GetDPI gets the DPI for the renderer. GetDPI() float64 // SetDPI sets the DPI for the renderer. SetDPI(dpi float64) // SetClassName sets the current class name. SetClassName(string) // SetStrokeColor sets the current stroke color. SetStrokeColor(color.Color) // SetFillColor sets the current fill color. SetFillColor(color.Color) // SetStrokeWidth sets the stroke width. SetStrokeWidth(width float64) // SetStrokeDashArray sets the stroke dash array. SetStrokeDashArray(dashArray []float64) // MoveTo moves the cursor to the specified point. MoveTo(x, y int) // LineTo draws a line to the specified point, starting from the previous one. LineTo(x, y int) // QuadCurveTo draws a quad curve. `cx` and `cy` are the Bézier control points. QuadCurveTo(cx, cy, x, y int) // ArcTo draws an arc with a given center (`cx`, `cy`), a given set of // radii (`rx`, `ry`), a `startAngle` and `deltaAngle` (in radians). ArcTo(cx, cy int, rx, ry, startAngle, delta float64) // Close finalizes a shape, closing the path. Close() // Stroke strokes the current path. Stroke() // Fill fills the current path. Fill() // FillStroke fills and strokes the current path. FillStroke() // Circle draws a circle at the given coordinates, with a given radius. Circle(radius float64, x, y int) // SetFont sets the current font. SetFont(font Font) // SetFontColor sets the current font color. SetFontColor(color.Color) // SetFontSize sets the current font size. SetFontSize(size float64) // Text draws a text chunk. Text(body string, x, y int) // MeasureText measures the specified text. MeasureText(body string) Box // SetTextRotation sets the rotation of the text. SetTextRotation(radians float64) // ClearTextRotation clears rotation of the text. ClearTextRotation() // Save saves the rendered data to the given writer. Save(w io.Writer) error }
Renderer represents a chart renderer.
type RendererProvider ¶
RendererProvider is a function that returns a renderer.
type SizeProvider ¶
SizeProvider is a provider for integer size.
type Style ¶
type Style struct { Hidden bool Padding Box ClassName string FillColor color.Color StrokeWidth float64 StrokeColor color.Color StrokeDashArray []float64 DotColor color.Color DotWidth float64 DotWidthProvider SizeProvider DotColorProvider DotColorProvider Font Font FontSize float64 FontColor color.Color TextHorizontalAlign TextHorizontalAlign TextVerticalAlign TextVerticalAlign TextWrap TextWrap TextLineSpacing int TextRotationDegrees float64 }
Style is a simple style set.
func (Style) GetClassName ¶
GetClassName returns the class name or a default.
func (Style) GetDotColor ¶
GetDotColor returns the stroke color.
func (Style) GetDotOptions ¶
GetDotOptions returns the dot components.
func (Style) GetDotWidth ¶
GetDotWidth returns the dot width for scatter plots.
func (Style) GetFillAndStrokeOptions ¶
GetFillAndStrokeOptions returns the fill and stroke components.
func (Style) GetFillColor ¶
GetFillColor returns the fill color.
func (Style) GetFillOptions ¶
GetFillOptions returns the fill components.
func (Style) GetFontColor ¶
GetFontColor gets the font size.
func (Style) GetFontSize ¶
GetFontSize gets the font size.
func (Style) GetPadding ¶
GetPadding returns the padding.
func (Style) GetStrokeColor ¶
GetStrokeColor returns the stroke color.
func (Style) GetStrokeDashArray ¶
GetStrokeDashArray returns the stroke dash array.
func (Style) GetStrokeOptions ¶
GetStrokeOptions returns the stroke components.
func (Style) GetStrokeWidth ¶
GetStrokeWidth returns the stroke width.
func (Style) GetTextHorizontalAlign ¶
func (s Style) GetTextHorizontalAlign(defaults ...TextHorizontalAlign) TextHorizontalAlign
GetTextHorizontalAlign returns the horizontal alignment.
func (Style) GetTextLineSpacing ¶
GetTextLineSpacing returns the spacing in pixels between lines of text (vertically).
func (Style) GetTextOptions ¶
GetTextOptions returns just the text components of the style.
func (Style) GetTextRotationDegrees ¶
GetTextRotationDegrees returns the text rotation in degrees.
func (Style) GetTextVerticalAlign ¶
func (s Style) GetTextVerticalAlign(defaults ...TextVerticalAlign) TextVerticalAlign
GetTextVerticalAlign returns the vertical alignment.
func (Style) GetTextWrap ¶
GetTextWrap returns the word wrap.
func (Style) InheritFrom ¶
InheritFrom coalesces two styles into a new style.
func (Style) ShouldDrawDot ¶
ShouldDrawDot tells drawing functions if they should draw the dot.
func (Style) ShouldDrawFill ¶
ShouldDrawFill tells drawing functions if they should draw the stroke.
func (Style) ShouldDrawStroke ¶
ShouldDrawStroke tells drawing functions if they should draw the stroke.
func (Style) WriteDrawingOptionsToRenderer ¶
WriteDrawingOptionsToRenderer passes just the drawing style options to a renderer.
func (Style) WriteTextOptionsToRenderer ¶
WriteTextOptionsToRenderer passes just the text style options to a renderer.
func (Style) WriteToRenderer ¶
WriteToRenderer passes the style's options to a renderer.
type TextHorizontalAlign ¶
type TextHorizontalAlign int
TextHorizontalAlign is an enum for the horizontal alignment options.
const ( // TextHorizontalAlignUnset is an unset state for text horizontal alignment. TextHorizontalAlignUnset TextHorizontalAlign = iota // TextHorizontalAlignLeft aligns a string horizontally so that it's left // ligature starts at horizontal pixel 0. TextHorizontalAlignLeft // TextHorizontalAlignCenter left aligns a string horizontally so that // there are equal pixels to the left and to the right of a string within // a box. TextHorizontalAlignCenter // TextHorizontalAlignRight right aligns a string horizontally so that // the right ligature ends at the right-most pixel of a box. TextHorizontalAlignRight )
type TextStyle ¶
type TextStyle struct { HorizontalAlign TextHorizontalAlign VerticalAlign TextVerticalAlign Wrap TextWrap }
TextStyle encapsulates text style options.
type TextVerticalAlign ¶
type TextVerticalAlign int
TextVerticalAlign is an enum for the vertical alignment options.
const ( // TextVerticalAlignUnset is the unset state for vertical alignment options. TextVerticalAlignUnset TextVerticalAlign = iota // TextVerticalAlignBaseline aligns text according to the "baseline" of // the string, or where a normal ascender begins. TextVerticalAlignBaseline // TextVerticalAlignBottom aligns the text according to the lowers pixel // of any of the ligatures (ex. g or q both extend below the baseline). TextVerticalAlignBottom // TextVerticalAlignMiddle aligns the text so that there is an equal // amount of space above and below the top and bottom of the ligatures. TextVerticalAlignMiddle // TextVerticalAlignMiddleBaseline aligns the text vertically so that there // is an equal number of pixels above and below the baseline of the string. TextVerticalAlignMiddleBaseline // TextVerticalAlignTop alignts the text so that the top of the ligatures // are at y-pixel 0 in the container. TextVerticalAlignTop )
type TextWrap ¶
type TextWrap int
TextWrap is an enum for the word wrap options.
const ( // TextWrapUnset is the unset state for text wrap options. TextWrapUnset TextWrap = iota // TextWrapNone will spill text past horizontal boundaries. TextWrapNone // TextWrapWord will split a string on words (i.e. spaces) to fit within // a horizontal boundary. TextWrapWord // TextWrapRune will split a string on a rune (i.e. utf-8 codepage) to fit // within a horizontal boundary. TextWrapRune )