Movatterモバイル変換


[0]ホーム

URL:


chartdraw

package
v0.5.21Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2025 License:MITImports:20Imported by:5

Details

Repository

github.com/go-analyze/charts

Links

Documentation

Index

Constants

View Source
const (// Deprecated: DefaultChartHeight is deprecated, it's not expected to be used externally. If you use this field,// open a new issue to prevent it from being made internal.// DefaultChartHeight is the default chart height.DefaultChartHeight = 400// Deprecated: DefaultChartWidth is deprecated, it's not expected to be used externally. If you use this field,// open a new issue to prevent it from being made internal.// DefaultChartWidth is the default chart width.DefaultChartWidth = 1024// Deprecated: DefaultStrokeWidth is deprecated, it's not expected to be used externally. If you use this field,// open a new issue to prevent it from being made internal.// DefaultStrokeWidth is the default chart stroke width.DefaultStrokeWidth = 0.0// Deprecated: DefaultDotWidth is deprecated, it's not expected to be used externally. If you use this field,// open a new issue to prevent it from being made internal.// DefaultDotWidth is the default chart dot width.DefaultDotWidth = 0.0// Deprecated: DefaultSeriesLineWidth is deprecated, it's not expected to be used externally. If you use this field,// open a new issue to prevent it from being made internal.// DefaultSeriesLineWidth is the default line width.DefaultSeriesLineWidth = 1.0// Deprecated: DefaultAxisLineWidth is deprecated, it's not expected to be used externally. If you use this field,// open a new issue to prevent it from being made internal.// DefaultAxisLineWidth is the line width of the axis lines.DefaultAxisLineWidth = 1.0// Deprecated: DefaultDPI is deprecated, it's not expected to be used externally. If you use this field,// open a new issue to prevent it from being made internal.// DefaultDPI is the default dots per inch for the chart.DefaultDPI = 92.0// Deprecated: DefaultFontSize is deprecated, it's not expected to be used externally. If you use this field,// open a new issue to prevent it from being made internal.// DefaultFontSize is the default font size.DefaultFontSize = 10.0// Deprecated: DefaultTitleFontSize is deprecated, it's not expected to be used externally. If you use this field,// open a new issue to prevent it from being made internal.// DefaultTitleFontSize is the default title font size.DefaultTitleFontSize = 18.0// Deprecated: DefaultAnnotationDeltaWidth is deprecated, it's not expected to be used externally. If you use this// field, open a new issue to prevent it from being made internal.// DefaultAnnotationDeltaWidth is the width of the left triangle out of annotations.DefaultAnnotationDeltaWidth = 10// Deprecated: DefaultAnnotationFontSize is deprecated, it's not expected to be used externally. If you use this// field, open a new issue to prevent it from being made internal.// DefaultAnnotationFontSize is the font size of annotations.DefaultAnnotationFontSize = 10.0// Deprecated: DefaultAxisFontSize is deprecated, it's not expected to be used externally. If you use this// field, open a new issue to prevent it from being made internal.// DefaultAxisFontSize is the font size of the axis labels.DefaultAxisFontSize = 10.0// Deprecated: DefaultTitleTop is deprecated, it's not expected to be used externally. If you use this// field, open a new issue to prevent it from being made internal.// DefaultTitleTop is the default distance from the top of the chart to put the title.DefaultTitleTop = 10// Deprecated: DefaultBackgroundStrokeWidth is deprecated, it's not expected to be used externally. If you use this// field, open a new issue to prevent it from being made internal.// DefaultBackgroundStrokeWidth is the default stroke on the chart background.DefaultBackgroundStrokeWidth = 0.0// Deprecated: DefaultCanvasStrokeWidth is deprecated, it's not expected to be used externally. If you use this// field, open a new issue to prevent it from being made internal.// DefaultCanvasStrokeWidth is the default stroke on the chart canvas.DefaultCanvasStrokeWidth = 0.0// Deprecated: DefaultLineSpacing is deprecated, it's not expected to be used externally. If you use this field,// open a new issue to prevent it from being made internal.// DefaultLineSpacing is the default vertical distance between lines of text.DefaultLineSpacing = 5// Deprecated: DefaultYAxisMargin is deprecated, it's not expected to be used externally. If you use this field,// open a new issue to prevent it from being made internal.// DefaultYAxisMargin is the default distance from the right of the canvas to the y-axis labels.DefaultYAxisMargin = 10// Deprecated: DefaultXAxisMargin is deprecated, it's not expected to be used externally. If you use this field,// open a new issue to prevent it from being made internal.// DefaultXAxisMargin is the default distance from bottom of the canvas to the x-axis labels.DefaultXAxisMargin = 10// Deprecated: DefaultVerticalTickHeight is deprecated, it's not expected to be used externally. If you use this// field, open a new issue to prevent it from being made internal.// DefaultVerticalTickHeight is half the margin.DefaultVerticalTickHeight =DefaultXAxisMargin >> 1// Deprecated: DefaultHorizontalTickWidth is deprecated, it's not expected to be used externally. If you use this// field, open a new issue to prevent it from being made internal.// DefaultHorizontalTickWidth is half the margin.DefaultHorizontalTickWidth =DefaultYAxisMargin >> 1// Deprecated: DefaultTickCountSanityCheck is deprecated, it's not expected to be used externally. If you use this// field, open a new issue to prevent it from being made internal.// DefaultTickCountSanityCheck is a hard limit on number of ticks to prevent infinite loops.DefaultTickCountSanityCheck = 1 << 10//1024// Deprecated: DefaultMinimumTickHorizontalSpacing is deprecated, it's not expected to be used externally. If you// use this field, open a new issue to prevent it from being made internal.// DefaultMinimumTickHorizontalSpacing is the minimum distance between horizontal ticks.DefaultMinimumTickHorizontalSpacing = 20// Deprecated: DefaultMinimumTickVerticalSpacing is deprecated, it's not expected to be used externally. If you// use this field, open a new issue to prevent it from being made internal.// DefaultMinimumTickVerticalSpacing is the minimum distance between vertical ticks.DefaultMinimumTickVerticalSpacing = 20// DefaultDateFormat is the default date format.DefaultDateFormat = "2006-01-02"// DefaultDateHourFormat is the date format for hour timestamp formats.DefaultDateHourFormat = "01-02 3PM"// DefaultDateMinuteFormat is the date format for minute range timestamp formats.DefaultDateMinuteFormat = "01-02 3:04PM"// Deprecated: DefaultFloatFormat is deprecated, it's not expected to be used externally. If you// use this field, open a new issue to prevent it from being made internal.// DefaultFloatFormat is the default float format.DefaultFloatFormat = "%.2f"// Deprecated: DefaultPercentValueFormat is deprecated, it's not expected to be used externally. If you// use this field, open a new issue to prevent it from being made internal.// DefaultPercentValueFormat is the default percent format.DefaultPercentValueFormat = "%0.2f%%"// Deprecated: DefaultBarSpacing is deprecated, it's not expected to be used externally. If you// use this field, open a new issue to prevent it from being made internal.// DefaultBarSpacing is the default pixel spacing between bars.DefaultBarSpacing = 100// Deprecated: DefaultBarWidth is deprecated, it's not expected to be used externally. If you// use this field, open a new issue to prevent it from being made internal.// DefaultBarWidth is the default pixel width of bars in a bar chart.DefaultBarWidth = 50)

TODO - remove internal defaults from public API

View Source
const (// ContentTypePNG is the png mime type.ContentTypePNG = "image/png"// ContentTypeSVG is the svg mime type.ContentTypeSVG = "image/svg+xml")
View Source
const (// Deprecated: DefaultMACDPeriodPrimary is deprecated, it's not expected to be used externally. If you// use this field, open a new issue to prevent it from being made internal.// DefaultMACDPeriodPrimary is the long window.DefaultMACDPeriodPrimary = 26// Deprecated: DefaultMACDPeriodSecondary is deprecated, it's not expected to be used externally. If you// use this field, open a new issue to prevent it from being made internal.// DefaultMACDPeriodSecondary is the short window.DefaultMACDPeriodSecondary = 12// Deprecated: DefaultMACDSignalPeriod is deprecated, it's not expected to be used externally. If you// use this field, open a new issue to prevent it from being made internal.// DefaultMACDSignalPeriod is the signal period to compute for the MACD.DefaultMACDSignalPeriod = 9)

TODO - remove internal defaults from public API

View Source
const (// Deprecated: DefaultEMAPeriod is deprecated, it's not expected to be used externally. If you// use this field, open a new issue to prevent it from being made internal.// DefaultEMAPeriod is the default EMA period used in the sigma calculation.DefaultEMAPeriod = 12)

TODO - remove internal defaults from public API

View Source
const (// Deprecated: DefaultSimpleMovingAveragePeriod is deprecated, it's not expected to be used externally. If you// use this field, open a new issue to prevent it from being made internal.// DefaultSimpleMovingAveragePeriod is the default number of values to average.DefaultSimpleMovingAveragePeriod = 16)

TODO - remove internal defaults from public API

View Source
const (// Disabled indicates if the value should be interpreted as a set intentionally to zero.Disabled = -1)

Variables

View Source
var (// ColorWhite is white.ColorWhite =drawing.ColorWhite// ColorBlue is the basic theme blue color.ColorBlue =drawing.Color{R: 0, G: 116, B: 217, A: 255}// ColorCyan is the basic theme cyan color.ColorCyan =drawing.Color{R: 0, G: 217, B: 210, A: 255}// ColorGreen is the basic theme green color.ColorGreen =drawing.Color{R: 0, G: 217, B: 101, A: 255}// ColorRed is the basic theme red color.ColorRed =drawing.Color{R: 217, G: 0, B: 116, A: 255}// ColorOrange is the basic theme orange color.ColorOrange =drawing.Color{R: 217, G: 101, B: 0, A: 255}// ColorYellow is the basic theme yellow color.ColorYellow =drawing.Color{R: 217, G: 210, B: 0, A: 255}// ColorBlack is the basic theme black color.ColorBlack =drawing.Color{R: 51, G: 51, B: 51, A: 255}// ColorLightGray is the basic theme light gray color.ColorLightGray =drawing.Color{R: 239, G: 239, B: 239, A: 255}// ColorAlternateBlue is an alternate theme color.ColorAlternateBlue =drawing.Color{R: 106, G: 195, B: 203, A: 255}// ColorAlternateGreen is an alternate theme color.ColorAlternateGreen =drawing.Color{R: 42, G: 190, B: 137, A: 255}// ColorAlternateGray is an alternate theme color.ColorAlternateGray =drawing.Color{R: 110, G: 128, B: 139, A: 255}// ColorAlternateYellow is an alternate theme color.ColorAlternateYellow =drawing.Color{R: 240, G: 174, B: 90, A: 255}// ColorAlternateLightGray is an alternate theme color.ColorAlternateLightGray =drawing.Color{R: 187, G: 190, B: 191, A: 255}// ColorTransparent is a transparent (alpha zero) color.ColorTransparent =drawing.Color{R: 1, G: 1, B: 1, A: 0})
View Source
var (// Deprecated: DefaultBackgroundColor is deprecated, it's not expected to be used externally. If you// use this field, open a new issue to prevent it from being made internal.// DefaultBackgroundColor is the default chart background color.// It is equivalent to css color:white.DefaultBackgroundColor =ColorWhite// Deprecated: DefaultBackgroundStrokeColor is deprecated, it's not expected to be used externally. If you// use this field, open a new issue to prevent it from being made internal.// DefaultBackgroundStrokeColor is the default chart border color.// It is equivalent to color:white.DefaultBackgroundStrokeColor =ColorWhite// Deprecated: DefaultCanvasColor is deprecated, it's not expected to be used externally. If you// use this field, open a new issue to prevent it from being made internal.// DefaultCanvasColor is the default chart canvas color.// It is equivalent to css color:white.DefaultCanvasColor =ColorWhite// Deprecated: DefaultCanvasStrokeColor is deprecated, it's not expected to be used externally. If you// use this field, open a new issue to prevent it from being made internal.// DefaultCanvasStrokeColor is the default chart canvas stroke color.// It is equivalent to css color:white.DefaultCanvasStrokeColor =ColorWhite// Deprecated: DefaultTextColor is deprecated, it's not expected to be used externally. If you// use this field, open a new issue to prevent it from being made internal.// DefaultTextColor is the default chart text color.// It is equivalent to #333333.DefaultTextColor =ColorBlack// Deprecated: DefaultAxisColor is deprecated, it's not expected to be used externally. If you// use this field, open a new issue to prevent it from being made internal.// DefaultAxisColor is the default chart axis line color.// It is equivalent to #333333.DefaultAxisColor =ColorBlack// Deprecated: DefaultAnnotationFillColor is deprecated, it's not expected to be used externally. If you// use this field, open a new issue to prevent it from being made internal.// DefaultAnnotationFillColor is the default annotation background color.DefaultAnnotationFillColor =ColorWhite)

TODO - remove internal defaults from public API

View Source
var (// Deprecated: DefaultColors is deprecated, it's not expected to be used externally. If you// use this field, open a new issue to prevent it from being made internal.// DefaultColors are a couple default series colors.DefaultColors = []drawing.Color{ColorBlue,ColorGreen,ColorRed,ColorCyan,ColorOrange,}// Deprecated: DefaultAlternateColors is deprecated, it's not expected to be used externally. If you// use this field, open a new issue to prevent it from being made internal.// DefaultAlternateColors are a couple alternate colors.DefaultAlternateColors = []drawing.Color{ColorAlternateBlue,ColorAlternateGreen,ColorAlternateGray,ColorAlternateYellow,ColorBlue,ColorGreen,ColorRed,ColorCyan,ColorOrange,})
View Source
var (// Deprecated: DefaultAnnotationPadding is deprecated, it's not expected to be used externally. If you// use this field, open a new issue to prevent it from being made internal.// DefaultAnnotationPadding is the padding around an annotation.DefaultAnnotationPadding =Box{Top: 5, Left: 5, Right: 5, Bottom: 5}// Deprecated: DefaultBackgroundPadding is deprecated, it's not expected to be used externally. If you// use this field, open a new issue to prevent it from being made internal.// DefaultBackgroundPadding is the default canvas padding config.DefaultBackgroundPadding =Box{Top: 5, Left: 5, Right: 5, Bottom: 5})
View Source
var AlternateColorPalette alternateColorPalette

AlternateColorPalette represents the an alternate default palette.

View Source
var (// BoxZero is a preset box that represents an intentional zero value.BoxZero =Box{IsSet:true})
View Source
var DefaultColorPalette defaultColorPalette

DefaultColorPalette represents the default palette.

View Source
var (// Draw contains helpers for drawing common objects.Draw = &draw{})
View Source
var (// Text contains utilities for text.Text = &text{})

Functions

funcAbsInt

func AbsInt(valueint)int

AbsInt returns the absolute value of an int.

funcCirclePoint

func CirclePoint(cx, cyint, radius, thetaRadiansfloat64) (x, yint)

CirclePoint returns the absolute position of a circle diameter point givenby the radius and the theta.

funcDegreesAdd

func DegreesAdd(baseDegrees, deltaDegreesfloat64)float64

DegreesAdd adds a delta to a base in degrees.

funcDegreesToRadians

func DegreesToRadians(degreesfloat64)float64

DegreesToRadians returns degrees as radians.

funcExponentialValueFormatter

func ExponentialValueFormatter(v interface{})string

ExponentialValueFormatter is a ValueFormatter for float64, exponential notation, e.g. 1.52e+08.

funcFloatValueFormatter

func FloatValueFormatter(v interface{})string

FloatValueFormatter is a ValueFormatter for float64.

funcFloatValueFormatterWithFormat

func FloatValueFormatterWithFormat(v interface{}, floatFormatstring)string

FloatValueFormatterWithFormat is a ValueFormatter for float64 with a given format.

funcGetAlternateColor

func GetAlternateColor(indexint)drawing.Color

GetAlternateColor returns a color from the default list by index.NOTE: the index will wrap around (using a modulo).

funcGetDefaultColor

func GetDefaultColor(indexint)drawing.Color

GetDefaultColor returns a color from the default list by index.NOTE: the index will wrap around (using a modulo).

funcGetDefaultFont

func GetDefaultFont() *truetype.Font

GetDefaultFont get default font.

funcGetFontadded inv0.3.2

func GetFont(fontFamilystring) *truetype.Font

GetFont get the font by font family or the default if the family is not installed.

funcGetRoundToForDelta

func GetRoundToForDelta(deltafloat64)float64

GetRoundToForDelta returns a `roundTo` value for a given delta.

funcInstallFontadded inv0.3.2

func InstallFont(fontFamilystring, data []byte)error

InstallFont installs the font for charts.

funcJet

func Jet(v, vmin, vmaxfloat64)drawing.Color

Jet is a color map provider based on matlab's jet color map.

funcLinearRange

func LinearRange(start, endfloat64) []float64

LinearRange returns an array of values representing the range from start to end, incremented by 1.0.

funcLinearRangeWithStep

func LinearRangeWithStep(start, end, stepfloat64) []float64

LinearRangeWithStep returns the array values of a linear seq with a given start, end and optional step.

funcMaxInt

func MaxInt(values ...int)int

MaxInt returns the maximum int.

funcMeanFloat64

func MeanFloat64(values ...float64)float64

MeanFloat64 returns the mean of a set of values

funcMeanInt

func MeanInt(values ...int)int

MeanInt returns the mean of a set of integer values.

funcMinInt

func MinInt(values ...int)int

MinInt returns the minimum int.

funcMinMax

func MinMax(values ...float64) (min, maxfloat64)

MinMax returns the minimum and maximum of a given set of values.

funcNormalize

func Normalize(values ...float64) []float64

Normalize returns a set of numbers on the interval [0,1] for a given set of inputs.An example: 4,3,2,1 => 0.4, 0.3, 0.2, 0.1Caveat; the total may be < 1.0; there are going to be issues with irrational numbers etc.

funcPercentDifference

func PercentDifference(v1, v2float64)float64

PercentDifference computes the percentage difference between two values.The formula is (v2-v1)/v1.

funcPercentToRadians

func PercentToRadians(pctfloat64)float64

PercentToRadians converts a normalized value (0,1) to radians.

funcPercentValueFormatter

func PercentValueFormatter(v interface{})string

PercentValueFormatter is a formatter for percent values.NOTE: it normalizes the values, i.e. multiplies by 100.0.

funcRadianAdd

func RadianAdd(base, deltafloat64)float64

RadianAdd adds a delta to a base in radians.

funcRadiansToDegrees

func RadiansToDegrees(valuefloat64)float64

RadiansToDegrees translates a radian value to a degree value.

funcRandomValues

func RandomValues(countint) []float64

RandomValues returns an array of random values.

funcRandomValuesWithMax

func RandomValuesWithMax(countint, maxfloat64) []float64

RandomValuesWithMax returns an array of random values with a given average.

funcRotateCoordinate

func RotateCoordinate(cx, cy, x, yint, thetaRadiansfloat64) (rx, ryint)

RotateCoordinate rotates a coordinate around a given center by a theta in radians.

funcRoundDown

func RoundDown(value, roundTofloat64)float64

RoundDown rounds down to a given roundTo value.

funcRoundPlaces

func RoundPlaces(inputfloat64, placesint) (roundedfloat64)

RoundPlaces rounds an input to a given places.

funcRoundUp

func RoundUp(value, roundTofloat64)float64

RoundUp rounds up to a given roundTo value.

funcSVGWithCSS

func SVGWithCSS(cssstring, noncestring) func(width, heightint)Renderer

SVGWithCSS returns a new png/raster renderer with attached custom CSSThe optional nonce argument sets a CSP nonce.

funcSetDefaultFontadded inv0.3.2

func SetDefaultFont(fontFamilystring)error

SetDefaultFont set default font by name.

funcSumFloat64

func SumFloat64(values ...float64)float64

SumFloat64 sums a set of values.

funcSumInt

func SumInt(values ...int)int

SumInt sums a set of values, if an overflow occurs math.MaxInt will be returned exactly. Similar on an underflowmath.MinInt is returned.

funcTimeDateValueFormatter

func TimeDateValueFormatter(v interface{})string

TimeDateValueFormatter is a ValueFormatter for timestamps.

funcTimeFromFloat64

func TimeFromFloat64(tffloat64)time.Time

TimeFromFloat64 returns a time in nanosecond from a float64.

funcTimeHourValueFormatter

func TimeHourValueFormatter(v interface{})string

TimeHourValueFormatter is a ValueFormatter for timestamps.

funcTimeMinuteValueFormatter

func TimeMinuteValueFormatter(v interface{})string

TimeMinuteValueFormatter is a ValueFormatter for timestamps.

funcTimeToFloat64

func TimeToFloat64(ttime.Time)float64

TimeToFloat64 returns a float64 representation of a time.

funcTimeValueFormatter

func TimeValueFormatter(v interface{})string

TimeValueFormatter is a ValueFormatter for timestamps.

funcToFloat64

func ToFloat64(ttime.Time)float64

ToFloat64 returns a float64 representation of a time.

funcViridis

func Viridis(v, vmin, vmaxfloat64)drawing.Color

Viridis creates a color map provider.

Types

typeAnnotationSeries

type AnnotationSeries struct {NamestringStyleStyleYAxisYAxisTypeAnnotations []Value2}

AnnotationSeries is a series of labels on the chart.

funcFirstValueAnnotation

func FirstValueAnnotation(innerSeriesValuesProvider, vfs ...ValueFormatter)AnnotationSeries

FirstValueAnnotation returns an annotation series of just the first value of a value provider as an annotation.

funcLastValueAnnotationSeries

func LastValueAnnotationSeries(innerSeriesValuesProvider, vfs ...ValueFormatter)AnnotationSeries

LastValueAnnotationSeries returns an annotation series of just the last value of a value provider.

func (AnnotationSeries)GetName

func (asAnnotationSeries) GetName()string

GetName returns the name of the time series.

func (AnnotationSeries)GetStyle

func (asAnnotationSeries) GetStyle()Style

GetStyle returns the line style.

func (AnnotationSeries)GetYAxis

func (asAnnotationSeries) GetYAxis()YAxisType

GetYAxis returns which YAxis the series draws on.

func (AnnotationSeries)Measure

func (asAnnotationSeries) Measure(rRenderer, canvasBoxBox, xrange, yrangeRange, defaultsStyle)Box

Measure returns a bounds box of the series.

func (AnnotationSeries)Render

func (asAnnotationSeries) Render(rRenderer, canvasBoxBox, xrange, yrangeRange, defaultsStyle)

Render draws the series.

func (AnnotationSeries)Validate

func (asAnnotationSeries) Validate()error

Validate validates the series.

typeArray

type Array []float64

Array is a wrapper for an array of floats that implements `ValuesProvider`.

funcNewArray

func NewArray(values ...float64)Array

NewArray returns a new array from a given set of values.Array implements Sequence, which allows it to be used with the sequence helpers.

func (Array)GetValue

func (aArray) GetValue(indexint)float64

GetValue returns the value at a given index.

func (Array)Len

func (aArray) Len()int

Len returns the value provider length.

typeAxis

type Axis interface {GetName()stringSetName(namestring)GetStyle()StyleSetStyle(styleStyle)GetTicks() []TickGenerateTicks(rRenderer, raRange, vfValueFormatter) []Tick// GetGridLines returns the gridlines for the axis.GetGridLines(ticks []Tick) []GridLine// Measure should return an absolute box for the axis.// This is used when auto-fitting the canvas to the background.Measure(rRenderer, canvasBoxBox, raRange, styleStyle, ticks []Tick)Box// Render renders the axis.Render(rRenderer, canvasBoxBox, raRange, styleStyle, ticks []Tick)}

Axis is a chart feature detailing what values happen where.

typeBarChart

type BarChart struct {TitlestringTitleStyleStyleColorPaletteColorPaletteWidthintHeightintDPIfloat64BarWidthintBackgroundStyleCanvasStyleXAxisStyleYAxisYAxisBarSpacingintUseBaseValueboolBaseValuefloat64Font *truetype.FontBars     []ValueElements []Renderable}

BarChart is a chart that draws bars on a range.

func (BarChart)GetBarSpacing

func (bcBarChart) GetBarSpacing()int

GetBarSpacing returns the spacing between bars.

func (BarChart)GetBarWidth

func (bcBarChart) GetBarWidth()int

GetBarWidth returns the default bar width.

func (BarChart)GetColorPalette

func (bcBarChart) GetColorPalette()ColorPalette

GetColorPalette returns the color palette for the chart.

func (BarChart)GetDPI

func (bcBarChart) GetDPI()float64

GetDPI returns the dpi for the chart.

func (BarChart)GetFont

func (bcBarChart) GetFont() *truetype.Font

GetFont returns the text font.

func (BarChart)GetHeight

func (bcBarChart) GetHeight()int

GetHeight returns the chart height or the default value.

func (BarChart)GetWidth

func (bcBarChart) GetWidth()int

GetWidth returns the chart width or the default value.

func (BarChart)Render

Render renders the chart with the given renderer to the given io.Writer.

typeBollingerBandsSeries

type BollingerBandsSeries struct {NamestringStyleStyleYAxisYAxisTypePeriodintKfloat64InnerSeriesValuesProvider// contains filtered or unexported fields}

BollingerBandsSeries draws bollinger bands for an inner series.Bollinger bands are defined by two lines, one at SMA+k*stddev, one at SMA-k*stdev.

func (*BollingerBandsSeries)GetBoundedLastValues

func (bbs *BollingerBandsSeries) GetBoundedLastValues() (x, y1, y2float64)

GetBoundedLastValues returns the last bounded value for the series.

func (*BollingerBandsSeries)GetBoundedValues

func (bbs *BollingerBandsSeries) GetBoundedValues(indexint) (x, y1, y2float64)

GetBoundedValues gets the bounded value for the series.

func (*BollingerBandsSeries)GetK

func (bbs *BollingerBandsSeries) GetK(defaults ...float64)float64

GetK returns the K value, or the number of standard deviations above and belowto band the simple moving average with.Typical K value is 2.0.

func (*BollingerBandsSeries)GetName

func (bbs *BollingerBandsSeries) GetName()string

GetName returns the name of the time series.

func (*BollingerBandsSeries)GetPeriod

func (bbs *BollingerBandsSeries) GetPeriod()int

GetPeriod returns the window size.

func (*BollingerBandsSeries)GetStyle

func (bbs *BollingerBandsSeries) GetStyle()Style

GetStyle returns the line style.

func (*BollingerBandsSeries)GetYAxis

func (bbs *BollingerBandsSeries) GetYAxis()YAxisType

GetYAxis returns which YAxis the series draws on.

func (*BollingerBandsSeries)Len

func (bbs *BollingerBandsSeries) Len()int

Len returns the number of elements in the series.

func (*BollingerBandsSeries)Render

func (bbs *BollingerBandsSeries) Render(rRenderer, canvasBoxBox, xrange, yrangeRange, defaultsStyle)

Render renders the series.

func (*BollingerBandsSeries)Validate

func (bbs *BollingerBandsSeries) Validate()error

Validate validates the series.

typeBoundedLastValuesProvider

type BoundedLastValuesProvider interface {GetBoundedLastValues() (x, y1, y2float64)}

BoundedLastValuesProvider is a special type of value provider that can return it's (potentially computed) bounded last value.

typeBoundedValuesProvider

type BoundedValuesProvider interface {Len()intGetBoundedValues(indexint) (x, y1, y2float64)}

BoundedValuesProvider allows series to return a range.

typeBox

type Box struct {TopintBottomintLeftintRightintIsSetbool}

Box represents the main 4 dimensions of a box.

funcNewBox

func NewBox(top, left, right, bottomint)Box

NewBox returns a new (set) box.

func (Box)Aspect

func (bBox) Aspect()float64

Aspect returns the aspect ratio of the box.

func (Box)Center

func (bBox) Center() (x, yint)

Center returns the center of the box.

func (Box)CenterXadded inv0.5.6

func (bBox) CenterX()int

CenterX returns the center x position of the box.

func (Box)CenterYadded inv0.5.6

func (bBox) CenterY()int

CenterY returns the center y position of the box.

func (Box)Clone

func (bBox) Clone()Box

Clone returns a new copy of the box.

func (Box)Constrain

func (bBox) Constrain(otherBox)Box

Constrain is similar to `Fit` except that it will workmore literally like the opposite of grow.

func (Box)Corners

func (bBox) Corners()BoxCorners

Corners returns the box as a set of corners.

func (Box)Equals

func (bBox) Equals(otherBox)bool

Equals returns if the box equals another box.

func (Box)Fit

func (bBox) Fit(otherBox)Box

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)GetBottom

func (bBox) GetBottom(defaults ...int)int

GetBottom returns a coalesced value with a default.

func (Box)GetLeft

func (bBox) GetLeft(defaults ...int)int

GetLeft returns a coalesced value with a default.

func (Box)GetRight

func (bBox) GetRight(defaults ...int)int

GetRight returns a coalesced value with a default.

func (Box)GetTop

func (bBox) GetTop(defaults ...int)int

GetTop returns a coalesced value with a default.

func (Box)Grow

func (bBox) Grow(otherBox)Box

Grow grows a box based on another box.

func (Box)Height

func (bBox) Height()int

Height returns the height

func (Box)IsBiggerThan

func (bBox) IsBiggerThan(otherBox)bool

IsBiggerThan returns true if a box is bigger than another box.

func (Box)IsSmallerThan

func (bBox) IsSmallerThan(otherBox)bool

IsSmallerThan returns true if a box is smaller than another box.

func (Box)IsZero

func (bBox) IsZero()bool

IsZero returns if the box is set or not.

func (Box)OuterConstrain

func (bBox) OuterConstrain(bounds, otherBox)Box

OuterConstrain is similar to `Constraint` with the differencethat it applies corrections

func (Box)Overlapsadded inv0.3.4

func (bBox) Overlaps(otherBox)bool

Overlaps returns true if the two boxes overlap each other.

func (Box)Shift

func (bBox) Shift(x, yint)Box

Shift pushes a box by x,y.

func (Box)String

func (bBox) String()string

String returns a string representation of the box.

func (Box)Validate

func (bBox) Validate()error

func (Box)Width

func (bBox) Width()int

Width returns the width

func (Box)WithBottomadded inv0.3.0

func (bBox) WithBottom(valint)Box

func (Box)WithLeftadded inv0.3.0

func (bBox) WithLeft(valint)Box

func (Box)WithRightadded inv0.3.0

func (bBox) WithRight(valint)Box

func (Box)WithTopadded inv0.3.0

func (bBox) WithTop(valint)Box

typeBoxCorners

type BoxCorners struct {TopLeft, TopRight, BottomRight, BottomLeftPoint}

BoxCorners is a box with independent corners.

func (BoxCorners)Box

func (bcBoxCorners) Box()Box

Box return the BoxCorners as a regular box.

func (BoxCorners)Center

func (bcBoxCorners) Center() (x, yint)

Center returns the center of the box

func (BoxCorners)Equals

func (bcBoxCorners) Equals(otherBoxCorners)bool

Equals returns if the box equals another box.

func (BoxCorners)Height

func (bcBoxCorners) Height()int

Height returns the height

func (BoxCorners)Rotate

func (bcBoxCorners) Rotate(thetaDegreesfloat64)BoxCorners

Rotate rotates the box.

func (BoxCorners)String

func (bcBoxCorners) String()string

func (BoxCorners)ToPointsadded inv0.5.6

func (bcBoxCorners) ToPoints() []Point

ToPoints returns the corner points as a slice of Points.

func (BoxCorners)Width

func (bcBoxCorners) Width()int

Width returns the width

typeChart

type Chart struct {TitlestringTitleStyleStyleColorPaletteColorPaletteWidthintHeightintDPIfloat64BackgroundStyleCanvasStyleXAxisXAxisYAxisYAxisYAxisSecondaryYAxisFont *truetype.FontSeries   []SeriesElements []Renderable}

Chart is what we're drawing.

func (Chart)Box

func (cChart) Box()Box

Box returns the chart bounds as a box.

func (Chart)GetColorPalette

func (cChart) GetColorPalette()ColorPalette

GetColorPalette returns the color palette for the chart.

func (Chart)GetDPI

func (cChart) GetDPI(defaults ...float64)float64

GetDPI returns the dpi for the chart.

func (Chart)GetFont

func (cChart) GetFont() *truetype.Font

GetFont returns the text font.

func (Chart)GetHeight

func (cChart) GetHeight()int

GetHeight returns the chart height or the default value.

func (Chart)GetWidth

func (cChart) GetWidth()int

GetWidth returns the chart width or the default value.

func (Chart)Render

func (cChart) Render(rpRendererProvider, wio.Writer)error

Render renders the chart with the given renderer to the given io.Writer.

typeColorPalette

type ColorPalette interface {BackgroundColor()drawing.ColorBackgroundStrokeColor()drawing.ColorCanvasColor()drawing.ColorCanvasStrokeColor()drawing.ColorAxisStrokeColor()drawing.ColorTextColor()drawing.ColorGetSeriesColor(indexint)drawing.Color}

ColorPalette is a set of colors that.

typeColorProvider

type ColorProvider func(v, vmin, vmaxfloat64)drawing.Color

ColorProvider is a general provider for color ranges based on values.

typeConcatSeries

type ConcatSeries []Series

ConcatSeries is a special type of series that concatenates its `InnerSeries`.

func (ConcatSeries)GetValue

func (csConcatSeries) GetValue(indexint) (x, yfloat64)

GetValue returns the value at the (meta) index (i.e 0 => totalLen-1)

func (ConcatSeries)Len

func (csConcatSeries) Len()int

Len returns the length of the concatenated set of series.

func (ConcatSeries)Validate

func (csConcatSeries) Validate()error

Validate validates the series.

typeContinuousRange

type ContinuousRange struct {Minfloat64Maxfloat64DomainintDescendingbool}

ContinuousRange represents a boundary for a set of numbers.

func (*ContinuousRange)GetDelta

func (r *ContinuousRange) GetDelta()float64

GetDelta returns the difference between the min and max value.

func (*ContinuousRange)GetDomain

func (r *ContinuousRange) GetDomain()int

GetDomain returns the range domain.

func (*ContinuousRange)GetMax

func (r *ContinuousRange) GetMax()float64

GetMax returns the max value for the continuous range.

func (*ContinuousRange)GetMin

func (r *ContinuousRange) GetMin()float64

GetMin gets the min value for the continuous range.

func (*ContinuousRange)IsDescending

func (r *ContinuousRange) IsDescending()bool

IsDescending returns if the range is descending.

func (*ContinuousRange)IsZero

func (r *ContinuousRange) IsZero()bool

IsZero returns if the ContinuousRange has been set or not.

func (*ContinuousRange)SetDomain

func (r *ContinuousRange) SetDomain(domainint)

SetDomain sets the range domain.

func (*ContinuousRange)SetMax

func (r *ContinuousRange) SetMax(maxfloat64)

SetMax sets the max value for the continuous range.

func (*ContinuousRange)SetMin

func (r *ContinuousRange) SetMin(minfloat64)

SetMin sets the min value for the continuous range.

func (*ContinuousRange)String

func (r *ContinuousRange) String()string

String returns a simple string for the ContinuousRange.

func (*ContinuousRange)Translate

func (r *ContinuousRange) Translate(valuefloat64)int

Translate maps a given value into the ContinuousRange space.

typeContinuousSeries

type ContinuousSeries struct {NamestringStyleStyleYAxisYAxisTypeXValueFormatterValueFormatterYValueFormatterValueFormatterXValues []float64YValues []float64}

ContinuousSeries represents a line on a chart.

func (ContinuousSeries)GetFirstValues

func (csContinuousSeries) GetFirstValues() (float64,float64)

GetFirstValues gets the first x,y values.

func (ContinuousSeries)GetLastValues

func (csContinuousSeries) GetLastValues() (float64,float64)

GetLastValues gets the last x,y values.

func (ContinuousSeries)GetName

func (csContinuousSeries) GetName()string

GetName returns the name of the time series.

func (ContinuousSeries)GetStyle

func (csContinuousSeries) GetStyle()Style

GetStyle returns the line style.

func (ContinuousSeries)GetValueFormatters

func (csContinuousSeries) GetValueFormatters() (x, yValueFormatter)

GetValueFormatters returns value formatter defaults for the series.

func (ContinuousSeries)GetValues

func (csContinuousSeries) GetValues(indexint) (float64,float64)

GetValues gets the x,y values at a given index.

func (ContinuousSeries)GetYAxis

func (csContinuousSeries) GetYAxis()YAxisType

GetYAxis returns which YAxis the series draws on.

func (ContinuousSeries)Len

func (csContinuousSeries) Len()int

Len returns the number of elements in the series.

func (ContinuousSeries)Render

func (csContinuousSeries) Render(rRenderer, canvasBoxBox, xrange, yrangeRange, defaultsStyle)

Render renders the series.

func (ContinuousSeries)Validate

func (csContinuousSeries) Validate()error

Validate validates the series.

typeDonutChart

type DonutChart struct {TitlestringTitleStyleStyleColorPaletteColorPaletteWidthintHeightintDPIfloat64BackgroundStyleCanvasStyleSliceStyleStyleFont *truetype.FontValues   []ValueElements []Renderable}

DonutChart is a chart that draws sections of a circle based on percentages with a hole.

func (DonutChart)Box

func (pcDonutChart) Box()Box

Box returns the chart bounds as a box.

func (DonutChart)GetColorPalette

func (pcDonutChart) GetColorPalette()ColorPalette

GetColorPalette returns the color palette for the chart.

func (DonutChart)GetDPI

func (pcDonutChart) GetDPI(defaults ...float64)float64

GetDPI returns the dpi for the chart.

func (DonutChart)GetFont

func (pcDonutChart) GetFont() *truetype.Font

GetFont returns the text font.

func (DonutChart)GetHeight

func (pcDonutChart) GetHeight()int

GetHeight returns the chart height or the default value.

func (DonutChart)GetWidth

func (pcDonutChart) GetWidth()int

GetWidth returns the chart width or the default value.

func (DonutChart)Render

Render renders the chart with the given renderer to the given io.Writer.

typeDotColorProvider

type DotColorProvider func(xrange, yrangeRange, indexint, x, yfloat64)drawing.Color

DotColorProvider is a provider for dot color.

typeEMASeries

type EMASeries struct {NamestringStyleStyleYAxisYAxisTypePeriodintInnerSeriesValuesProvider// contains filtered or unexported fields}

EMASeries is a computed series.

func (*EMASeries)GetFirstValues

func (ema *EMASeries) GetFirstValues() (x, yfloat64)

GetFirstValues computes the first moving average value.

func (*EMASeries)GetLastValues

func (ema *EMASeries) GetLastValues() (x, yfloat64)

GetLastValues computes the last moving average value but walking back window size samples,and recomputing the last moving average chunk.

func (*EMASeries)GetName

func (ema *EMASeries) GetName()string

GetName returns the name of the time series.

func (*EMASeries)GetPeriod

func (ema *EMASeries) GetPeriod()int

GetPeriod returns the window size.

func (*EMASeries)GetSigma

func (ema *EMASeries) GetSigma()float64

GetSigma returns the smoothing factor for the series.

func (*EMASeries)GetStyle

func (ema *EMASeries) GetStyle()Style

GetStyle returns the line style.

func (*EMASeries)GetValues

func (ema *EMASeries) GetValues(indexint) (x, yfloat64)

GetValues gets a value at a given index.

func (*EMASeries)GetYAxis

func (ema *EMASeries) GetYAxis()YAxisType

GetYAxis returns which YAxis the series draws on.

func (*EMASeries)Len

func (ema *EMASeries) Len()int

Len returns the number of elements in the series.

func (*EMASeries)Render

func (ema *EMASeries) Render(rRenderer, canvasBoxBox, xrange, yrangeRange, defaultsStyle)

Render renders the series.

func (*EMASeries)Validate

func (ema *EMASeries) Validate()error

Validate validates the series.

typeFirstValuesProvider

type FirstValuesProvider interface {GetFirstValues() (x, yfloat64)}

FirstValuesProvider is a special type of value provider that can return it's (potentially computed) first value.

typeFontStyleadded inv0.2.0

type FontStyle struct {FontSizefloat64FontColordrawing.ColorFont      *truetype.Font}

FontStyle contains the font-specific style aspects.

func (FontStyle)GetFontadded inv0.2.0

func (sFontStyle) GetFont(defaults ...*truetype.Font) *truetype.Font

GetFont returns the font face.

func (FontStyle)GetFontColoradded inv0.2.0

func (sFontStyle) GetFontColor(defaults ...drawing.Color)drawing.Color

GetFontColor gets the font size.

func (FontStyle)GetFontSizeadded inv0.2.0

func (sFontStyle) GetFontSize(defaults ...float64)float64

GetFontSize gets the font size.

func (FontStyle)IsZeroadded inv0.5.1

func (sFontStyle) IsZero()bool

IsZero returns if the font style is set or not.

func (FontStyle)WithColoradded inv0.3.0

func (sFontStyle) WithColor(colordrawing.Color)FontStyle

func (FontStyle)WithFontadded inv0.3.0

func (sFontStyle) WithFont(font *truetype.Font)FontStyle

func (FontStyle)WithSizeadded inv0.3.0

func (sFontStyle) WithSize(sizefloat64)FontStyle

func (FontStyle)WriteTextOptionsToRendereradded inv0.2.0

func (sFontStyle) WriteTextOptionsToRenderer(rRenderer)

WriteTextOptionsToRenderer passes just the text style options to a renderer.

typeFullBoundedValuesProvider

type FullBoundedValuesProvider interface {BoundedValuesProviderBoundedLastValuesProvider}

FullBoundedValuesProvider is an interface that combines `BoundedValuesProvider` and `BoundedLastValuesProvider`

typeFullValuesProvider

type FullValuesProvider interface {ValuesProviderLastValuesProvider}

FullValuesProvider is an interface that combines `ValuesProvider` and `LastValuesProvider`

typeGridLine

type GridLine struct {IsMinorboolStyleStyleValuefloat64}

GridLine is a line on a graph canvas.

funcGenerateGridLines

func GenerateGridLines(ticks []Tick, majorStyle, minorStyleStyle) []GridLine

GenerateGridLines generates grid lines.

func (GridLine)Major

func (glGridLine) Major()bool

Major returns if the gridline is a `major` line.

func (GridLine)Minor

func (glGridLine) Minor()bool

Minor returns if the gridline is a `minor` line.

func (GridLine)Render

func (glGridLine) Render(rRenderer, canvasBoxBox, raRange, isVerticalbool, defaultsStyle)

Render renders the gridline

typeGridLineProvider

type GridLineProvider interface {GetGridLines(ticks []Tick, isVerticalbool, majorStyle, minorStyleStyle) []GridLine}

GridLineProvider is a type that provides grid lines.

typeHistogramSeries

type HistogramSeries struct {NamestringStyleStyleYAxisYAxisTypeInnerSeriesValuesProvider}

HistogramSeries is a special type of series that draws as a histogram.Some peculiarities; it will always be lower bounded at 0 (at the very least).This may alter ranges a bit and generally you want to put a histogram series on its own y-axis.

func (HistogramSeries)GetBoundedValues

func (hsHistogramSeries) GetBoundedValues(indexint) (x, y1, y2float64)

GetBoundedValues returns the bounded values used for drawing bars (for BoundedValuesProvider interface).

func (HistogramSeries)GetName

func (hsHistogramSeries) GetName()string

GetName returns the series name (for Series interface).

func (HistogramSeries)GetStyle

func (hsHistogramSeries) GetStyle()Style

GetStyle returns the style used for rendering (for Series interface).

func (HistogramSeries)GetValues

func (hsHistogramSeries) GetValues(indexint) (x, yfloat64)

GetValues proxies value access to the inner series (for ValuesProvider interface).

func (HistogramSeries)GetYAxis

func (hsHistogramSeries) GetYAxis()YAxisType

GetYAxis returns which yaxis the series is mapped to.

func (HistogramSeries)Len

func (hsHistogramSeries) Len()int

Len returns the number of values in the inner series (for BoundedValuesProvider interface).

func (HistogramSeries)Render

func (hsHistogramSeries) Render(rRenderer, canvasBoxBox, xrange, yrangeRange, defaultsStyle)

Render draws the histogram series using the given renderer (for Series interface).

func (HistogramSeries)Validate

func (hsHistogramSeries) Validate()error

Validate validates the series.

typeImageWriter

type ImageWriter struct {// contains filtered or unexported fields}

ImageWriter is a special type of io.Writer that produces a final image.

func (*ImageWriter)Image

func (ir *ImageWriter) Image() (image.Image,error)

Image returns an *image.Image for the result.

func (*ImageWriter)SetRGBA

func (ir *ImageWriter) SetRGBA(i *image.RGBA)

SetRGBA sets a raw version of the image.

func (*ImageWriter)Write

func (ir *ImageWriter) Write(buffer []byte) (int,error)

typeIsZeroable

type IsZeroable interface {IsZero()bool}

IsZeroable is a type that returns if it's been set or not.

typeLastValuesProvider

type LastValuesProvider interface {GetLastValues() (x, yfloat64)}

LastValuesProvider is a special type of value provider that can return it's (potentially computed) last value.

typeLinearCoefficientProvider

type LinearCoefficientProvider interface {Coefficients() (m, b, stdev, avgfloat64)}

LinearCoefficientProvider is a type that returns linear coefficients.

typeLinearCoefficientSet

type LinearCoefficientSet struct {Mfloat64Bfloat64StdDevfloat64Avgfloat64}

LinearCoefficientSet is the m and b values for the linear equation in the form:y = (m*x) + b

funcLinearCoefficients

func LinearCoefficients(m, bfloat64)LinearCoefficientSet

LinearCoefficients returns a fixed linear coefficient pair.

funcNormalizedLinearCoefficients

func NormalizedLinearCoefficients(m, b, stdev, avgfloat64)LinearCoefficientSet

NormalizedLinearCoefficients returns a fixed linear coefficient pair.

func (LinearCoefficientSet)Coefficients

func (lcsLinearCoefficientSet) Coefficients() (m, b, stdev, avgfloat64)

Coefficients returns the coefficients.

typeLinearRegressionSeries

type LinearRegressionSeries struct {NamestringStyleStyleYAxisYAxisTypeLimitintOffsetintInnerSeriesValuesProvider// contains filtered or unexported fields}

LinearRegressionSeries is a series that plots the n-nearest neighborslinear regression for the values.

func (*LinearRegressionSeries)Coefficients

func (lrs *LinearRegressionSeries) Coefficients() (m, b, stdev, avgfloat64)

Coefficients returns the linear coefficients for the series.

func (*LinearRegressionSeries)GetEndIndex

func (lrs *LinearRegressionSeries) GetEndIndex()int

GetEndIndex returns the effective limit end.

func (*LinearRegressionSeries)GetFirstValues

func (lrs *LinearRegressionSeries) GetFirstValues() (x, yfloat64)

GetFirstValues computes the first linear regression value.

func (*LinearRegressionSeries)GetLastValues

func (lrs *LinearRegressionSeries) GetLastValues() (x, yfloat64)

GetLastValues computes the last linear regression value.

func (*LinearRegressionSeries)GetLimit

func (lrs *LinearRegressionSeries) GetLimit()int

GetLimit returns the window size.

func (*LinearRegressionSeries)GetName

func (lrs *LinearRegressionSeries) GetName()string

GetName returns the name of the time series.

func (*LinearRegressionSeries)GetOffset

func (lrs *LinearRegressionSeries) GetOffset()int

GetOffset returns the data offset.

func (*LinearRegressionSeries)GetStyle

func (lrs *LinearRegressionSeries) GetStyle()Style

GetStyle returns the line style.

func (*LinearRegressionSeries)GetValues

func (lrs *LinearRegressionSeries) GetValues(indexint) (x, yfloat64)

GetValues gets a value at a given index.

func (*LinearRegressionSeries)GetYAxis

func (lrs *LinearRegressionSeries) GetYAxis()YAxisType

GetYAxis returns which YAxis the series draws on.

func (*LinearRegressionSeries)IsZero

func (lrs *LinearRegressionSeries) IsZero()bool

IsZero returns if we've computed the coefficients or not.

func (*LinearRegressionSeries)Len

func (lrs *LinearRegressionSeries) Len()int

Len returns the number of elements in the series.

func (*LinearRegressionSeries)Render

func (lrs *LinearRegressionSeries) Render(rRenderer, canvasBoxBox, xrange, yrangeRange, defaultsStyle)

Render renders the series.

func (*LinearRegressionSeries)Validate

func (lrs *LinearRegressionSeries) Validate()error

Validate validates the series.

typeLinearSeq

type LinearSeq struct {// contains filtered or unexported fields}

LinearSeq is a stepwise generator.

funcNewLinearSequence

func NewLinearSequence() *LinearSeq

NewLinearSequence returns a new linear generator.

func (*LinearSeq)End

func (lg *LinearSeq) End()float64

End returns the end value.

func (*LinearSeq)GetValue

func (lg *LinearSeq) GetValue(indexint)float64

GetValue returns the value at a given index.

func (*LinearSeq)Len

func (lg *LinearSeq) Len()int

Len returns the number of elements in the seq.

func (*LinearSeq)Start

func (lg *LinearSeq) Start()float64

Start returns the start value.

func (*LinearSeq)Step

func (lg *LinearSeq) Step()float64

Step returns the step value.

func (*LinearSeq)WithEnd

func (lg *LinearSeq) WithEnd(endfloat64) *LinearSeq

WithEnd sets the end and returns the linear generator.

func (*LinearSeq)WithStart

func (lg *LinearSeq) WithStart(startfloat64) *LinearSeq

WithStart sets the start and returns the linear generator.

func (*LinearSeq)WithStep

func (lg *LinearSeq) WithStep(stepfloat64) *LinearSeq

WithStep sets the step and returns the linear generator.

typeLinearSeries

type LinearSeries struct {NamestringStyleStyleYAxisYAxisTypeXValues     []float64InnerSeriesLinearCoefficientProvider// contains filtered or unexported fields}

LinearSeries is a series that plots a line in a given domain.

func (*LinearSeries)GetEndIndex

func (ls *LinearSeries) GetEndIndex()int

GetEndIndex returns the effective limit end.

func (*LinearSeries)GetFirstValues

func (ls *LinearSeries) GetFirstValues() (x, yfloat64)

GetFirstValues computes the first linear regression value.

func (*LinearSeries)GetLastValues

func (ls *LinearSeries) GetLastValues() (x, yfloat64)

GetLastValues computes the last linear regression value.

func (*LinearSeries)GetName

func (ls *LinearSeries) GetName()string

GetName returns the name of the time series.

func (*LinearSeries)GetStyle

func (ls *LinearSeries) GetStyle()Style

GetStyle returns the line style.

func (*LinearSeries)GetValues

func (ls *LinearSeries) GetValues(indexint) (x, yfloat64)

GetValues gets a value at a given index.

func (*LinearSeries)GetYAxis

func (ls *LinearSeries) GetYAxis()YAxisType

GetYAxis returns which YAxis the series draws on.

func (*LinearSeries)IsZero

func (ls *LinearSeries) IsZero()bool

IsZero returns if the linear series has computed coefficients or not.

func (*LinearSeries)Len

func (ls *LinearSeries) Len()int

Len returns the number of elements in the series.

func (*LinearSeries)Render

func (ls *LinearSeries) Render(rRenderer, canvasBoxBox, xrange, yrangeRange, defaultsStyle)

Render renders the series.

func (*LinearSeries)Validate

func (ls *LinearSeries) Validate()error

Validate validates the series.

typeLogarithmicRange

type LogarithmicRange struct {Minfloat64Maxfloat64DomainintDescendingbool}

LogarithmicRange represents a boundary for a set of numbers.

func (*LogarithmicRange)GetDelta

func (r *LogarithmicRange) GetDelta()float64

GetDelta returns the difference between the min and max value.

func (*LogarithmicRange)GetDomain

func (r *LogarithmicRange) GetDomain()int

GetDomain returns the range domain.

func (*LogarithmicRange)GetMax

func (r *LogarithmicRange) GetMax()float64

GetMax returns the max value for the continuous range.

func (*LogarithmicRange)GetMin

func (r *LogarithmicRange) GetMin()float64

GetMin gets the min value for the continuous range.

func (*LogarithmicRange)GetTicks

func (r *LogarithmicRange) GetTicks(vfValueFormatter) []Tick

GetTicks calculates the needed ticks for the axis, in log scale. Only supports Y values > 0.

func (*LogarithmicRange)IsDescending

func (r *LogarithmicRange) IsDescending()bool

IsDescending returns if the range is descending.

func (*LogarithmicRange)IsZero

func (r *LogarithmicRange) IsZero()bool

IsZero returns if the LogarithmicRange has been set or not.

func (*LogarithmicRange)SetDomain

func (r *LogarithmicRange) SetDomain(domainint)

SetDomain sets the range domain.

func (*LogarithmicRange)SetMax

func (r *LogarithmicRange) SetMax(maxfloat64)

SetMax sets the max value for the continuous range.

func (*LogarithmicRange)SetMin

func (r *LogarithmicRange) SetMin(minfloat64)

SetMin sets the min value for the continuous range.

func (*LogarithmicRange)String

func (r *LogarithmicRange) String()string

String returns a simple string for the LogarithmicRange.

func (*LogarithmicRange)Translate

func (r *LogarithmicRange) Translate(valuefloat64)int

Translate maps a given value into the LogarithmicRange space. Modified version from ContinuousRange.

typeMACDLineSeries

type MACDLineSeries struct {NamestringStyleStyleYAxisYAxisTypeInnerSeriesValuesProviderPrimaryPeriodintSecondaryPeriodintSigmafloat64// contains filtered or unexported fields}

MACDLineSeries is a series that computes the inner ema1-ema2 value as a series.

func (*MACDLineSeries)GetName

func (macdl *MACDLineSeries) GetName()string

GetName returns the name of the time series.

func (*MACDLineSeries)GetPeriods

func (macdl *MACDLineSeries) GetPeriods() (w1, w2int)

GetPeriods returns the primary and secondary periods.

func (*MACDLineSeries)GetStyle

func (macdl *MACDLineSeries) GetStyle()Style

GetStyle returns the line style.

func (*MACDLineSeries)GetValues

func (macdl *MACDLineSeries) GetValues(indexint) (xfloat64, yfloat64)

GetValues gets a value at a given index. For MACD it is the signal value.

func (*MACDLineSeries)GetYAxis

func (macdl *MACDLineSeries) GetYAxis()YAxisType

GetYAxis returns which YAxis the series draws on.

func (*MACDLineSeries)Len

func (macdl *MACDLineSeries) Len()int

Len returns the number of elements in the series.

func (*MACDLineSeries)Render

func (macdl *MACDLineSeries) Render(rRenderer, canvasBoxBox, xrange, yrangeRange, defaultsStyle)

Render renders the series.

func (*MACDLineSeries)Validate

func (macdl *MACDLineSeries) Validate()error

Validate validates the series.

typeMACDSeries

type MACDSeries struct {NamestringStyleStyleYAxisYAxisTypeInnerSeriesValuesProviderPrimaryPeriodintSecondaryPeriodintSignalPeriodint// contains filtered or unexported fields}

MACDSeries computes the difference between the MACD line and the MACD Signal line.It is used in technical analysis and gives a lagging indicator of momentum.

func (*MACDSeries)GetName

func (macd *MACDSeries) GetName()string

GetName returns the name of the time series.

func (*MACDSeries)GetPeriods

func (macd *MACDSeries) GetPeriods() (w1, w2, sigint)

GetPeriods returns the primary and secondary periods.

func (*MACDSeries)GetStyle

func (macd *MACDSeries) GetStyle()Style

GetStyle returns the line style.

func (*MACDSeries)GetValues

func (macd *MACDSeries) GetValues(indexint) (xfloat64, yfloat64)

GetValues gets a value at a given index. For MACD it is the signal value.

func (*MACDSeries)GetYAxis

func (macd *MACDSeries) GetYAxis()YAxisType

GetYAxis returns which YAxis the series draws on.

func (*MACDSeries)Len

func (macd *MACDSeries) Len()int

Len returns the number of elements in the series.

func (*MACDSeries)Validate

func (macd *MACDSeries) Validate()error

Validate validates the series.

typeMACDSignalSeries

type MACDSignalSeries struct {NamestringStyleStyleYAxisYAxisTypeInnerSeriesValuesProviderPrimaryPeriodintSecondaryPeriodintSignalPeriodint// contains filtered or unexported fields}

MACDSignalSeries computes the EMA of the MACDLineSeries.

func (*MACDSignalSeries)GetName

func (macds *MACDSignalSeries) GetName()string

GetName returns the name of the time series.

func (*MACDSignalSeries)GetPeriods

func (macds *MACDSignalSeries) GetPeriods() (w1, w2, sigint)

GetPeriods returns the primary and secondary periods.

func (*MACDSignalSeries)GetStyle

func (macds *MACDSignalSeries) GetStyle()Style

GetStyle returns the line style.

func (*MACDSignalSeries)GetValues

func (macds *MACDSignalSeries) GetValues(indexint) (xfloat64, yfloat64)

GetValues gets a value at a given index. For MACD it is the signal value.

func (*MACDSignalSeries)GetYAxis

func (macds *MACDSignalSeries) GetYAxis()YAxisType

GetYAxis returns which YAxis the series draws on.

func (*MACDSignalSeries)Len

func (macds *MACDSignalSeries) Len()int

Len returns the number of elements in the series.

func (*MACDSignalSeries)Render

func (macds *MACDSignalSeries) Render(rRenderer, canvasBoxBox, xrange, yrangeRange, defaultsStyle)

Render renders the series.

func (*MACDSignalSeries)Validate

func (macds *MACDSignalSeries) Validate()error

Validate validates the series.

typeMaxSeries

type MaxSeries struct {NamestringStyleStyleYAxisYAxisTypeInnerSeriesValuesProvider// contains filtered or unexported fields}

MaxSeries draws a horizontal line at the maximum value of the inner series.

func (*MaxSeries)GetName

func (ms *MaxSeries) GetName()string

GetName returns the name of the time series.

func (*MaxSeries)GetStyle

func (ms *MaxSeries) GetStyle()Style

GetStyle returns the line style.

func (*MaxSeries)GetValues

func (ms *MaxSeries) GetValues(indexint) (x, yfloat64)

GetValues gets a value at a given index.

func (*MaxSeries)GetYAxis

func (ms *MaxSeries) GetYAxis()YAxisType

GetYAxis returns which YAxis the series draws on.

func (*MaxSeries)Len

func (ms *MaxSeries) Len()int

Len returns the number of elements in the series.

func (*MaxSeries)Render

func (ms *MaxSeries) Render(rRenderer, canvasBoxBox, xrange, yrangeRange, defaultsStyle)

Render renders the series.

func (*MaxSeries)Validate

func (ms *MaxSeries) Validate()error

Validate validates the series.

typeMinSeries

type MinSeries struct {NamestringStyleStyleYAxisYAxisTypeInnerSeriesValuesProvider// contains filtered or unexported fields}

MinSeries draws a horizontal line at the minimum value of the inner series.

func (*MinSeries)GetName

func (ms *MinSeries) GetName()string

GetName returns the name of the time series.

func (*MinSeries)GetStyle

func (ms *MinSeries) GetStyle()Style

GetStyle returns the line style.

func (*MinSeries)GetValues

func (ms *MinSeries) GetValues(indexint) (x, yfloat64)

GetValues gets a value at a given index.

func (*MinSeries)GetYAxis

func (ms *MinSeries) GetYAxis()YAxisType

GetYAxis returns which YAxis the series draws on.

func (*MinSeries)Len

func (ms *MinSeries) Len()int

Len returns the number of elements in the series.

func (*MinSeries)Render

func (ms *MinSeries) Render(rRenderer, canvasBoxBox, xrange, yrangeRange, defaultsStyle)

Render renders the series.

func (*MinSeries)Validate

func (ms *MinSeries) Validate()error

Validate validates the series.

typeNameProvider

type NameProvider interface {GetName()string}

NameProvider is a type that returns a name.

typePercentChangeSeries

type PercentChangeSeries struct {NamestringStyleStyleYAxisYAxisTypeInnerSeriesPercentChangeSeriesSource}

PercentChangeSeries applies apercentage difference function to a given continuous series.

func (PercentChangeSeries)GetFirstValues

func (pcsPercentChangeSeries) GetFirstValues() (x, yfloat64)

GetFirstValues returns the first x and y values of the inner series (for FirstValuesProvider interface).

func (PercentChangeSeries)GetLastValues

func (pcsPercentChangeSeries) GetLastValues() (x, yfloat64)

GetLastValues gets the last values.

func (PercentChangeSeries)GetName

func (pcsPercentChangeSeries) GetName()string

GetName returns the name of the time series.

func (PercentChangeSeries)GetStyle

func (pcsPercentChangeSeries) GetStyle()Style

GetStyle returns the line style.

func (PercentChangeSeries)GetValueFormatters

func (pcsPercentChangeSeries) GetValueFormatters() (x, yValueFormatter)

GetValueFormatters returns value formatter defaults for the series.

func (PercentChangeSeries)GetValues

func (pcsPercentChangeSeries) GetValues(indexint) (x, yfloat64)

GetValues gets x, y values at a given index.

func (PercentChangeSeries)GetYAxis

func (pcsPercentChangeSeries) GetYAxis()YAxisType

GetYAxis returns which YAxis the series draws on.

func (PercentChangeSeries)Len

func (pcsPercentChangeSeries) Len()int

Len returns the number of elements in the inner series (for Series interface).

func (PercentChangeSeries)Render

func (pcsPercentChangeSeries) Render(rRenderer, canvasBoxBox, xrange, yrangeRange, defaultsStyle)

Render renders the series.

func (PercentChangeSeries)Validate

func (pcsPercentChangeSeries) Validate()error

Validate validates the series.

typePercentChangeSeriesSource

PercentChangeSeriesSource is a series thatcan be used with a PercentChangeSeries

typePieChart

type PieChart struct {TitlestringTitleStyleStyleColorPaletteColorPaletteWidthintHeightintDPIfloat64BackgroundStyleCanvasStyleSliceStyleStyleFont *truetype.FontValues   []ValueElements []Renderable}

PieChart is a chart that draws sections of a circle based on percentages.

func (PieChart)Box

func (pcPieChart) Box()Box

Box returns the chart bounds as a box.

func (PieChart)GetColorPalette

func (pcPieChart) GetColorPalette()ColorPalette

GetColorPalette returns the color palette for the chart.

func (PieChart)GetDPI

func (pcPieChart) GetDPI(defaults ...float64)float64

GetDPI returns the dpi for the chart.

func (PieChart)GetFont

func (pcPieChart) GetFont() *truetype.Font

GetFont returns the text font.

func (PieChart)GetHeight

func (pcPieChart) GetHeight()int

GetHeight returns the chart height or the default value.

func (PieChart)GetWidth

func (pcPieChart) GetWidth()int

GetWidth returns the chart width or the default value.

func (PieChart)Render

Render renders the chart with the given renderer to the given io.Writer.

typePoint

type Point struct {X, Yint}

Point is an X,Y pair

func (Point)DistanceTo

func (pPoint) DistanceTo(otherPoint)float64

DistanceTo calculates the distance to another point.

func (Point)Equals

func (pPoint) Equals(otherPoint)bool

Equals returns if a point equals another point.

func (Point)String

func (pPoint) String()string

String returns a string representation of the point.

typePolynomialRegressionSeries

type PolynomialRegressionSeries struct {NamestringStyleStyleYAxisYAxisTypeLimitintOffsetintDegreeintInnerSeriesValuesProvider// contains filtered or unexported fields}

PolynomialRegressionSeries implements a polynomial regression over a given inner series.

func (*PolynomialRegressionSeries)GetEndIndex

func (prs *PolynomialRegressionSeries) GetEndIndex()int

GetEndIndex returns the effective limit end.

func (*PolynomialRegressionSeries)GetFirstValues

func (prs *PolynomialRegressionSeries) GetFirstValues() (x, yfloat64)

GetFirstValues computes the first poly regression value.

func (*PolynomialRegressionSeries)GetLastValues

func (prs *PolynomialRegressionSeries) GetLastValues() (x, yfloat64)

GetLastValues computes the last poly regression value.

func (*PolynomialRegressionSeries)GetLimit

func (prs *PolynomialRegressionSeries) GetLimit()int

GetLimit returns the window size.

func (*PolynomialRegressionSeries)GetName

func (prs *PolynomialRegressionSeries) GetName()string

GetName returns the name of the time series.

func (*PolynomialRegressionSeries)GetOffset

func (prs *PolynomialRegressionSeries) GetOffset()int

GetOffset returns the data offset.

func (*PolynomialRegressionSeries)GetStyle

func (prs *PolynomialRegressionSeries) GetStyle()Style

GetStyle returns the line style.

func (*PolynomialRegressionSeries)GetValues

func (prs *PolynomialRegressionSeries) GetValues(indexint) (x, yfloat64)

GetValues returns the series value for a given index.

func (*PolynomialRegressionSeries)GetYAxis

GetYAxis returns which YAxis the series draws on.

func (*PolynomialRegressionSeries)Len

Len returns the number of elements in the series.

func (*PolynomialRegressionSeries)Render

func (prs *PolynomialRegressionSeries) Render(rRenderer, canvasBoxBox, xrange, yrangeRange, defaultsStyle)

Render renders the series.

func (*PolynomialRegressionSeries)Validate

func (prs *PolynomialRegressionSeries) Validate()error

Validate validates the series.

typeRGBACollector

type RGBACollector interface {SetRGBA(i *image.RGBA)}

RGBACollector is a render target for a chart.

typeRandomSeq

type RandomSeq struct {// contains filtered or unexported fields}

RandomSeq is a random number seq generator.

funcNewRandomSequence

func NewRandomSequence() *RandomSeq

NewRandomSequence creates a new random seq.

func (*RandomSeq)GetValue

func (r *RandomSeq) GetValue(_int)float64

GetValue returns the value.

func (*RandomSeq)Len

func (r *RandomSeq) Len()int

Len returns the number of elements that will be generated.

func (*RandomSeq)Max

func (r *RandomSeq) Max() *float64

Max returns the maximum value.

func (*RandomSeq)Min

func (r *RandomSeq) Min() *float64

Min returns the minimum value.

func (*RandomSeq)WithLen

func (r *RandomSeq) WithLen(lengthint) *RandomSeq

WithLen sets a maximum len

func (*RandomSeq)WithMax

func (r *RandomSeq) WithMax(maxfloat64) *RandomSeq

WithMax sets the average and returns the Random.

func (*RandomSeq)WithMin

func (r *RandomSeq) WithMin(minfloat64) *RandomSeq

WithMin sets the scale and returns the Random.

typeRange

type Range interface {StringableIsZeroableGetMin()float64SetMin(minfloat64)GetMax()float64SetMax(maxfloat64)GetDelta()float64GetDomain()intSetDomain(domainint)IsDescending()bool// Translate the range to the domain.Translate(valuefloat64)int}

Range is a common interface for a range of values.

typeRenderable

type Renderable func(rRenderer, canvasBoxBox, defaultsStyle)

Renderable is a function that can be called to render custom elements on the chart.

funcLegend

func Legend(c *Chart, userDefaults ...Style)Renderable

Legend returns a legend renderable function.

funcLegendLeft

func LegendLeft(c *Chart, userDefaults ...Style)Renderable

LegendLeft is a legend that is designed for longer series lists.

funcLegendThin

func LegendThin(c *Chart, userDefaults ...Style)Renderable

LegendThin is a legend that doesn't obscure the chart area.

typeRenderer

type Renderer interface {// ResetStyle should reset any style related settings on the renderer.ResetStyle()// GetDPI gets the DPI for the renderer.GetDPI()float64// SetDPI sets the DPI for the renderer.SetDPI(dpifloat64)// SetClassName sets the current class name.SetClassName(string)// SetStrokeColor sets the current stroke color.SetStrokeColor(drawing.Color)// SetFillColor sets the current fill color.SetFillColor(drawing.Color)// SetStrokeWidth sets the stroke width.SetStrokeWidth(widthfloat64)// SetStrokeDashArray sets the stroke dash array.SetStrokeDashArray(dashArray []float64)// MoveTo moves the cursor to a given point.MoveTo(x, yint)// LineTo both starts a shape and draws a line to a given point// from the previous point.LineTo(x, yint)// QuadCurveTo draws a quad curve.// cx and cy represent the bezier "control points".QuadCurveTo(cx, cy, x, yint)// ArcTo draws an arc with a given center (cx,cy)// a given set of radii (rx,ry), a startAngle and delta (in radians).ArcTo(cx, cyint, rx, ry, startAngle, deltafloat64)// Close finalizes a shape as drawn by LineTo.Close()// Stroke strokes the path.Stroke()// Fill fills the path, but does not stroke.Fill()// FillStroke fills and strokes a path.FillStroke()// Circle draws a circle at the given coords with a given radius.Circle(radiusfloat64, x, yint)// SetFont sets a font for a text field.SetFont(*truetype.Font)// SetFontColor sets a font's colorSetFontColor(drawing.Color)// SetFontSize sets the font size for a text field.SetFontSize(sizefloat64)// Text draws a text blob.Text(bodystring, x, yint)// MeasureText measures text.MeasureText(bodystring)Box// SetTextRotation sets a rotation for drawing elements.SetTextRotation(radiansfloat64)// ClearTextRotation clears rotation.ClearTextRotation()// Save writes the image to the given writer.Save(wio.Writer)error}

Renderer represents the basic methods required to draw a chart.

funcJPGadded inv0.5.1

func JPG(width, heightint)Renderer

JPG returns a new jpg raster renderer.

funcPNG

func PNG(width, heightint)Renderer

PNG returns a new png raster renderer.

funcSVG

func SVG(width, heightint)Renderer

SVG returns a new png/raster renderer.

typeRendererProvider

type RendererProvider func(int,int)Renderer

RendererProvider is a function that returns a renderer.

typeSMASeries

type SMASeries struct {NamestringStyleStyleYAxisYAxisTypePeriodintInnerSeriesValuesProvider}

SMASeries is a computed series.

func (SMASeries)GetFirstValues

func (smaSMASeries) GetFirstValues() (x, yfloat64)

GetFirstValues computes the first moving average value.

func (SMASeries)GetLastValues

func (smaSMASeries) GetLastValues() (x, yfloat64)

GetLastValues computes the last moving average value but walking back window size samples,and recomputing the last moving average chunk.

func (SMASeries)GetName

func (smaSMASeries) GetName()string

GetName returns the name of the time series.

func (SMASeries)GetPeriod

func (smaSMASeries) GetPeriod(defaults ...int)int

GetPeriod returns the window size.

func (SMASeries)GetStyle

func (smaSMASeries) GetStyle()Style

GetStyle returns the line style.

func (SMASeries)GetValues

func (smaSMASeries) GetValues(indexint) (x, yfloat64)

GetValues gets a value at a given index.

func (SMASeries)GetYAxis

func (smaSMASeries) GetYAxis()YAxisType

GetYAxis returns which YAxis the series draws on.

func (SMASeries)Len

func (smaSMASeries) Len()int

Len returns the number of elements in the series.

func (SMASeries)Render

func (smaSMASeries) Render(rRenderer, canvasBoxBox, xrange, yrangeRange, defaultsStyle)

Render renders the series.

func (SMASeries)Validate

func (smaSMASeries) Validate()error

Validate validates the series.

typeSeq

type Seq struct {Sequence}

Seq is a utility wrapper for seq providers.

funcValueSequence

func ValueSequence(values ...float64)Seq

ValueSequence returns a sequence for a given values set.

func (Seq)Average

func (sSeq) Average()float64

Average returns the float average of the values in the buffer.

func (Seq)Each

func (sSeq) Each(mapfn func(int,float64))

Each applies the `mapfn` to all values in the value provider.

func (Seq)FoldLeft

func (sSeq) FoldLeft(mapfn func(iint, v0, vfloat64)float64) (v0float64)

FoldLeft collapses a seq from left to right.

func (Seq)FoldRight

func (sSeq) FoldRight(mapfn func(iint, v0, vfloat64)float64) (v0float64)

FoldRight collapses a seq from right to left.

func (Seq)Map

func (sSeq) Map(mapfn func(iint, vfloat64)float64)Seq

Map applies the `mapfn` to all values in the value provider,returning a new seq.

func (Seq)Max

func (sSeq) Max()float64

Max returns the maximum value in the seq.

func (Seq)Median

func (sSeq) Median() (medianfloat64)

Median returns the median or middle value in the sorted seq.

func (Seq)Min

func (sSeq) Min()float64

Min returns the minimum value in the seq.

func (Seq)MinMax

func (sSeq) MinMax() (min, maxfloat64)

MinMax returns the minimum and the maximum in one pass.

func (Seq)Normalize

func (sSeq) Normalize()Seq

Normalize maps every value to the interval [0, 1.0].

func (Seq)Percentile

func (sSeq) Percentile(percentfloat64) (percentilefloat64)

Percentile finds the relative standing in a slice of floats.`percent` should be given on the interval [0,1.0).

func (Seq)Reverse

func (sSeq) Reverse()Seq

Reverse reverses the sequence

func (Seq)Sort

func (sSeq) Sort()Seq

Sort returns the seq sorted in ascending order.This fully enumerates the seq.

func (Seq)StdDev

func (sSeq) StdDev()float64

StdDev returns the standard deviation.

func (Seq)Sum

func (sSeq) Sum() (accumfloat64)

Sum adds all the elements of a series together.

func (Seq)Values

func (sSeq) Values() (output []float64)

Values enumerates the seq into a slice.

func (Seq)Variance

func (sSeq) Variance()float64

Variance computes the variance of the buffer.

typeSequence

type Sequence interface {Len()intGetValue(int)float64}

Sequence is a provider for values for a seq.

typeSeries

type Series interface {GetName()stringGetYAxis()YAxisTypeGetStyle()StyleValidate()errorRender(rRenderer, canvasBoxBox, xrange, yrangeRange, sStyle)}

Series is an alias to Renderable.

typeSizeProvider

type SizeProvider func(xrange, yrangeRange, indexint, x, yfloat64)float64

SizeProvider is a provider for integer size.

typeStackedBar

type StackedBar struct {NamestringWidthintValues []Value}

StackedBar is a bar within a StackedBarChart.

func (StackedBar)GetWidth

func (sbStackedBar) GetWidth()int

GetWidth returns the width of the bar.

typeStackedBarChart

type StackedBarChart struct {TitlestringTitleStyleStyleColorPaletteColorPaletteWidthintHeightintDPIfloat64BackgroundStyleCanvasStyleXAxisStyleYAxisStyleBarSpacingintFont *truetype.FontIsHorizontalboolBars     []StackedBarElements []Renderable}

StackedBarChart is a chart that draws sections of a bar based on percentages.

func (StackedBarChart)Box

func (sbcStackedBarChart) Box()Box

Box returns the chart bounds as a box.

func (StackedBarChart)GetBarSpacing

func (sbcStackedBarChart) GetBarSpacing()int

GetBarSpacing returns the spacing between bars.

func (StackedBarChart)GetColorPalette

func (sbcStackedBarChart) GetColorPalette()ColorPalette

GetColorPalette returns the color palette for the chart.

func (StackedBarChart)GetDPI

func (sbcStackedBarChart) GetDPI(defaults ...float64)float64

GetDPI returns the dpi for the chart.

func (StackedBarChart)GetFont

func (sbcStackedBarChart) GetFont() *truetype.Font

GetFont returns the text font.

func (StackedBarChart)GetHeight

func (sbcStackedBarChart) GetHeight()int

GetHeight returns the chart height or the default value.

func (StackedBarChart)GetWidth

func (sbcStackedBarChart) GetWidth()int

GetWidth returns the chart width or the default value.

func (StackedBarChart)Render

Render renders the chart with the given renderer to the given io.Writer.

typeStringable

type Stringable interface {String()string}

Stringable is a type that has a string representation.

typeStyle

type Style struct {FontStyleHiddenboolPaddingBoxClassNamestringStrokeWidthfloat64StrokeColordrawing.ColorStrokeDashArray []float64DotColordrawing.ColorDotWidthfloat64DotWidthProviderSizeProviderDotColorProviderDotColorProviderFillColordrawing.ColorTextHorizontalAlignTextHorizontalAlignTextVerticalAlignTextVerticalAlignTextWrapTextWrapTextLineSpacingintTextRotationDegreesfloat64//0 is unset or normal}

Style is a simple style set.

funcHidden

func Hidden()Style

Hidden is a prebuilt style with the `Hidden` property set to true.

funcShown

func Shown()Style

Shown is a prebuilt style with the `Hidden` property set to false.You can also think of this as the default.

funcStyleTextDefaults

func StyleTextDefaults()Style

StyleTextDefaults returns a style for drawing outside a chart context.

func (Style)GetClassName

func (sStyle) GetClassName(defaults ...string)string

GetClassName returns the class name or a default.

func (Style)GetDotColor

func (sStyle) GetDotColor(defaults ...drawing.Color)drawing.Color

GetDotColor returns the stroke color.

func (Style)GetDotOptions

func (sStyle) GetDotOptions()Style

GetDotOptions returns the dot components.

func (Style)GetDotWidth

func (sStyle) GetDotWidth(defaults ...float64)float64

GetDotWidth returns the dot width for scatter plots.

func (Style)GetFillAndStrokeOptions

func (sStyle) GetFillAndStrokeOptions()Style

GetFillAndStrokeOptions returns the fill and stroke components.

func (Style)GetFillColor

func (sStyle) GetFillColor(defaults ...drawing.Color)drawing.Color

GetFillColor returns the fill color.

func (Style)GetFillOptions

func (sStyle) GetFillOptions()Style

GetFillOptions returns the fill components.

func (Style)GetPadding

func (sStyle) GetPadding(defaults ...Box)Box

GetPadding returns the padding.

func (Style)GetStrokeColor

func (sStyle) GetStrokeColor(defaults ...drawing.Color)drawing.Color

GetStrokeColor returns the stroke color.

func (Style)GetStrokeDashArray

func (sStyle) GetStrokeDashArray(defaults ...[]float64) []float64

GetStrokeDashArray returns the stroke dash array.

func (Style)GetStrokeOptions

func (sStyle) GetStrokeOptions()Style

GetStrokeOptions returns the stroke components.

func (Style)GetStrokeWidth

func (sStyle) GetStrokeWidth(defaults ...float64)float64

GetStrokeWidth returns the stroke width.

func (Style)GetTextHorizontalAlign

func (sStyle) GetTextHorizontalAlign(defaults ...TextHorizontalAlign)TextHorizontalAlign

GetTextHorizontalAlign returns the horizontal alignment.

func (Style)GetTextLineSpacing

func (sStyle) GetTextLineSpacing(defaults ...int)int

GetTextLineSpacing returns the spacing in pixels between lines of text (vertically).

func (Style)GetTextOptions

func (sStyle) GetTextOptions()Style

GetTextOptions returns just the text components of the style.

func (Style)GetTextRotationDegrees

func (sStyle) GetTextRotationDegrees(defaults ...float64)float64

GetTextRotationDegrees returns the text rotation in degrees.

func (Style)GetTextVerticalAlign

func (sStyle) GetTextVerticalAlign(defaults ...TextVerticalAlign)TextVerticalAlign

GetTextVerticalAlign returns the vertical alignment.

func (Style)GetTextWrap

func (sStyle) GetTextWrap(defaults ...TextWrap)TextWrap

GetTextWrap returns the word wrap.

func (Style)InheritFrom

func (sStyle) InheritFrom(defaultsStyle) (finalStyle)

InheritFrom coalesces two styles into a new style.

func (Style)IsZero

func (sStyle) IsZero()bool

IsZero returns if the object is set or not.

func (Style)ShouldDrawDot

func (sStyle) ShouldDrawDot()bool

ShouldDrawDot tells drawing functions if they should draw the dot.

func (Style)ShouldDrawFill

func (sStyle) ShouldDrawFill()bool

ShouldDrawFill tells drawing functions if they should draw the stroke.

func (Style)ShouldDrawStroke

func (sStyle) ShouldDrawStroke()bool

ShouldDrawStroke tells drawing functions if they should draw the stroke.

func (Style)String

func (sStyle) String()string

String returns a text representation of the style.

func (Style)WriteDrawingOptionsToRenderer

func (sStyle) WriteDrawingOptionsToRenderer(rRenderer)

WriteDrawingOptionsToRenderer passes just the drawing style options to a renderer.

func (Style)WriteToRenderer

func (sStyle) WriteToRenderer(rRenderer)

WriteToRenderer passes the style's options to a renderer.

typeStyleProvider

type StyleProvider interface {GetStyle()Style}

StyleProvider is a type that returns a style.

typeTextHorizontalAlign

type TextHorizontalAlignint

TextHorizontalAlign is an enum for the horizontal alignment options.

const (// TextHorizontalAlignUnset is the unset state for text horizontal alignment.TextHorizontalAlignUnsetTextHorizontalAlign = 0// TextHorizontalAlignLeft aligns a string horizontally so that it's left ligature starts at horizontal pixel 0.TextHorizontalAlignLeftTextHorizontalAlign = 1// 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.TextHorizontalAlignCenterTextHorizontalAlign = 2// TextHorizontalAlignRight right aligns a string horizontally so that the right ligature ends at the right-most pixel// of a box.TextHorizontalAlignRightTextHorizontalAlign = 3)

typeTextStyle

type TextStyle struct {HorizontalAlignTextHorizontalAlignVerticalAlignTextVerticalAlignWrapTextWrap}

TextStyle encapsulates text style options.

typeTextVerticalAlign

type TextVerticalAlignint

TextVerticalAlign is an enum for the vertical alignment options.

const (// TextVerticalAlignUnset is the unset state for vertical alignment options.TextVerticalAlignUnsetTextVerticalAlign = 0// TextVerticalAlignBaseline aligns text according to the "baseline" of the string, or where a normal ascender begins.TextVerticalAlignBaselineTextVerticalAlign = 1// TextVerticalAlignBottom aligns the text according to the lowers pixel of any of the ligatures (ex. g or q both extend below the baseline).TextVerticalAlignBottomTextVerticalAlign = 2// TextVerticalAlignMiddle aligns the text so that there is an equal amount of space above and below the top and bottom of the ligatures.TextVerticalAlignMiddleTextVerticalAlign = 3// TextVerticalAlignMiddleBaseline aligns the text vertically so that there is an equal number of pixels above and below the baseline of the string.TextVerticalAlignMiddleBaselineTextVerticalAlign = 4// TextVerticalAlignTop aligns the text so that the top of the ligatures are at y-pixel 0 in the container.TextVerticalAlignTopTextVerticalAlign = 5)

typeTextWrap

type TextWrapint

TextWrap is an enum for the word wrap options.

const (// TextWrapUnset is the unset state for text wrap options.TextWrapUnsetTextWrap = 0// TextWrapNone will spill text past horizontal boundaries.TextWrapNoneTextWrap = 1// TextWrapWord will split a string on words (i.e. spaces) to fit within a horizontal boundary.TextWrapWordTextWrap = 2// TextWrapRune will split a string on a rune (i.e. utf-8 codepage) to fit within a horizontal boundary.TextWrapRuneTextWrap = 3)

typeTick

type Tick struct {Valuefloat64Labelstring}

Tick represents a label on an axis.

funcGenerateContinuousTicks

func GenerateContinuousTicks(rRenderer, raRange, isVerticalbool, styleStyle, vfValueFormatter) []Tick

GenerateContinuousTicks generates a set of ticks.

typeTickPosition

type TickPositionint

TickPosition is an enumeration of possible tick drawing positions.

const (// TickPositionUnset means to use the default tick position.TickPositionUnsetTickPosition = 0// TickPositionBetweenTicks draws the labels for a tick between the previous and current tick.TickPositionBetweenTicksTickPosition = 1// TickPositionUnderTick draws the tick below the tick.TickPositionUnderTickTickPosition = 2)

typeTicks

type Ticks []Tick

Ticks is an array of ticks.

func (Ticks)Len

func (tTicks) Len()int

Len returns the length of the ticks set.

func (Ticks)Less

func (tTicks) Less(i, jint)bool

Less returns if i's value is less than j's value.

func (Ticks)String

func (tTicks) String()string

String returns a string representation of the set of ticks.

func (Ticks)Swap

func (tTicks) Swap(i, jint)

Swap swaps two elements.

typeTicksProvider

type TicksProvider interface {GetTicks(vfValueFormatter) []Tick}

TicksProvider is a type that provides ticks.

typeTimeSeries

type TimeSeries struct {NamestringStyleStyleYAxisYAxisTypeXValues []time.TimeYValues []float64}

TimeSeries is a line on a chart.

func (TimeSeries)GetFirstValues

func (tsTimeSeries) GetFirstValues() (x, yfloat64)

GetFirstValues gets the first values.

func (TimeSeries)GetLastValues

func (tsTimeSeries) GetLastValues() (x, yfloat64)

GetLastValues gets the last values.

func (TimeSeries)GetName

func (tsTimeSeries) GetName()string

GetName returns the name of the time series.

func (TimeSeries)GetStyle

func (tsTimeSeries) GetStyle()Style

GetStyle returns the line style.

func (TimeSeries)GetValueFormatters

func (tsTimeSeries) GetValueFormatters() (x, yValueFormatter)

GetValueFormatters returns value formatter defaults for the series.

func (TimeSeries)GetValues

func (tsTimeSeries) GetValues(indexint) (x, yfloat64)

GetValues gets x, y values at a given index.

func (TimeSeries)GetYAxis

func (tsTimeSeries) GetYAxis()YAxisType

GetYAxis returns which YAxis the series draws on.

func (TimeSeries)Len

func (tsTimeSeries) Len()int

Len returns the number of elements in the series.

func (TimeSeries)Render

func (tsTimeSeries) Render(rRenderer, canvasBoxBox, xrange, yrangeRange, defaultsStyle)

Render renders the series.

func (TimeSeries)Validate

func (tsTimeSeries) Validate()error

Validate validates the series.

typeTimes

type Times []time.Time

Times are an array of times.It wraps the array with methods that implement `seq.Provider`.

func (Times)Array

func (tTimes) Array() []time.Time

Array returns the times to an array.

func (Times)GetValue

func (tTimes) GetValue(indexint)float64

GetValue returns a value at an index as a time.

func (Times)Len

func (tTimes) Len()int

Len returns the length of the array.

func (Times)Less

func (tTimes) Less(i, jint)bool

Less reports whether the time at i occurs before the time at j.

func (Times)Swap

func (tTimes) Swap(i, jint)

Swap exchanges the time values at indexes i and j.

typeValue

type Value struct {StyleStyleLabelstringValuefloat64}

Value is a chart value.

typeValue2

type Value2 struct {StyleStyleLabelstringXValue, YValuefloat64}

Value2 is a two axis value.

typeValueBuffer

type ValueBuffer struct {// contains filtered or unexported fields}

ValueBuffer is a fifo data structure that is backed by a pre-allocated array.Instead of allocating a whole new node object for each element, array elements are re-used (which saves GC churn).Enqueue can be O(n), Dequeue is generally O(1).Buffer implements `seq.Provider`.

funcNewValueBuffer

func NewValueBuffer(values ...float64) *ValueBuffer

NewValueBuffer creates a new value buffer with an optional set of values.

funcNewValueBufferWithCapacity

func NewValueBufferWithCapacity(capacityint) *ValueBuffer

NewValueBufferWithCapacity creates a new ValueBuffer pre-allocated with the given capacity.

func (*ValueBuffer)Array

func (b *ValueBuffer) Array()Array

Array returns the ring buffer, in order, as an array.

func (*ValueBuffer)Capacity

func (b *ValueBuffer) Capacity()int

Capacity returns the total size of the Buffer, including empty elements.

func (*ValueBuffer)Clear

func (b *ValueBuffer) Clear()

Clear removes all objects from the Buffer.

func (*ValueBuffer)Dequeue

func (b *ValueBuffer) Dequeue()float64

Dequeue removes the first element from the RingBuffer.

func (*ValueBuffer)Each

func (b *ValueBuffer) Each(mapfn func(int,float64))

Each calls the consumer for each element in the buffer.

func (*ValueBuffer)Enqueue

func (b *ValueBuffer) Enqueue(valuefloat64)

Enqueue adds an element to the "back" of the Buffer.

func (*ValueBuffer)GetValue

func (b *ValueBuffer) GetValue(indexint)float64

GetValue returns the value stored at the provided index.

func (*ValueBuffer)Len

func (b *ValueBuffer) Len()int

Len returns the length of the Buffer (as it is currently populated).Actual memory footprint may be different.

func (*ValueBuffer)Peek

func (b *ValueBuffer) Peek()float64

Peek returns but does not remove the first element.

func (*ValueBuffer)PeekBack

func (b *ValueBuffer) PeekBack()float64

PeekBack returns but does not remove the last element.

func (*ValueBuffer)SetCapacity

func (b *ValueBuffer) SetCapacity(capacityint)

SetCapacity sets the capacity of the Buffer.

func (*ValueBuffer)String

func (b *ValueBuffer) String()string

String returns a string representation for value buffers.

func (*ValueBuffer)TrimExcess

func (b *ValueBuffer) TrimExcess()

TrimExcess resizes the capacity of the buffer to better fit the contents.

typeValueFormatter

type ValueFormatter func(v interface{})string

ValueFormatter is a function that takes a value and produces a string.

funcKValueFormatter

func KValueFormatter(kfloat64, vfValueFormatter)ValueFormatter

KValueFormatter is a formatter for K values.

funcTimeValueFormatterWithFormat

func TimeValueFormatterWithFormat(formatstring)ValueFormatter

TimeValueFormatterWithFormat returns a time formatter with a given format.

typeValueFormatterProvider

type ValueFormatterProvider interface {GetValueFormatters() (x, yValueFormatter)}

ValueFormatterProvider is a series that has custom formatters.

typeValues

type Values []Value

Values is an array of Value.

func (Values)Normalize

func (vsValues) Normalize() []Value

Normalize returns the values normalized.

func (Values)Values

func (vsValues) Values() []float64

Values returns the values.

func (Values)ValuesNormalized

func (vsValues) ValuesNormalized() []float64

ValuesNormalized returns normalized values.

typeValuesProvider

type ValuesProvider interface {Len()intGetValues(indexint) (float64,float64)}

ValuesProvider is a type that produces values.

typeXAxis

type XAxis struct {NamestringNameStyleStyleStyleStyleValueFormatterValueFormatterRangeRangeTickStyleStyleTicks        []TickTickPositionTickPositionGridLines      []GridLineGridMajorStyleStyleGridMinorStyleStyle}

XAxis represents the horizontal axis.

funcHideXAxis

func HideXAxis()XAxis

HideXAxis hides the x-axis.

func (XAxis)GetGridLines

func (xaXAxis) GetGridLines(ticks []Tick) []GridLine

GetGridLines returns the gridlines for the axis.

func (XAxis)GetName

func (xaXAxis) GetName()string

GetName returns the name.

func (XAxis)GetStyle

func (xaXAxis) GetStyle()Style

GetStyle returns the style.

func (XAxis)GetTickPosition

func (xaXAxis) GetTickPosition(defaults ...TickPosition)TickPosition

GetTickPosition returns the tick position option for the axis.

func (XAxis)GetTicks

func (xaXAxis) GetTicks(rRenderer, raRange, defaultsStyle, vfValueFormatter) []Tick

GetTicks returns the ticks for a series.The coalesce priority is:

  • User Supplied Ticks (i.e. Ticks array on the axis itself).
  • Range ticks (i.e. if the range provides ticks).
  • Generating continuous ticks based on minimum spacing and canvas width.

func (XAxis)GetValueFormatter

func (xaXAxis) GetValueFormatter()ValueFormatter

GetValueFormatter returns the value formatter for the axis.

func (XAxis)Measure

func (xaXAxis) Measure(rRenderer, canvasBoxBox, raRange, defaultsStyle, ticks []Tick)Box

Measure returns the bounds of the axis.

func (XAxis)Render

func (xaXAxis) Render(rRenderer, canvasBoxBox, raRange, defaultsStyle, ticks []Tick)

Render renders the axis

typeYAxis

type YAxis struct {NamestringNameStyleStyleStyleStyleZeroGridLineAxisTypeYAxisTypeAscendingboolValueFormatterValueFormatterRangeRangeTickStyleStyleTicks     []TickGridLines      []GridLineGridMajorStyleStyleGridMinorStyleStyle}

YAxis is a vertical rule of the range.There can be (2) y-axes; a primary and secondary.

funcHideYAxis

func HideYAxis()YAxis

HideYAxis hides a y-axis.

func (YAxis)GetGridLines

func (yaYAxis) GetGridLines(ticks []Tick) []GridLine

GetGridLines returns the gridlines for the axis.

func (YAxis)GetName

func (yaYAxis) GetName()string

GetName returns the name.

func (YAxis)GetNameStyle

func (yaYAxis) GetNameStyle()Style

GetNameStyle returns the name style.

func (YAxis)GetStyle

func (yaYAxis) GetStyle()Style

GetStyle returns the style.

func (YAxis)GetTickStyle

func (yaYAxis) GetTickStyle()Style

GetTickStyle returns the tick style.

func (YAxis)GetTicks

func (yaYAxis) GetTicks(rRenderer, raRange, defaultsStyle, vfValueFormatter) []Tick

GetTicks returns the ticks for a series.The coalesce priority is:

  • User Supplied Ticks (i.e. Ticks array on the axis itself).
  • Range ticks (i.e. if the range provides ticks).
  • Generating continuous ticks based on minimum spacing and canvas width.

func (YAxis)GetValueFormatter

func (yaYAxis) GetValueFormatter()ValueFormatter

GetValueFormatter returns the value formatter for the axis.

func (YAxis)Measure

func (yaYAxis) Measure(rRenderer, canvasBoxBox, raRange, defaultsStyle, ticks []Tick)Box

Measure returns the bounds of the axis.

func (YAxis)Render

func (yaYAxis) Render(rRenderer, canvasBoxBox, raRange, defaultsStyle, ticks []Tick)

Render renders the axis.

typeYAxisType

type YAxisTypeint

YAxisType is a type of y-axis; it can either be primary or secondary.

const (// YAxisPrimary is the primary axis.YAxisPrimaryYAxisType = 0// YAxisSecondary is the secondary axis.YAxisSecondaryYAxisType = 1)

Source Files

View all Source files

Directories

PathSynopsis
examples
axescommand
bar_chartcommand
basiccommand
descendingcommand
legendcommand
min_maxcommand
pie_chartcommand
rerendercommand
scattercommand
timeseriescommand
twoaxiscommand
twopointcommand

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp