repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
wcharczuk/go-chart
box.go
Equals
func (p Point) Equals(other Point) bool { return p.X == other.X && p.Y == other.Y }
go
func (p Point) Equals(other Point) bool { return p.X == other.X && p.Y == other.Y }
[ "func", "(", "p", "Point", ")", "Equals", "(", "other", "Point", ")", "bool", "{", "return", "p", ".", "X", "==", "other", ".", "X", "&&", "p", ".", "Y", "==", "other", ".", "Y", "\n", "}" ]
// Equals returns if a point equals another point.
[ "Equals", "returns", "if", "a", "point", "equals", "another", "point", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/box.go#L346-L348
train
wcharczuk/go-chart
tick.go
Swap
func (t Ticks) Swap(i, j int) { t[i], t[j] = t[j], t[i] }
go
func (t Ticks) Swap(i, j int) { t[i], t[j] = t[j], t[i] }
[ "func", "(", "t", "Ticks", ")", "Swap", "(", "i", ",", "j", "int", ")", "{", "t", "[", "i", "]", ",", "t", "[", "j", "]", "=", "t", "[", "j", "]", ",", "t", "[", "i", "]", "\n", "}" ]
// Swap swaps two elements.
[ "Swap", "swaps", "two", "elements", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/tick.go#L31-L33
train
wcharczuk/go-chart
tick.go
Less
func (t Ticks) Less(i, j int) bool { return t[i].Value < t[j].Value }
go
func (t Ticks) Less(i, j int) bool { return t[i].Value < t[j].Value }
[ "func", "(", "t", "Ticks", ")", "Less", "(", "i", ",", "j", "int", ")", "bool", "{", "return", "t", "[", "i", "]", ".", "Value", "<", "t", "[", "j", "]", ".", "Value", "\n", "}" ]
// Less returns if i's value is less than j's value.
[ "Less", "returns", "if", "i", "s", "value", "is", "less", "than", "j", "s", "value", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/tick.go#L36-L38
train
wcharczuk/go-chart
tick.go
String
func (t Ticks) String() string { var values []string for i, tick := range t { values = append(values, fmt.Sprintf("[%d: %s]", i, tick.Label)) } return strings.Join(values, ", ") }
go
func (t Ticks) String() string { var values []string for i, tick := range t { values = append(values, fmt.Sprintf("[%d: %s]", i, tick.Label)) } return strings.Join(values, ", ") }
[ "func", "(", "t", "Ticks", ")", "String", "(", ")", "string", "{", "var", "values", "[", "]", "string", "\n", "for", "i", ",", "tick", ":=", "range", "t", "{", "values", "=", "append", "(", "values", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ...
// String returns a string representation of the set of ticks.
[ "String", "returns", "a", "string", "representation", "of", "the", "set", "of", "ticks", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/tick.go#L41-L47
train
wcharczuk/go-chart
tick.go
GenerateContinuousTicks
func GenerateContinuousTicks(r Renderer, ra Range, isVertical bool, style Style, vf ValueFormatter) []Tick { if vf == nil { vf = FloatValueFormatter } var ticks []Tick min, max := ra.GetMin(), ra.GetMax() if ra.IsDescending() { ticks = append(ticks, Tick{ Value: max, Label: vf(max), }) } else { ticks = append(ticks, Tick{ Value: min, Label: vf(min), }) } minLabel := vf(min) style.GetTextOptions().WriteToRenderer(r) labelBox := r.MeasureText(minLabel) var tickSize float64 if isVertical { tickSize = float64(labelBox.Height() + DefaultMinimumTickVerticalSpacing) } else { tickSize = float64(labelBox.Width() + DefaultMinimumTickHorizontalSpacing) } domain := float64(ra.GetDomain()) domainRemainder := domain - (tickSize * 2) intermediateTickCount := int(math.Floor(float64(domainRemainder) / float64(tickSize))) rangeDelta := math.Abs(max - min) tickStep := rangeDelta / float64(intermediateTickCount) roundTo := util.Math.GetRoundToForDelta(rangeDelta) / 10 intermediateTickCount = util.Math.MinInt(intermediateTickCount, DefaultTickCountSanityCheck) for x := 1; x < intermediateTickCount; x++ { var tickValue float64 if ra.IsDescending() { tickValue = max - util.Math.RoundUp(tickStep*float64(x), roundTo) } else { tickValue = min + util.Math.RoundUp(tickStep*float64(x), roundTo) } ticks = append(ticks, Tick{ Value: tickValue, Label: vf(tickValue), }) } if ra.IsDescending() { ticks = append(ticks, Tick{ Value: min, Label: vf(min), }) } else { ticks = append(ticks, Tick{ Value: max, Label: vf(max), }) } return ticks }
go
func GenerateContinuousTicks(r Renderer, ra Range, isVertical bool, style Style, vf ValueFormatter) []Tick { if vf == nil { vf = FloatValueFormatter } var ticks []Tick min, max := ra.GetMin(), ra.GetMax() if ra.IsDescending() { ticks = append(ticks, Tick{ Value: max, Label: vf(max), }) } else { ticks = append(ticks, Tick{ Value: min, Label: vf(min), }) } minLabel := vf(min) style.GetTextOptions().WriteToRenderer(r) labelBox := r.MeasureText(minLabel) var tickSize float64 if isVertical { tickSize = float64(labelBox.Height() + DefaultMinimumTickVerticalSpacing) } else { tickSize = float64(labelBox.Width() + DefaultMinimumTickHorizontalSpacing) } domain := float64(ra.GetDomain()) domainRemainder := domain - (tickSize * 2) intermediateTickCount := int(math.Floor(float64(domainRemainder) / float64(tickSize))) rangeDelta := math.Abs(max - min) tickStep := rangeDelta / float64(intermediateTickCount) roundTo := util.Math.GetRoundToForDelta(rangeDelta) / 10 intermediateTickCount = util.Math.MinInt(intermediateTickCount, DefaultTickCountSanityCheck) for x := 1; x < intermediateTickCount; x++ { var tickValue float64 if ra.IsDescending() { tickValue = max - util.Math.RoundUp(tickStep*float64(x), roundTo) } else { tickValue = min + util.Math.RoundUp(tickStep*float64(x), roundTo) } ticks = append(ticks, Tick{ Value: tickValue, Label: vf(tickValue), }) } if ra.IsDescending() { ticks = append(ticks, Tick{ Value: min, Label: vf(min), }) } else { ticks = append(ticks, Tick{ Value: max, Label: vf(max), }) } return ticks }
[ "func", "GenerateContinuousTicks", "(", "r", "Renderer", ",", "ra", "Range", ",", "isVertical", "bool", ",", "style", "Style", ",", "vf", "ValueFormatter", ")", "[", "]", "Tick", "{", "if", "vf", "==", "nil", "{", "vf", "=", "FloatValueFormatter", "\n", ...
// GenerateContinuousTicks generates a set of ticks.
[ "GenerateContinuousTicks", "generates", "a", "set", "of", "ticks", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/tick.go#L50-L117
train
wcharczuk/go-chart
matrix/matrix.go
New
func New(rows, cols int, values ...float64) *Matrix { if len(values) == 0 { return &Matrix{ stride: cols, epsilon: DefaultEpsilon, elements: make([]float64, rows*cols), } } elems := make([]float64, rows*cols) copy(elems, values) return &Matrix{ stride: cols, epsilon: DefaultEpsilon, elements: elems, } }
go
func New(rows, cols int, values ...float64) *Matrix { if len(values) == 0 { return &Matrix{ stride: cols, epsilon: DefaultEpsilon, elements: make([]float64, rows*cols), } } elems := make([]float64, rows*cols) copy(elems, values) return &Matrix{ stride: cols, epsilon: DefaultEpsilon, elements: elems, } }
[ "func", "New", "(", "rows", ",", "cols", "int", ",", "values", "...", "float64", ")", "*", "Matrix", "{", "if", "len", "(", "values", ")", "==", "0", "{", "return", "&", "Matrix", "{", "stride", ":", "cols", ",", "epsilon", ":", "DefaultEpsilon", "...
// New returns a new matrix.
[ "New", "returns", "a", "new", "matrix", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L24-L39
train
wcharczuk/go-chart
matrix/matrix.go
Identity
func Identity(order int) *Matrix { m := New(order, order) for i := 0; i < order; i++ { m.Set(i, i, 1) } return m }
go
func Identity(order int) *Matrix { m := New(order, order) for i := 0; i < order; i++ { m.Set(i, i, 1) } return m }
[ "func", "Identity", "(", "order", "int", ")", "*", "Matrix", "{", "m", ":=", "New", "(", "order", ",", "order", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "order", ";", "i", "++", "{", "m", ".", "Set", "(", "i", ",", "i", ",", "1", ...
// Identity returns the identity matrix of a given order.
[ "Identity", "returns", "the", "identity", "matrix", "of", "a", "given", "order", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L42-L48
train
wcharczuk/go-chart
matrix/matrix.go
Ones
func Ones(rows, cols int) *Matrix { ones := make([]float64, rows*cols) for i := 0; i < (rows * cols); i++ { ones[i] = 1 } return &Matrix{ stride: cols, epsilon: DefaultEpsilon, elements: ones, } }
go
func Ones(rows, cols int) *Matrix { ones := make([]float64, rows*cols) for i := 0; i < (rows * cols); i++ { ones[i] = 1 } return &Matrix{ stride: cols, epsilon: DefaultEpsilon, elements: ones, } }
[ "func", "Ones", "(", "rows", ",", "cols", "int", ")", "*", "Matrix", "{", "ones", ":=", "make", "(", "[", "]", "float64", ",", "rows", "*", "cols", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "(", "rows", "*", "cols", ")", ";", "i", "+...
// Ones returns an matrix of ones.
[ "Ones", "returns", "an", "matrix", "of", "ones", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L56-L67
train
wcharczuk/go-chart
matrix/matrix.go
Eye
func Eye(n int) *Matrix { m := Zero(n, n) for i := 0; i < len(m.elements); i += n + 1 { m.elements[i] = 1 } return m }
go
func Eye(n int) *Matrix { m := Zero(n, n) for i := 0; i < len(m.elements); i += n + 1 { m.elements[i] = 1 } return m }
[ "func", "Eye", "(", "n", "int", ")", "*", "Matrix", "{", "m", ":=", "Zero", "(", "n", ",", "n", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "m", ".", "elements", ")", ";", "i", "+=", "n", "+", "1", "{", "m", ".", "eleme...
// Eye returns the eye matrix.
[ "Eye", "returns", "the", "eye", "matrix", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L70-L76
train
wcharczuk/go-chart
matrix/matrix.go
NewFromArrays
func NewFromArrays(a [][]float64) *Matrix { rows := len(a) if rows == 0 { return nil } cols := len(a[0]) m := New(rows, cols) for row := 0; row < rows; row++ { for col := 0; col < cols; col++ { m.Set(row, col, a[row][col]) } } return m }
go
func NewFromArrays(a [][]float64) *Matrix { rows := len(a) if rows == 0 { return nil } cols := len(a[0]) m := New(rows, cols) for row := 0; row < rows; row++ { for col := 0; col < cols; col++ { m.Set(row, col, a[row][col]) } } return m }
[ "func", "NewFromArrays", "(", "a", "[", "]", "[", "]", "float64", ")", "*", "Matrix", "{", "rows", ":=", "len", "(", "a", ")", "\n", "if", "rows", "==", "0", "{", "return", "nil", "\n", "}", "\n", "cols", ":=", "len", "(", "a", "[", "0", "]",...
// NewFromArrays creates a matrix from a jagged array set.
[ "NewFromArrays", "creates", "a", "matrix", "from", "a", "jagged", "array", "set", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L79-L92
train
wcharczuk/go-chart
matrix/matrix.go
String
func (m *Matrix) String() string { buffer := bytes.NewBuffer(nil) rows, cols := m.Size() for row := 0; row < rows; row++ { for col := 0; col < cols; col++ { buffer.WriteString(f64s(m.Get(row, col))) buffer.WriteRune(' ') } buffer.WriteRune('\n') } return buffer.String() }
go
func (m *Matrix) String() string { buffer := bytes.NewBuffer(nil) rows, cols := m.Size() for row := 0; row < rows; row++ { for col := 0; col < cols; col++ { buffer.WriteString(f64s(m.Get(row, col))) buffer.WriteRune(' ') } buffer.WriteRune('\n') } return buffer.String() }
[ "func", "(", "m", "*", "Matrix", ")", "String", "(", ")", "string", "{", "buffer", ":=", "bytes", ".", "NewBuffer", "(", "nil", ")", "\n", "rows", ",", "cols", ":=", "m", ".", "Size", "(", ")", "\n\n", "for", "row", ":=", "0", ";", "row", "<", ...
// String returns a string representation of the matrix.
[ "String", "returns", "a", "string", "representation", "of", "the", "matrix", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L102-L114
train
wcharczuk/go-chart
matrix/matrix.go
WithEpsilon
func (m *Matrix) WithEpsilon(epsilon float64) *Matrix { m.epsilon = epsilon return m }
go
func (m *Matrix) WithEpsilon(epsilon float64) *Matrix { m.epsilon = epsilon return m }
[ "func", "(", "m", "*", "Matrix", ")", "WithEpsilon", "(", "epsilon", "float64", ")", "*", "Matrix", "{", "m", ".", "epsilon", "=", "epsilon", "\n", "return", "m", "\n", "}" ]
// WithEpsilon sets the epsilon on the matrix and returns a reference to the matrix.
[ "WithEpsilon", "sets", "the", "epsilon", "on", "the", "matrix", "and", "returns", "a", "reference", "to", "the", "matrix", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L122-L125
train
wcharczuk/go-chart
matrix/matrix.go
Each
func (m *Matrix) Each(action func(row, col int, value float64)) { rows, cols := m.Size() for row := 0; row < rows; row++ { for col := 0; col < cols; col++ { action(row, col, m.Get(row, col)) } } }
go
func (m *Matrix) Each(action func(row, col int, value float64)) { rows, cols := m.Size() for row := 0; row < rows; row++ { for col := 0; col < cols; col++ { action(row, col, m.Get(row, col)) } } }
[ "func", "(", "m", "*", "Matrix", ")", "Each", "(", "action", "func", "(", "row", ",", "col", "int", ",", "value", "float64", ")", ")", "{", "rows", ",", "cols", ":=", "m", ".", "Size", "(", ")", "\n", "for", "row", ":=", "0", ";", "row", "<",...
// Each applies the action to each element of the matrix in // rows => cols order.
[ "Each", "applies", "the", "action", "to", "each", "element", "of", "the", "matrix", "in", "rows", "=", ">", "cols", "order", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L129-L136
train
wcharczuk/go-chart
matrix/matrix.go
Round
func (m *Matrix) Round() *Matrix { rows, cols := m.Size() for row := 0; row < rows; row++ { for col := 0; col < cols; col++ { m.Set(row, col, roundToEpsilon(m.Get(row, col), m.epsilon)) } } return m }
go
func (m *Matrix) Round() *Matrix { rows, cols := m.Size() for row := 0; row < rows; row++ { for col := 0; col < cols; col++ { m.Set(row, col, roundToEpsilon(m.Get(row, col), m.epsilon)) } } return m }
[ "func", "(", "m", "*", "Matrix", ")", "Round", "(", ")", "*", "Matrix", "{", "rows", ",", "cols", ":=", "m", ".", "Size", "(", ")", "\n", "for", "row", ":=", "0", ";", "row", "<", "rows", ";", "row", "++", "{", "for", "col", ":=", "0", ";",...
// Round rounds all the values in a matrix to it epsilon, // returning a reference to the original
[ "Round", "rounds", "all", "the", "values", "in", "a", "matrix", "to", "it", "epsilon", "returning", "a", "reference", "to", "the", "original" ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L140-L148
train
wcharczuk/go-chart
matrix/matrix.go
Arrays
func (m *Matrix) Arrays() [][]float64 { rows, cols := m.Size() a := make([][]float64, rows) for row := 0; row < rows; row++ { a[row] = make([]float64, cols) for col := 0; col < cols; col++ { a[row][col] = m.Get(row, col) } } return a }
go
func (m *Matrix) Arrays() [][]float64 { rows, cols := m.Size() a := make([][]float64, rows) for row := 0; row < rows; row++ { a[row] = make([]float64, cols) for col := 0; col < cols; col++ { a[row][col] = m.Get(row, col) } } return a }
[ "func", "(", "m", "*", "Matrix", ")", "Arrays", "(", ")", "[", "]", "[", "]", "float64", "{", "rows", ",", "cols", ":=", "m", ".", "Size", "(", ")", "\n", "a", ":=", "make", "(", "[", "]", "[", "]", "float64", ",", "rows", ")", "\n\n", "for...
// Arrays returns the matrix as a two dimensional jagged array.
[ "Arrays", "returns", "the", "matrix", "as", "a", "two", "dimensional", "jagged", "array", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L151-L163
train
wcharczuk/go-chart
matrix/matrix.go
Size
func (m *Matrix) Size() (rows, cols int) { rows = len(m.elements) / m.stride cols = m.stride return }
go
func (m *Matrix) Size() (rows, cols int) { rows = len(m.elements) / m.stride cols = m.stride return }
[ "func", "(", "m", "*", "Matrix", ")", "Size", "(", ")", "(", "rows", ",", "cols", "int", ")", "{", "rows", "=", "len", "(", "m", ".", "elements", ")", "/", "m", ".", "stride", "\n", "cols", "=", "m", ".", "stride", "\n", "return", "\n", "}" ]
// Size returns the dimensions of the matrix.
[ "Size", "returns", "the", "dimensions", "of", "the", "matrix", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L166-L170
train
wcharczuk/go-chart
matrix/matrix.go
IsSquare
func (m *Matrix) IsSquare() bool { return m.stride == (len(m.elements) / m.stride) }
go
func (m *Matrix) IsSquare() bool { return m.stride == (len(m.elements) / m.stride) }
[ "func", "(", "m", "*", "Matrix", ")", "IsSquare", "(", ")", "bool", "{", "return", "m", ".", "stride", "==", "(", "len", "(", "m", ".", "elements", ")", "/", "m", ".", "stride", ")", "\n", "}" ]
// IsSquare returns if the row count is equal to the column count.
[ "IsSquare", "returns", "if", "the", "row", "count", "is", "equal", "to", "the", "column", "count", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L173-L175
train
wcharczuk/go-chart
matrix/matrix.go
IsSymmetric
func (m *Matrix) IsSymmetric() bool { rows, cols := m.Size() if rows != cols { return false } for i := 0; i < rows; i++ { for j := 0; j < i; j++ { if m.Get(i, j) != m.Get(j, i) { return false } } } return true }
go
func (m *Matrix) IsSymmetric() bool { rows, cols := m.Size() if rows != cols { return false } for i := 0; i < rows; i++ { for j := 0; j < i; j++ { if m.Get(i, j) != m.Get(j, i) { return false } } } return true }
[ "func", "(", "m", "*", "Matrix", ")", "IsSymmetric", "(", ")", "bool", "{", "rows", ",", "cols", ":=", "m", ".", "Size", "(", ")", "\n\n", "if", "rows", "!=", "cols", "{", "return", "false", "\n", "}", "\n\n", "for", "i", ":=", "0", ";", "i", ...
// IsSymmetric returns if the matrix is symmetric about its diagonal.
[ "IsSymmetric", "returns", "if", "the", "matrix", "is", "symmetric", "about", "its", "diagonal", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L178-L193
train
wcharczuk/go-chart
matrix/matrix.go
Get
func (m *Matrix) Get(row, col int) float64 { index := (m.stride * row) + col return m.elements[index] }
go
func (m *Matrix) Get(row, col int) float64 { index := (m.stride * row) + col return m.elements[index] }
[ "func", "(", "m", "*", "Matrix", ")", "Get", "(", "row", ",", "col", "int", ")", "float64", "{", "index", ":=", "(", "m", ".", "stride", "*", "row", ")", "+", "col", "\n", "return", "m", ".", "elements", "[", "index", "]", "\n", "}" ]
// Get returns the element at the given row, col.
[ "Get", "returns", "the", "element", "at", "the", "given", "row", "col", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L196-L199
train
wcharczuk/go-chart
matrix/matrix.go
Set
func (m *Matrix) Set(row, col int, val float64) { index := (m.stride * row) + col m.elements[index] = val }
go
func (m *Matrix) Set(row, col int, val float64) { index := (m.stride * row) + col m.elements[index] = val }
[ "func", "(", "m", "*", "Matrix", ")", "Set", "(", "row", ",", "col", "int", ",", "val", "float64", ")", "{", "index", ":=", "(", "m", ".", "stride", "*", "row", ")", "+", "col", "\n", "m", ".", "elements", "[", "index", "]", "=", "val", "\n",...
// Set sets a value.
[ "Set", "sets", "a", "value", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L202-L205
train
wcharczuk/go-chart
matrix/matrix.go
Col
func (m *Matrix) Col(col int) Vector { rows, _ := m.Size() values := make([]float64, rows) for row := 0; row < rows; row++ { values[row] = m.Get(row, col) } return Vector(values) }
go
func (m *Matrix) Col(col int) Vector { rows, _ := m.Size() values := make([]float64, rows) for row := 0; row < rows; row++ { values[row] = m.Get(row, col) } return Vector(values) }
[ "func", "(", "m", "*", "Matrix", ")", "Col", "(", "col", "int", ")", "Vector", "{", "rows", ",", "_", ":=", "m", ".", "Size", "(", ")", "\n", "values", ":=", "make", "(", "[", "]", "float64", ",", "rows", ")", "\n", "for", "row", ":=", "0", ...
// Col returns a column of the matrix as a vector.
[ "Col", "returns", "a", "column", "of", "the", "matrix", "as", "a", "vector", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L208-L215
train
wcharczuk/go-chart
matrix/matrix.go
Row
func (m *Matrix) Row(row int) Vector { _, cols := m.Size() values := make([]float64, cols) for col := 0; col < cols; col++ { values[col] = m.Get(row, col) } return Vector(values) }
go
func (m *Matrix) Row(row int) Vector { _, cols := m.Size() values := make([]float64, cols) for col := 0; col < cols; col++ { values[col] = m.Get(row, col) } return Vector(values) }
[ "func", "(", "m", "*", "Matrix", ")", "Row", "(", "row", "int", ")", "Vector", "{", "_", ",", "cols", ":=", "m", ".", "Size", "(", ")", "\n", "values", ":=", "make", "(", "[", "]", "float64", ",", "cols", ")", "\n", "for", "col", ":=", "0", ...
// Row returns a row of the matrix as a vector.
[ "Row", "returns", "a", "row", "of", "the", "matrix", "as", "a", "vector", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L218-L225
train
wcharczuk/go-chart
matrix/matrix.go
SubMatrix
func (m *Matrix) SubMatrix(i, j, rows, cols int) *Matrix { return &Matrix{ elements: m.elements[i*m.stride+j : i*m.stride+j+(rows-1)*m.stride+cols], stride: m.stride, epsilon: m.epsilon, } }
go
func (m *Matrix) SubMatrix(i, j, rows, cols int) *Matrix { return &Matrix{ elements: m.elements[i*m.stride+j : i*m.stride+j+(rows-1)*m.stride+cols], stride: m.stride, epsilon: m.epsilon, } }
[ "func", "(", "m", "*", "Matrix", ")", "SubMatrix", "(", "i", ",", "j", ",", "rows", ",", "cols", "int", ")", "*", "Matrix", "{", "return", "&", "Matrix", "{", "elements", ":", "m", ".", "elements", "[", "i", "*", "m", ".", "stride", "+", "j", ...
// SubMatrix returns a sub matrix from a given outer matrix.
[ "SubMatrix", "returns", "a", "sub", "matrix", "from", "a", "given", "outer", "matrix", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L228-L234
train
wcharczuk/go-chart
matrix/matrix.go
ScaleRow
func (m *Matrix) ScaleRow(row int, scale float64) { startIndex := row * m.stride for i := startIndex; i < m.stride; i++ { m.elements[i] = m.elements[i] * scale } }
go
func (m *Matrix) ScaleRow(row int, scale float64) { startIndex := row * m.stride for i := startIndex; i < m.stride; i++ { m.elements[i] = m.elements[i] * scale } }
[ "func", "(", "m", "*", "Matrix", ")", "ScaleRow", "(", "row", "int", ",", "scale", "float64", ")", "{", "startIndex", ":=", "row", "*", "m", ".", "stride", "\n", "for", "i", ":=", "startIndex", ";", "i", "<", "m", ".", "stride", ";", "i", "++", ...
// ScaleRow applies a scale to an entire row.
[ "ScaleRow", "applies", "a", "scale", "to", "an", "entire", "row", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L237-L242
train
wcharczuk/go-chart
matrix/matrix.go
SwapRows
func (m *Matrix) SwapRows(i, j int) { var vi, vj float64 for col := 0; col < m.stride; col++ { vi = m.Get(i, col) vj = m.Get(j, col) m.Set(i, col, vj) m.Set(j, col, vi) } }
go
func (m *Matrix) SwapRows(i, j int) { var vi, vj float64 for col := 0; col < m.stride; col++ { vi = m.Get(i, col) vj = m.Get(j, col) m.Set(i, col, vj) m.Set(j, col, vi) } }
[ "func", "(", "m", "*", "Matrix", ")", "SwapRows", "(", "i", ",", "j", "int", ")", "{", "var", "vi", ",", "vj", "float64", "\n", "for", "col", ":=", "0", ";", "col", "<", "m", ".", "stride", ";", "col", "++", "{", "vi", "=", "m", ".", "Get",...
// SwapRows swaps a row in the matrix in place.
[ "SwapRows", "swaps", "a", "row", "in", "the", "matrix", "in", "place", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L255-L263
train
wcharczuk/go-chart
matrix/matrix.go
Augment
func (m *Matrix) Augment(m2 *Matrix) (*Matrix, error) { mr, mc := m.Size() m2r, m2c := m2.Size() if mr != m2r { return nil, ErrDimensionMismatch } m3 := Zero(mr, mc+m2c) for row := 0; row < mr; row++ { for col := 0; col < mc; col++ { m3.Set(row, col, m.Get(row, col)) } for col := 0; col < m2c; col++ { m3.Set(row, mc+col, m2.Get(row, col)) } } return m3, nil }
go
func (m *Matrix) Augment(m2 *Matrix) (*Matrix, error) { mr, mc := m.Size() m2r, m2c := m2.Size() if mr != m2r { return nil, ErrDimensionMismatch } m3 := Zero(mr, mc+m2c) for row := 0; row < mr; row++ { for col := 0; col < mc; col++ { m3.Set(row, col, m.Get(row, col)) } for col := 0; col < m2c; col++ { m3.Set(row, mc+col, m2.Get(row, col)) } } return m3, nil }
[ "func", "(", "m", "*", "Matrix", ")", "Augment", "(", "m2", "*", "Matrix", ")", "(", "*", "Matrix", ",", "error", ")", "{", "mr", ",", "mc", ":=", "m", ".", "Size", "(", ")", "\n", "m2r", ",", "m2c", ":=", "m2", ".", "Size", "(", ")", "\n",...
// Augment concatenates two matrices about the horizontal.
[ "Augment", "concatenates", "two", "matrices", "about", "the", "horizontal", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L266-L283
train
wcharczuk/go-chart
matrix/matrix.go
Copy
func (m *Matrix) Copy() *Matrix { m2 := &Matrix{stride: m.stride, epsilon: m.epsilon, elements: make([]float64, len(m.elements))} copy(m2.elements, m.elements) return m2 }
go
func (m *Matrix) Copy() *Matrix { m2 := &Matrix{stride: m.stride, epsilon: m.epsilon, elements: make([]float64, len(m.elements))} copy(m2.elements, m.elements) return m2 }
[ "func", "(", "m", "*", "Matrix", ")", "Copy", "(", ")", "*", "Matrix", "{", "m2", ":=", "&", "Matrix", "{", "stride", ":", "m", ".", "stride", ",", "epsilon", ":", "m", ".", "epsilon", ",", "elements", ":", "make", "(", "[", "]", "float64", ","...
// Copy returns a duplicate of a given matrix.
[ "Copy", "returns", "a", "duplicate", "of", "a", "given", "matrix", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L286-L290
train
wcharczuk/go-chart
matrix/matrix.go
DiagonalVector
func (m *Matrix) DiagonalVector() Vector { rows, cols := m.Size() rank := minInt(rows, cols) values := make([]float64, rank) for index := 0; index < rank; index++ { values[index] = m.Get(index, index) } return Vector(values) }
go
func (m *Matrix) DiagonalVector() Vector { rows, cols := m.Size() rank := minInt(rows, cols) values := make([]float64, rank) for index := 0; index < rank; index++ { values[index] = m.Get(index, index) } return Vector(values) }
[ "func", "(", "m", "*", "Matrix", ")", "DiagonalVector", "(", ")", "Vector", "{", "rows", ",", "cols", ":=", "m", ".", "Size", "(", ")", "\n", "rank", ":=", "minInt", "(", "rows", ",", "cols", ")", "\n", "values", ":=", "make", "(", "[", "]", "f...
// DiagonalVector returns a vector from the diagonal of a matrix.
[ "DiagonalVector", "returns", "a", "vector", "from", "the", "diagonal", "of", "a", "matrix", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L293-L302
train
wcharczuk/go-chart
matrix/matrix.go
Diagonal
func (m *Matrix) Diagonal() *Matrix { rows, cols := m.Size() rank := minInt(rows, cols) m2 := New(rank, rank) for index := 0; index < rank; index++ { m2.Set(index, index, m.Get(index, index)) } return m2 }
go
func (m *Matrix) Diagonal() *Matrix { rows, cols := m.Size() rank := minInt(rows, cols) m2 := New(rank, rank) for index := 0; index < rank; index++ { m2.Set(index, index, m.Get(index, index)) } return m2 }
[ "func", "(", "m", "*", "Matrix", ")", "Diagonal", "(", ")", "*", "Matrix", "{", "rows", ",", "cols", ":=", "m", ".", "Size", "(", ")", "\n", "rank", ":=", "minInt", "(", "rows", ",", "cols", ")", "\n", "m2", ":=", "New", "(", "rank", ",", "ra...
// Diagonal returns a matrix from the diagonal of a matrix.
[ "Diagonal", "returns", "a", "matrix", "from", "the", "diagonal", "of", "a", "matrix", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L305-L314
train
wcharczuk/go-chart
matrix/matrix.go
Equals
func (m *Matrix) Equals(other *Matrix) bool { if other == nil && m != nil { return false } else if other == nil { return true } if m.stride != other.stride { return false } msize := len(m.elements) m2size := len(other.elements) if msize != m2size { return false } for i := 0; i < msize; i++ { if m.elements[i] != other.elements[i] { return false } } return true }
go
func (m *Matrix) Equals(other *Matrix) bool { if other == nil && m != nil { return false } else if other == nil { return true } if m.stride != other.stride { return false } msize := len(m.elements) m2size := len(other.elements) if msize != m2size { return false } for i := 0; i < msize; i++ { if m.elements[i] != other.elements[i] { return false } } return true }
[ "func", "(", "m", "*", "Matrix", ")", "Equals", "(", "other", "*", "Matrix", ")", "bool", "{", "if", "other", "==", "nil", "&&", "m", "!=", "nil", "{", "return", "false", "\n", "}", "else", "if", "other", "==", "nil", "{", "return", "true", "\n",...
// Equals returns if a matrix equals another matrix.
[ "Equals", "returns", "if", "a", "matrix", "equals", "another", "matrix", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L317-L341
train
wcharczuk/go-chart
matrix/matrix.go
L
func (m *Matrix) L() *Matrix { rows, cols := m.Size() m2 := New(rows, cols) for row := 0; row < rows; row++ { for col := row; col < cols; col++ { m2.Set(row, col, m.Get(row, col)) } } return m2 }
go
func (m *Matrix) L() *Matrix { rows, cols := m.Size() m2 := New(rows, cols) for row := 0; row < rows; row++ { for col := row; col < cols; col++ { m2.Set(row, col, m.Get(row, col)) } } return m2 }
[ "func", "(", "m", "*", "Matrix", ")", "L", "(", ")", "*", "Matrix", "{", "rows", ",", "cols", ":=", "m", ".", "Size", "(", ")", "\n", "m2", ":=", "New", "(", "rows", ",", "cols", ")", "\n", "for", "row", ":=", "0", ";", "row", "<", "rows", ...
// L returns the matrix with zeros below the diagonal.
[ "L", "returns", "the", "matrix", "with", "zeros", "below", "the", "diagonal", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L344-L353
train
wcharczuk/go-chart
matrix/matrix.go
Multiply
func (m *Matrix) Multiply(m2 *Matrix) (m3 *Matrix, err error) { if m.stride*m2.stride != len(m2.elements) { return nil, ErrDimensionMismatch } m3 = &Matrix{epsilon: m.epsilon, stride: m2.stride, elements: make([]float64, (len(m.elements)/m.stride)*m2.stride)} for m1c0, m3x := 0, 0; m1c0 < len(m.elements); m1c0 += m.stride { for m2r0 := 0; m2r0 < m2.stride; m2r0++ { for m1x, m2x := m1c0, m2r0; m2x < len(m2.elements); m2x += m2.stride { m3.elements[m3x] += m.elements[m1x] * m2.elements[m2x] m1x++ } m3x++ } } return }
go
func (m *Matrix) Multiply(m2 *Matrix) (m3 *Matrix, err error) { if m.stride*m2.stride != len(m2.elements) { return nil, ErrDimensionMismatch } m3 = &Matrix{epsilon: m.epsilon, stride: m2.stride, elements: make([]float64, (len(m.elements)/m.stride)*m2.stride)} for m1c0, m3x := 0, 0; m1c0 < len(m.elements); m1c0 += m.stride { for m2r0 := 0; m2r0 < m2.stride; m2r0++ { for m1x, m2x := m1c0, m2r0; m2x < len(m2.elements); m2x += m2.stride { m3.elements[m3x] += m.elements[m1x] * m2.elements[m2x] m1x++ } m3x++ } } return }
[ "func", "(", "m", "*", "Matrix", ")", "Multiply", "(", "m2", "*", "Matrix", ")", "(", "m3", "*", "Matrix", ",", "err", "error", ")", "{", "if", "m", ".", "stride", "*", "m2", ".", "stride", "!=", "len", "(", "m2", ".", "elements", ")", "{", "...
// math operations // Multiply multiplies two matrices.
[ "math", "operations", "Multiply", "multiplies", "two", "matrices", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L371-L387
train
wcharczuk/go-chart
matrix/matrix.go
Pivotize
func (m *Matrix) Pivotize() *Matrix { pv := make([]int, m.stride) for i := range pv { pv[i] = i } for j, dx := 0, 0; j < m.stride; j++ { row := j max := m.elements[dx] for i, ixcj := j, dx; i < m.stride; i++ { if m.elements[ixcj] > max { max = m.elements[ixcj] row = i } ixcj += m.stride } if j != row { pv[row], pv[j] = pv[j], pv[row] } dx += m.stride + 1 } p := Zero(m.stride, m.stride) for r, c := range pv { p.elements[r*m.stride+c] = 1 } return p }
go
func (m *Matrix) Pivotize() *Matrix { pv := make([]int, m.stride) for i := range pv { pv[i] = i } for j, dx := 0, 0; j < m.stride; j++ { row := j max := m.elements[dx] for i, ixcj := j, dx; i < m.stride; i++ { if m.elements[ixcj] > max { max = m.elements[ixcj] row = i } ixcj += m.stride } if j != row { pv[row], pv[j] = pv[j], pv[row] } dx += m.stride + 1 } p := Zero(m.stride, m.stride) for r, c := range pv { p.elements[r*m.stride+c] = 1 } return p }
[ "func", "(", "m", "*", "Matrix", ")", "Pivotize", "(", ")", "*", "Matrix", "{", "pv", ":=", "make", "(", "[", "]", "int", ",", "m", ".", "stride", ")", "\n\n", "for", "i", ":=", "range", "pv", "{", "pv", "[", "i", "]", "=", "i", "\n", "}", ...
// Pivotize does something i'm not sure what.
[ "Pivotize", "does", "something", "i", "m", "not", "sure", "what", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L390-L417
train
wcharczuk/go-chart
matrix/matrix.go
Times
func (m *Matrix) Times(m2 *Matrix) (*Matrix, error) { mr, mc := m.Size() m2r, m2c := m2.Size() if mc != m2r { return nil, fmt.Errorf("cannot multiply (%dx%d) and (%dx%d)", mr, mc, m2r, m2c) //return nil, ErrDimensionMismatch } c := Zero(mr, m2c) for i := 0; i < mr; i++ { sums := c.elements[i*c.stride : (i+1)*c.stride] for k, a := range m.elements[i*m.stride : i*m.stride+m.stride] { for j, b := range m2.elements[k*m2.stride : k*m2.stride+m2.stride] { sums[j] += a * b } } } return c, nil }
go
func (m *Matrix) Times(m2 *Matrix) (*Matrix, error) { mr, mc := m.Size() m2r, m2c := m2.Size() if mc != m2r { return nil, fmt.Errorf("cannot multiply (%dx%d) and (%dx%d)", mr, mc, m2r, m2c) //return nil, ErrDimensionMismatch } c := Zero(mr, m2c) for i := 0; i < mr; i++ { sums := c.elements[i*c.stride : (i+1)*c.stride] for k, a := range m.elements[i*m.stride : i*m.stride+m.stride] { for j, b := range m2.elements[k*m2.stride : k*m2.stride+m2.stride] { sums[j] += a * b } } } return c, nil }
[ "func", "(", "m", "*", "Matrix", ")", "Times", "(", "m2", "*", "Matrix", ")", "(", "*", "Matrix", ",", "error", ")", "{", "mr", ",", "mc", ":=", "m", ".", "Size", "(", ")", "\n", "m2r", ",", "m2c", ":=", "m2", ".", "Size", "(", ")", "\n\n",...
// Times returns the product of a matrix and another.
[ "Times", "returns", "the", "product", "of", "a", "matrix", "and", "another", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L420-L441
train
wcharczuk/go-chart
matrix/matrix.go
LU
func (m *Matrix) LU() (l, u, p *Matrix) { l = Zero(m.stride, m.stride) u = Zero(m.stride, m.stride) p = m.Pivotize() m, _ = p.Multiply(m) for j, jxc0 := 0, 0; j < m.stride; j++ { l.elements[jxc0+j] = 1 for i, ixc0 := 0, 0; ixc0 <= jxc0; i++ { sum := 0. for k, kxcj := 0, j; k < i; k++ { sum += u.elements[kxcj] * l.elements[ixc0+k] kxcj += m.stride } u.elements[ixc0+j] = m.elements[ixc0+j] - sum ixc0 += m.stride } for ixc0 := jxc0; ixc0 < len(m.elements); ixc0 += m.stride { sum := 0. for k, kxcj := 0, j; k < j; k++ { sum += u.elements[kxcj] * l.elements[ixc0+k] kxcj += m.stride } l.elements[ixc0+j] = (m.elements[ixc0+j] - sum) / u.elements[jxc0+j] } jxc0 += m.stride } return }
go
func (m *Matrix) LU() (l, u, p *Matrix) { l = Zero(m.stride, m.stride) u = Zero(m.stride, m.stride) p = m.Pivotize() m, _ = p.Multiply(m) for j, jxc0 := 0, 0; j < m.stride; j++ { l.elements[jxc0+j] = 1 for i, ixc0 := 0, 0; ixc0 <= jxc0; i++ { sum := 0. for k, kxcj := 0, j; k < i; k++ { sum += u.elements[kxcj] * l.elements[ixc0+k] kxcj += m.stride } u.elements[ixc0+j] = m.elements[ixc0+j] - sum ixc0 += m.stride } for ixc0 := jxc0; ixc0 < len(m.elements); ixc0 += m.stride { sum := 0. for k, kxcj := 0, j; k < j; k++ { sum += u.elements[kxcj] * l.elements[ixc0+k] kxcj += m.stride } l.elements[ixc0+j] = (m.elements[ixc0+j] - sum) / u.elements[jxc0+j] } jxc0 += m.stride } return }
[ "func", "(", "m", "*", "Matrix", ")", "LU", "(", ")", "(", "l", ",", "u", ",", "p", "*", "Matrix", ")", "{", "l", "=", "Zero", "(", "m", ".", "stride", ",", "m", ".", "stride", ")", "\n", "u", "=", "Zero", "(", "m", ".", "stride", ",", ...
// Decompositions // LU performs the LU decomposition.
[ "Decompositions", "LU", "performs", "the", "LU", "decomposition", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L446-L473
train
wcharczuk/go-chart
matrix/matrix.go
Transpose
func (m *Matrix) Transpose() *Matrix { rows, cols := m.Size() m2 := Zero(cols, rows) for i := 0; i < rows; i++ { for j := 0; j < cols; j++ { m2.Set(j, i, m.Get(i, j)) } } return m2 }
go
func (m *Matrix) Transpose() *Matrix { rows, cols := m.Size() m2 := Zero(cols, rows) for i := 0; i < rows; i++ { for j := 0; j < cols; j++ { m2.Set(j, i, m.Get(i, j)) } } return m2 }
[ "func", "(", "m", "*", "Matrix", ")", "Transpose", "(", ")", "*", "Matrix", "{", "rows", ",", "cols", ":=", "m", ".", "Size", "(", ")", "\n", "m2", ":=", "Zero", "(", "cols", ",", "rows", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "ro...
// Transpose flips a matrix about its diagonal, returning a new copy.
[ "Transpose", "flips", "a", "matrix", "about", "its", "diagonal", "returning", "a", "new", "copy", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L550-L559
train
wcharczuk/go-chart
value.go
Values
func (vs Values) Values() []float64 { values := make([]float64, len(vs)) for index, v := range vs { values[index] = v.Value } return values }
go
func (vs Values) Values() []float64 { values := make([]float64, len(vs)) for index, v := range vs { values[index] = v.Value } return values }
[ "func", "(", "vs", "Values", ")", "Values", "(", ")", "[", "]", "float64", "{", "values", ":=", "make", "(", "[", "]", "float64", ",", "len", "(", "vs", ")", ")", "\n", "for", "index", ",", "v", ":=", "range", "vs", "{", "values", "[", "index",...
// Values returns the values.
[ "Values", "returns", "the", "values", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/value.go#L16-L22
train
wcharczuk/go-chart
value.go
Normalize
func (vs Values) Normalize() []Value { var output []Value var total float64 for _, v := range vs { total += v.Value } for _, v := range vs { if v.Value > 0 { output = append(output, Value{ Style: v.Style, Label: v.Label, Value: util.Math.RoundDown(v.Value/total, 0.0001), }) } } return output }
go
func (vs Values) Normalize() []Value { var output []Value var total float64 for _, v := range vs { total += v.Value } for _, v := range vs { if v.Value > 0 { output = append(output, Value{ Style: v.Style, Label: v.Label, Value: util.Math.RoundDown(v.Value/total, 0.0001), }) } } return output }
[ "func", "(", "vs", "Values", ")", "Normalize", "(", ")", "[", "]", "Value", "{", "var", "output", "[", "]", "Value", "\n", "var", "total", "float64", "\n\n", "for", "_", ",", "v", ":=", "range", "vs", "{", "total", "+=", "v", ".", "Value", "\n", ...
// Normalize returns the values normalized.
[ "Normalize", "returns", "the", "values", "normalized", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/value.go#L30-L48
train
wcharczuk/go-chart
value_formatter.go
formatTime
func formatTime(v interface{}, dateFormat string) string { if typed, isTyped := v.(time.Time); isTyped { return typed.Format(dateFormat) } if typed, isTyped := v.(int64); isTyped { return time.Unix(0, typed).Format(dateFormat) } if typed, isTyped := v.(float64); isTyped { return time.Unix(0, int64(typed)).Format(dateFormat) } return "" }
go
func formatTime(v interface{}, dateFormat string) string { if typed, isTyped := v.(time.Time); isTyped { return typed.Format(dateFormat) } if typed, isTyped := v.(int64); isTyped { return time.Unix(0, typed).Format(dateFormat) } if typed, isTyped := v.(float64); isTyped { return time.Unix(0, int64(typed)).Format(dateFormat) } return "" }
[ "func", "formatTime", "(", "v", "interface", "{", "}", ",", "dateFormat", "string", ")", "string", "{", "if", "typed", ",", "isTyped", ":=", "v", ".", "(", "time", ".", "Time", ")", ";", "isTyped", "{", "return", "typed", ".", "Format", "(", "dateFor...
// TimeValueFormatterWithFormat is a ValueFormatter for timestamps with a given format.
[ "TimeValueFormatterWithFormat", "is", "a", "ValueFormatter", "for", "timestamps", "with", "a", "given", "format", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/value_formatter.go#L40-L51
train
wcharczuk/go-chart
value_formatter.go
IntValueFormatter
func IntValueFormatter(v interface{}) string { switch v.(type) { case int: return strconv.Itoa(v.(int)) case int64: return strconv.FormatInt(v.(int64), 10) case float32: return strconv.FormatInt(int64(v.(float32)), 10) case float64: return strconv.FormatInt(int64(v.(float64)), 10) default: return "" } }
go
func IntValueFormatter(v interface{}) string { switch v.(type) { case int: return strconv.Itoa(v.(int)) case int64: return strconv.FormatInt(v.(int64), 10) case float32: return strconv.FormatInt(int64(v.(float32)), 10) case float64: return strconv.FormatInt(int64(v.(float64)), 10) default: return "" } }
[ "func", "IntValueFormatter", "(", "v", "interface", "{", "}", ")", "string", "{", "switch", "v", ".", "(", "type", ")", "{", "case", "int", ":", "return", "strconv", ".", "Itoa", "(", "v", ".", "(", "int", ")", ")", "\n", "case", "int64", ":", "r...
// IntValueFormatter is a ValueFormatter for float64.
[ "IntValueFormatter", "is", "a", "ValueFormatter", "for", "float64", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/value_formatter.go#L54-L67
train
wcharczuk/go-chart
value_formatter.go
FloatValueFormatterWithFormat
func FloatValueFormatterWithFormat(v interface{}, floatFormat string) string { if typed, isTyped := v.(int); isTyped { return fmt.Sprintf(floatFormat, float64(typed)) } if typed, isTyped := v.(int64); isTyped { return fmt.Sprintf(floatFormat, float64(typed)) } if typed, isTyped := v.(float32); isTyped { return fmt.Sprintf(floatFormat, typed) } if typed, isTyped := v.(float64); isTyped { return fmt.Sprintf(floatFormat, typed) } return "" }
go
func FloatValueFormatterWithFormat(v interface{}, floatFormat string) string { if typed, isTyped := v.(int); isTyped { return fmt.Sprintf(floatFormat, float64(typed)) } if typed, isTyped := v.(int64); isTyped { return fmt.Sprintf(floatFormat, float64(typed)) } if typed, isTyped := v.(float32); isTyped { return fmt.Sprintf(floatFormat, typed) } if typed, isTyped := v.(float64); isTyped { return fmt.Sprintf(floatFormat, typed) } return "" }
[ "func", "FloatValueFormatterWithFormat", "(", "v", "interface", "{", "}", ",", "floatFormat", "string", ")", "string", "{", "if", "typed", ",", "isTyped", ":=", "v", ".", "(", "int", ")", ";", "isTyped", "{", "return", "fmt", ".", "Sprintf", "(", "floatF...
// FloatValueFormatterWithFormat is a ValueFormatter for float64 with a given format.
[ "FloatValueFormatterWithFormat", "is", "a", "ValueFormatter", "for", "float64", "with", "a", "given", "format", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/value_formatter.go#L84-L98
train
wcharczuk/go-chart
time_series.go
GetValues
func (ts TimeSeries) GetValues(index int) (x, y float64) { x = util.Time.ToFloat64(ts.XValues[index]) y = ts.YValues[index] return }
go
func (ts TimeSeries) GetValues(index int) (x, y float64) { x = util.Time.ToFloat64(ts.XValues[index]) y = ts.YValues[index] return }
[ "func", "(", "ts", "TimeSeries", ")", "GetValues", "(", "index", "int", ")", "(", "x", ",", "y", "float64", ")", "{", "x", "=", "util", ".", "Time", ".", "ToFloat64", "(", "ts", ".", "XValues", "[", "index", "]", ")", "\n", "y", "=", "ts", ".",...
// GetValues gets x, y values at a given index.
[ "GetValues", "gets", "x", "y", "values", "at", "a", "given", "index", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/time_series.go#L45-L49
train
wcharczuk/go-chart
time_series.go
GetFirstValues
func (ts TimeSeries) GetFirstValues() (x, y float64) { x = util.Time.ToFloat64(ts.XValues[0]) y = ts.YValues[0] return }
go
func (ts TimeSeries) GetFirstValues() (x, y float64) { x = util.Time.ToFloat64(ts.XValues[0]) y = ts.YValues[0] return }
[ "func", "(", "ts", "TimeSeries", ")", "GetFirstValues", "(", ")", "(", "x", ",", "y", "float64", ")", "{", "x", "=", "util", ".", "Time", ".", "ToFloat64", "(", "ts", ".", "XValues", "[", "0", "]", ")", "\n", "y", "=", "ts", ".", "YValues", "["...
// GetFirstValues gets the first values.
[ "GetFirstValues", "gets", "the", "first", "values", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/time_series.go#L52-L56
train
wcharczuk/go-chart
time_series.go
GetLastValues
func (ts TimeSeries) GetLastValues() (x, y float64) { x = util.Time.ToFloat64(ts.XValues[len(ts.XValues)-1]) y = ts.YValues[len(ts.YValues)-1] return }
go
func (ts TimeSeries) GetLastValues() (x, y float64) { x = util.Time.ToFloat64(ts.XValues[len(ts.XValues)-1]) y = ts.YValues[len(ts.YValues)-1] return }
[ "func", "(", "ts", "TimeSeries", ")", "GetLastValues", "(", ")", "(", "x", ",", "y", "float64", ")", "{", "x", "=", "util", ".", "Time", ".", "ToFloat64", "(", "ts", ".", "XValues", "[", "len", "(", "ts", ".", "XValues", ")", "-", "1", "]", ")"...
// GetLastValues gets the last values.
[ "GetLastValues", "gets", "the", "last", "values", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/time_series.go#L59-L63
train
wcharczuk/go-chart
util/time.go
Millis
func (tu timeUtil) Millis(d time.Duration) float64 { return float64(d) / float64(time.Millisecond) }
go
func (tu timeUtil) Millis(d time.Duration) float64 { return float64(d) / float64(time.Millisecond) }
[ "func", "(", "tu", "timeUtil", ")", "Millis", "(", "d", "time", ".", "Duration", ")", "float64", "{", "return", "float64", "(", "d", ")", "/", "float64", "(", "time", ".", "Millisecond", ")", "\n", "}" ]
// Millis returns the duration as milliseconds.
[ "Millis", "returns", "the", "duration", "as", "milliseconds", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/time.go#L13-L15
train
wcharczuk/go-chart
util/time.go
ToFloat64
func (tu timeUtil) ToFloat64(t time.Time) float64 { return float64(t.UnixNano()) }
go
func (tu timeUtil) ToFloat64(t time.Time) float64 { return float64(t.UnixNano()) }
[ "func", "(", "tu", "timeUtil", ")", "ToFloat64", "(", "t", "time", ".", "Time", ")", "float64", "{", "return", "float64", "(", "t", ".", "UnixNano", "(", ")", ")", "\n", "}" ]
// TimeToFloat64 returns a float64 representation of a time.
[ "TimeToFloat64", "returns", "a", "float64", "representation", "of", "a", "time", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/time.go#L18-L20
train
wcharczuk/go-chart
util/time.go
FromFloat64
func (tu timeUtil) FromFloat64(tf float64) time.Time { return time.Unix(0, int64(tf)) }
go
func (tu timeUtil) FromFloat64(tf float64) time.Time { return time.Unix(0, int64(tf)) }
[ "func", "(", "tu", "timeUtil", ")", "FromFloat64", "(", "tf", "float64", ")", "time", ".", "Time", "{", "return", "time", ".", "Unix", "(", "0", ",", "int64", "(", "tf", ")", ")", "\n", "}" ]
// Float64ToTime returns a time from a float64.
[ "Float64ToTime", "returns", "a", "time", "from", "a", "float64", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/time.go#L23-L25
train
wcharczuk/go-chart
util/time.go
StartAndEnd
func (tu timeUtil) StartAndEnd(values ...time.Time) (start time.Time, end time.Time) { if len(values) == 0 { return } start = values[0] end = values[0] for _, v := range values[1:] { if end.Before(v) { end = v } if start.After(v) { start = v } } return }
go
func (tu timeUtil) StartAndEnd(values ...time.Time) (start time.Time, end time.Time) { if len(values) == 0 { return } start = values[0] end = values[0] for _, v := range values[1:] { if end.Before(v) { end = v } if start.After(v) { start = v } } return }
[ "func", "(", "tu", "timeUtil", ")", "StartAndEnd", "(", "values", "...", "time", ".", "Time", ")", "(", "start", "time", ".", "Time", ",", "end", "time", ".", "Time", ")", "{", "if", "len", "(", "values", ")", "==", "0", "{", "return", "\n", "}",...
// StartAndEnd returns the start and end of a given set of time in one pass.
[ "StartAndEnd", "returns", "the", "start", "and", "end", "of", "a", "given", "set", "of", "time", "in", "one", "pass", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/time.go#L82-L99
train
wcharczuk/go-chart
sma_series.go
GetPeriod
func (sma SMASeries) GetPeriod(defaults ...int) int { if sma.Period == 0 { if len(defaults) > 0 { return defaults[0] } return DefaultSimpleMovingAveragePeriod } return sma.Period }
go
func (sma SMASeries) GetPeriod(defaults ...int) int { if sma.Period == 0 { if len(defaults) > 0 { return defaults[0] } return DefaultSimpleMovingAveragePeriod } return sma.Period }
[ "func", "(", "sma", "SMASeries", ")", "GetPeriod", "(", "defaults", "...", "int", ")", "int", "{", "if", "sma", ".", "Period", "==", "0", "{", "if", "len", "(", "defaults", ")", ">", "0", "{", "return", "defaults", "[", "0", "]", "\n", "}", "\n",...
// GetPeriod returns the window size.
[ "GetPeriod", "returns", "the", "window", "size", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/sma_series.go#L52-L60
train
wcharczuk/go-chart
style.go
StyleTextDefaults
func StyleTextDefaults() Style { font, _ := GetDefaultFont() return Style{ Show: true, Font: font, FontColor: DefaultTextColor, FontSize: DefaultTitleFontSize, } }
go
func StyleTextDefaults() Style { font, _ := GetDefaultFont() return Style{ Show: true, Font: font, FontColor: DefaultTextColor, FontSize: DefaultTitleFontSize, } }
[ "func", "StyleTextDefaults", "(", ")", "Style", "{", "font", ",", "_", ":=", "GetDefaultFont", "(", ")", "\n", "return", "Style", "{", "Show", ":", "true", ",", "Font", ":", "font", ",", "FontColor", ":", "DefaultTextColor", ",", "FontSize", ":", "Defaul...
// StyleTextDefaults returns a style for drawing outside a // chart context.
[ "StyleTextDefaults", "returns", "a", "style", "for", "drawing", "outside", "a", "chart", "context", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L27-L35
train
wcharczuk/go-chart
style.go
IsZero
func (s Style) IsZero() bool { return s.StrokeColor.IsZero() && s.StrokeWidth == 0 && s.DotColor.IsZero() && s.DotWidth == 0 && s.FillColor.IsZero() && s.FontColor.IsZero() && s.FontSize == 0 && s.Font == nil && s.ClassName == "" }
go
func (s Style) IsZero() bool { return s.StrokeColor.IsZero() && s.StrokeWidth == 0 && s.DotColor.IsZero() && s.DotWidth == 0 && s.FillColor.IsZero() && s.FontColor.IsZero() && s.FontSize == 0 && s.Font == nil && s.ClassName == "" }
[ "func", "(", "s", "Style", ")", "IsZero", "(", ")", "bool", "{", "return", "s", ".", "StrokeColor", ".", "IsZero", "(", ")", "&&", "s", ".", "StrokeWidth", "==", "0", "&&", "s", ".", "DotColor", ".", "IsZero", "(", ")", "&&", "s", ".", "DotWidth"...
// IsZero returns if the object is set or not.
[ "IsZero", "returns", "if", "the", "object", "is", "set", "or", "not", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L68-L78
train
wcharczuk/go-chart
style.go
String
func (s Style) String() string { if s.IsZero() { return "{}" } var output []string if s.Show { output = []string{"\"show\": true"} } else { output = []string{"\"show\": false"} } if s.ClassName != "" { output = append(output, fmt.Sprintf("\"class_name\": %s", s.ClassName)) } else { output = append(output, "\"class_name\": null") } if !s.Padding.IsZero() { output = append(output, fmt.Sprintf("\"padding\": %s", s.Padding.String())) } else { output = append(output, "\"padding\": null") } if s.StrokeWidth >= 0 { output = append(output, fmt.Sprintf("\"stroke_width\": %0.2f", s.StrokeWidth)) } else { output = append(output, "\"stroke_width\": null") } if !s.StrokeColor.IsZero() { output = append(output, fmt.Sprintf("\"stroke_color\": %s", s.StrokeColor.String())) } else { output = append(output, "\"stroke_color\": null") } if len(s.StrokeDashArray) > 0 { var elements []string for _, v := range s.StrokeDashArray { elements = append(elements, fmt.Sprintf("%.2f", v)) } dashArray := strings.Join(elements, ", ") output = append(output, fmt.Sprintf("\"stroke_dash_array\": [%s]", dashArray)) } else { output = append(output, "\"stroke_dash_array\": null") } if s.DotWidth >= 0 { output = append(output, fmt.Sprintf("\"dot_width\": %0.2f", s.DotWidth)) } else { output = append(output, "\"dot_width\": null") } if !s.DotColor.IsZero() { output = append(output, fmt.Sprintf("\"dot_color\": %s", s.DotColor.String())) } else { output = append(output, "\"dot_color\": null") } if !s.FillColor.IsZero() { output = append(output, fmt.Sprintf("\"fill_color\": %s", s.FillColor.String())) } else { output = append(output, "\"fill_color\": null") } if s.FontSize != 0 { output = append(output, fmt.Sprintf("\"font_size\": \"%0.2fpt\"", s.FontSize)) } else { output = append(output, "\"font_size\": null") } if !s.FontColor.IsZero() { output = append(output, fmt.Sprintf("\"font_color\": %s", s.FontColor.String())) } else { output = append(output, "\"font_color\": null") } if s.Font != nil { output = append(output, fmt.Sprintf("\"font\": \"%s\"", s.Font.Name(truetype.NameIDFontFamily))) } else { output = append(output, "\"font_color\": null") } return "{" + strings.Join(output, ", ") + "}" }
go
func (s Style) String() string { if s.IsZero() { return "{}" } var output []string if s.Show { output = []string{"\"show\": true"} } else { output = []string{"\"show\": false"} } if s.ClassName != "" { output = append(output, fmt.Sprintf("\"class_name\": %s", s.ClassName)) } else { output = append(output, "\"class_name\": null") } if !s.Padding.IsZero() { output = append(output, fmt.Sprintf("\"padding\": %s", s.Padding.String())) } else { output = append(output, "\"padding\": null") } if s.StrokeWidth >= 0 { output = append(output, fmt.Sprintf("\"stroke_width\": %0.2f", s.StrokeWidth)) } else { output = append(output, "\"stroke_width\": null") } if !s.StrokeColor.IsZero() { output = append(output, fmt.Sprintf("\"stroke_color\": %s", s.StrokeColor.String())) } else { output = append(output, "\"stroke_color\": null") } if len(s.StrokeDashArray) > 0 { var elements []string for _, v := range s.StrokeDashArray { elements = append(elements, fmt.Sprintf("%.2f", v)) } dashArray := strings.Join(elements, ", ") output = append(output, fmt.Sprintf("\"stroke_dash_array\": [%s]", dashArray)) } else { output = append(output, "\"stroke_dash_array\": null") } if s.DotWidth >= 0 { output = append(output, fmt.Sprintf("\"dot_width\": %0.2f", s.DotWidth)) } else { output = append(output, "\"dot_width\": null") } if !s.DotColor.IsZero() { output = append(output, fmt.Sprintf("\"dot_color\": %s", s.DotColor.String())) } else { output = append(output, "\"dot_color\": null") } if !s.FillColor.IsZero() { output = append(output, fmt.Sprintf("\"fill_color\": %s", s.FillColor.String())) } else { output = append(output, "\"fill_color\": null") } if s.FontSize != 0 { output = append(output, fmt.Sprintf("\"font_size\": \"%0.2fpt\"", s.FontSize)) } else { output = append(output, "\"font_size\": null") } if !s.FontColor.IsZero() { output = append(output, fmt.Sprintf("\"font_color\": %s", s.FontColor.String())) } else { output = append(output, "\"font_color\": null") } if s.Font != nil { output = append(output, fmt.Sprintf("\"font\": \"%s\"", s.Font.Name(truetype.NameIDFontFamily))) } else { output = append(output, "\"font_color\": null") } return "{" + strings.Join(output, ", ") + "}" }
[ "func", "(", "s", "Style", ")", "String", "(", ")", "string", "{", "if", "s", ".", "IsZero", "(", ")", "{", "return", "\"", "\"", "\n", "}", "\n\n", "var", "output", "[", "]", "string", "\n", "if", "s", ".", "Show", "{", "output", "=", "[", "...
// String returns a text representation of the style.
[ "String", "returns", "a", "text", "representation", "of", "the", "style", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L81-L165
train
wcharczuk/go-chart
style.go
GetStrokeColor
func (s Style) GetStrokeColor(defaults ...drawing.Color) drawing.Color { if s.StrokeColor.IsZero() { if len(defaults) > 0 { return defaults[0] } return drawing.ColorTransparent } return s.StrokeColor }
go
func (s Style) GetStrokeColor(defaults ...drawing.Color) drawing.Color { if s.StrokeColor.IsZero() { if len(defaults) > 0 { return defaults[0] } return drawing.ColorTransparent } return s.StrokeColor }
[ "func", "(", "s", "Style", ")", "GetStrokeColor", "(", "defaults", "...", "drawing", ".", "Color", ")", "drawing", ".", "Color", "{", "if", "s", ".", "StrokeColor", ".", "IsZero", "(", ")", "{", "if", "len", "(", "defaults", ")", ">", "0", "{", "re...
// GetStrokeColor returns the stroke color.
[ "GetStrokeColor", "returns", "the", "stroke", "color", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L178-L186
train
wcharczuk/go-chart
style.go
GetFillColor
func (s Style) GetFillColor(defaults ...drawing.Color) drawing.Color { if s.FillColor.IsZero() { if len(defaults) > 0 { return defaults[0] } return drawing.ColorTransparent } return s.FillColor }
go
func (s Style) GetFillColor(defaults ...drawing.Color) drawing.Color { if s.FillColor.IsZero() { if len(defaults) > 0 { return defaults[0] } return drawing.ColorTransparent } return s.FillColor }
[ "func", "(", "s", "Style", ")", "GetFillColor", "(", "defaults", "...", "drawing", ".", "Color", ")", "drawing", ".", "Color", "{", "if", "s", ".", "FillColor", ".", "IsZero", "(", ")", "{", "if", "len", "(", "defaults", ")", ">", "0", "{", "return...
// GetFillColor returns the fill color.
[ "GetFillColor", "returns", "the", "fill", "color", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L189-L197
train
wcharczuk/go-chart
style.go
GetDotColor
func (s Style) GetDotColor(defaults ...drawing.Color) drawing.Color { if s.DotColor.IsZero() { if len(defaults) > 0 { return defaults[0] } return drawing.ColorTransparent } return s.DotColor }
go
func (s Style) GetDotColor(defaults ...drawing.Color) drawing.Color { if s.DotColor.IsZero() { if len(defaults) > 0 { return defaults[0] } return drawing.ColorTransparent } return s.DotColor }
[ "func", "(", "s", "Style", ")", "GetDotColor", "(", "defaults", "...", "drawing", ".", "Color", ")", "drawing", ".", "Color", "{", "if", "s", ".", "DotColor", ".", "IsZero", "(", ")", "{", "if", "len", "(", "defaults", ")", ">", "0", "{", "return",...
// GetDotColor returns the stroke color.
[ "GetDotColor", "returns", "the", "stroke", "color", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L200-L208
train
wcharczuk/go-chart
style.go
GetStrokeWidth
func (s Style) GetStrokeWidth(defaults ...float64) float64 { if s.StrokeWidth == 0 { if len(defaults) > 0 { return defaults[0] } return DefaultStrokeWidth } return s.StrokeWidth }
go
func (s Style) GetStrokeWidth(defaults ...float64) float64 { if s.StrokeWidth == 0 { if len(defaults) > 0 { return defaults[0] } return DefaultStrokeWidth } return s.StrokeWidth }
[ "func", "(", "s", "Style", ")", "GetStrokeWidth", "(", "defaults", "...", "float64", ")", "float64", "{", "if", "s", ".", "StrokeWidth", "==", "0", "{", "if", "len", "(", "defaults", ")", ">", "0", "{", "return", "defaults", "[", "0", "]", "\n", "}...
// GetStrokeWidth returns the stroke width.
[ "GetStrokeWidth", "returns", "the", "stroke", "width", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L211-L219
train
wcharczuk/go-chart
style.go
GetDotWidth
func (s Style) GetDotWidth(defaults ...float64) float64 { if s.DotWidth == 0 { if len(defaults) > 0 { return defaults[0] } return DefaultDotWidth } return s.DotWidth }
go
func (s Style) GetDotWidth(defaults ...float64) float64 { if s.DotWidth == 0 { if len(defaults) > 0 { return defaults[0] } return DefaultDotWidth } return s.DotWidth }
[ "func", "(", "s", "Style", ")", "GetDotWidth", "(", "defaults", "...", "float64", ")", "float64", "{", "if", "s", ".", "DotWidth", "==", "0", "{", "if", "len", "(", "defaults", ")", ">", "0", "{", "return", "defaults", "[", "0", "]", "\n", "}", "...
// GetDotWidth returns the dot width for scatter plots.
[ "GetDotWidth", "returns", "the", "dot", "width", "for", "scatter", "plots", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L222-L230
train
wcharczuk/go-chart
style.go
GetStrokeDashArray
func (s Style) GetStrokeDashArray(defaults ...[]float64) []float64 { if len(s.StrokeDashArray) == 0 { if len(defaults) > 0 { return defaults[0] } return nil } return s.StrokeDashArray }
go
func (s Style) GetStrokeDashArray(defaults ...[]float64) []float64 { if len(s.StrokeDashArray) == 0 { if len(defaults) > 0 { return defaults[0] } return nil } return s.StrokeDashArray }
[ "func", "(", "s", "Style", ")", "GetStrokeDashArray", "(", "defaults", "...", "[", "]", "float64", ")", "[", "]", "float64", "{", "if", "len", "(", "s", ".", "StrokeDashArray", ")", "==", "0", "{", "if", "len", "(", "defaults", ")", ">", "0", "{", ...
// GetStrokeDashArray returns the stroke dash array.
[ "GetStrokeDashArray", "returns", "the", "stroke", "dash", "array", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L233-L241
train
wcharczuk/go-chart
style.go
GetFontSize
func (s Style) GetFontSize(defaults ...float64) float64 { if s.FontSize == 0 { if len(defaults) > 0 { return defaults[0] } return DefaultFontSize } return s.FontSize }
go
func (s Style) GetFontSize(defaults ...float64) float64 { if s.FontSize == 0 { if len(defaults) > 0 { return defaults[0] } return DefaultFontSize } return s.FontSize }
[ "func", "(", "s", "Style", ")", "GetFontSize", "(", "defaults", "...", "float64", ")", "float64", "{", "if", "s", ".", "FontSize", "==", "0", "{", "if", "len", "(", "defaults", ")", ">", "0", "{", "return", "defaults", "[", "0", "]", "\n", "}", "...
// GetFontSize gets the font size.
[ "GetFontSize", "gets", "the", "font", "size", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L244-L252
train
wcharczuk/go-chart
style.go
GetFontColor
func (s Style) GetFontColor(defaults ...drawing.Color) drawing.Color { if s.FontColor.IsZero() { if len(defaults) > 0 { return defaults[0] } return drawing.ColorTransparent } return s.FontColor }
go
func (s Style) GetFontColor(defaults ...drawing.Color) drawing.Color { if s.FontColor.IsZero() { if len(defaults) > 0 { return defaults[0] } return drawing.ColorTransparent } return s.FontColor }
[ "func", "(", "s", "Style", ")", "GetFontColor", "(", "defaults", "...", "drawing", ".", "Color", ")", "drawing", ".", "Color", "{", "if", "s", ".", "FontColor", ".", "IsZero", "(", ")", "{", "if", "len", "(", "defaults", ")", ">", "0", "{", "return...
// GetFontColor gets the font size.
[ "GetFontColor", "gets", "the", "font", "size", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L255-L263
train
wcharczuk/go-chart
style.go
GetFont
func (s Style) GetFont(defaults ...*truetype.Font) *truetype.Font { if s.Font == nil { if len(defaults) > 0 { return defaults[0] } return nil } return s.Font }
go
func (s Style) GetFont(defaults ...*truetype.Font) *truetype.Font { if s.Font == nil { if len(defaults) > 0 { return defaults[0] } return nil } return s.Font }
[ "func", "(", "s", "Style", ")", "GetFont", "(", "defaults", "...", "*", "truetype", ".", "Font", ")", "*", "truetype", ".", "Font", "{", "if", "s", ".", "Font", "==", "nil", "{", "if", "len", "(", "defaults", ")", ">", "0", "{", "return", "defaul...
// GetFont returns the font face.
[ "GetFont", "returns", "the", "font", "face", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L266-L274
train
wcharczuk/go-chart
style.go
GetPadding
func (s Style) GetPadding(defaults ...Box) Box { if s.Padding.IsZero() { if len(defaults) > 0 { return defaults[0] } return Box{} } return s.Padding }
go
func (s Style) GetPadding(defaults ...Box) Box { if s.Padding.IsZero() { if len(defaults) > 0 { return defaults[0] } return Box{} } return s.Padding }
[ "func", "(", "s", "Style", ")", "GetPadding", "(", "defaults", "...", "Box", ")", "Box", "{", "if", "s", ".", "Padding", ".", "IsZero", "(", ")", "{", "if", "len", "(", "defaults", ")", ">", "0", "{", "return", "defaults", "[", "0", "]", "\n", ...
// GetPadding returns the padding.
[ "GetPadding", "returns", "the", "padding", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L277-L285
train
wcharczuk/go-chart
style.go
GetTextHorizontalAlign
func (s Style) GetTextHorizontalAlign(defaults ...TextHorizontalAlign) TextHorizontalAlign { if s.TextHorizontalAlign == TextHorizontalAlignUnset { if len(defaults) > 0 { return defaults[0] } return TextHorizontalAlignUnset } return s.TextHorizontalAlign }
go
func (s Style) GetTextHorizontalAlign(defaults ...TextHorizontalAlign) TextHorizontalAlign { if s.TextHorizontalAlign == TextHorizontalAlignUnset { if len(defaults) > 0 { return defaults[0] } return TextHorizontalAlignUnset } return s.TextHorizontalAlign }
[ "func", "(", "s", "Style", ")", "GetTextHorizontalAlign", "(", "defaults", "...", "TextHorizontalAlign", ")", "TextHorizontalAlign", "{", "if", "s", ".", "TextHorizontalAlign", "==", "TextHorizontalAlignUnset", "{", "if", "len", "(", "defaults", ")", ">", "0", "...
// GetTextHorizontalAlign returns the horizontal alignment.
[ "GetTextHorizontalAlign", "returns", "the", "horizontal", "alignment", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L288-L296
train
wcharczuk/go-chart
style.go
GetTextVerticalAlign
func (s Style) GetTextVerticalAlign(defaults ...TextVerticalAlign) TextVerticalAlign { if s.TextVerticalAlign == TextVerticalAlignUnset { if len(defaults) > 0 { return defaults[0] } return TextVerticalAlignUnset } return s.TextVerticalAlign }
go
func (s Style) GetTextVerticalAlign(defaults ...TextVerticalAlign) TextVerticalAlign { if s.TextVerticalAlign == TextVerticalAlignUnset { if len(defaults) > 0 { return defaults[0] } return TextVerticalAlignUnset } return s.TextVerticalAlign }
[ "func", "(", "s", "Style", ")", "GetTextVerticalAlign", "(", "defaults", "...", "TextVerticalAlign", ")", "TextVerticalAlign", "{", "if", "s", ".", "TextVerticalAlign", "==", "TextVerticalAlignUnset", "{", "if", "len", "(", "defaults", ")", ">", "0", "{", "ret...
// GetTextVerticalAlign returns the vertical alignment.
[ "GetTextVerticalAlign", "returns", "the", "vertical", "alignment", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L299-L307
train
wcharczuk/go-chart
style.go
GetTextWrap
func (s Style) GetTextWrap(defaults ...TextWrap) TextWrap { if s.TextWrap == TextWrapUnset { if len(defaults) > 0 { return defaults[0] } return TextWrapUnset } return s.TextWrap }
go
func (s Style) GetTextWrap(defaults ...TextWrap) TextWrap { if s.TextWrap == TextWrapUnset { if len(defaults) > 0 { return defaults[0] } return TextWrapUnset } return s.TextWrap }
[ "func", "(", "s", "Style", ")", "GetTextWrap", "(", "defaults", "...", "TextWrap", ")", "TextWrap", "{", "if", "s", ".", "TextWrap", "==", "TextWrapUnset", "{", "if", "len", "(", "defaults", ")", ">", "0", "{", "return", "defaults", "[", "0", "]", "\...
// GetTextWrap returns the word wrap.
[ "GetTextWrap", "returns", "the", "word", "wrap", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L310-L318
train
wcharczuk/go-chart
style.go
GetTextRotationDegrees
func (s Style) GetTextRotationDegrees(defaults ...float64) float64 { if s.TextRotationDegrees == 0 { if len(defaults) > 0 { return defaults[0] } } return s.TextRotationDegrees }
go
func (s Style) GetTextRotationDegrees(defaults ...float64) float64 { if s.TextRotationDegrees == 0 { if len(defaults) > 0 { return defaults[0] } } return s.TextRotationDegrees }
[ "func", "(", "s", "Style", ")", "GetTextRotationDegrees", "(", "defaults", "...", "float64", ")", "float64", "{", "if", "s", ".", "TextRotationDegrees", "==", "0", "{", "if", "len", "(", "defaults", ")", ">", "0", "{", "return", "defaults", "[", "0", "...
// GetTextRotationDegrees returns the text rotation in degrees.
[ "GetTextRotationDegrees", "returns", "the", "text", "rotation", "in", "degrees", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L332-L339
train
wcharczuk/go-chart
style.go
WriteToRenderer
func (s Style) WriteToRenderer(r Renderer) { r.SetClassName(s.GetClassName()) r.SetStrokeColor(s.GetStrokeColor()) r.SetStrokeWidth(s.GetStrokeWidth()) r.SetStrokeDashArray(s.GetStrokeDashArray()) r.SetFillColor(s.GetFillColor()) r.SetFont(s.GetFont()) r.SetFontColor(s.GetFontColor()) r.SetFontSize(s.GetFontSize()) r.ClearTextRotation() if s.GetTextRotationDegrees() != 0 { r.SetTextRotation(util.Math.DegreesToRadians(s.GetTextRotationDegrees())) } }
go
func (s Style) WriteToRenderer(r Renderer) { r.SetClassName(s.GetClassName()) r.SetStrokeColor(s.GetStrokeColor()) r.SetStrokeWidth(s.GetStrokeWidth()) r.SetStrokeDashArray(s.GetStrokeDashArray()) r.SetFillColor(s.GetFillColor()) r.SetFont(s.GetFont()) r.SetFontColor(s.GetFontColor()) r.SetFontSize(s.GetFontSize()) r.ClearTextRotation() if s.GetTextRotationDegrees() != 0 { r.SetTextRotation(util.Math.DegreesToRadians(s.GetTextRotationDegrees())) } }
[ "func", "(", "s", "Style", ")", "WriteToRenderer", "(", "r", "Renderer", ")", "{", "r", ".", "SetClassName", "(", "s", ".", "GetClassName", "(", ")", ")", "\n", "r", ".", "SetStrokeColor", "(", "s", ".", "GetStrokeColor", "(", ")", ")", "\n", "r", ...
// WriteToRenderer passes the style's options to a renderer.
[ "WriteToRenderer", "passes", "the", "style", "s", "options", "to", "a", "renderer", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L342-L356
train
wcharczuk/go-chart
style.go
WriteDrawingOptionsToRenderer
func (s Style) WriteDrawingOptionsToRenderer(r Renderer) { r.SetClassName(s.GetClassName()) r.SetStrokeColor(s.GetStrokeColor()) r.SetStrokeWidth(s.GetStrokeWidth()) r.SetStrokeDashArray(s.GetStrokeDashArray()) r.SetFillColor(s.GetFillColor()) }
go
func (s Style) WriteDrawingOptionsToRenderer(r Renderer) { r.SetClassName(s.GetClassName()) r.SetStrokeColor(s.GetStrokeColor()) r.SetStrokeWidth(s.GetStrokeWidth()) r.SetStrokeDashArray(s.GetStrokeDashArray()) r.SetFillColor(s.GetFillColor()) }
[ "func", "(", "s", "Style", ")", "WriteDrawingOptionsToRenderer", "(", "r", "Renderer", ")", "{", "r", ".", "SetClassName", "(", "s", ".", "GetClassName", "(", ")", ")", "\n", "r", ".", "SetStrokeColor", "(", "s", ".", "GetStrokeColor", "(", ")", ")", "...
// WriteDrawingOptionsToRenderer passes just the drawing style options to a renderer.
[ "WriteDrawingOptionsToRenderer", "passes", "just", "the", "drawing", "style", "options", "to", "a", "renderer", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L359-L365
train
wcharczuk/go-chart
style.go
WriteTextOptionsToRenderer
func (s Style) WriteTextOptionsToRenderer(r Renderer) { r.SetClassName(s.GetClassName()) r.SetFont(s.GetFont()) r.SetFontColor(s.GetFontColor()) r.SetFontSize(s.GetFontSize()) }
go
func (s Style) WriteTextOptionsToRenderer(r Renderer) { r.SetClassName(s.GetClassName()) r.SetFont(s.GetFont()) r.SetFontColor(s.GetFontColor()) r.SetFontSize(s.GetFontSize()) }
[ "func", "(", "s", "Style", ")", "WriteTextOptionsToRenderer", "(", "r", "Renderer", ")", "{", "r", ".", "SetClassName", "(", "s", ".", "GetClassName", "(", ")", ")", "\n", "r", ".", "SetFont", "(", "s", ".", "GetFont", "(", ")", ")", "\n", "r", "."...
// WriteTextOptionsToRenderer passes just the text style options to a renderer.
[ "WriteTextOptionsToRenderer", "passes", "just", "the", "text", "style", "options", "to", "a", "renderer", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L368-L373
train
wcharczuk/go-chart
style.go
InheritFrom
func (s Style) InheritFrom(defaults Style) (final Style) { final.ClassName = s.GetClassName(defaults.ClassName) final.StrokeColor = s.GetStrokeColor(defaults.StrokeColor) final.StrokeWidth = s.GetStrokeWidth(defaults.StrokeWidth) final.StrokeDashArray = s.GetStrokeDashArray(defaults.StrokeDashArray) final.DotColor = s.GetDotColor(defaults.DotColor) final.DotWidth = s.GetDotWidth(defaults.DotWidth) final.DotWidthProvider = s.DotWidthProvider final.DotColorProvider = s.DotColorProvider final.FillColor = s.GetFillColor(defaults.FillColor) final.FontColor = s.GetFontColor(defaults.FontColor) final.FontSize = s.GetFontSize(defaults.FontSize) final.Font = s.GetFont(defaults.Font) final.Padding = s.GetPadding(defaults.Padding) final.TextHorizontalAlign = s.GetTextHorizontalAlign(defaults.TextHorizontalAlign) final.TextVerticalAlign = s.GetTextVerticalAlign(defaults.TextVerticalAlign) final.TextWrap = s.GetTextWrap(defaults.TextWrap) final.TextLineSpacing = s.GetTextLineSpacing(defaults.TextLineSpacing) final.TextRotationDegrees = s.GetTextRotationDegrees(defaults.TextRotationDegrees) return }
go
func (s Style) InheritFrom(defaults Style) (final Style) { final.ClassName = s.GetClassName(defaults.ClassName) final.StrokeColor = s.GetStrokeColor(defaults.StrokeColor) final.StrokeWidth = s.GetStrokeWidth(defaults.StrokeWidth) final.StrokeDashArray = s.GetStrokeDashArray(defaults.StrokeDashArray) final.DotColor = s.GetDotColor(defaults.DotColor) final.DotWidth = s.GetDotWidth(defaults.DotWidth) final.DotWidthProvider = s.DotWidthProvider final.DotColorProvider = s.DotColorProvider final.FillColor = s.GetFillColor(defaults.FillColor) final.FontColor = s.GetFontColor(defaults.FontColor) final.FontSize = s.GetFontSize(defaults.FontSize) final.Font = s.GetFont(defaults.Font) final.Padding = s.GetPadding(defaults.Padding) final.TextHorizontalAlign = s.GetTextHorizontalAlign(defaults.TextHorizontalAlign) final.TextVerticalAlign = s.GetTextVerticalAlign(defaults.TextVerticalAlign) final.TextWrap = s.GetTextWrap(defaults.TextWrap) final.TextLineSpacing = s.GetTextLineSpacing(defaults.TextLineSpacing) final.TextRotationDegrees = s.GetTextRotationDegrees(defaults.TextRotationDegrees) return }
[ "func", "(", "s", "Style", ")", "InheritFrom", "(", "defaults", "Style", ")", "(", "final", "Style", ")", "{", "final", ".", "ClassName", "=", "s", ".", "GetClassName", "(", "defaults", ".", "ClassName", ")", "\n\n", "final", ".", "StrokeColor", "=", "...
// InheritFrom coalesces two styles into a new style.
[ "InheritFrom", "coalesces", "two", "styles", "into", "a", "new", "style", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L376-L401
train
wcharczuk/go-chart
style.go
GetStrokeOptions
func (s Style) GetStrokeOptions() Style { return Style{ ClassName: s.ClassName, StrokeDashArray: s.StrokeDashArray, StrokeColor: s.StrokeColor, StrokeWidth: s.StrokeWidth, } }
go
func (s Style) GetStrokeOptions() Style { return Style{ ClassName: s.ClassName, StrokeDashArray: s.StrokeDashArray, StrokeColor: s.StrokeColor, StrokeWidth: s.StrokeWidth, } }
[ "func", "(", "s", "Style", ")", "GetStrokeOptions", "(", ")", "Style", "{", "return", "Style", "{", "ClassName", ":", "s", ".", "ClassName", ",", "StrokeDashArray", ":", "s", ".", "StrokeDashArray", ",", "StrokeColor", ":", "s", ".", "StrokeColor", ",", ...
// GetStrokeOptions returns the stroke components.
[ "GetStrokeOptions", "returns", "the", "stroke", "components", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L404-L411
train
wcharczuk/go-chart
style.go
GetFillOptions
func (s Style) GetFillOptions() Style { return Style{ ClassName: s.ClassName, FillColor: s.FillColor, } }
go
func (s Style) GetFillOptions() Style { return Style{ ClassName: s.ClassName, FillColor: s.FillColor, } }
[ "func", "(", "s", "Style", ")", "GetFillOptions", "(", ")", "Style", "{", "return", "Style", "{", "ClassName", ":", "s", ".", "ClassName", ",", "FillColor", ":", "s", ".", "FillColor", ",", "}", "\n", "}" ]
// GetFillOptions returns the fill components.
[ "GetFillOptions", "returns", "the", "fill", "components", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L414-L419
train
wcharczuk/go-chart
style.go
GetDotOptions
func (s Style) GetDotOptions() Style { return Style{ ClassName: s.ClassName, StrokeDashArray: nil, FillColor: s.DotColor, StrokeColor: s.DotColor, StrokeWidth: 1.0, } }
go
func (s Style) GetDotOptions() Style { return Style{ ClassName: s.ClassName, StrokeDashArray: nil, FillColor: s.DotColor, StrokeColor: s.DotColor, StrokeWidth: 1.0, } }
[ "func", "(", "s", "Style", ")", "GetDotOptions", "(", ")", "Style", "{", "return", "Style", "{", "ClassName", ":", "s", ".", "ClassName", ",", "StrokeDashArray", ":", "nil", ",", "FillColor", ":", "s", ".", "DotColor", ",", "StrokeColor", ":", "s", "."...
// GetDotOptions returns the dot components.
[ "GetDotOptions", "returns", "the", "dot", "components", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L422-L430
train
wcharczuk/go-chart
style.go
GetFillAndStrokeOptions
func (s Style) GetFillAndStrokeOptions() Style { return Style{ ClassName: s.ClassName, StrokeDashArray: s.StrokeDashArray, FillColor: s.FillColor, StrokeColor: s.StrokeColor, StrokeWidth: s.StrokeWidth, } }
go
func (s Style) GetFillAndStrokeOptions() Style { return Style{ ClassName: s.ClassName, StrokeDashArray: s.StrokeDashArray, FillColor: s.FillColor, StrokeColor: s.StrokeColor, StrokeWidth: s.StrokeWidth, } }
[ "func", "(", "s", "Style", ")", "GetFillAndStrokeOptions", "(", ")", "Style", "{", "return", "Style", "{", "ClassName", ":", "s", ".", "ClassName", ",", "StrokeDashArray", ":", "s", ".", "StrokeDashArray", ",", "FillColor", ":", "s", ".", "FillColor", ",",...
// GetFillAndStrokeOptions returns the fill and stroke components.
[ "GetFillAndStrokeOptions", "returns", "the", "fill", "and", "stroke", "components", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L433-L441
train
wcharczuk/go-chart
style.go
GetTextOptions
func (s Style) GetTextOptions() Style { return Style{ ClassName: s.ClassName, FontColor: s.FontColor, FontSize: s.FontSize, Font: s.Font, TextHorizontalAlign: s.TextHorizontalAlign, TextVerticalAlign: s.TextVerticalAlign, TextWrap: s.TextWrap, TextLineSpacing: s.TextLineSpacing, TextRotationDegrees: s.TextRotationDegrees, } }
go
func (s Style) GetTextOptions() Style { return Style{ ClassName: s.ClassName, FontColor: s.FontColor, FontSize: s.FontSize, Font: s.Font, TextHorizontalAlign: s.TextHorizontalAlign, TextVerticalAlign: s.TextVerticalAlign, TextWrap: s.TextWrap, TextLineSpacing: s.TextLineSpacing, TextRotationDegrees: s.TextRotationDegrees, } }
[ "func", "(", "s", "Style", ")", "GetTextOptions", "(", ")", "Style", "{", "return", "Style", "{", "ClassName", ":", "s", ".", "ClassName", ",", "FontColor", ":", "s", ".", "FontColor", ",", "FontSize", ":", "s", ".", "FontSize", ",", "Font", ":", "s"...
// GetTextOptions returns just the text components of the style.
[ "GetTextOptions", "returns", "just", "the", "text", "components", "of", "the", "style", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L444-L456
train
wcharczuk/go-chart
style.go
ShouldDrawDot
func (s Style) ShouldDrawDot() bool { return (!s.DotColor.IsZero() && s.DotWidth > 0) || s.DotColorProvider != nil || s.DotWidthProvider != nil }
go
func (s Style) ShouldDrawDot() bool { return (!s.DotColor.IsZero() && s.DotWidth > 0) || s.DotColorProvider != nil || s.DotWidthProvider != nil }
[ "func", "(", "s", "Style", ")", "ShouldDrawDot", "(", ")", "bool", "{", "return", "(", "!", "s", ".", "DotColor", ".", "IsZero", "(", ")", "&&", "s", ".", "DotWidth", ">", "0", ")", "||", "s", ".", "DotColorProvider", "!=", "nil", "||", "s", ".",...
// ShouldDrawDot tells drawing functions if they should draw the dot.
[ "ShouldDrawDot", "tells", "drawing", "functions", "if", "they", "should", "draw", "the", "dot", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L464-L466
train
wcharczuk/go-chart
matrix/regression.go
Poly
func Poly(xvalues, yvalues []float64, degree int) ([]float64, error) { if len(xvalues) != len(yvalues) { return nil, ErrPolyRegArraysSameLength } m := len(yvalues) n := degree + 1 y := New(m, 1, yvalues...) x := Zero(m, n) for i := 0; i < m; i++ { ip := float64(1) for j := 0; j < n; j++ { x.Set(i, j, ip) ip *= xvalues[i] } } q, r := x.QR() qty, err := q.Transpose().Times(y) if err != nil { return nil, err } c := make([]float64, n) for i := n - 1; i >= 0; i-- { c[i] = qty.Get(i, 0) for j := i + 1; j < n; j++ { c[i] -= c[j] * r.Get(i, j) } c[i] /= r.Get(i, i) } return c, nil }
go
func Poly(xvalues, yvalues []float64, degree int) ([]float64, error) { if len(xvalues) != len(yvalues) { return nil, ErrPolyRegArraysSameLength } m := len(yvalues) n := degree + 1 y := New(m, 1, yvalues...) x := Zero(m, n) for i := 0; i < m; i++ { ip := float64(1) for j := 0; j < n; j++ { x.Set(i, j, ip) ip *= xvalues[i] } } q, r := x.QR() qty, err := q.Transpose().Times(y) if err != nil { return nil, err } c := make([]float64, n) for i := n - 1; i >= 0; i-- { c[i] = qty.Get(i, 0) for j := i + 1; j < n; j++ { c[i] -= c[j] * r.Get(i, j) } c[i] /= r.Get(i, i) } return c, nil }
[ "func", "Poly", "(", "xvalues", ",", "yvalues", "[", "]", "float64", ",", "degree", "int", ")", "(", "[", "]", "float64", ",", "error", ")", "{", "if", "len", "(", "xvalues", ")", "!=", "len", "(", "yvalues", ")", "{", "return", "nil", ",", "ErrP...
// Poly returns the polynomial regress of a given degree over the given values.
[ "Poly", "returns", "the", "polynomial", "regress", "of", "a", "given", "degree", "over", "the", "given", "values", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/regression.go#L11-L45
train
wcharczuk/go-chart
linear_coefficient_provider.go
LinearCoefficients
func LinearCoefficients(m, b float64) LinearCoefficientSet { return LinearCoefficientSet{ M: m, B: b, } }
go
func LinearCoefficients(m, b float64) LinearCoefficientSet { return LinearCoefficientSet{ M: m, B: b, } }
[ "func", "LinearCoefficients", "(", "m", ",", "b", "float64", ")", "LinearCoefficientSet", "{", "return", "LinearCoefficientSet", "{", "M", ":", "m", ",", "B", ":", "b", ",", "}", "\n", "}" ]
// LinearCoefficients returns a fixed linear coefficient pair.
[ "LinearCoefficients", "returns", "a", "fixed", "linear", "coefficient", "pair", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/linear_coefficient_provider.go#L9-L14
train
wcharczuk/go-chart
linear_coefficient_provider.go
NormalizedLinearCoefficients
func NormalizedLinearCoefficients(m, b, stdev, avg float64) LinearCoefficientSet { return LinearCoefficientSet{ M: m, B: b, StdDev: stdev, Avg: avg, } }
go
func NormalizedLinearCoefficients(m, b, stdev, avg float64) LinearCoefficientSet { return LinearCoefficientSet{ M: m, B: b, StdDev: stdev, Avg: avg, } }
[ "func", "NormalizedLinearCoefficients", "(", "m", ",", "b", ",", "stdev", ",", "avg", "float64", ")", "LinearCoefficientSet", "{", "return", "LinearCoefficientSet", "{", "M", ":", "m", ",", "B", ":", "b", ",", "StdDev", ":", "stdev", ",", "Avg", ":", "av...
// NormalizedLinearCoefficients returns a fixed linear coefficient pair.
[ "NormalizedLinearCoefficients", "returns", "a", "fixed", "linear", "coefficient", "pair", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/linear_coefficient_provider.go#L17-L24
train
wcharczuk/go-chart
linear_coefficient_provider.go
Coefficients
func (lcs LinearCoefficientSet) Coefficients() (m, b, stdev, avg float64) { m = lcs.M b = lcs.B stdev = lcs.StdDev avg = lcs.Avg return }
go
func (lcs LinearCoefficientSet) Coefficients() (m, b, stdev, avg float64) { m = lcs.M b = lcs.B stdev = lcs.StdDev avg = lcs.Avg return }
[ "func", "(", "lcs", "LinearCoefficientSet", ")", "Coefficients", "(", ")", "(", "m", ",", "b", ",", "stdev", ",", "avg", "float64", ")", "{", "m", "=", "lcs", ".", "M", "\n", "b", "=", "lcs", ".", "B", "\n", "stdev", "=", "lcs", ".", "StdDev", ...
// Coefficients returns the coefficients.
[ "Coefficients", "returns", "the", "coefficients", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/linear_coefficient_provider.go#L36-L42
train
wcharczuk/go-chart
grid_line.go
Render
func (gl GridLine) Render(r Renderer, canvasBox Box, ra Range, isVertical bool, defaults Style) { r.SetStrokeColor(gl.Style.GetStrokeColor(defaults.GetStrokeColor())) r.SetStrokeWidth(gl.Style.GetStrokeWidth(defaults.GetStrokeWidth())) r.SetStrokeDashArray(gl.Style.GetStrokeDashArray(defaults.GetStrokeDashArray())) if isVertical { lineLeft := canvasBox.Left + ra.Translate(gl.Value) lineBottom := canvasBox.Bottom lineTop := canvasBox.Top r.MoveTo(lineLeft, lineBottom) r.LineTo(lineLeft, lineTop) r.Stroke() } else { lineLeft := canvasBox.Left lineRight := canvasBox.Right lineHeight := canvasBox.Bottom - ra.Translate(gl.Value) r.MoveTo(lineLeft, lineHeight) r.LineTo(lineRight, lineHeight) r.Stroke() } }
go
func (gl GridLine) Render(r Renderer, canvasBox Box, ra Range, isVertical bool, defaults Style) { r.SetStrokeColor(gl.Style.GetStrokeColor(defaults.GetStrokeColor())) r.SetStrokeWidth(gl.Style.GetStrokeWidth(defaults.GetStrokeWidth())) r.SetStrokeDashArray(gl.Style.GetStrokeDashArray(defaults.GetStrokeDashArray())) if isVertical { lineLeft := canvasBox.Left + ra.Translate(gl.Value) lineBottom := canvasBox.Bottom lineTop := canvasBox.Top r.MoveTo(lineLeft, lineBottom) r.LineTo(lineLeft, lineTop) r.Stroke() } else { lineLeft := canvasBox.Left lineRight := canvasBox.Right lineHeight := canvasBox.Bottom - ra.Translate(gl.Value) r.MoveTo(lineLeft, lineHeight) r.LineTo(lineRight, lineHeight) r.Stroke() } }
[ "func", "(", "gl", "GridLine", ")", "Render", "(", "r", "Renderer", ",", "canvasBox", "Box", ",", "ra", "Range", ",", "isVertical", "bool", ",", "defaults", "Style", ")", "{", "r", ".", "SetStrokeColor", "(", "gl", ".", "Style", ".", "GetStrokeColor", ...
// Render renders the gridline
[ "Render", "renders", "the", "gridline" ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/grid_line.go#L26-L48
train
wcharczuk/go-chart
grid_line.go
GenerateGridLines
func GenerateGridLines(ticks []Tick, majorStyle, minorStyle Style) []GridLine { var gl []GridLine isMinor := false if len(ticks) < 3 { return gl } for _, t := range ticks[1 : len(ticks)-1] { s := majorStyle if isMinor { s = minorStyle } gl = append(gl, GridLine{ Style: s, IsMinor: isMinor, Value: t.Value, }) isMinor = !isMinor } return gl }
go
func GenerateGridLines(ticks []Tick, majorStyle, minorStyle Style) []GridLine { var gl []GridLine isMinor := false if len(ticks) < 3 { return gl } for _, t := range ticks[1 : len(ticks)-1] { s := majorStyle if isMinor { s = minorStyle } gl = append(gl, GridLine{ Style: s, IsMinor: isMinor, Value: t.Value, }) isMinor = !isMinor } return gl }
[ "func", "GenerateGridLines", "(", "ticks", "[", "]", "Tick", ",", "majorStyle", ",", "minorStyle", "Style", ")", "[", "]", "GridLine", "{", "var", "gl", "[", "]", "GridLine", "\n", "isMinor", ":=", "false", "\n\n", "if", "len", "(", "ticks", ")", "<", ...
// GenerateGridLines generates grid lines.
[ "GenerateGridLines", "generates", "grid", "lines", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/grid_line.go#L51-L72
train
wcharczuk/go-chart
histogram_series.go
GetValues
func (hs HistogramSeries) GetValues(index int) (x, y float64) { return hs.InnerSeries.GetValues(index) }
go
func (hs HistogramSeries) GetValues(index int) (x, y float64) { return hs.InnerSeries.GetValues(index) }
[ "func", "(", "hs", "HistogramSeries", ")", "GetValues", "(", "index", "int", ")", "(", "x", ",", "y", "float64", ")", "{", "return", "hs", ".", "InnerSeries", ".", "GetValues", "(", "index", ")", "\n", "}" ]
// GetValues implements ValuesProvider.GetValues.
[ "GetValues", "implements", "ValuesProvider", ".", "GetValues", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/histogram_series.go#L36-L38
train
wcharczuk/go-chart
histogram_series.go
GetBoundedValues
func (hs HistogramSeries) GetBoundedValues(index int) (x, y1, y2 float64) { vx, vy := hs.InnerSeries.GetValues(index) x = vx if vy > 0 { y1 = vy return } y2 = vy return }
go
func (hs HistogramSeries) GetBoundedValues(index int) (x, y1, y2 float64) { vx, vy := hs.InnerSeries.GetValues(index) x = vx if vy > 0 { y1 = vy return } y2 = vy return }
[ "func", "(", "hs", "HistogramSeries", ")", "GetBoundedValues", "(", "index", "int", ")", "(", "x", ",", "y1", ",", "y2", "float64", ")", "{", "vx", ",", "vy", ":=", "hs", ".", "InnerSeries", ".", "GetValues", "(", "index", ")", "\n\n", "x", "=", "v...
// GetBoundedValues implements BoundedValuesProvider.GetBoundedValue
[ "GetBoundedValues", "implements", "BoundedValuesProvider", ".", "GetBoundedValue" ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/histogram_series.go#L41-L53
train
wcharczuk/go-chart
histogram_series.go
Render
func (hs HistogramSeries) Render(r Renderer, canvasBox Box, xrange, yrange Range, defaults Style) { style := hs.Style.InheritFrom(defaults) Draw.HistogramSeries(r, canvasBox, xrange, yrange, style, hs) }
go
func (hs HistogramSeries) Render(r Renderer, canvasBox Box, xrange, yrange Range, defaults Style) { style := hs.Style.InheritFrom(defaults) Draw.HistogramSeries(r, canvasBox, xrange, yrange, style, hs) }
[ "func", "(", "hs", "HistogramSeries", ")", "Render", "(", "r", "Renderer", ",", "canvasBox", "Box", ",", "xrange", ",", "yrange", "Range", ",", "defaults", "Style", ")", "{", "style", ":=", "hs", ".", "Style", ".", "InheritFrom", "(", "defaults", ")", ...
// Render implements Series.Render.
[ "Render", "implements", "Series", ".", "Render", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/histogram_series.go#L56-L59
train
wcharczuk/go-chart
util/date.go
Eastern
func (d date) Eastern() (*time.Location, error) { // Try POSIX est, err := time.LoadLocation("America/New_York") if err != nil { // Try Windows est, err = time.LoadLocation("EST") if err != nil { return nil, err } } return est, nil }
go
func (d date) Eastern() (*time.Location, error) { // Try POSIX est, err := time.LoadLocation("America/New_York") if err != nil { // Try Windows est, err = time.LoadLocation("EST") if err != nil { return nil, err } } return est, nil }
[ "func", "(", "d", "date", ")", "Eastern", "(", ")", "(", "*", "time", ".", "Location", ",", "error", ")", "{", "// Try POSIX", "est", ",", "err", ":=", "time", ".", "LoadLocation", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "// Tr...
// Eastern returns the eastern timezone.
[ "Eastern", "returns", "the", "eastern", "timezone", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/date.go#L61-L72
train
wcharczuk/go-chart
util/date.go
Pacific
func (d date) Pacific() (*time.Location, error) { // Try POSIX pst, err := time.LoadLocation("America/Los_Angeles") if err != nil { // Try Windows pst, err = time.LoadLocation("PST") if err != nil { return nil, err } } return pst, nil }
go
func (d date) Pacific() (*time.Location, error) { // Try POSIX pst, err := time.LoadLocation("America/Los_Angeles") if err != nil { // Try Windows pst, err = time.LoadLocation("PST") if err != nil { return nil, err } } return pst, nil }
[ "func", "(", "d", "date", ")", "Pacific", "(", ")", "(", "*", "time", ".", "Location", ",", "error", ")", "{", "// Try POSIX", "pst", ",", "err", ":=", "time", ".", "LoadLocation", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "// Tr...
// Pacific returns the pacific timezone.
[ "Pacific", "returns", "the", "pacific", "timezone", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/date.go#L83-L94
train
wcharczuk/go-chart
util/date.go
TimeUTC
func (d date) TimeUTC(hour, min, sec, nsec int) time.Time { return time.Date(0, 0, 0, hour, min, sec, nsec, time.UTC) }
go
func (d date) TimeUTC(hour, min, sec, nsec int) time.Time { return time.Date(0, 0, 0, hour, min, sec, nsec, time.UTC) }
[ "func", "(", "d", "date", ")", "TimeUTC", "(", "hour", ",", "min", ",", "sec", ",", "nsec", "int", ")", "time", ".", "Time", "{", "return", "time", ".", "Date", "(", "0", ",", "0", ",", "0", ",", "hour", ",", "min", ",", "sec", ",", "nsec", ...
// TimeUTC returns a new time.Time for the given clock components in UTC. // It is meant to be used with the `OnDate` function.
[ "TimeUTC", "returns", "a", "new", "time", ".", "Time", "for", "the", "given", "clock", "components", "in", "UTC", ".", "It", "is", "meant", "to", "be", "used", "with", "the", "OnDate", "function", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/date.go#L98-L100
train
wcharczuk/go-chart
util/date.go
Time
func (d date) Time(hour, min, sec, nsec int, loc *time.Location) time.Time { return time.Date(0, 0, 0, hour, min, sec, nsec, loc) }
go
func (d date) Time(hour, min, sec, nsec int, loc *time.Location) time.Time { return time.Date(0, 0, 0, hour, min, sec, nsec, loc) }
[ "func", "(", "d", "date", ")", "Time", "(", "hour", ",", "min", ",", "sec", ",", "nsec", "int", ",", "loc", "*", "time", ".", "Location", ")", "time", ".", "Time", "{", "return", "time", ".", "Date", "(", "0", ",", "0", ",", "0", ",", "hour",...
// Time returns a new time.Time for the given clock components. // It is meant to be used with the `OnDate` function.
[ "Time", "returns", "a", "new", "time", ".", "Time", "for", "the", "given", "clock", "components", ".", "It", "is", "meant", "to", "be", "used", "with", "the", "OnDate", "function", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/date.go#L104-L106
train
wcharczuk/go-chart
util/date.go
IsWeekDay
func (d date) IsWeekDay(day time.Weekday) bool { return !d.IsWeekendDay(day) }
go
func (d date) IsWeekDay(day time.Weekday) bool { return !d.IsWeekendDay(day) }
[ "func", "(", "d", "date", ")", "IsWeekDay", "(", "day", "time", ".", "Weekday", ")", "bool", "{", "return", "!", "d", ".", "IsWeekendDay", "(", "day", ")", "\n", "}" ]
// IsWeekDay returns if the day is a monday->friday.
[ "IsWeekDay", "returns", "if", "the", "day", "is", "a", "monday", "-", ">", "friday", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/date.go#L130-L132
train
wcharczuk/go-chart
util/date.go
IsWeekendDay
func (d date) IsWeekendDay(day time.Weekday) bool { return day == time.Saturday || day == time.Sunday }
go
func (d date) IsWeekendDay(day time.Weekday) bool { return day == time.Saturday || day == time.Sunday }
[ "func", "(", "d", "date", ")", "IsWeekendDay", "(", "day", "time", ".", "Weekday", ")", "bool", "{", "return", "day", "==", "time", ".", "Saturday", "||", "day", "==", "time", ".", "Sunday", "\n", "}" ]
// IsWeekendDay returns if the day is a monday->friday.
[ "IsWeekendDay", "returns", "if", "the", "day", "is", "a", "monday", "-", ">", "friday", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/date.go#L135-L137
train
wcharczuk/go-chart
util/date.go
NextDay
func (d date) NextDay(ts time.Time) time.Time { return ts.AddDate(0, 0, 1) }
go
func (d date) NextDay(ts time.Time) time.Time { return ts.AddDate(0, 0, 1) }
[ "func", "(", "d", "date", ")", "NextDay", "(", "ts", "time", ".", "Time", ")", "time", ".", "Time", "{", "return", "ts", ".", "AddDate", "(", "0", ",", "0", ",", "1", ")", "\n", "}" ]
// NextDay returns the timestamp advanced a day.
[ "NextDay", "returns", "the", "timestamp", "advanced", "a", "day", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/date.go#L157-L159
train
wcharczuk/go-chart
util/date.go
NextHour
func (d date) NextHour(ts time.Time) time.Time { //advance a full hour ... advanced := ts.Add(time.Hour) minutes := time.Duration(advanced.Minute()) * time.Minute final := advanced.Add(-minutes) return time.Date(final.Year(), final.Month(), final.Day(), final.Hour(), 0, 0, 0, final.Location()) }
go
func (d date) NextHour(ts time.Time) time.Time { //advance a full hour ... advanced := ts.Add(time.Hour) minutes := time.Duration(advanced.Minute()) * time.Minute final := advanced.Add(-minutes) return time.Date(final.Year(), final.Month(), final.Day(), final.Hour(), 0, 0, 0, final.Location()) }
[ "func", "(", "d", "date", ")", "NextHour", "(", "ts", "time", ".", "Time", ")", "time", ".", "Time", "{", "//advance a full hour ...", "advanced", ":=", "ts", ".", "Add", "(", "time", ".", "Hour", ")", "\n", "minutes", ":=", "time", ".", "Duration", ...
// NextHour returns the next timestamp on the hour.
[ "NextHour", "returns", "the", "next", "timestamp", "on", "the", "hour", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/date.go#L162-L168
train
wcharczuk/go-chart
util/date.go
NextDayOfWeek
func (d date) NextDayOfWeek(after time.Time, dayOfWeek time.Weekday) time.Time { afterWeekday := after.Weekday() if afterWeekday == dayOfWeek { return after.AddDate(0, 0, 7) } // 1 vs 5 ~ add 4 days if afterWeekday < dayOfWeek { dayDelta := int(dayOfWeek - afterWeekday) return after.AddDate(0, 0, dayDelta) } // 5 vs 1, add 7-(5-1) ~ 3 days dayDelta := 7 - int(afterWeekday-dayOfWeek) return after.AddDate(0, 0, dayDelta) }
go
func (d date) NextDayOfWeek(after time.Time, dayOfWeek time.Weekday) time.Time { afterWeekday := after.Weekday() if afterWeekday == dayOfWeek { return after.AddDate(0, 0, 7) } // 1 vs 5 ~ add 4 days if afterWeekday < dayOfWeek { dayDelta := int(dayOfWeek - afterWeekday) return after.AddDate(0, 0, dayDelta) } // 5 vs 1, add 7-(5-1) ~ 3 days dayDelta := 7 - int(afterWeekday-dayOfWeek) return after.AddDate(0, 0, dayDelta) }
[ "func", "(", "d", "date", ")", "NextDayOfWeek", "(", "after", "time", ".", "Time", ",", "dayOfWeek", "time", ".", "Weekday", ")", "time", ".", "Time", "{", "afterWeekday", ":=", "after", ".", "Weekday", "(", ")", "\n", "if", "afterWeekday", "==", "dayO...
// NextDayOfWeek returns the next instance of a given weekday after a given timestamp.
[ "NextDayOfWeek", "returns", "the", "next", "instance", "of", "a", "given", "weekday", "after", "a", "given", "timestamp", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/date.go#L171-L186
train
wcharczuk/go-chart
seq/random.go
RandomValuesWithMax
func RandomValuesWithMax(count int, max float64) []float64 { return Seq{NewRandom().WithMax(max).WithLen(count)}.Array() }
go
func RandomValuesWithMax(count int, max float64) []float64 { return Seq{NewRandom().WithMax(max).WithLen(count)}.Array() }
[ "func", "RandomValuesWithMax", "(", "count", "int", ",", "max", "float64", ")", "[", "]", "float64", "{", "return", "Seq", "{", "NewRandom", "(", ")", ".", "WithMax", "(", "max", ")", ".", "WithLen", "(", "count", ")", "}", ".", "Array", "(", ")", ...
// RandomValuesWithMax returns an array of random values with a given average.
[ "RandomValuesWithMax", "returns", "an", "array", "of", "random", "values", "with", "a", "given", "average", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/random.go#L15-L17
train
wcharczuk/go-chart
seq/random.go
NewRandom
func NewRandom() *Random { return &Random{ rnd: rand.New(rand.NewSource(time.Now().Unix())), } }
go
func NewRandom() *Random { return &Random{ rnd: rand.New(rand.NewSource(time.Now().Unix())), } }
[ "func", "NewRandom", "(", ")", "*", "Random", "{", "return", "&", "Random", "{", "rnd", ":", "rand", ".", "New", "(", "rand", ".", "NewSource", "(", "time", ".", "Now", "(", ")", ".", "Unix", "(", ")", ")", ")", ",", "}", "\n", "}" ]
// NewRandom creates a new random seq.
[ "NewRandom", "creates", "a", "new", "random", "seq", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/random.go#L20-L24
train
wcharczuk/go-chart
seq/random.go
Len
func (r *Random) Len() int { if r.len != nil { return *r.len } return math.MaxInt32 }
go
func (r *Random) Len() int { if r.len != nil { return *r.len } return math.MaxInt32 }
[ "func", "(", "r", "*", "Random", ")", "Len", "(", ")", "int", "{", "if", "r", ".", "len", "!=", "nil", "{", "return", "*", "r", ".", "len", "\n", "}", "\n", "return", "math", ".", "MaxInt32", "\n", "}" ]
// Len returns the number of elements that will be generated.
[ "Len", "returns", "the", "number", "of", "elements", "that", "will", "be", "generated", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/random.go#L35-L40
train
wcharczuk/go-chart
seq/random.go
GetValue
func (r *Random) GetValue(_ int) float64 { if r.min != nil && r.max != nil { var delta float64 if *r.max > *r.min { delta = *r.max - *r.min } else { delta = *r.min - *r.max } return *r.min + (r.rnd.Float64() * delta) } else if r.max != nil { return r.rnd.Float64() * *r.max } else if r.min != nil { return *r.min + (r.rnd.Float64()) } return r.rnd.Float64() }
go
func (r *Random) GetValue(_ int) float64 { if r.min != nil && r.max != nil { var delta float64 if *r.max > *r.min { delta = *r.max - *r.min } else { delta = *r.min - *r.max } return *r.min + (r.rnd.Float64() * delta) } else if r.max != nil { return r.rnd.Float64() * *r.max } else if r.min != nil { return *r.min + (r.rnd.Float64()) } return r.rnd.Float64() }
[ "func", "(", "r", "*", "Random", ")", "GetValue", "(", "_", "int", ")", "float64", "{", "if", "r", ".", "min", "!=", "nil", "&&", "r", ".", "max", "!=", "nil", "{", "var", "delta", "float64", "\n\n", "if", "*", "r", ".", "max", ">", "*", "r",...
// GetValue returns the value.
[ "GetValue", "returns", "the", "value", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/random.go#L43-L60
train
wcharczuk/go-chart
seq/random.go
WithLen
func (r *Random) WithLen(length int) *Random { r.len = &length return r }
go
func (r *Random) WithLen(length int) *Random { r.len = &length return r }
[ "func", "(", "r", "*", "Random", ")", "WithLen", "(", "length", "int", ")", "*", "Random", "{", "r", ".", "len", "=", "&", "length", "\n", "return", "r", "\n", "}" ]
// WithLen sets a maximum len
[ "WithLen", "sets", "a", "maximum", "len" ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/random.go#L63-L66
train
wcharczuk/go-chart
seq/random.go
WithMin
func (r *Random) WithMin(min float64) *Random { r.min = &min return r }
go
func (r *Random) WithMin(min float64) *Random { r.min = &min return r }
[ "func", "(", "r", "*", "Random", ")", "WithMin", "(", "min", "float64", ")", "*", "Random", "{", "r", ".", "min", "=", "&", "min", "\n", "return", "r", "\n", "}" ]
// WithMin sets the scale and returns the Random.
[ "WithMin", "sets", "the", "scale", "and", "returns", "the", "Random", "." ]
9852fce5a172598e72d16f4306f0f17a53d94eb4
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/random.go#L74-L77
train