id
int32 0
167k
| 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
listlengths 21
1.41k
| docstring
stringlengths 6
2.61k
| docstring_tokens
listlengths 3
215
| sha
stringlengths 40
40
| url
stringlengths 85
252
|
---|---|---|---|---|---|---|---|---|---|---|---|
147,600 |
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",
"(",
"[",
"]",
"float64",
",",
"rank",
")",
"\n\n",
"for",
"index",
":=",
"0",
";",
"index",
"<",
"rank",
";",
"index",
"++",
"{",
"values",
"[",
"index",
"]",
"=",
"m",
".",
"Get",
"(",
"index",
",",
"index",
")",
"\n",
"}",
"\n",
"return",
"Vector",
"(",
"values",
")",
"\n",
"}"
] |
// 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
|
147,601 |
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",
",",
"rank",
")",
"\n\n",
"for",
"index",
":=",
"0",
";",
"index",
"<",
"rank",
";",
"index",
"++",
"{",
"m2",
".",
"Set",
"(",
"index",
",",
"index",
",",
"m",
".",
"Get",
"(",
"index",
",",
"index",
")",
")",
"\n",
"}",
"\n",
"return",
"m2",
"\n",
"}"
] |
// 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
|
147,602 |
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",
"}",
"\n\n",
"if",
"m",
".",
"stride",
"!=",
"other",
".",
"stride",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"msize",
":=",
"len",
"(",
"m",
".",
"elements",
")",
"\n",
"m2size",
":=",
"len",
"(",
"other",
".",
"elements",
")",
"\n\n",
"if",
"msize",
"!=",
"m2size",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"msize",
";",
"i",
"++",
"{",
"if",
"m",
".",
"elements",
"[",
"i",
"]",
"!=",
"other",
".",
"elements",
"[",
"i",
"]",
"{",
"return",
"false",
"\n",
"}",
"\n",
"}",
"\n",
"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
|
147,603 |
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",
";",
"row",
"++",
"{",
"for",
"col",
":=",
"row",
";",
"col",
"<",
"cols",
";",
"col",
"++",
"{",
"m2",
".",
"Set",
"(",
"row",
",",
"col",
",",
"m",
".",
"Get",
"(",
"row",
",",
"col",
")",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"m2",
"\n",
"}"
] |
// 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
|
147,604 |
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",
")",
"{",
"return",
"nil",
",",
"ErrDimensionMismatch",
"\n",
"}",
"\n\n",
"m3",
"=",
"&",
"Matrix",
"{",
"epsilon",
":",
"m",
".",
"epsilon",
",",
"stride",
":",
"m2",
".",
"stride",
",",
"elements",
":",
"make",
"(",
"[",
"]",
"float64",
",",
"(",
"len",
"(",
"m",
".",
"elements",
")",
"/",
"m",
".",
"stride",
")",
"*",
"m2",
".",
"stride",
")",
"}",
"\n",
"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",
"]",
"\n",
"m1x",
"++",
"\n",
"}",
"\n",
"m3x",
"++",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] |
// 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
|
147,605 |
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",
"}",
"\n\n",
"for",
"j",
",",
"dx",
":=",
"0",
",",
"0",
";",
"j",
"<",
"m",
".",
"stride",
";",
"j",
"++",
"{",
"row",
":=",
"j",
"\n",
"max",
":=",
"m",
".",
"elements",
"[",
"dx",
"]",
"\n",
"for",
"i",
",",
"ixcj",
":=",
"j",
",",
"dx",
";",
"i",
"<",
"m",
".",
"stride",
";",
"i",
"++",
"{",
"if",
"m",
".",
"elements",
"[",
"ixcj",
"]",
">",
"max",
"{",
"max",
"=",
"m",
".",
"elements",
"[",
"ixcj",
"]",
"\n",
"row",
"=",
"i",
"\n",
"}",
"\n",
"ixcj",
"+=",
"m",
".",
"stride",
"\n",
"}",
"\n",
"if",
"j",
"!=",
"row",
"{",
"pv",
"[",
"row",
"]",
",",
"pv",
"[",
"j",
"]",
"=",
"pv",
"[",
"j",
"]",
",",
"pv",
"[",
"row",
"]",
"\n",
"}",
"\n",
"dx",
"+=",
"m",
".",
"stride",
"+",
"1",
"\n",
"}",
"\n",
"p",
":=",
"Zero",
"(",
"m",
".",
"stride",
",",
"m",
".",
"stride",
")",
"\n",
"for",
"r",
",",
"c",
":=",
"range",
"pv",
"{",
"p",
".",
"elements",
"[",
"r",
"*",
"m",
".",
"stride",
"+",
"c",
"]",
"=",
"1",
"\n",
"}",
"\n",
"return",
"p",
"\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
|
147,606 |
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",
"if",
"mc",
"!=",
"m2r",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"mr",
",",
"mc",
",",
"m2r",
",",
"m2c",
")",
"\n",
"//return nil, ErrDimensionMismatch",
"}",
"\n\n",
"c",
":=",
"Zero",
"(",
"mr",
",",
"m2c",
")",
"\n\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"mr",
";",
"i",
"++",
"{",
"sums",
":=",
"c",
".",
"elements",
"[",
"i",
"*",
"c",
".",
"stride",
":",
"(",
"i",
"+",
"1",
")",
"*",
"c",
".",
"stride",
"]",
"\n",
"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",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"c",
",",
"nil",
"\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
|
147,607 |
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",
",",
"m",
".",
"stride",
")",
"\n",
"p",
"=",
"m",
".",
"Pivotize",
"(",
")",
"\n",
"m",
",",
"_",
"=",
"p",
".",
"Multiply",
"(",
"m",
")",
"\n",
"for",
"j",
",",
"jxc0",
":=",
"0",
",",
"0",
";",
"j",
"<",
"m",
".",
"stride",
";",
"j",
"++",
"{",
"l",
".",
"elements",
"[",
"jxc0",
"+",
"j",
"]",
"=",
"1",
"\n",
"for",
"i",
",",
"ixc0",
":=",
"0",
",",
"0",
";",
"ixc0",
"<=",
"jxc0",
";",
"i",
"++",
"{",
"sum",
":=",
"0.",
"\n",
"for",
"k",
",",
"kxcj",
":=",
"0",
",",
"j",
";",
"k",
"<",
"i",
";",
"k",
"++",
"{",
"sum",
"+=",
"u",
".",
"elements",
"[",
"kxcj",
"]",
"*",
"l",
".",
"elements",
"[",
"ixc0",
"+",
"k",
"]",
"\n",
"kxcj",
"+=",
"m",
".",
"stride",
"\n",
"}",
"\n",
"u",
".",
"elements",
"[",
"ixc0",
"+",
"j",
"]",
"=",
"m",
".",
"elements",
"[",
"ixc0",
"+",
"j",
"]",
"-",
"sum",
"\n",
"ixc0",
"+=",
"m",
".",
"stride",
"\n",
"}",
"\n",
"for",
"ixc0",
":=",
"jxc0",
";",
"ixc0",
"<",
"len",
"(",
"m",
".",
"elements",
")",
";",
"ixc0",
"+=",
"m",
".",
"stride",
"{",
"sum",
":=",
"0.",
"\n",
"for",
"k",
",",
"kxcj",
":=",
"0",
",",
"j",
";",
"k",
"<",
"j",
";",
"k",
"++",
"{",
"sum",
"+=",
"u",
".",
"elements",
"[",
"kxcj",
"]",
"*",
"l",
".",
"elements",
"[",
"ixc0",
"+",
"k",
"]",
"\n",
"kxcj",
"+=",
"m",
".",
"stride",
"\n",
"}",
"\n",
"l",
".",
"elements",
"[",
"ixc0",
"+",
"j",
"]",
"=",
"(",
"m",
".",
"elements",
"[",
"ixc0",
"+",
"j",
"]",
"-",
"sum",
")",
"/",
"u",
".",
"elements",
"[",
"jxc0",
"+",
"j",
"]",
"\n",
"}",
"\n",
"jxc0",
"+=",
"m",
".",
"stride",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] |
// 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
|
147,608 |
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",
"<",
"rows",
";",
"i",
"++",
"{",
"for",
"j",
":=",
"0",
";",
"j",
"<",
"cols",
";",
"j",
"++",
"{",
"m2",
".",
"Set",
"(",
"j",
",",
"i",
",",
"m",
".",
"Get",
"(",
"i",
",",
"j",
")",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"m2",
"\n",
"}"
] |
// 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
|
147,609 |
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",
"]",
"=",
"v",
".",
"Value",
"\n",
"}",
"\n",
"return",
"values",
"\n",
"}"
] |
// Values returns the values.
|
[
"Values",
"returns",
"the",
"values",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/value.go#L16-L22
|
147,610 |
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",
"}",
"\n\n",
"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",
")",
",",
"}",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"output",
"\n",
"}"
] |
// Normalize returns the values normalized.
|
[
"Normalize",
"returns",
"the",
"values",
"normalized",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/value.go#L30-L48
|
147,611 |
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",
"(",
"dateFormat",
")",
"\n",
"}",
"\n",
"if",
"typed",
",",
"isTyped",
":=",
"v",
".",
"(",
"int64",
")",
";",
"isTyped",
"{",
"return",
"time",
".",
"Unix",
"(",
"0",
",",
"typed",
")",
".",
"Format",
"(",
"dateFormat",
")",
"\n",
"}",
"\n",
"if",
"typed",
",",
"isTyped",
":=",
"v",
".",
"(",
"float64",
")",
";",
"isTyped",
"{",
"return",
"time",
".",
"Unix",
"(",
"0",
",",
"int64",
"(",
"typed",
")",
")",
".",
"Format",
"(",
"dateFormat",
")",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
"\n",
"}"
] |
// 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
|
147,612 |
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",
":",
"return",
"strconv",
".",
"FormatInt",
"(",
"v",
".",
"(",
"int64",
")",
",",
"10",
")",
"\n",
"case",
"float32",
":",
"return",
"strconv",
".",
"FormatInt",
"(",
"int64",
"(",
"v",
".",
"(",
"float32",
")",
")",
",",
"10",
")",
"\n",
"case",
"float64",
":",
"return",
"strconv",
".",
"FormatInt",
"(",
"int64",
"(",
"v",
".",
"(",
"float64",
")",
")",
",",
"10",
")",
"\n",
"default",
":",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"}"
] |
// 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
|
147,613 |
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",
"(",
"floatFormat",
",",
"float64",
"(",
"typed",
")",
")",
"\n",
"}",
"\n",
"if",
"typed",
",",
"isTyped",
":=",
"v",
".",
"(",
"int64",
")",
";",
"isTyped",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"floatFormat",
",",
"float64",
"(",
"typed",
")",
")",
"\n",
"}",
"\n",
"if",
"typed",
",",
"isTyped",
":=",
"v",
".",
"(",
"float32",
")",
";",
"isTyped",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"floatFormat",
",",
"typed",
")",
"\n",
"}",
"\n",
"if",
"typed",
",",
"isTyped",
":=",
"v",
".",
"(",
"float64",
")",
";",
"isTyped",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"floatFormat",
",",
"typed",
")",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
"\n",
"}"
] |
// 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
|
147,614 |
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",
".",
"YValues",
"[",
"index",
"]",
"\n",
"return",
"\n",
"}"
] |
// 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
|
147,615 |
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",
"[",
"0",
"]",
"\n",
"return",
"\n",
"}"
] |
// GetFirstValues gets the first values.
|
[
"GetFirstValues",
"gets",
"the",
"first",
"values",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/time_series.go#L52-L56
|
147,616 |
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",
"]",
")",
"\n",
"y",
"=",
"ts",
".",
"YValues",
"[",
"len",
"(",
"ts",
".",
"YValues",
")",
"-",
"1",
"]",
"\n",
"return",
"\n",
"}"
] |
// GetLastValues gets the last values.
|
[
"GetLastValues",
"gets",
"the",
"last",
"values",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/time_series.go#L59-L63
|
147,617 |
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
|
147,618 |
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
|
147,619 |
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
|
147,620 |
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",
"}",
"\n\n",
"start",
"=",
"values",
"[",
"0",
"]",
"\n",
"end",
"=",
"values",
"[",
"0",
"]",
"\n\n",
"for",
"_",
",",
"v",
":=",
"range",
"values",
"[",
"1",
":",
"]",
"{",
"if",
"end",
".",
"Before",
"(",
"v",
")",
"{",
"end",
"=",
"v",
"\n",
"}",
"\n",
"if",
"start",
".",
"After",
"(",
"v",
")",
"{",
"start",
"=",
"v",
"\n",
"}",
"\n",
"}",
"\n",
"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
|
147,621 |
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",
"return",
"DefaultSimpleMovingAveragePeriod",
"\n",
"}",
"\n",
"return",
"sma",
".",
"Period",
"\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
|
147,622 |
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",
":",
"DefaultTitleFontSize",
",",
"}",
"\n",
"}"
] |
// 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
|
147,623 |
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",
"==",
"0",
"&&",
"s",
".",
"FillColor",
".",
"IsZero",
"(",
")",
"&&",
"s",
".",
"FontColor",
".",
"IsZero",
"(",
")",
"&&",
"s",
".",
"FontSize",
"==",
"0",
"&&",
"s",
".",
"Font",
"==",
"nil",
"&&",
"s",
".",
"ClassName",
"==",
"\"",
"\"",
"\n",
"}"
] |
// 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
|
147,624 |
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",
"{",
"\"",
"\\\"",
"\\\"",
"\"",
"}",
"\n",
"}",
"else",
"{",
"output",
"=",
"[",
"]",
"string",
"{",
"\"",
"\\\"",
"\\\"",
"\"",
"}",
"\n",
"}",
"\n\n",
"if",
"s",
".",
"ClassName",
"!=",
"\"",
"\"",
"{",
"output",
"=",
"append",
"(",
"output",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"s",
".",
"ClassName",
")",
")",
"\n",
"}",
"else",
"{",
"output",
"=",
"append",
"(",
"output",
",",
"\"",
"\\\"",
"\\\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"!",
"s",
".",
"Padding",
".",
"IsZero",
"(",
")",
"{",
"output",
"=",
"append",
"(",
"output",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"s",
".",
"Padding",
".",
"String",
"(",
")",
")",
")",
"\n",
"}",
"else",
"{",
"output",
"=",
"append",
"(",
"output",
",",
"\"",
"\\\"",
"\\\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"s",
".",
"StrokeWidth",
">=",
"0",
"{",
"output",
"=",
"append",
"(",
"output",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"s",
".",
"StrokeWidth",
")",
")",
"\n",
"}",
"else",
"{",
"output",
"=",
"append",
"(",
"output",
",",
"\"",
"\\\"",
"\\\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"!",
"s",
".",
"StrokeColor",
".",
"IsZero",
"(",
")",
"{",
"output",
"=",
"append",
"(",
"output",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"s",
".",
"StrokeColor",
".",
"String",
"(",
")",
")",
")",
"\n",
"}",
"else",
"{",
"output",
"=",
"append",
"(",
"output",
",",
"\"",
"\\\"",
"\\\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"s",
".",
"StrokeDashArray",
")",
">",
"0",
"{",
"var",
"elements",
"[",
"]",
"string",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"s",
".",
"StrokeDashArray",
"{",
"elements",
"=",
"append",
"(",
"elements",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"v",
")",
")",
"\n",
"}",
"\n",
"dashArray",
":=",
"strings",
".",
"Join",
"(",
"elements",
",",
"\"",
"\"",
")",
"\n",
"output",
"=",
"append",
"(",
"output",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"dashArray",
")",
")",
"\n",
"}",
"else",
"{",
"output",
"=",
"append",
"(",
"output",
",",
"\"",
"\\\"",
"\\\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"s",
".",
"DotWidth",
">=",
"0",
"{",
"output",
"=",
"append",
"(",
"output",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"s",
".",
"DotWidth",
")",
")",
"\n",
"}",
"else",
"{",
"output",
"=",
"append",
"(",
"output",
",",
"\"",
"\\\"",
"\\\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"!",
"s",
".",
"DotColor",
".",
"IsZero",
"(",
")",
"{",
"output",
"=",
"append",
"(",
"output",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"s",
".",
"DotColor",
".",
"String",
"(",
")",
")",
")",
"\n",
"}",
"else",
"{",
"output",
"=",
"append",
"(",
"output",
",",
"\"",
"\\\"",
"\\\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"!",
"s",
".",
"FillColor",
".",
"IsZero",
"(",
")",
"{",
"output",
"=",
"append",
"(",
"output",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"s",
".",
"FillColor",
".",
"String",
"(",
")",
")",
")",
"\n",
"}",
"else",
"{",
"output",
"=",
"append",
"(",
"output",
",",
"\"",
"\\\"",
"\\\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"s",
".",
"FontSize",
"!=",
"0",
"{",
"output",
"=",
"append",
"(",
"output",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\\"",
"\\\"",
"\\\"",
"\\\"",
"\"",
",",
"s",
".",
"FontSize",
")",
")",
"\n",
"}",
"else",
"{",
"output",
"=",
"append",
"(",
"output",
",",
"\"",
"\\\"",
"\\\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"!",
"s",
".",
"FontColor",
".",
"IsZero",
"(",
")",
"{",
"output",
"=",
"append",
"(",
"output",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"s",
".",
"FontColor",
".",
"String",
"(",
")",
")",
")",
"\n",
"}",
"else",
"{",
"output",
"=",
"append",
"(",
"output",
",",
"\"",
"\\\"",
"\\\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"s",
".",
"Font",
"!=",
"nil",
"{",
"output",
"=",
"append",
"(",
"output",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\\\"",
"\\\"",
"\\\"",
"\\\"",
"\"",
",",
"s",
".",
"Font",
".",
"Name",
"(",
"truetype",
".",
"NameIDFontFamily",
")",
")",
")",
"\n",
"}",
"else",
"{",
"output",
"=",
"append",
"(",
"output",
",",
"\"",
"\\\"",
"\\\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"\"",
"\"",
"+",
"strings",
".",
"Join",
"(",
"output",
",",
"\"",
"\"",
")",
"+",
"\"",
"\"",
"\n",
"}"
] |
// 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
|
147,625 |
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",
"{",
"return",
"defaults",
"[",
"0",
"]",
"\n",
"}",
"\n",
"return",
"drawing",
".",
"ColorTransparent",
"\n",
"}",
"\n",
"return",
"s",
".",
"StrokeColor",
"\n",
"}"
] |
// GetStrokeColor returns the stroke color.
|
[
"GetStrokeColor",
"returns",
"the",
"stroke",
"color",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L178-L186
|
147,626 |
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",
"defaults",
"[",
"0",
"]",
"\n",
"}",
"\n",
"return",
"drawing",
".",
"ColorTransparent",
"\n",
"}",
"\n",
"return",
"s",
".",
"FillColor",
"\n",
"}"
] |
// GetFillColor returns the fill color.
|
[
"GetFillColor",
"returns",
"the",
"fill",
"color",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L189-L197
|
147,627 |
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",
"defaults",
"[",
"0",
"]",
"\n",
"}",
"\n",
"return",
"drawing",
".",
"ColorTransparent",
"\n",
"}",
"\n",
"return",
"s",
".",
"DotColor",
"\n",
"}"
] |
// GetDotColor returns the stroke color.
|
[
"GetDotColor",
"returns",
"the",
"stroke",
"color",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L200-L208
|
147,628 |
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",
"}",
"\n",
"return",
"DefaultStrokeWidth",
"\n",
"}",
"\n",
"return",
"s",
".",
"StrokeWidth",
"\n",
"}"
] |
// GetStrokeWidth returns the stroke width.
|
[
"GetStrokeWidth",
"returns",
"the",
"stroke",
"width",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L211-L219
|
147,629 |
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",
"}",
"\n",
"return",
"DefaultDotWidth",
"\n",
"}",
"\n",
"return",
"s",
".",
"DotWidth",
"\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
|
147,630 |
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",
"{",
"return",
"defaults",
"[",
"0",
"]",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"s",
".",
"StrokeDashArray",
"\n",
"}"
] |
// 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
|
147,631 |
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",
"}",
"\n",
"return",
"DefaultFontSize",
"\n",
"}",
"\n",
"return",
"s",
".",
"FontSize",
"\n",
"}"
] |
// GetFontSize gets the font size.
|
[
"GetFontSize",
"gets",
"the",
"font",
"size",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L244-L252
|
147,632 |
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",
"defaults",
"[",
"0",
"]",
"\n",
"}",
"\n",
"return",
"drawing",
".",
"ColorTransparent",
"\n",
"}",
"\n",
"return",
"s",
".",
"FontColor",
"\n",
"}"
] |
// GetFontColor gets the font size.
|
[
"GetFontColor",
"gets",
"the",
"font",
"size",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L255-L263
|
147,633 |
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",
"defaults",
"[",
"0",
"]",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"s",
".",
"Font",
"\n",
"}"
] |
// GetFont returns the font face.
|
[
"GetFont",
"returns",
"the",
"font",
"face",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L266-L274
|
147,634 |
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",
"}",
"\n",
"return",
"Box",
"{",
"}",
"\n",
"}",
"\n",
"return",
"s",
".",
"Padding",
"\n",
"}"
] |
// GetPadding returns the padding.
|
[
"GetPadding",
"returns",
"the",
"padding",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L277-L285
|
147,635 |
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",
"{",
"return",
"defaults",
"[",
"0",
"]",
"\n",
"}",
"\n",
"return",
"TextHorizontalAlignUnset",
"\n",
"}",
"\n",
"return",
"s",
".",
"TextHorizontalAlign",
"\n",
"}"
] |
// GetTextHorizontalAlign returns the horizontal alignment.
|
[
"GetTextHorizontalAlign",
"returns",
"the",
"horizontal",
"alignment",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L288-L296
|
147,636 |
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",
"{",
"return",
"defaults",
"[",
"0",
"]",
"\n",
"}",
"\n",
"return",
"TextVerticalAlignUnset",
"\n",
"}",
"\n",
"return",
"s",
".",
"TextVerticalAlign",
"\n",
"}"
] |
// GetTextVerticalAlign returns the vertical alignment.
|
[
"GetTextVerticalAlign",
"returns",
"the",
"vertical",
"alignment",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L299-L307
|
147,637 |
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",
"]",
"\n",
"}",
"\n",
"return",
"TextWrapUnset",
"\n",
"}",
"\n",
"return",
"s",
".",
"TextWrap",
"\n",
"}"
] |
// GetTextWrap returns the word wrap.
|
[
"GetTextWrap",
"returns",
"the",
"word",
"wrap",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L310-L318
|
147,638 |
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",
"]",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"s",
".",
"TextRotationDegrees",
"\n",
"}"
] |
// 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
|
147,639 |
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",
".",
"SetStrokeWidth",
"(",
"s",
".",
"GetStrokeWidth",
"(",
")",
")",
"\n",
"r",
".",
"SetStrokeDashArray",
"(",
"s",
".",
"GetStrokeDashArray",
"(",
")",
")",
"\n",
"r",
".",
"SetFillColor",
"(",
"s",
".",
"GetFillColor",
"(",
")",
")",
"\n",
"r",
".",
"SetFont",
"(",
"s",
".",
"GetFont",
"(",
")",
")",
"\n",
"r",
".",
"SetFontColor",
"(",
"s",
".",
"GetFontColor",
"(",
")",
")",
"\n",
"r",
".",
"SetFontSize",
"(",
"s",
".",
"GetFontSize",
"(",
")",
")",
"\n\n",
"r",
".",
"ClearTextRotation",
"(",
")",
"\n",
"if",
"s",
".",
"GetTextRotationDegrees",
"(",
")",
"!=",
"0",
"{",
"r",
".",
"SetTextRotation",
"(",
"util",
".",
"Math",
".",
"DegreesToRadians",
"(",
"s",
".",
"GetTextRotationDegrees",
"(",
")",
")",
")",
"\n",
"}",
"\n",
"}"
] |
// 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
|
147,640 |
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",
"(",
")",
")",
"\n",
"r",
".",
"SetStrokeWidth",
"(",
"s",
".",
"GetStrokeWidth",
"(",
")",
")",
"\n",
"r",
".",
"SetStrokeDashArray",
"(",
"s",
".",
"GetStrokeDashArray",
"(",
")",
")",
"\n",
"r",
".",
"SetFillColor",
"(",
"s",
".",
"GetFillColor",
"(",
")",
")",
"\n",
"}"
] |
// 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
|
147,641 |
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",
".",
"SetFontColor",
"(",
"s",
".",
"GetFontColor",
"(",
")",
")",
"\n",
"r",
".",
"SetFontSize",
"(",
"s",
".",
"GetFontSize",
"(",
")",
")",
"\n",
"}"
] |
// 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
|
147,642 |
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",
"=",
"s",
".",
"GetStrokeColor",
"(",
"defaults",
".",
"StrokeColor",
")",
"\n",
"final",
".",
"StrokeWidth",
"=",
"s",
".",
"GetStrokeWidth",
"(",
"defaults",
".",
"StrokeWidth",
")",
"\n",
"final",
".",
"StrokeDashArray",
"=",
"s",
".",
"GetStrokeDashArray",
"(",
"defaults",
".",
"StrokeDashArray",
")",
"\n\n",
"final",
".",
"DotColor",
"=",
"s",
".",
"GetDotColor",
"(",
"defaults",
".",
"DotColor",
")",
"\n",
"final",
".",
"DotWidth",
"=",
"s",
".",
"GetDotWidth",
"(",
"defaults",
".",
"DotWidth",
")",
"\n\n",
"final",
".",
"DotWidthProvider",
"=",
"s",
".",
"DotWidthProvider",
"\n",
"final",
".",
"DotColorProvider",
"=",
"s",
".",
"DotColorProvider",
"\n\n",
"final",
".",
"FillColor",
"=",
"s",
".",
"GetFillColor",
"(",
"defaults",
".",
"FillColor",
")",
"\n",
"final",
".",
"FontColor",
"=",
"s",
".",
"GetFontColor",
"(",
"defaults",
".",
"FontColor",
")",
"\n",
"final",
".",
"FontSize",
"=",
"s",
".",
"GetFontSize",
"(",
"defaults",
".",
"FontSize",
")",
"\n",
"final",
".",
"Font",
"=",
"s",
".",
"GetFont",
"(",
"defaults",
".",
"Font",
")",
"\n",
"final",
".",
"Padding",
"=",
"s",
".",
"GetPadding",
"(",
"defaults",
".",
"Padding",
")",
"\n",
"final",
".",
"TextHorizontalAlign",
"=",
"s",
".",
"GetTextHorizontalAlign",
"(",
"defaults",
".",
"TextHorizontalAlign",
")",
"\n",
"final",
".",
"TextVerticalAlign",
"=",
"s",
".",
"GetTextVerticalAlign",
"(",
"defaults",
".",
"TextVerticalAlign",
")",
"\n",
"final",
".",
"TextWrap",
"=",
"s",
".",
"GetTextWrap",
"(",
"defaults",
".",
"TextWrap",
")",
"\n",
"final",
".",
"TextLineSpacing",
"=",
"s",
".",
"GetTextLineSpacing",
"(",
"defaults",
".",
"TextLineSpacing",
")",
"\n",
"final",
".",
"TextRotationDegrees",
"=",
"s",
".",
"GetTextRotationDegrees",
"(",
"defaults",
".",
"TextRotationDegrees",
")",
"\n\n",
"return",
"\n",
"}"
] |
// 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
|
147,643 |
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",
",",
"StrokeWidth",
":",
"s",
".",
"StrokeWidth",
",",
"}",
"\n",
"}"
] |
// GetStrokeOptions returns the stroke components.
|
[
"GetStrokeOptions",
"returns",
"the",
"stroke",
"components",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L404-L411
|
147,644 |
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
|
147,645 |
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",
".",
"DotColor",
",",
"StrokeWidth",
":",
"1.0",
",",
"}",
"\n",
"}"
] |
// GetDotOptions returns the dot components.
|
[
"GetDotOptions",
"returns",
"the",
"dot",
"components",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/style.go#L422-L430
|
147,646 |
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",
",",
"StrokeColor",
":",
"s",
".",
"StrokeColor",
",",
"StrokeWidth",
":",
"s",
".",
"StrokeWidth",
",",
"}",
"\n",
"}"
] |
// 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
|
147,647 |
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",
".",
"Font",
",",
"TextHorizontalAlign",
":",
"s",
".",
"TextHorizontalAlign",
",",
"TextVerticalAlign",
":",
"s",
".",
"TextVerticalAlign",
",",
"TextWrap",
":",
"s",
".",
"TextWrap",
",",
"TextLineSpacing",
":",
"s",
".",
"TextLineSpacing",
",",
"TextRotationDegrees",
":",
"s",
".",
"TextRotationDegrees",
",",
"}",
"\n",
"}"
] |
// 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
|
147,648 |
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",
".",
"DotWidthProvider",
"!=",
"nil",
"\n",
"}"
] |
// 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
|
147,649 |
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",
",",
"ErrPolyRegArraysSameLength",
"\n",
"}",
"\n\n",
"m",
":=",
"len",
"(",
"yvalues",
")",
"\n",
"n",
":=",
"degree",
"+",
"1",
"\n",
"y",
":=",
"New",
"(",
"m",
",",
"1",
",",
"yvalues",
"...",
")",
"\n",
"x",
":=",
"Zero",
"(",
"m",
",",
"n",
")",
"\n\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"m",
";",
"i",
"++",
"{",
"ip",
":=",
"float64",
"(",
"1",
")",
"\n",
"for",
"j",
":=",
"0",
";",
"j",
"<",
"n",
";",
"j",
"++",
"{",
"x",
".",
"Set",
"(",
"i",
",",
"j",
",",
"ip",
")",
"\n",
"ip",
"*=",
"xvalues",
"[",
"i",
"]",
"\n",
"}",
"\n",
"}",
"\n\n",
"q",
",",
"r",
":=",
"x",
".",
"QR",
"(",
")",
"\n",
"qty",
",",
"err",
":=",
"q",
".",
"Transpose",
"(",
")",
".",
"Times",
"(",
"y",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"c",
":=",
"make",
"(",
"[",
"]",
"float64",
",",
"n",
")",
"\n",
"for",
"i",
":=",
"n",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
"{",
"c",
"[",
"i",
"]",
"=",
"qty",
".",
"Get",
"(",
"i",
",",
"0",
")",
"\n",
"for",
"j",
":=",
"i",
"+",
"1",
";",
"j",
"<",
"n",
";",
"j",
"++",
"{",
"c",
"[",
"i",
"]",
"-=",
"c",
"[",
"j",
"]",
"*",
"r",
".",
"Get",
"(",
"i",
",",
"j",
")",
"\n",
"}",
"\n",
"c",
"[",
"i",
"]",
"/=",
"r",
".",
"Get",
"(",
"i",
",",
"i",
")",
"\n",
"}",
"\n\n",
"return",
"c",
",",
"nil",
"\n",
"}"
] |
// 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
|
147,650 |
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
|
147,651 |
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",
":",
"avg",
",",
"}",
"\n",
"}"
] |
// 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
|
147,652 |
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",
"\n",
"avg",
"=",
"lcs",
".",
"Avg",
"\n",
"return",
"\n",
"}"
] |
// Coefficients returns the coefficients.
|
[
"Coefficients",
"returns",
"the",
"coefficients",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/linear_coefficient_provider.go#L36-L42
|
147,653 |
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",
"(",
"defaults",
".",
"GetStrokeColor",
"(",
")",
")",
")",
"\n",
"r",
".",
"SetStrokeWidth",
"(",
"gl",
".",
"Style",
".",
"GetStrokeWidth",
"(",
"defaults",
".",
"GetStrokeWidth",
"(",
")",
")",
")",
"\n",
"r",
".",
"SetStrokeDashArray",
"(",
"gl",
".",
"Style",
".",
"GetStrokeDashArray",
"(",
"defaults",
".",
"GetStrokeDashArray",
"(",
")",
")",
")",
"\n\n",
"if",
"isVertical",
"{",
"lineLeft",
":=",
"canvasBox",
".",
"Left",
"+",
"ra",
".",
"Translate",
"(",
"gl",
".",
"Value",
")",
"\n",
"lineBottom",
":=",
"canvasBox",
".",
"Bottom",
"\n",
"lineTop",
":=",
"canvasBox",
".",
"Top",
"\n\n",
"r",
".",
"MoveTo",
"(",
"lineLeft",
",",
"lineBottom",
")",
"\n",
"r",
".",
"LineTo",
"(",
"lineLeft",
",",
"lineTop",
")",
"\n",
"r",
".",
"Stroke",
"(",
")",
"\n",
"}",
"else",
"{",
"lineLeft",
":=",
"canvasBox",
".",
"Left",
"\n",
"lineRight",
":=",
"canvasBox",
".",
"Right",
"\n",
"lineHeight",
":=",
"canvasBox",
".",
"Bottom",
"-",
"ra",
".",
"Translate",
"(",
"gl",
".",
"Value",
")",
"\n\n",
"r",
".",
"MoveTo",
"(",
"lineLeft",
",",
"lineHeight",
")",
"\n",
"r",
".",
"LineTo",
"(",
"lineRight",
",",
"lineHeight",
")",
"\n",
"r",
".",
"Stroke",
"(",
")",
"\n",
"}",
"\n",
"}"
] |
// Render renders the gridline
|
[
"Render",
"renders",
"the",
"gridline"
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/grid_line.go#L26-L48
|
147,654 |
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",
")",
"<",
"3",
"{",
"return",
"gl",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"t",
":=",
"range",
"ticks",
"[",
"1",
":",
"len",
"(",
"ticks",
")",
"-",
"1",
"]",
"{",
"s",
":=",
"majorStyle",
"\n",
"if",
"isMinor",
"{",
"s",
"=",
"minorStyle",
"\n",
"}",
"\n",
"gl",
"=",
"append",
"(",
"gl",
",",
"GridLine",
"{",
"Style",
":",
"s",
",",
"IsMinor",
":",
"isMinor",
",",
"Value",
":",
"t",
".",
"Value",
",",
"}",
")",
"\n",
"isMinor",
"=",
"!",
"isMinor",
"\n",
"}",
"\n",
"return",
"gl",
"\n",
"}"
] |
// GenerateGridLines generates grid lines.
|
[
"GenerateGridLines",
"generates",
"grid",
"lines",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/grid_line.go#L51-L72
|
147,655 |
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
|
147,656 |
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",
"=",
"vx",
"\n\n",
"if",
"vy",
">",
"0",
"{",
"y1",
"=",
"vy",
"\n",
"return",
"\n",
"}",
"\n\n",
"y2",
"=",
"vy",
"\n",
"return",
"\n",
"}"
] |
// GetBoundedValues implements BoundedValuesProvider.GetBoundedValue
|
[
"GetBoundedValues",
"implements",
"BoundedValuesProvider",
".",
"GetBoundedValue"
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/histogram_series.go#L41-L53
|
147,657 |
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",
")",
"\n",
"Draw",
".",
"HistogramSeries",
"(",
"r",
",",
"canvasBox",
",",
"xrange",
",",
"yrange",
",",
"style",
",",
"hs",
")",
"\n",
"}"
] |
// Render implements Series.Render.
|
[
"Render",
"implements",
"Series",
".",
"Render",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/histogram_series.go#L56-L59
|
147,658 |
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",
"{",
"// Try Windows",
"est",
",",
"err",
"=",
"time",
".",
"LoadLocation",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"est",
",",
"nil",
"\n",
"}"
] |
// Eastern returns the eastern timezone.
|
[
"Eastern",
"returns",
"the",
"eastern",
"timezone",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/date.go#L61-L72
|
147,659 |
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",
"{",
"// Try Windows",
"pst",
",",
"err",
"=",
"time",
".",
"LoadLocation",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"pst",
",",
"nil",
"\n",
"}"
] |
// Pacific returns the pacific timezone.
|
[
"Pacific",
"returns",
"the",
"pacific",
"timezone",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/date.go#L83-L94
|
147,660 |
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",
",",
"time",
".",
"UTC",
")",
"\n",
"}"
] |
// 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
|
147,661 |
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",
",",
"min",
",",
"sec",
",",
"nsec",
",",
"loc",
")",
"\n",
"}"
] |
// 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
|
147,662 |
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
|
147,663 |
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
|
147,664 |
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
|
147,665 |
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",
"(",
"advanced",
".",
"Minute",
"(",
")",
")",
"*",
"time",
".",
"Minute",
"\n",
"final",
":=",
"advanced",
".",
"Add",
"(",
"-",
"minutes",
")",
"\n",
"return",
"time",
".",
"Date",
"(",
"final",
".",
"Year",
"(",
")",
",",
"final",
".",
"Month",
"(",
")",
",",
"final",
".",
"Day",
"(",
")",
",",
"final",
".",
"Hour",
"(",
")",
",",
"0",
",",
"0",
",",
"0",
",",
"final",
".",
"Location",
"(",
")",
")",
"\n",
"}"
] |
// 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
|
147,666 |
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",
"==",
"dayOfWeek",
"{",
"return",
"after",
".",
"AddDate",
"(",
"0",
",",
"0",
",",
"7",
")",
"\n",
"}",
"\n\n",
"// 1 vs 5 ~ add 4 days",
"if",
"afterWeekday",
"<",
"dayOfWeek",
"{",
"dayDelta",
":=",
"int",
"(",
"dayOfWeek",
"-",
"afterWeekday",
")",
"\n",
"return",
"after",
".",
"AddDate",
"(",
"0",
",",
"0",
",",
"dayDelta",
")",
"\n",
"}",
"\n\n",
"// 5 vs 1, add 7-(5-1) ~ 3 days",
"dayDelta",
":=",
"7",
"-",
"int",
"(",
"afterWeekday",
"-",
"dayOfWeek",
")",
"\n",
"return",
"after",
".",
"AddDate",
"(",
"0",
",",
"0",
",",
"dayDelta",
")",
"\n",
"}"
] |
// 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
|
147,667 |
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",
"(",
")",
"\n",
"}"
] |
// 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
|
147,668 |
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
|
147,669 |
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
|
147,670 |
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",
".",
"min",
"{",
"delta",
"=",
"*",
"r",
".",
"max",
"-",
"*",
"r",
".",
"min",
"\n",
"}",
"else",
"{",
"delta",
"=",
"*",
"r",
".",
"min",
"-",
"*",
"r",
".",
"max",
"\n",
"}",
"\n\n",
"return",
"*",
"r",
".",
"min",
"+",
"(",
"r",
".",
"rnd",
".",
"Float64",
"(",
")",
"*",
"delta",
")",
"\n",
"}",
"else",
"if",
"r",
".",
"max",
"!=",
"nil",
"{",
"return",
"r",
".",
"rnd",
".",
"Float64",
"(",
")",
"*",
"*",
"r",
".",
"max",
"\n",
"}",
"else",
"if",
"r",
".",
"min",
"!=",
"nil",
"{",
"return",
"*",
"r",
".",
"min",
"+",
"(",
"r",
".",
"rnd",
".",
"Float64",
"(",
")",
")",
"\n",
"}",
"\n",
"return",
"r",
".",
"rnd",
".",
"Float64",
"(",
")",
"\n",
"}"
] |
// GetValue returns the value.
|
[
"GetValue",
"returns",
"the",
"value",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/random.go#L43-L60
|
147,671 |
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
|
147,672 |
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
|
147,673 |
wcharczuk/go-chart
|
seq/random.go
|
WithMax
|
func (r *Random) WithMax(max float64) *Random {
r.max = &max
return r
}
|
go
|
func (r *Random) WithMax(max float64) *Random {
r.max = &max
return r
}
|
[
"func",
"(",
"r",
"*",
"Random",
")",
"WithMax",
"(",
"max",
"float64",
")",
"*",
"Random",
"{",
"r",
".",
"max",
"=",
"&",
"max",
"\n",
"return",
"r",
"\n",
"}"
] |
// WithMax sets the average and returns the Random.
|
[
"WithMax",
"sets",
"the",
"average",
"and",
"returns",
"the",
"Random",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/random.go#L85-L88
|
147,674 |
wcharczuk/go-chart
|
continuous_range.go
|
IsZero
|
func (r ContinuousRange) IsZero() bool {
return (r.Min == 0 || math.IsNaN(r.Min)) &&
(r.Max == 0 || math.IsNaN(r.Max)) &&
r.Domain == 0
}
|
go
|
func (r ContinuousRange) IsZero() bool {
return (r.Min == 0 || math.IsNaN(r.Min)) &&
(r.Max == 0 || math.IsNaN(r.Max)) &&
r.Domain == 0
}
|
[
"func",
"(",
"r",
"ContinuousRange",
")",
"IsZero",
"(",
")",
"bool",
"{",
"return",
"(",
"r",
".",
"Min",
"==",
"0",
"||",
"math",
".",
"IsNaN",
"(",
"r",
".",
"Min",
")",
")",
"&&",
"(",
"r",
".",
"Max",
"==",
"0",
"||",
"math",
".",
"IsNaN",
"(",
"r",
".",
"Max",
")",
")",
"&&",
"r",
".",
"Domain",
"==",
"0",
"\n",
"}"
] |
// IsZero returns if the ContinuousRange has been set or not.
|
[
"IsZero",
"returns",
"if",
"the",
"ContinuousRange",
"has",
"been",
"set",
"or",
"not",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/continuous_range.go#L22-L26
|
147,675 |
wcharczuk/go-chart
|
continuous_range.go
|
String
|
func (r ContinuousRange) String() string {
return fmt.Sprintf("ContinuousRange [%.2f,%.2f] => %d", r.Min, r.Max, r.Domain)
}
|
go
|
func (r ContinuousRange) String() string {
return fmt.Sprintf("ContinuousRange [%.2f,%.2f] => %d", r.Min, r.Max, r.Domain)
}
|
[
"func",
"(",
"r",
"ContinuousRange",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"r",
".",
"Min",
",",
"r",
".",
"Max",
",",
"r",
".",
"Domain",
")",
"\n",
"}"
] |
// String returns a simple string for the ContinuousRange.
|
[
"String",
"returns",
"a",
"simple",
"string",
"for",
"the",
"ContinuousRange",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/continuous_range.go#L64-L66
|
147,676 |
wcharczuk/go-chart
|
continuous_range.go
|
Translate
|
func (r ContinuousRange) Translate(value float64) int {
normalized := value - r.Min
ratio := normalized / r.GetDelta()
if r.IsDescending() {
return r.Domain - int(math.Ceil(ratio*float64(r.Domain)))
}
return int(math.Ceil(ratio * float64(r.Domain)))
}
|
go
|
func (r ContinuousRange) Translate(value float64) int {
normalized := value - r.Min
ratio := normalized / r.GetDelta()
if r.IsDescending() {
return r.Domain - int(math.Ceil(ratio*float64(r.Domain)))
}
return int(math.Ceil(ratio * float64(r.Domain)))
}
|
[
"func",
"(",
"r",
"ContinuousRange",
")",
"Translate",
"(",
"value",
"float64",
")",
"int",
"{",
"normalized",
":=",
"value",
"-",
"r",
".",
"Min",
"\n",
"ratio",
":=",
"normalized",
"/",
"r",
".",
"GetDelta",
"(",
")",
"\n\n",
"if",
"r",
".",
"IsDescending",
"(",
")",
"{",
"return",
"r",
".",
"Domain",
"-",
"int",
"(",
"math",
".",
"Ceil",
"(",
"ratio",
"*",
"float64",
"(",
"r",
".",
"Domain",
")",
")",
")",
"\n",
"}",
"\n\n",
"return",
"int",
"(",
"math",
".",
"Ceil",
"(",
"ratio",
"*",
"float64",
"(",
"r",
".",
"Domain",
")",
")",
")",
"\n",
"}"
] |
// Translate maps a given value into the ContinuousRange space.
|
[
"Translate",
"maps",
"a",
"given",
"value",
"into",
"the",
"ContinuousRange",
"space",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/continuous_range.go#L69-L78
|
147,677 |
wcharczuk/go-chart
|
bollinger_band_series.go
|
GetK
|
func (bbs BollingerBandsSeries) GetK(defaults ...float64) float64 {
if bbs.K == 0 {
if len(defaults) > 0 {
return defaults[0]
}
return 2.0
}
return bbs.K
}
|
go
|
func (bbs BollingerBandsSeries) GetK(defaults ...float64) float64 {
if bbs.K == 0 {
if len(defaults) > 0 {
return defaults[0]
}
return 2.0
}
return bbs.K
}
|
[
"func",
"(",
"bbs",
"BollingerBandsSeries",
")",
"GetK",
"(",
"defaults",
"...",
"float64",
")",
"float64",
"{",
"if",
"bbs",
".",
"K",
"==",
"0",
"{",
"if",
"len",
"(",
"defaults",
")",
">",
"0",
"{",
"return",
"defaults",
"[",
"0",
"]",
"\n",
"}",
"\n",
"return",
"2.0",
"\n",
"}",
"\n",
"return",
"bbs",
".",
"K",
"\n",
"}"
] |
// GetK returns the K value, or the number of standard deviations above and below
// to band the simple moving average with.
// Typical K value is 2.0.
|
[
"GetK",
"returns",
"the",
"K",
"value",
"or",
"the",
"number",
"of",
"standard",
"deviations",
"above",
"and",
"below",
"to",
"band",
"the",
"simple",
"moving",
"average",
"with",
".",
"Typical",
"K",
"value",
"is",
"2",
".",
"0",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/bollinger_band_series.go#L54-L62
|
147,678 |
wcharczuk/go-chart
|
bollinger_band_series.go
|
GetBoundedValues
|
func (bbs *BollingerBandsSeries) GetBoundedValues(index int) (x, y1, y2 float64) {
if bbs.InnerSeries == nil {
return
}
if bbs.valueBuffer == nil || index == 0 {
bbs.valueBuffer = seq.NewBufferWithCapacity(bbs.GetPeriod())
}
if bbs.valueBuffer.Len() >= bbs.GetPeriod() {
bbs.valueBuffer.Dequeue()
}
px, py := bbs.InnerSeries.GetValues(index)
bbs.valueBuffer.Enqueue(py)
x = px
ay := seq.New(bbs.valueBuffer).Average()
std := seq.New(bbs.valueBuffer).StdDev()
y1 = ay + (bbs.GetK() * std)
y2 = ay - (bbs.GetK() * std)
return
}
|
go
|
func (bbs *BollingerBandsSeries) GetBoundedValues(index int) (x, y1, y2 float64) {
if bbs.InnerSeries == nil {
return
}
if bbs.valueBuffer == nil || index == 0 {
bbs.valueBuffer = seq.NewBufferWithCapacity(bbs.GetPeriod())
}
if bbs.valueBuffer.Len() >= bbs.GetPeriod() {
bbs.valueBuffer.Dequeue()
}
px, py := bbs.InnerSeries.GetValues(index)
bbs.valueBuffer.Enqueue(py)
x = px
ay := seq.New(bbs.valueBuffer).Average()
std := seq.New(bbs.valueBuffer).StdDev()
y1 = ay + (bbs.GetK() * std)
y2 = ay - (bbs.GetK() * std)
return
}
|
[
"func",
"(",
"bbs",
"*",
"BollingerBandsSeries",
")",
"GetBoundedValues",
"(",
"index",
"int",
")",
"(",
"x",
",",
"y1",
",",
"y2",
"float64",
")",
"{",
"if",
"bbs",
".",
"InnerSeries",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"if",
"bbs",
".",
"valueBuffer",
"==",
"nil",
"||",
"index",
"==",
"0",
"{",
"bbs",
".",
"valueBuffer",
"=",
"seq",
".",
"NewBufferWithCapacity",
"(",
"bbs",
".",
"GetPeriod",
"(",
")",
")",
"\n",
"}",
"\n",
"if",
"bbs",
".",
"valueBuffer",
".",
"Len",
"(",
")",
">=",
"bbs",
".",
"GetPeriod",
"(",
")",
"{",
"bbs",
".",
"valueBuffer",
".",
"Dequeue",
"(",
")",
"\n",
"}",
"\n",
"px",
",",
"py",
":=",
"bbs",
".",
"InnerSeries",
".",
"GetValues",
"(",
"index",
")",
"\n",
"bbs",
".",
"valueBuffer",
".",
"Enqueue",
"(",
"py",
")",
"\n",
"x",
"=",
"px",
"\n\n",
"ay",
":=",
"seq",
".",
"New",
"(",
"bbs",
".",
"valueBuffer",
")",
".",
"Average",
"(",
")",
"\n",
"std",
":=",
"seq",
".",
"New",
"(",
"bbs",
".",
"valueBuffer",
")",
".",
"StdDev",
"(",
")",
"\n\n",
"y1",
"=",
"ay",
"+",
"(",
"bbs",
".",
"GetK",
"(",
")",
"*",
"std",
")",
"\n",
"y2",
"=",
"ay",
"-",
"(",
"bbs",
".",
"GetK",
"(",
")",
"*",
"std",
")",
"\n",
"return",
"\n",
"}"
] |
// GetBoundedValues gets the bounded value for the series.
|
[
"GetBoundedValues",
"gets",
"the",
"bounded",
"value",
"for",
"the",
"series",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/bollinger_band_series.go#L70-L90
|
147,679 |
wcharczuk/go-chart
|
bollinger_band_series.go
|
GetBoundedLastValues
|
func (bbs *BollingerBandsSeries) GetBoundedLastValues() (x, y1, y2 float64) {
if bbs.InnerSeries == nil {
return
}
period := bbs.GetPeriod()
seriesLength := bbs.InnerSeries.Len()
startAt := seriesLength - period
if startAt < 0 {
startAt = 0
}
vb := seq.NewBufferWithCapacity(period)
for index := startAt; index < seriesLength; index++ {
xn, yn := bbs.InnerSeries.GetValues(index)
vb.Enqueue(yn)
x = xn
}
ay := seq.Seq{Provider: vb}.Average()
std := seq.Seq{Provider: vb}.StdDev()
y1 = ay + (bbs.GetK() * std)
y2 = ay - (bbs.GetK() * std)
return
}
|
go
|
func (bbs *BollingerBandsSeries) GetBoundedLastValues() (x, y1, y2 float64) {
if bbs.InnerSeries == nil {
return
}
period := bbs.GetPeriod()
seriesLength := bbs.InnerSeries.Len()
startAt := seriesLength - period
if startAt < 0 {
startAt = 0
}
vb := seq.NewBufferWithCapacity(period)
for index := startAt; index < seriesLength; index++ {
xn, yn := bbs.InnerSeries.GetValues(index)
vb.Enqueue(yn)
x = xn
}
ay := seq.Seq{Provider: vb}.Average()
std := seq.Seq{Provider: vb}.StdDev()
y1 = ay + (bbs.GetK() * std)
y2 = ay - (bbs.GetK() * std)
return
}
|
[
"func",
"(",
"bbs",
"*",
"BollingerBandsSeries",
")",
"GetBoundedLastValues",
"(",
")",
"(",
"x",
",",
"y1",
",",
"y2",
"float64",
")",
"{",
"if",
"bbs",
".",
"InnerSeries",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"period",
":=",
"bbs",
".",
"GetPeriod",
"(",
")",
"\n",
"seriesLength",
":=",
"bbs",
".",
"InnerSeries",
".",
"Len",
"(",
")",
"\n",
"startAt",
":=",
"seriesLength",
"-",
"period",
"\n",
"if",
"startAt",
"<",
"0",
"{",
"startAt",
"=",
"0",
"\n",
"}",
"\n\n",
"vb",
":=",
"seq",
".",
"NewBufferWithCapacity",
"(",
"period",
")",
"\n",
"for",
"index",
":=",
"startAt",
";",
"index",
"<",
"seriesLength",
";",
"index",
"++",
"{",
"xn",
",",
"yn",
":=",
"bbs",
".",
"InnerSeries",
".",
"GetValues",
"(",
"index",
")",
"\n",
"vb",
".",
"Enqueue",
"(",
"yn",
")",
"\n",
"x",
"=",
"xn",
"\n",
"}",
"\n\n",
"ay",
":=",
"seq",
".",
"Seq",
"{",
"Provider",
":",
"vb",
"}",
".",
"Average",
"(",
")",
"\n",
"std",
":=",
"seq",
".",
"Seq",
"{",
"Provider",
":",
"vb",
"}",
".",
"StdDev",
"(",
")",
"\n\n",
"y1",
"=",
"ay",
"+",
"(",
"bbs",
".",
"GetK",
"(",
")",
"*",
"std",
")",
"\n",
"y2",
"=",
"ay",
"-",
"(",
"bbs",
".",
"GetK",
"(",
")",
"*",
"std",
")",
"\n\n",
"return",
"\n",
"}"
] |
// GetBoundedLastValues returns the last bounded value for the series.
|
[
"GetBoundedLastValues",
"returns",
"the",
"last",
"bounded",
"value",
"for",
"the",
"series",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/bollinger_band_series.go#L93-L118
|
147,680 |
wcharczuk/go-chart
|
drawing/raster_graphic_context.go
|
NewRasterGraphicContext
|
func NewRasterGraphicContext(img draw.Image) (*RasterGraphicContext, error) {
var painter Painter
switch selectImage := img.(type) {
case *image.RGBA:
painter = raster.NewRGBAPainter(selectImage)
default:
return nil, errors.New("NewRasterGraphicContext() :: invalid image type")
}
return NewRasterGraphicContextWithPainter(img, painter), nil
}
|
go
|
func NewRasterGraphicContext(img draw.Image) (*RasterGraphicContext, error) {
var painter Painter
switch selectImage := img.(type) {
case *image.RGBA:
painter = raster.NewRGBAPainter(selectImage)
default:
return nil, errors.New("NewRasterGraphicContext() :: invalid image type")
}
return NewRasterGraphicContextWithPainter(img, painter), nil
}
|
[
"func",
"NewRasterGraphicContext",
"(",
"img",
"draw",
".",
"Image",
")",
"(",
"*",
"RasterGraphicContext",
",",
"error",
")",
"{",
"var",
"painter",
"Painter",
"\n",
"switch",
"selectImage",
":=",
"img",
".",
"(",
"type",
")",
"{",
"case",
"*",
"image",
".",
"RGBA",
":",
"painter",
"=",
"raster",
".",
"NewRGBAPainter",
"(",
"selectImage",
")",
"\n",
"default",
":",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"NewRasterGraphicContextWithPainter",
"(",
"img",
",",
"painter",
")",
",",
"nil",
"\n",
"}"
] |
// NewRasterGraphicContext creates a new Graphic context from an image.
|
[
"NewRasterGraphicContext",
"creates",
"a",
"new",
"Graphic",
"context",
"from",
"an",
"image",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/raster_graphic_context.go#L17-L26
|
147,681 |
wcharczuk/go-chart
|
drawing/raster_graphic_context.go
|
SetDPI
|
func (rgc *RasterGraphicContext) SetDPI(dpi float64) {
rgc.DPI = dpi
rgc.recalc()
}
|
go
|
func (rgc *RasterGraphicContext) SetDPI(dpi float64) {
rgc.DPI = dpi
rgc.recalc()
}
|
[
"func",
"(",
"rgc",
"*",
"RasterGraphicContext",
")",
"SetDPI",
"(",
"dpi",
"float64",
")",
"{",
"rgc",
".",
"DPI",
"=",
"dpi",
"\n",
"rgc",
".",
"recalc",
"(",
")",
"\n",
"}"
] |
// SetDPI sets the screen resolution in dots per inch.
|
[
"SetDPI",
"sets",
"the",
"screen",
"resolution",
"in",
"dots",
"per",
"inch",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/raster_graphic_context.go#L54-L57
|
147,682 |
wcharczuk/go-chart
|
drawing/raster_graphic_context.go
|
Clear
|
func (rgc *RasterGraphicContext) Clear() {
width, height := rgc.img.Bounds().Dx(), rgc.img.Bounds().Dy()
rgc.ClearRect(0, 0, width, height)
}
|
go
|
func (rgc *RasterGraphicContext) Clear() {
width, height := rgc.img.Bounds().Dx(), rgc.img.Bounds().Dy()
rgc.ClearRect(0, 0, width, height)
}
|
[
"func",
"(",
"rgc",
"*",
"RasterGraphicContext",
")",
"Clear",
"(",
")",
"{",
"width",
",",
"height",
":=",
"rgc",
".",
"img",
".",
"Bounds",
"(",
")",
".",
"Dx",
"(",
")",
",",
"rgc",
".",
"img",
".",
"Bounds",
"(",
")",
".",
"Dy",
"(",
")",
"\n",
"rgc",
".",
"ClearRect",
"(",
"0",
",",
"0",
",",
"width",
",",
"height",
")",
"\n",
"}"
] |
// Clear fills the current canvas with a default transparent color
|
[
"Clear",
"fills",
"the",
"current",
"canvas",
"with",
"a",
"default",
"transparent",
"color"
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/raster_graphic_context.go#L65-L68
|
147,683 |
wcharczuk/go-chart
|
drawing/raster_graphic_context.go
|
ClearRect
|
func (rgc *RasterGraphicContext) ClearRect(x1, y1, x2, y2 int) {
imageColor := image.NewUniform(rgc.current.FillColor)
draw.Draw(rgc.img, image.Rect(x1, y1, x2, y2), imageColor, image.ZP, draw.Over)
}
|
go
|
func (rgc *RasterGraphicContext) ClearRect(x1, y1, x2, y2 int) {
imageColor := image.NewUniform(rgc.current.FillColor)
draw.Draw(rgc.img, image.Rect(x1, y1, x2, y2), imageColor, image.ZP, draw.Over)
}
|
[
"func",
"(",
"rgc",
"*",
"RasterGraphicContext",
")",
"ClearRect",
"(",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
"int",
")",
"{",
"imageColor",
":=",
"image",
".",
"NewUniform",
"(",
"rgc",
".",
"current",
".",
"FillColor",
")",
"\n",
"draw",
".",
"Draw",
"(",
"rgc",
".",
"img",
",",
"image",
".",
"Rect",
"(",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
")",
",",
"imageColor",
",",
"image",
".",
"ZP",
",",
"draw",
".",
"Over",
")",
"\n",
"}"
] |
// ClearRect fills the current canvas with a default transparent color at the specified rectangle
|
[
"ClearRect",
"fills",
"the",
"current",
"canvas",
"with",
"a",
"default",
"transparent",
"color",
"at",
"the",
"specified",
"rectangle"
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/raster_graphic_context.go#L71-L74
|
147,684 |
wcharczuk/go-chart
|
drawing/raster_graphic_context.go
|
DrawImage
|
func (rgc *RasterGraphicContext) DrawImage(img image.Image) {
DrawImage(img, rgc.img, rgc.current.Tr, draw.Over, BilinearFilter)
}
|
go
|
func (rgc *RasterGraphicContext) DrawImage(img image.Image) {
DrawImage(img, rgc.img, rgc.current.Tr, draw.Over, BilinearFilter)
}
|
[
"func",
"(",
"rgc",
"*",
"RasterGraphicContext",
")",
"DrawImage",
"(",
"img",
"image",
".",
"Image",
")",
"{",
"DrawImage",
"(",
"img",
",",
"rgc",
".",
"img",
",",
"rgc",
".",
"current",
".",
"Tr",
",",
"draw",
".",
"Over",
",",
"BilinearFilter",
")",
"\n",
"}"
] |
// DrawImage draws the raster image in the current canvas
|
[
"DrawImage",
"draws",
"the",
"raster",
"image",
"in",
"the",
"current",
"canvas"
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/raster_graphic_context.go#L77-L79
|
147,685 |
wcharczuk/go-chart
|
drawing/raster_graphic_context.go
|
CreateStringPath
|
func (rgc *RasterGraphicContext) CreateStringPath(s string, x, y float64) (cursor float64, err error) {
f := rgc.GetFont()
if f == nil {
err = errors.New("No font loaded, cannot continue")
return
}
rgc.recalc()
startx := x
prev, hasPrev := truetype.Index(0), false
for _, rc := range s {
index := f.Index(rc)
if hasPrev {
x += fUnitsToFloat64(f.Kern(fixed.Int26_6(rgc.current.Scale), prev, index))
}
err = rgc.drawGlyph(index, x, y)
if err != nil {
cursor = x - startx
return
}
x += fUnitsToFloat64(f.HMetric(fixed.Int26_6(rgc.current.Scale), index).AdvanceWidth)
prev, hasPrev = index, true
}
cursor = x - startx
return
}
|
go
|
func (rgc *RasterGraphicContext) CreateStringPath(s string, x, y float64) (cursor float64, err error) {
f := rgc.GetFont()
if f == nil {
err = errors.New("No font loaded, cannot continue")
return
}
rgc.recalc()
startx := x
prev, hasPrev := truetype.Index(0), false
for _, rc := range s {
index := f.Index(rc)
if hasPrev {
x += fUnitsToFloat64(f.Kern(fixed.Int26_6(rgc.current.Scale), prev, index))
}
err = rgc.drawGlyph(index, x, y)
if err != nil {
cursor = x - startx
return
}
x += fUnitsToFloat64(f.HMetric(fixed.Int26_6(rgc.current.Scale), index).AdvanceWidth)
prev, hasPrev = index, true
}
cursor = x - startx
return
}
|
[
"func",
"(",
"rgc",
"*",
"RasterGraphicContext",
")",
"CreateStringPath",
"(",
"s",
"string",
",",
"x",
",",
"y",
"float64",
")",
"(",
"cursor",
"float64",
",",
"err",
"error",
")",
"{",
"f",
":=",
"rgc",
".",
"GetFont",
"(",
")",
"\n",
"if",
"f",
"==",
"nil",
"{",
"err",
"=",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n",
"rgc",
".",
"recalc",
"(",
")",
"\n\n",
"startx",
":=",
"x",
"\n",
"prev",
",",
"hasPrev",
":=",
"truetype",
".",
"Index",
"(",
"0",
")",
",",
"false",
"\n",
"for",
"_",
",",
"rc",
":=",
"range",
"s",
"{",
"index",
":=",
"f",
".",
"Index",
"(",
"rc",
")",
"\n",
"if",
"hasPrev",
"{",
"x",
"+=",
"fUnitsToFloat64",
"(",
"f",
".",
"Kern",
"(",
"fixed",
".",
"Int26_6",
"(",
"rgc",
".",
"current",
".",
"Scale",
")",
",",
"prev",
",",
"index",
")",
")",
"\n",
"}",
"\n",
"err",
"=",
"rgc",
".",
"drawGlyph",
"(",
"index",
",",
"x",
",",
"y",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"cursor",
"=",
"x",
"-",
"startx",
"\n",
"return",
"\n",
"}",
"\n",
"x",
"+=",
"fUnitsToFloat64",
"(",
"f",
".",
"HMetric",
"(",
"fixed",
".",
"Int26_6",
"(",
"rgc",
".",
"current",
".",
"Scale",
")",
",",
"index",
")",
".",
"AdvanceWidth",
")",
"\n",
"prev",
",",
"hasPrev",
"=",
"index",
",",
"true",
"\n",
"}",
"\n",
"cursor",
"=",
"x",
"-",
"startx",
"\n",
"return",
"\n",
"}"
] |
// CreateStringPath creates a path from the string s at x, y, and returns the string width.
// The text is placed so that the left edge of the em square of the first character of s
// and the baseline intersect at x, y. The majority of the affected pixels will be
// above and to the right of the point, but some may be below or to the left.
// For example, drawing a string that starts with a 'J' in an italic font may
// affect pixels below and left of the point.
|
[
"CreateStringPath",
"creates",
"a",
"path",
"from",
"the",
"string",
"s",
"at",
"x",
"y",
"and",
"returns",
"the",
"string",
"width",
".",
"The",
"text",
"is",
"placed",
"so",
"that",
"the",
"left",
"edge",
"of",
"the",
"em",
"square",
"of",
"the",
"first",
"character",
"of",
"s",
"and",
"the",
"baseline",
"intersect",
"at",
"x",
"y",
".",
"The",
"majority",
"of",
"the",
"affected",
"pixels",
"will",
"be",
"above",
"and",
"to",
"the",
"right",
"of",
"the",
"point",
"but",
"some",
"may",
"be",
"below",
"or",
"to",
"the",
"left",
".",
"For",
"example",
"drawing",
"a",
"string",
"that",
"starts",
"with",
"a",
"J",
"in",
"an",
"italic",
"font",
"may",
"affect",
"pixels",
"below",
"and",
"left",
"of",
"the",
"point",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/raster_graphic_context.go#L125-L150
|
147,686 |
wcharczuk/go-chart
|
drawing/raster_graphic_context.go
|
GetStringBounds
|
func (rgc *RasterGraphicContext) GetStringBounds(s string) (left, top, right, bottom float64, err error) {
f := rgc.GetFont()
if f == nil {
err = errors.New("No font loaded, cannot continue")
return
}
rgc.recalc()
left = math.MaxFloat64
top = math.MaxFloat64
cursor := 0.0
prev, hasPrev := truetype.Index(0), false
for _, rc := range s {
index := f.Index(rc)
if hasPrev {
cursor += fUnitsToFloat64(f.Kern(fixed.Int26_6(rgc.current.Scale), prev, index))
}
if err = rgc.glyphBuf.Load(rgc.current.Font, fixed.Int26_6(rgc.current.Scale), index, font.HintingNone); err != nil {
return
}
e0 := 0
for _, e1 := range rgc.glyphBuf.Ends {
ps := rgc.glyphBuf.Points[e0:e1]
for _, p := range ps {
x, y := pointToF64Point(p)
top = math.Min(top, y)
bottom = math.Max(bottom, y)
left = math.Min(left, x+cursor)
right = math.Max(right, x+cursor)
}
e0 = e1
}
cursor += fUnitsToFloat64(f.HMetric(fixed.Int26_6(rgc.current.Scale), index).AdvanceWidth)
prev, hasPrev = index, true
}
return
}
|
go
|
func (rgc *RasterGraphicContext) GetStringBounds(s string) (left, top, right, bottom float64, err error) {
f := rgc.GetFont()
if f == nil {
err = errors.New("No font loaded, cannot continue")
return
}
rgc.recalc()
left = math.MaxFloat64
top = math.MaxFloat64
cursor := 0.0
prev, hasPrev := truetype.Index(0), false
for _, rc := range s {
index := f.Index(rc)
if hasPrev {
cursor += fUnitsToFloat64(f.Kern(fixed.Int26_6(rgc.current.Scale), prev, index))
}
if err = rgc.glyphBuf.Load(rgc.current.Font, fixed.Int26_6(rgc.current.Scale), index, font.HintingNone); err != nil {
return
}
e0 := 0
for _, e1 := range rgc.glyphBuf.Ends {
ps := rgc.glyphBuf.Points[e0:e1]
for _, p := range ps {
x, y := pointToF64Point(p)
top = math.Min(top, y)
bottom = math.Max(bottom, y)
left = math.Min(left, x+cursor)
right = math.Max(right, x+cursor)
}
e0 = e1
}
cursor += fUnitsToFloat64(f.HMetric(fixed.Int26_6(rgc.current.Scale), index).AdvanceWidth)
prev, hasPrev = index, true
}
return
}
|
[
"func",
"(",
"rgc",
"*",
"RasterGraphicContext",
")",
"GetStringBounds",
"(",
"s",
"string",
")",
"(",
"left",
",",
"top",
",",
"right",
",",
"bottom",
"float64",
",",
"err",
"error",
")",
"{",
"f",
":=",
"rgc",
".",
"GetFont",
"(",
")",
"\n",
"if",
"f",
"==",
"nil",
"{",
"err",
"=",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\n",
"}",
"\n",
"rgc",
".",
"recalc",
"(",
")",
"\n\n",
"left",
"=",
"math",
".",
"MaxFloat64",
"\n",
"top",
"=",
"math",
".",
"MaxFloat64",
"\n\n",
"cursor",
":=",
"0.0",
"\n",
"prev",
",",
"hasPrev",
":=",
"truetype",
".",
"Index",
"(",
"0",
")",
",",
"false",
"\n",
"for",
"_",
",",
"rc",
":=",
"range",
"s",
"{",
"index",
":=",
"f",
".",
"Index",
"(",
"rc",
")",
"\n",
"if",
"hasPrev",
"{",
"cursor",
"+=",
"fUnitsToFloat64",
"(",
"f",
".",
"Kern",
"(",
"fixed",
".",
"Int26_6",
"(",
"rgc",
".",
"current",
".",
"Scale",
")",
",",
"prev",
",",
"index",
")",
")",
"\n",
"}",
"\n\n",
"if",
"err",
"=",
"rgc",
".",
"glyphBuf",
".",
"Load",
"(",
"rgc",
".",
"current",
".",
"Font",
",",
"fixed",
".",
"Int26_6",
"(",
"rgc",
".",
"current",
".",
"Scale",
")",
",",
"index",
",",
"font",
".",
"HintingNone",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"e0",
":=",
"0",
"\n",
"for",
"_",
",",
"e1",
":=",
"range",
"rgc",
".",
"glyphBuf",
".",
"Ends",
"{",
"ps",
":=",
"rgc",
".",
"glyphBuf",
".",
"Points",
"[",
"e0",
":",
"e1",
"]",
"\n",
"for",
"_",
",",
"p",
":=",
"range",
"ps",
"{",
"x",
",",
"y",
":=",
"pointToF64Point",
"(",
"p",
")",
"\n",
"top",
"=",
"math",
".",
"Min",
"(",
"top",
",",
"y",
")",
"\n",
"bottom",
"=",
"math",
".",
"Max",
"(",
"bottom",
",",
"y",
")",
"\n",
"left",
"=",
"math",
".",
"Min",
"(",
"left",
",",
"x",
"+",
"cursor",
")",
"\n",
"right",
"=",
"math",
".",
"Max",
"(",
"right",
",",
"x",
"+",
"cursor",
")",
"\n",
"}",
"\n",
"e0",
"=",
"e1",
"\n",
"}",
"\n",
"cursor",
"+=",
"fUnitsToFloat64",
"(",
"f",
".",
"HMetric",
"(",
"fixed",
".",
"Int26_6",
"(",
"rgc",
".",
"current",
".",
"Scale",
")",
",",
"index",
")",
".",
"AdvanceWidth",
")",
"\n",
"prev",
",",
"hasPrev",
"=",
"index",
",",
"true",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] |
// GetStringBounds returns the approximate pixel bounds of a string.
|
[
"GetStringBounds",
"returns",
"the",
"approximate",
"pixel",
"bounds",
"of",
"a",
"string",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/raster_graphic_context.go#L153-L191
|
147,687 |
wcharczuk/go-chart
|
drawing/raster_graphic_context.go
|
recalc
|
func (rgc *RasterGraphicContext) recalc() {
rgc.current.Scale = rgc.current.FontSizePoints * float64(rgc.DPI)
}
|
go
|
func (rgc *RasterGraphicContext) recalc() {
rgc.current.Scale = rgc.current.FontSizePoints * float64(rgc.DPI)
}
|
[
"func",
"(",
"rgc",
"*",
"RasterGraphicContext",
")",
"recalc",
"(",
")",
"{",
"rgc",
".",
"current",
".",
"Scale",
"=",
"rgc",
".",
"current",
".",
"FontSizePoints",
"*",
"float64",
"(",
"rgc",
".",
"DPI",
")",
"\n",
"}"
] |
// recalc recalculates scale and bounds values from the font size, screen
// resolution and font metrics, and invalidates the glyph cache.
|
[
"recalc",
"recalculates",
"scale",
"and",
"bounds",
"values",
"from",
"the",
"font",
"size",
"screen",
"resolution",
"and",
"font",
"metrics",
"and",
"invalidates",
"the",
"glyph",
"cache",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/raster_graphic_context.go#L195-L197
|
147,688 |
wcharczuk/go-chart
|
drawing/raster_graphic_context.go
|
SetFont
|
func (rgc *RasterGraphicContext) SetFont(font *truetype.Font) {
rgc.current.Font = font
}
|
go
|
func (rgc *RasterGraphicContext) SetFont(font *truetype.Font) {
rgc.current.Font = font
}
|
[
"func",
"(",
"rgc",
"*",
"RasterGraphicContext",
")",
"SetFont",
"(",
"font",
"*",
"truetype",
".",
"Font",
")",
"{",
"rgc",
".",
"current",
".",
"Font",
"=",
"font",
"\n",
"}"
] |
// SetFont sets the font used to draw text.
|
[
"SetFont",
"sets",
"the",
"font",
"used",
"to",
"draw",
"text",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/raster_graphic_context.go#L200-L202
|
147,689 |
wcharczuk/go-chart
|
drawing/raster_graphic_context.go
|
Stroke
|
func (rgc *RasterGraphicContext) Stroke(paths ...*Path) {
paths = append(paths, rgc.current.Path)
rgc.strokeRasterizer.UseNonZeroWinding = true
stroker := NewLineStroker(rgc.current.Cap, rgc.current.Join, Transformer{Tr: rgc.current.Tr, Flattener: FtLineBuilder{Adder: rgc.strokeRasterizer}})
stroker.HalfLineWidth = rgc.current.LineWidth / 2
var liner Flattener
if rgc.current.Dash != nil && len(rgc.current.Dash) > 0 {
liner = NewDashVertexConverter(rgc.current.Dash, rgc.current.DashOffset, stroker)
} else {
liner = stroker
}
for _, p := range paths {
Flatten(p, liner, rgc.current.Tr.GetScale())
}
rgc.paint(rgc.strokeRasterizer, rgc.current.StrokeColor)
}
|
go
|
func (rgc *RasterGraphicContext) Stroke(paths ...*Path) {
paths = append(paths, rgc.current.Path)
rgc.strokeRasterizer.UseNonZeroWinding = true
stroker := NewLineStroker(rgc.current.Cap, rgc.current.Join, Transformer{Tr: rgc.current.Tr, Flattener: FtLineBuilder{Adder: rgc.strokeRasterizer}})
stroker.HalfLineWidth = rgc.current.LineWidth / 2
var liner Flattener
if rgc.current.Dash != nil && len(rgc.current.Dash) > 0 {
liner = NewDashVertexConverter(rgc.current.Dash, rgc.current.DashOffset, stroker)
} else {
liner = stroker
}
for _, p := range paths {
Flatten(p, liner, rgc.current.Tr.GetScale())
}
rgc.paint(rgc.strokeRasterizer, rgc.current.StrokeColor)
}
|
[
"func",
"(",
"rgc",
"*",
"RasterGraphicContext",
")",
"Stroke",
"(",
"paths",
"...",
"*",
"Path",
")",
"{",
"paths",
"=",
"append",
"(",
"paths",
",",
"rgc",
".",
"current",
".",
"Path",
")",
"\n",
"rgc",
".",
"strokeRasterizer",
".",
"UseNonZeroWinding",
"=",
"true",
"\n\n",
"stroker",
":=",
"NewLineStroker",
"(",
"rgc",
".",
"current",
".",
"Cap",
",",
"rgc",
".",
"current",
".",
"Join",
",",
"Transformer",
"{",
"Tr",
":",
"rgc",
".",
"current",
".",
"Tr",
",",
"Flattener",
":",
"FtLineBuilder",
"{",
"Adder",
":",
"rgc",
".",
"strokeRasterizer",
"}",
"}",
")",
"\n",
"stroker",
".",
"HalfLineWidth",
"=",
"rgc",
".",
"current",
".",
"LineWidth",
"/",
"2",
"\n\n",
"var",
"liner",
"Flattener",
"\n",
"if",
"rgc",
".",
"current",
".",
"Dash",
"!=",
"nil",
"&&",
"len",
"(",
"rgc",
".",
"current",
".",
"Dash",
")",
">",
"0",
"{",
"liner",
"=",
"NewDashVertexConverter",
"(",
"rgc",
".",
"current",
".",
"Dash",
",",
"rgc",
".",
"current",
".",
"DashOffset",
",",
"stroker",
")",
"\n",
"}",
"else",
"{",
"liner",
"=",
"stroker",
"\n",
"}",
"\n",
"for",
"_",
",",
"p",
":=",
"range",
"paths",
"{",
"Flatten",
"(",
"p",
",",
"liner",
",",
"rgc",
".",
"current",
".",
"Tr",
".",
"GetScale",
"(",
")",
")",
"\n",
"}",
"\n\n",
"rgc",
".",
"paint",
"(",
"rgc",
".",
"strokeRasterizer",
",",
"rgc",
".",
"current",
".",
"StrokeColor",
")",
"\n",
"}"
] |
// Stroke strokes the paths with the color specified by SetStrokeColor
|
[
"Stroke",
"strokes",
"the",
"paths",
"with",
"the",
"color",
"specified",
"by",
"SetStrokeColor"
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/raster_graphic_context.go#L223-L241
|
147,690 |
wcharczuk/go-chart
|
drawing/raster_graphic_context.go
|
Fill
|
func (rgc *RasterGraphicContext) Fill(paths ...*Path) {
paths = append(paths, rgc.current.Path)
rgc.fillRasterizer.UseNonZeroWinding = rgc.current.FillRule == FillRuleWinding
flattener := Transformer{Tr: rgc.current.Tr, Flattener: FtLineBuilder{Adder: rgc.fillRasterizer}}
for _, p := range paths {
Flatten(p, flattener, rgc.current.Tr.GetScale())
}
rgc.paint(rgc.fillRasterizer, rgc.current.FillColor)
}
|
go
|
func (rgc *RasterGraphicContext) Fill(paths ...*Path) {
paths = append(paths, rgc.current.Path)
rgc.fillRasterizer.UseNonZeroWinding = rgc.current.FillRule == FillRuleWinding
flattener := Transformer{Tr: rgc.current.Tr, Flattener: FtLineBuilder{Adder: rgc.fillRasterizer}}
for _, p := range paths {
Flatten(p, flattener, rgc.current.Tr.GetScale())
}
rgc.paint(rgc.fillRasterizer, rgc.current.FillColor)
}
|
[
"func",
"(",
"rgc",
"*",
"RasterGraphicContext",
")",
"Fill",
"(",
"paths",
"...",
"*",
"Path",
")",
"{",
"paths",
"=",
"append",
"(",
"paths",
",",
"rgc",
".",
"current",
".",
"Path",
")",
"\n",
"rgc",
".",
"fillRasterizer",
".",
"UseNonZeroWinding",
"=",
"rgc",
".",
"current",
".",
"FillRule",
"==",
"FillRuleWinding",
"\n\n",
"flattener",
":=",
"Transformer",
"{",
"Tr",
":",
"rgc",
".",
"current",
".",
"Tr",
",",
"Flattener",
":",
"FtLineBuilder",
"{",
"Adder",
":",
"rgc",
".",
"fillRasterizer",
"}",
"}",
"\n",
"for",
"_",
",",
"p",
":=",
"range",
"paths",
"{",
"Flatten",
"(",
"p",
",",
"flattener",
",",
"rgc",
".",
"current",
".",
"Tr",
".",
"GetScale",
"(",
")",
")",
"\n",
"}",
"\n\n",
"rgc",
".",
"paint",
"(",
"rgc",
".",
"fillRasterizer",
",",
"rgc",
".",
"current",
".",
"FillColor",
")",
"\n",
"}"
] |
// Fill fills the paths with the color specified by SetFillColor
|
[
"Fill",
"fills",
"the",
"paths",
"with",
"the",
"color",
"specified",
"by",
"SetFillColor"
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/raster_graphic_context.go#L244-L254
|
147,691 |
wcharczuk/go-chart
|
drawing/raster_graphic_context.go
|
FillStroke
|
func (rgc *RasterGraphicContext) FillStroke(paths ...*Path) {
paths = append(paths, rgc.current.Path)
rgc.fillRasterizer.UseNonZeroWinding = rgc.current.FillRule == FillRuleWinding
rgc.strokeRasterizer.UseNonZeroWinding = true
flattener := Transformer{Tr: rgc.current.Tr, Flattener: FtLineBuilder{Adder: rgc.fillRasterizer}}
stroker := NewLineStroker(rgc.current.Cap, rgc.current.Join, Transformer{Tr: rgc.current.Tr, Flattener: FtLineBuilder{Adder: rgc.strokeRasterizer}})
stroker.HalfLineWidth = rgc.current.LineWidth / 2
var liner Flattener
if rgc.current.Dash != nil && len(rgc.current.Dash) > 0 {
liner = NewDashVertexConverter(rgc.current.Dash, rgc.current.DashOffset, stroker)
} else {
liner = stroker
}
demux := DemuxFlattener{Flatteners: []Flattener{flattener, liner}}
for _, p := range paths {
Flatten(p, demux, rgc.current.Tr.GetScale())
}
// Fill
rgc.paint(rgc.fillRasterizer, rgc.current.FillColor)
// Stroke
rgc.paint(rgc.strokeRasterizer, rgc.current.StrokeColor)
}
|
go
|
func (rgc *RasterGraphicContext) FillStroke(paths ...*Path) {
paths = append(paths, rgc.current.Path)
rgc.fillRasterizer.UseNonZeroWinding = rgc.current.FillRule == FillRuleWinding
rgc.strokeRasterizer.UseNonZeroWinding = true
flattener := Transformer{Tr: rgc.current.Tr, Flattener: FtLineBuilder{Adder: rgc.fillRasterizer}}
stroker := NewLineStroker(rgc.current.Cap, rgc.current.Join, Transformer{Tr: rgc.current.Tr, Flattener: FtLineBuilder{Adder: rgc.strokeRasterizer}})
stroker.HalfLineWidth = rgc.current.LineWidth / 2
var liner Flattener
if rgc.current.Dash != nil && len(rgc.current.Dash) > 0 {
liner = NewDashVertexConverter(rgc.current.Dash, rgc.current.DashOffset, stroker)
} else {
liner = stroker
}
demux := DemuxFlattener{Flatteners: []Flattener{flattener, liner}}
for _, p := range paths {
Flatten(p, demux, rgc.current.Tr.GetScale())
}
// Fill
rgc.paint(rgc.fillRasterizer, rgc.current.FillColor)
// Stroke
rgc.paint(rgc.strokeRasterizer, rgc.current.StrokeColor)
}
|
[
"func",
"(",
"rgc",
"*",
"RasterGraphicContext",
")",
"FillStroke",
"(",
"paths",
"...",
"*",
"Path",
")",
"{",
"paths",
"=",
"append",
"(",
"paths",
",",
"rgc",
".",
"current",
".",
"Path",
")",
"\n",
"rgc",
".",
"fillRasterizer",
".",
"UseNonZeroWinding",
"=",
"rgc",
".",
"current",
".",
"FillRule",
"==",
"FillRuleWinding",
"\n",
"rgc",
".",
"strokeRasterizer",
".",
"UseNonZeroWinding",
"=",
"true",
"\n\n",
"flattener",
":=",
"Transformer",
"{",
"Tr",
":",
"rgc",
".",
"current",
".",
"Tr",
",",
"Flattener",
":",
"FtLineBuilder",
"{",
"Adder",
":",
"rgc",
".",
"fillRasterizer",
"}",
"}",
"\n\n",
"stroker",
":=",
"NewLineStroker",
"(",
"rgc",
".",
"current",
".",
"Cap",
",",
"rgc",
".",
"current",
".",
"Join",
",",
"Transformer",
"{",
"Tr",
":",
"rgc",
".",
"current",
".",
"Tr",
",",
"Flattener",
":",
"FtLineBuilder",
"{",
"Adder",
":",
"rgc",
".",
"strokeRasterizer",
"}",
"}",
")",
"\n",
"stroker",
".",
"HalfLineWidth",
"=",
"rgc",
".",
"current",
".",
"LineWidth",
"/",
"2",
"\n\n",
"var",
"liner",
"Flattener",
"\n",
"if",
"rgc",
".",
"current",
".",
"Dash",
"!=",
"nil",
"&&",
"len",
"(",
"rgc",
".",
"current",
".",
"Dash",
")",
">",
"0",
"{",
"liner",
"=",
"NewDashVertexConverter",
"(",
"rgc",
".",
"current",
".",
"Dash",
",",
"rgc",
".",
"current",
".",
"DashOffset",
",",
"stroker",
")",
"\n",
"}",
"else",
"{",
"liner",
"=",
"stroker",
"\n",
"}",
"\n\n",
"demux",
":=",
"DemuxFlattener",
"{",
"Flatteners",
":",
"[",
"]",
"Flattener",
"{",
"flattener",
",",
"liner",
"}",
"}",
"\n",
"for",
"_",
",",
"p",
":=",
"range",
"paths",
"{",
"Flatten",
"(",
"p",
",",
"demux",
",",
"rgc",
".",
"current",
".",
"Tr",
".",
"GetScale",
"(",
")",
")",
"\n",
"}",
"\n\n",
"// Fill",
"rgc",
".",
"paint",
"(",
"rgc",
".",
"fillRasterizer",
",",
"rgc",
".",
"current",
".",
"FillColor",
")",
"\n",
"// Stroke",
"rgc",
".",
"paint",
"(",
"rgc",
".",
"strokeRasterizer",
",",
"rgc",
".",
"current",
".",
"StrokeColor",
")",
"\n",
"}"
] |
// FillStroke first fills the paths and than strokes them
|
[
"FillStroke",
"first",
"fills",
"the",
"paths",
"and",
"than",
"strokes",
"them"
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/raster_graphic_context.go#L257-L283
|
147,692 |
wcharczuk/go-chart
|
seq/times.go
|
GetValue
|
func (t Times) GetValue(index int) float64 {
return util.Time.ToFloat64(t[index])
}
|
go
|
func (t Times) GetValue(index int) float64 {
return util.Time.ToFloat64(t[index])
}
|
[
"func",
"(",
"t",
"Times",
")",
"GetValue",
"(",
"index",
"int",
")",
"float64",
"{",
"return",
"util",
".",
"Time",
".",
"ToFloat64",
"(",
"t",
"[",
"index",
"]",
")",
"\n",
"}"
] |
// GetValue returns a value at an index as a time.
|
[
"GetValue",
"returns",
"a",
"value",
"at",
"an",
"index",
"as",
"a",
"time",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/times.go#L29-L31
|
147,693 |
wcharczuk/go-chart
|
drawing/curve.go
|
SubdivideCubic
|
func SubdivideCubic(c, c1, c2 []float64) {
// First point of c is the first point of c1
c1[0], c1[1] = c[0], c[1]
// Last point of c is the last point of c2
c2[6], c2[7] = c[6], c[7]
// Subdivide segment using midpoints
c1[2] = (c[0] + c[2]) / 2
c1[3] = (c[1] + c[3]) / 2
midX := (c[2] + c[4]) / 2
midY := (c[3] + c[5]) / 2
c2[4] = (c[4] + c[6]) / 2
c2[5] = (c[5] + c[7]) / 2
c1[4] = (c1[2] + midX) / 2
c1[5] = (c1[3] + midY) / 2
c2[2] = (midX + c2[4]) / 2
c2[3] = (midY + c2[5]) / 2
c1[6] = (c1[4] + c2[2]) / 2
c1[7] = (c1[5] + c2[3]) / 2
// Last Point of c1 is equal to the first point of c2
c2[0], c2[1] = c1[6], c1[7]
}
|
go
|
func SubdivideCubic(c, c1, c2 []float64) {
// First point of c is the first point of c1
c1[0], c1[1] = c[0], c[1]
// Last point of c is the last point of c2
c2[6], c2[7] = c[6], c[7]
// Subdivide segment using midpoints
c1[2] = (c[0] + c[2]) / 2
c1[3] = (c[1] + c[3]) / 2
midX := (c[2] + c[4]) / 2
midY := (c[3] + c[5]) / 2
c2[4] = (c[4] + c[6]) / 2
c2[5] = (c[5] + c[7]) / 2
c1[4] = (c1[2] + midX) / 2
c1[5] = (c1[3] + midY) / 2
c2[2] = (midX + c2[4]) / 2
c2[3] = (midY + c2[5]) / 2
c1[6] = (c1[4] + c2[2]) / 2
c1[7] = (c1[5] + c2[3]) / 2
// Last Point of c1 is equal to the first point of c2
c2[0], c2[1] = c1[6], c1[7]
}
|
[
"func",
"SubdivideCubic",
"(",
"c",
",",
"c1",
",",
"c2",
"[",
"]",
"float64",
")",
"{",
"// First point of c is the first point of c1",
"c1",
"[",
"0",
"]",
",",
"c1",
"[",
"1",
"]",
"=",
"c",
"[",
"0",
"]",
",",
"c",
"[",
"1",
"]",
"\n",
"// Last point of c is the last point of c2",
"c2",
"[",
"6",
"]",
",",
"c2",
"[",
"7",
"]",
"=",
"c",
"[",
"6",
"]",
",",
"c",
"[",
"7",
"]",
"\n\n",
"// Subdivide segment using midpoints",
"c1",
"[",
"2",
"]",
"=",
"(",
"c",
"[",
"0",
"]",
"+",
"c",
"[",
"2",
"]",
")",
"/",
"2",
"\n",
"c1",
"[",
"3",
"]",
"=",
"(",
"c",
"[",
"1",
"]",
"+",
"c",
"[",
"3",
"]",
")",
"/",
"2",
"\n\n",
"midX",
":=",
"(",
"c",
"[",
"2",
"]",
"+",
"c",
"[",
"4",
"]",
")",
"/",
"2",
"\n",
"midY",
":=",
"(",
"c",
"[",
"3",
"]",
"+",
"c",
"[",
"5",
"]",
")",
"/",
"2",
"\n\n",
"c2",
"[",
"4",
"]",
"=",
"(",
"c",
"[",
"4",
"]",
"+",
"c",
"[",
"6",
"]",
")",
"/",
"2",
"\n",
"c2",
"[",
"5",
"]",
"=",
"(",
"c",
"[",
"5",
"]",
"+",
"c",
"[",
"7",
"]",
")",
"/",
"2",
"\n\n",
"c1",
"[",
"4",
"]",
"=",
"(",
"c1",
"[",
"2",
"]",
"+",
"midX",
")",
"/",
"2",
"\n",
"c1",
"[",
"5",
"]",
"=",
"(",
"c1",
"[",
"3",
"]",
"+",
"midY",
")",
"/",
"2",
"\n\n",
"c2",
"[",
"2",
"]",
"=",
"(",
"midX",
"+",
"c2",
"[",
"4",
"]",
")",
"/",
"2",
"\n",
"c2",
"[",
"3",
"]",
"=",
"(",
"midY",
"+",
"c2",
"[",
"5",
"]",
")",
"/",
"2",
"\n\n",
"c1",
"[",
"6",
"]",
"=",
"(",
"c1",
"[",
"4",
"]",
"+",
"c2",
"[",
"2",
"]",
")",
"/",
"2",
"\n",
"c1",
"[",
"7",
"]",
"=",
"(",
"c1",
"[",
"5",
"]",
"+",
"c2",
"[",
"3",
"]",
")",
"/",
"2",
"\n\n",
"// Last Point of c1 is equal to the first point of c2",
"c2",
"[",
"0",
"]",
",",
"c2",
"[",
"1",
"]",
"=",
"c1",
"[",
"6",
"]",
",",
"c1",
"[",
"7",
"]",
"\n",
"}"
] |
// Cubic
// x1, y1, cpx1, cpy1, cpx2, cpy2, x2, y2 float64
// SubdivideCubic a Bezier cubic curve in 2 equivalents Bezier cubic curves.
// c1 and c2 parameters are the resulting curves
|
[
"Cubic",
"x1",
"y1",
"cpx1",
"cpy1",
"cpx2",
"cpy2",
"x2",
"y2",
"float64",
"SubdivideCubic",
"a",
"Bezier",
"cubic",
"curve",
"in",
"2",
"equivalents",
"Bezier",
"cubic",
"curves",
".",
"c1",
"and",
"c2",
"parameters",
"are",
"the",
"resulting",
"curves"
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/curve.go#L15-L42
|
147,694 |
wcharczuk/go-chart
|
drawing/curve.go
|
TraceCubic
|
func TraceCubic(t Liner, cubic []float64, flatteningThreshold float64) {
// Allocation curves
var curves [CurveRecursionLimit * 8]float64
copy(curves[0:8], cubic[0:8])
i := 0
// current curve
var c []float64
var dx, dy, d2, d3 float64
for i >= 0 {
c = curves[i*8:]
dx = c[6] - c[0]
dy = c[7] - c[1]
d2 = math.Abs((c[2]-c[6])*dy - (c[3]-c[7])*dx)
d3 = math.Abs((c[4]-c[6])*dy - (c[5]-c[7])*dx)
// if it's flat then trace a line
if (d2+d3)*(d2+d3) < flatteningThreshold*(dx*dx+dy*dy) || i == len(curves)-1 {
t.LineTo(c[6], c[7])
i--
} else {
// second half of bezier go lower onto the stack
SubdivideCubic(c, curves[(i+1)*8:], curves[i*8:])
i++
}
}
}
|
go
|
func TraceCubic(t Liner, cubic []float64, flatteningThreshold float64) {
// Allocation curves
var curves [CurveRecursionLimit * 8]float64
copy(curves[0:8], cubic[0:8])
i := 0
// current curve
var c []float64
var dx, dy, d2, d3 float64
for i >= 0 {
c = curves[i*8:]
dx = c[6] - c[0]
dy = c[7] - c[1]
d2 = math.Abs((c[2]-c[6])*dy - (c[3]-c[7])*dx)
d3 = math.Abs((c[4]-c[6])*dy - (c[5]-c[7])*dx)
// if it's flat then trace a line
if (d2+d3)*(d2+d3) < flatteningThreshold*(dx*dx+dy*dy) || i == len(curves)-1 {
t.LineTo(c[6], c[7])
i--
} else {
// second half of bezier go lower onto the stack
SubdivideCubic(c, curves[(i+1)*8:], curves[i*8:])
i++
}
}
}
|
[
"func",
"TraceCubic",
"(",
"t",
"Liner",
",",
"cubic",
"[",
"]",
"float64",
",",
"flatteningThreshold",
"float64",
")",
"{",
"// Allocation curves",
"var",
"curves",
"[",
"CurveRecursionLimit",
"*",
"8",
"]",
"float64",
"\n",
"copy",
"(",
"curves",
"[",
"0",
":",
"8",
"]",
",",
"cubic",
"[",
"0",
":",
"8",
"]",
")",
"\n",
"i",
":=",
"0",
"\n\n",
"// current curve",
"var",
"c",
"[",
"]",
"float64",
"\n\n",
"var",
"dx",
",",
"dy",
",",
"d2",
",",
"d3",
"float64",
"\n\n",
"for",
"i",
">=",
"0",
"{",
"c",
"=",
"curves",
"[",
"i",
"*",
"8",
":",
"]",
"\n",
"dx",
"=",
"c",
"[",
"6",
"]",
"-",
"c",
"[",
"0",
"]",
"\n",
"dy",
"=",
"c",
"[",
"7",
"]",
"-",
"c",
"[",
"1",
"]",
"\n\n",
"d2",
"=",
"math",
".",
"Abs",
"(",
"(",
"c",
"[",
"2",
"]",
"-",
"c",
"[",
"6",
"]",
")",
"*",
"dy",
"-",
"(",
"c",
"[",
"3",
"]",
"-",
"c",
"[",
"7",
"]",
")",
"*",
"dx",
")",
"\n",
"d3",
"=",
"math",
".",
"Abs",
"(",
"(",
"c",
"[",
"4",
"]",
"-",
"c",
"[",
"6",
"]",
")",
"*",
"dy",
"-",
"(",
"c",
"[",
"5",
"]",
"-",
"c",
"[",
"7",
"]",
")",
"*",
"dx",
")",
"\n\n",
"// if it's flat then trace a line",
"if",
"(",
"d2",
"+",
"d3",
")",
"*",
"(",
"d2",
"+",
"d3",
")",
"<",
"flatteningThreshold",
"*",
"(",
"dx",
"*",
"dx",
"+",
"dy",
"*",
"dy",
")",
"||",
"i",
"==",
"len",
"(",
"curves",
")",
"-",
"1",
"{",
"t",
".",
"LineTo",
"(",
"c",
"[",
"6",
"]",
",",
"c",
"[",
"7",
"]",
")",
"\n",
"i",
"--",
"\n",
"}",
"else",
"{",
"// second half of bezier go lower onto the stack",
"SubdivideCubic",
"(",
"c",
",",
"curves",
"[",
"(",
"i",
"+",
"1",
")",
"*",
"8",
":",
"]",
",",
"curves",
"[",
"i",
"*",
"8",
":",
"]",
")",
"\n",
"i",
"++",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] |
// TraceCubic generate lines subdividing the cubic curve using a Liner
// flattening_threshold helps determines the flattening expectation of the curve
|
[
"TraceCubic",
"generate",
"lines",
"subdividing",
"the",
"cubic",
"curve",
"using",
"a",
"Liner",
"flattening_threshold",
"helps",
"determines",
"the",
"flattening",
"expectation",
"of",
"the",
"curve"
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/curve.go#L46-L75
|
147,695 |
wcharczuk/go-chart
|
drawing/curve.go
|
SubdivideQuad
|
func SubdivideQuad(c, c1, c2 []float64) {
// First point of c is the first point of c1
c1[0], c1[1] = c[0], c[1]
// Last point of c is the last point of c2
c2[4], c2[5] = c[4], c[5]
// Subdivide segment using midpoints
c1[2] = (c[0] + c[2]) / 2
c1[3] = (c[1] + c[3]) / 2
c2[2] = (c[2] + c[4]) / 2
c2[3] = (c[3] + c[5]) / 2
c1[4] = (c1[2] + c2[2]) / 2
c1[5] = (c1[3] + c2[3]) / 2
c2[0], c2[1] = c1[4], c1[5]
return
}
|
go
|
func SubdivideQuad(c, c1, c2 []float64) {
// First point of c is the first point of c1
c1[0], c1[1] = c[0], c[1]
// Last point of c is the last point of c2
c2[4], c2[5] = c[4], c[5]
// Subdivide segment using midpoints
c1[2] = (c[0] + c[2]) / 2
c1[3] = (c[1] + c[3]) / 2
c2[2] = (c[2] + c[4]) / 2
c2[3] = (c[3] + c[5]) / 2
c1[4] = (c1[2] + c2[2]) / 2
c1[5] = (c1[3] + c2[3]) / 2
c2[0], c2[1] = c1[4], c1[5]
return
}
|
[
"func",
"SubdivideQuad",
"(",
"c",
",",
"c1",
",",
"c2",
"[",
"]",
"float64",
")",
"{",
"// First point of c is the first point of c1",
"c1",
"[",
"0",
"]",
",",
"c1",
"[",
"1",
"]",
"=",
"c",
"[",
"0",
"]",
",",
"c",
"[",
"1",
"]",
"\n",
"// Last point of c is the last point of c2",
"c2",
"[",
"4",
"]",
",",
"c2",
"[",
"5",
"]",
"=",
"c",
"[",
"4",
"]",
",",
"c",
"[",
"5",
"]",
"\n\n",
"// Subdivide segment using midpoints",
"c1",
"[",
"2",
"]",
"=",
"(",
"c",
"[",
"0",
"]",
"+",
"c",
"[",
"2",
"]",
")",
"/",
"2",
"\n",
"c1",
"[",
"3",
"]",
"=",
"(",
"c",
"[",
"1",
"]",
"+",
"c",
"[",
"3",
"]",
")",
"/",
"2",
"\n",
"c2",
"[",
"2",
"]",
"=",
"(",
"c",
"[",
"2",
"]",
"+",
"c",
"[",
"4",
"]",
")",
"/",
"2",
"\n",
"c2",
"[",
"3",
"]",
"=",
"(",
"c",
"[",
"3",
"]",
"+",
"c",
"[",
"5",
"]",
")",
"/",
"2",
"\n",
"c1",
"[",
"4",
"]",
"=",
"(",
"c1",
"[",
"2",
"]",
"+",
"c2",
"[",
"2",
"]",
")",
"/",
"2",
"\n",
"c1",
"[",
"5",
"]",
"=",
"(",
"c1",
"[",
"3",
"]",
"+",
"c2",
"[",
"3",
"]",
")",
"/",
"2",
"\n",
"c2",
"[",
"0",
"]",
",",
"c2",
"[",
"1",
"]",
"=",
"c1",
"[",
"4",
"]",
",",
"c1",
"[",
"5",
"]",
"\n",
"return",
"\n",
"}"
] |
// Quad
// x1, y1, cpx1, cpy2, x2, y2 float64
// SubdivideQuad a Bezier quad curve in 2 equivalents Bezier quad curves.
// c1 and c2 parameters are the resulting curves
|
[
"Quad",
"x1",
"y1",
"cpx1",
"cpy2",
"x2",
"y2",
"float64",
"SubdivideQuad",
"a",
"Bezier",
"quad",
"curve",
"in",
"2",
"equivalents",
"Bezier",
"quad",
"curves",
".",
"c1",
"and",
"c2",
"parameters",
"are",
"the",
"resulting",
"curves"
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/curve.go#L82-L97
|
147,696 |
wcharczuk/go-chart
|
drawing/curve.go
|
TraceQuad
|
func TraceQuad(t Liner, quad []float64, flatteningThreshold float64) {
const curveLen = CurveRecursionLimit * 6
const curveEndIndex = curveLen - 1
const lastIteration = CurveRecursionLimit - 1
// Allocates curves stack
curves := make([]float64, curveLen)
// copy 6 elements from the quad path to the stack
copy(curves[0:6], quad[0:6])
var i int
var c []float64
var dx, dy, d float64
for i >= 0 {
c = traceGetWindow(curves, i)
dx, dy, d = traceCalcDeltas(c)
// bail early if the distance is 0
if d == 0 {
return
}
// if it's flat then trace a line
if traceIsFlat(dx, dy, d, flatteningThreshold) || i == lastIteration {
t.LineTo(c[4], c[5])
i--
} else {
SubdivideQuad(c, traceGetWindow(curves, i+1), traceGetWindow(curves, i))
i++
}
}
}
|
go
|
func TraceQuad(t Liner, quad []float64, flatteningThreshold float64) {
const curveLen = CurveRecursionLimit * 6
const curveEndIndex = curveLen - 1
const lastIteration = CurveRecursionLimit - 1
// Allocates curves stack
curves := make([]float64, curveLen)
// copy 6 elements from the quad path to the stack
copy(curves[0:6], quad[0:6])
var i int
var c []float64
var dx, dy, d float64
for i >= 0 {
c = traceGetWindow(curves, i)
dx, dy, d = traceCalcDeltas(c)
// bail early if the distance is 0
if d == 0 {
return
}
// if it's flat then trace a line
if traceIsFlat(dx, dy, d, flatteningThreshold) || i == lastIteration {
t.LineTo(c[4], c[5])
i--
} else {
SubdivideQuad(c, traceGetWindow(curves, i+1), traceGetWindow(curves, i))
i++
}
}
}
|
[
"func",
"TraceQuad",
"(",
"t",
"Liner",
",",
"quad",
"[",
"]",
"float64",
",",
"flatteningThreshold",
"float64",
")",
"{",
"const",
"curveLen",
"=",
"CurveRecursionLimit",
"*",
"6",
"\n",
"const",
"curveEndIndex",
"=",
"curveLen",
"-",
"1",
"\n",
"const",
"lastIteration",
"=",
"CurveRecursionLimit",
"-",
"1",
"\n\n",
"// Allocates curves stack",
"curves",
":=",
"make",
"(",
"[",
"]",
"float64",
",",
"curveLen",
")",
"\n\n",
"// copy 6 elements from the quad path to the stack",
"copy",
"(",
"curves",
"[",
"0",
":",
"6",
"]",
",",
"quad",
"[",
"0",
":",
"6",
"]",
")",
"\n\n",
"var",
"i",
"int",
"\n",
"var",
"c",
"[",
"]",
"float64",
"\n",
"var",
"dx",
",",
"dy",
",",
"d",
"float64",
"\n\n",
"for",
"i",
">=",
"0",
"{",
"c",
"=",
"traceGetWindow",
"(",
"curves",
",",
"i",
")",
"\n",
"dx",
",",
"dy",
",",
"d",
"=",
"traceCalcDeltas",
"(",
"c",
")",
"\n\n",
"// bail early if the distance is 0",
"if",
"d",
"==",
"0",
"{",
"return",
"\n",
"}",
"\n\n",
"// if it's flat then trace a line",
"if",
"traceIsFlat",
"(",
"dx",
",",
"dy",
",",
"d",
",",
"flatteningThreshold",
")",
"||",
"i",
"==",
"lastIteration",
"{",
"t",
".",
"LineTo",
"(",
"c",
"[",
"4",
"]",
",",
"c",
"[",
"5",
"]",
")",
"\n",
"i",
"--",
"\n",
"}",
"else",
"{",
"SubdivideQuad",
"(",
"c",
",",
"traceGetWindow",
"(",
"curves",
",",
"i",
"+",
"1",
")",
",",
"traceGetWindow",
"(",
"curves",
",",
"i",
")",
")",
"\n",
"i",
"++",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] |
// TraceQuad generate lines subdividing the curve using a Liner
// flattening_threshold helps determines the flattening expectation of the curve
|
[
"TraceQuad",
"generate",
"lines",
"subdividing",
"the",
"curve",
"using",
"a",
"Liner",
"flattening_threshold",
"helps",
"determines",
"the",
"flattening",
"expectation",
"of",
"the",
"curve"
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/curve.go#L123-L156
|
147,697 |
wcharczuk/go-chart
|
seq/linear.go
|
Range
|
func Range(start, end float64) []float64 {
return Seq{NewLinear().WithStart(start).WithEnd(end).WithStep(1.0)}.Array()
}
|
go
|
func Range(start, end float64) []float64 {
return Seq{NewLinear().WithStart(start).WithEnd(end).WithStep(1.0)}.Array()
}
|
[
"func",
"Range",
"(",
"start",
",",
"end",
"float64",
")",
"[",
"]",
"float64",
"{",
"return",
"Seq",
"{",
"NewLinear",
"(",
")",
".",
"WithStart",
"(",
"start",
")",
".",
"WithEnd",
"(",
"end",
")",
".",
"WithStep",
"(",
"1.0",
")",
"}",
".",
"Array",
"(",
")",
"\n",
"}"
] |
// Range returns the array values of a linear seq with a given start, end and optional step.
|
[
"Range",
"returns",
"the",
"array",
"values",
"of",
"a",
"linear",
"seq",
"with",
"a",
"given",
"start",
"end",
"and",
"optional",
"step",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/linear.go#L4-L6
|
147,698 |
wcharczuk/go-chart
|
seq/linear.go
|
RangeWithStep
|
func RangeWithStep(start, end, step float64) []float64 {
return Seq{NewLinear().WithStart(start).WithEnd(end).WithStep(step)}.Array()
}
|
go
|
func RangeWithStep(start, end, step float64) []float64 {
return Seq{NewLinear().WithStart(start).WithEnd(end).WithStep(step)}.Array()
}
|
[
"func",
"RangeWithStep",
"(",
"start",
",",
"end",
",",
"step",
"float64",
")",
"[",
"]",
"float64",
"{",
"return",
"Seq",
"{",
"NewLinear",
"(",
")",
".",
"WithStart",
"(",
"start",
")",
".",
"WithEnd",
"(",
"end",
")",
".",
"WithStep",
"(",
"step",
")",
"}",
".",
"Array",
"(",
")",
"\n",
"}"
] |
// RangeWithStep returns the array values of a linear seq with a given start, end and optional step.
|
[
"RangeWithStep",
"returns",
"the",
"array",
"values",
"of",
"a",
"linear",
"seq",
"with",
"a",
"given",
"start",
"end",
"and",
"optional",
"step",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/linear.go#L9-L11
|
147,699 |
wcharczuk/go-chart
|
seq/linear.go
|
Len
|
func (lg Linear) Len() int {
if lg.start < lg.end {
return int((lg.end-lg.start)/lg.step) + 1
}
return int((lg.start-lg.end)/lg.step) + 1
}
|
go
|
func (lg Linear) Len() int {
if lg.start < lg.end {
return int((lg.end-lg.start)/lg.step) + 1
}
return int((lg.start-lg.end)/lg.step) + 1
}
|
[
"func",
"(",
"lg",
"Linear",
")",
"Len",
"(",
")",
"int",
"{",
"if",
"lg",
".",
"start",
"<",
"lg",
".",
"end",
"{",
"return",
"int",
"(",
"(",
"lg",
".",
"end",
"-",
"lg",
".",
"start",
")",
"/",
"lg",
".",
"step",
")",
"+",
"1",
"\n",
"}",
"\n",
"return",
"int",
"(",
"(",
"lg",
".",
"start",
"-",
"lg",
".",
"end",
")",
"/",
"lg",
".",
"step",
")",
"+",
"1",
"\n",
"}"
] |
// Len returns the number of elements in the seq.
|
[
"Len",
"returns",
"the",
"number",
"of",
"elements",
"in",
"the",
"seq",
"."
] |
9852fce5a172598e72d16f4306f0f17a53d94eb4
|
https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/linear.go#L41-L46
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.