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 list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
25,500 | wcharczuk/go-chart | continuous_series.go | GetValues | func (cs ContinuousSeries) GetValues(index int) (float64, float64) {
return cs.XValues[index], cs.YValues[index]
} | go | func (cs ContinuousSeries) GetValues(index int) (float64, float64) {
return cs.XValues[index], cs.YValues[index]
} | [
"func",
"(",
"cs",
"ContinuousSeries",
")",
"GetValues",
"(",
"index",
"int",
")",
"(",
"float64",
",",
"float64",
")",
"{",
"return",
"cs",
".",
"XValues",
"[",
"index",
"]",
",",
"cs",
".",
"YValues",
"[",
"index",
"]",
"\n",
"}"
] | // GetValues gets the x,y values at a given index. | [
"GetValues",
"gets",
"the",
"x",
"y",
"values",
"at",
"a",
"given",
"index",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/continuous_series.go#L42-L44 |
25,501 | wcharczuk/go-chart | continuous_series.go | GetLastValues | func (cs ContinuousSeries) GetLastValues() (float64, float64) {
return cs.XValues[len(cs.XValues)-1], cs.YValues[len(cs.YValues)-1]
} | go | func (cs ContinuousSeries) GetLastValues() (float64, float64) {
return cs.XValues[len(cs.XValues)-1], cs.YValues[len(cs.YValues)-1]
} | [
"func",
"(",
"cs",
"ContinuousSeries",
")",
"GetLastValues",
"(",
")",
"(",
"float64",
",",
"float64",
")",
"{",
"return",
"cs",
".",
"XValues",
"[",
"len",
"(",
"cs",
".",
"XValues",
")",
"-",
"1",
"]",
",",
"cs",
".",
"YValues",
"[",
"len",
"(",
... | // GetLastValues gets the last x,y values. | [
"GetLastValues",
"gets",
"the",
"last",
"x",
"y",
"values",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/continuous_series.go#L52-L54 |
25,502 | wcharczuk/go-chart | draw.go | BoundedSeries | func (d draw) BoundedSeries(r Renderer, canvasBox Box, xrange, yrange Range, style Style, bbs BoundedValuesProvider, drawOffsetIndexes ...int) {
drawOffsetIndex := 0
if len(drawOffsetIndexes) > 0 {
drawOffsetIndex = drawOffsetIndexes[0]
}
cb := canvasBox.Bottom
cl := canvasBox.Left
v0x, v0y1, v0y2 := bbs.GetB... | go | func (d draw) BoundedSeries(r Renderer, canvasBox Box, xrange, yrange Range, style Style, bbs BoundedValuesProvider, drawOffsetIndexes ...int) {
drawOffsetIndex := 0
if len(drawOffsetIndexes) > 0 {
drawOffsetIndex = drawOffsetIndexes[0]
}
cb := canvasBox.Bottom
cl := canvasBox.Left
v0x, v0y1, v0y2 := bbs.GetB... | [
"func",
"(",
"d",
"draw",
")",
"BoundedSeries",
"(",
"r",
"Renderer",
",",
"canvasBox",
"Box",
",",
"xrange",
",",
"yrange",
"Range",
",",
"style",
"Style",
",",
"bbs",
"BoundedValuesProvider",
",",
"drawOffsetIndexes",
"...",
"int",
")",
"{",
"drawOffsetInd... | // BoundedSeries draws a series that implements BoundedValuesProvider. | [
"BoundedSeries",
"draws",
"a",
"series",
"that",
"implements",
"BoundedValuesProvider",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/draw.go#L90-L137 |
25,503 | wcharczuk/go-chart | draw.go | HistogramSeries | func (d draw) HistogramSeries(r Renderer, canvasBox Box, xrange, yrange Range, style Style, vs ValuesProvider, barWidths ...int) {
if vs.Len() == 0 {
return
}
//calculate bar width?
seriesLength := vs.Len()
barWidth := int(math.Floor(float64(xrange.GetDomain()) / float64(seriesLength)))
if len(barWidths) > 0 {... | go | func (d draw) HistogramSeries(r Renderer, canvasBox Box, xrange, yrange Range, style Style, vs ValuesProvider, barWidths ...int) {
if vs.Len() == 0 {
return
}
//calculate bar width?
seriesLength := vs.Len()
barWidth := int(math.Floor(float64(xrange.GetDomain()) / float64(seriesLength)))
if len(barWidths) > 0 {... | [
"func",
"(",
"d",
"draw",
")",
"HistogramSeries",
"(",
"r",
"Renderer",
",",
"canvasBox",
"Box",
",",
"xrange",
",",
"yrange",
"Range",
",",
"style",
"Style",
",",
"vs",
"ValuesProvider",
",",
"barWidths",
"...",
"int",
")",
"{",
"if",
"vs",
".",
"Len"... | // HistogramSeries draws a value provider as boxes from 0. | [
"HistogramSeries",
"draws",
"a",
"value",
"provider",
"as",
"boxes",
"from",
"0",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/draw.go#L140-L169 |
25,504 | wcharczuk/go-chart | draw.go | MeasureAnnotation | func (d draw) MeasureAnnotation(r Renderer, canvasBox Box, style Style, lx, ly int, label string) Box {
style.WriteToRenderer(r)
defer r.ResetStyle()
textBox := r.MeasureText(label)
textWidth := textBox.Width()
textHeight := textBox.Height()
halfTextHeight := textHeight >> 1
pt := style.Padding.GetTop(DefaultA... | go | func (d draw) MeasureAnnotation(r Renderer, canvasBox Box, style Style, lx, ly int, label string) Box {
style.WriteToRenderer(r)
defer r.ResetStyle()
textBox := r.MeasureText(label)
textWidth := textBox.Width()
textHeight := textBox.Height()
halfTextHeight := textHeight >> 1
pt := style.Padding.GetTop(DefaultA... | [
"func",
"(",
"d",
"draw",
")",
"MeasureAnnotation",
"(",
"r",
"Renderer",
",",
"canvasBox",
"Box",
",",
"style",
"Style",
",",
"lx",
",",
"ly",
"int",
",",
"label",
"string",
")",
"Box",
"{",
"style",
".",
"WriteToRenderer",
"(",
"r",
")",
"\n",
"def... | // MeasureAnnotation measures how big an annotation would be. | [
"MeasureAnnotation",
"measures",
"how",
"big",
"an",
"annotation",
"would",
"be",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/draw.go#L172-L198 |
25,505 | wcharczuk/go-chart | draw.go | Annotation | func (d draw) Annotation(r Renderer, canvasBox Box, style Style, lx, ly int, label string) {
style.GetTextOptions().WriteToRenderer(r)
defer r.ResetStyle()
textBox := r.MeasureText(label)
textWidth := textBox.Width()
halfTextHeight := textBox.Height() >> 1
style.GetFillAndStrokeOptions().WriteToRenderer(r)
pt... | go | func (d draw) Annotation(r Renderer, canvasBox Box, style Style, lx, ly int, label string) {
style.GetTextOptions().WriteToRenderer(r)
defer r.ResetStyle()
textBox := r.MeasureText(label)
textWidth := textBox.Width()
halfTextHeight := textBox.Height() >> 1
style.GetFillAndStrokeOptions().WriteToRenderer(r)
pt... | [
"func",
"(",
"d",
"draw",
")",
"Annotation",
"(",
"r",
"Renderer",
",",
"canvasBox",
"Box",
",",
"style",
"Style",
",",
"lx",
",",
"ly",
"int",
",",
"label",
"string",
")",
"{",
"style",
".",
"GetTextOptions",
"(",
")",
".",
"WriteToRenderer",
"(",
"... | // Annotation draws an anotation with a renderer. | [
"Annotation",
"draws",
"an",
"anotation",
"with",
"a",
"renderer",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/draw.go#L201-L242 |
25,506 | wcharczuk/go-chart | draw.go | Box | func (d draw) Box(r Renderer, b Box, s Style) {
s.GetFillAndStrokeOptions().WriteToRenderer(r)
defer r.ResetStyle()
r.MoveTo(b.Left, b.Top)
r.LineTo(b.Right, b.Top)
r.LineTo(b.Right, b.Bottom)
r.LineTo(b.Left, b.Bottom)
r.LineTo(b.Left, b.Top)
r.FillStroke()
} | go | func (d draw) Box(r Renderer, b Box, s Style) {
s.GetFillAndStrokeOptions().WriteToRenderer(r)
defer r.ResetStyle()
r.MoveTo(b.Left, b.Top)
r.LineTo(b.Right, b.Top)
r.LineTo(b.Right, b.Bottom)
r.LineTo(b.Left, b.Bottom)
r.LineTo(b.Left, b.Top)
r.FillStroke()
} | [
"func",
"(",
"d",
"draw",
")",
"Box",
"(",
"r",
"Renderer",
",",
"b",
"Box",
",",
"s",
"Style",
")",
"{",
"s",
".",
"GetFillAndStrokeOptions",
"(",
")",
".",
"WriteToRenderer",
"(",
"r",
")",
"\n",
"defer",
"r",
".",
"ResetStyle",
"(",
")",
"\n\n",... | // Box draws a box with a given style. | [
"Box",
"draws",
"a",
"box",
"with",
"a",
"given",
"style",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/draw.go#L245-L255 |
25,507 | wcharczuk/go-chart | draw.go | Text | func (d draw) Text(r Renderer, text string, x, y int, style Style) {
style.GetTextOptions().WriteToRenderer(r)
defer r.ResetStyle()
r.Text(text, x, y)
} | go | func (d draw) Text(r Renderer, text string, x, y int, style Style) {
style.GetTextOptions().WriteToRenderer(r)
defer r.ResetStyle()
r.Text(text, x, y)
} | [
"func",
"(",
"d",
"draw",
")",
"Text",
"(",
"r",
"Renderer",
",",
"text",
"string",
",",
"x",
",",
"y",
"int",
",",
"style",
"Style",
")",
"{",
"style",
".",
"GetTextOptions",
"(",
")",
".",
"WriteToRenderer",
"(",
"r",
")",
"\n",
"defer",
"r",
"... | // DrawText draws text with a given style. | [
"DrawText",
"draws",
"text",
"with",
"a",
"given",
"style",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/draw.go#L274-L279 |
25,508 | wcharczuk/go-chart | draw.go | TextWithin | func (d draw) TextWithin(r Renderer, text string, box Box, style Style) {
style.GetTextOptions().WriteToRenderer(r)
defer r.ResetStyle()
lines := Text.WrapFit(r, text, box.Width(), style)
linesBox := Text.MeasureLines(r, lines, style)
y := box.Top
switch style.GetTextVerticalAlign() {
case TextVerticalAlignBo... | go | func (d draw) TextWithin(r Renderer, text string, box Box, style Style) {
style.GetTextOptions().WriteToRenderer(r)
defer r.ResetStyle()
lines := Text.WrapFit(r, text, box.Width(), style)
linesBox := Text.MeasureLines(r, lines, style)
y := box.Top
switch style.GetTextVerticalAlign() {
case TextVerticalAlignBo... | [
"func",
"(",
"d",
"draw",
")",
"TextWithin",
"(",
"r",
"Renderer",
",",
"text",
"string",
",",
"box",
"Box",
",",
"style",
"Style",
")",
"{",
"style",
".",
"GetTextOptions",
"(",
")",
".",
"WriteToRenderer",
"(",
"r",
")",
"\n",
"defer",
"r",
".",
... | // TextWithin draws the text within a given box. | [
"TextWithin",
"draws",
"the",
"text",
"within",
"a",
"given",
"box",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/draw.go#L289-L325 |
25,509 | wcharczuk/go-chart | last_value_annotation.go | LastValueAnnotation | func LastValueAnnotation(innerSeries ValuesProvider, vfs ...ValueFormatter) AnnotationSeries {
var vf ValueFormatter
if len(vfs) > 0 {
vf = vfs[0]
} else if typed, isTyped := innerSeries.(ValueFormatterProvider); isTyped {
_, vf = typed.GetValueFormatters()
} else {
vf = FloatValueFormatter
}
var lastValue... | go | func LastValueAnnotation(innerSeries ValuesProvider, vfs ...ValueFormatter) AnnotationSeries {
var vf ValueFormatter
if len(vfs) > 0 {
vf = vfs[0]
} else if typed, isTyped := innerSeries.(ValueFormatterProvider); isTyped {
_, vf = typed.GetValueFormatters()
} else {
vf = FloatValueFormatter
}
var lastValue... | [
"func",
"LastValueAnnotation",
"(",
"innerSeries",
"ValuesProvider",
",",
"vfs",
"...",
"ValueFormatter",
")",
"AnnotationSeries",
"{",
"var",
"vf",
"ValueFormatter",
"\n",
"if",
"len",
"(",
"vfs",
")",
">",
"0",
"{",
"vf",
"=",
"vfs",
"[",
"0",
"]",
"\n",... | // LastValueAnnotation returns an annotation series of just the last value of a value provider. | [
"LastValueAnnotation",
"returns",
"an",
"annotation",
"series",
"of",
"just",
"the",
"last",
"value",
"of",
"a",
"value",
"provider",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/last_value_annotation.go#L6-L37 |
25,510 | wcharczuk/go-chart | vector_renderer.go | SetDPI | func (vr *vectorRenderer) SetDPI(dpi float64) {
vr.dpi = dpi
vr.c.dpi = dpi
} | go | func (vr *vectorRenderer) SetDPI(dpi float64) {
vr.dpi = dpi
vr.c.dpi = dpi
} | [
"func",
"(",
"vr",
"*",
"vectorRenderer",
")",
"SetDPI",
"(",
"dpi",
"float64",
")",
"{",
"vr",
".",
"dpi",
"=",
"dpi",
"\n",
"vr",
".",
"c",
".",
"dpi",
"=",
"dpi",
"\n",
"}"
] | // SetDPI implements the interface method. | [
"SetDPI",
"implements",
"the",
"interface",
"method",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/vector_renderer.go#L71-L74 |
25,511 | wcharczuk/go-chart | vector_renderer.go | QuadCurveTo | func (vr *vectorRenderer) QuadCurveTo(cx, cy, x, y int) {
vr.p = append(vr.p, fmt.Sprintf("Q%d,%d %d,%d", cx, cy, x, y))
} | go | func (vr *vectorRenderer) QuadCurveTo(cx, cy, x, y int) {
vr.p = append(vr.p, fmt.Sprintf("Q%d,%d %d,%d", cx, cy, x, y))
} | [
"func",
"(",
"vr",
"*",
"vectorRenderer",
")",
"QuadCurveTo",
"(",
"cx",
",",
"cy",
",",
"x",
",",
"y",
"int",
")",
"{",
"vr",
".",
"p",
"=",
"append",
"(",
"vr",
".",
"p",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"cx",
",",
"cy",
... | // QuadCurveTo draws a quad curve. | [
"QuadCurveTo",
"draws",
"a",
"quad",
"curve",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/vector_renderer.go#L112-L114 |
25,512 | wcharczuk/go-chart | vector_renderer.go | Close | func (vr *vectorRenderer) Close() {
vr.p = append(vr.p, fmt.Sprintf("Z"))
} | go | func (vr *vectorRenderer) Close() {
vr.p = append(vr.p, fmt.Sprintf("Z"))
} | [
"func",
"(",
"vr",
"*",
"vectorRenderer",
")",
"Close",
"(",
")",
"{",
"vr",
".",
"p",
"=",
"append",
"(",
"vr",
".",
"p",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
")",
")",
"\n",
"}"
] | // Close closes a shape. | [
"Close",
"closes",
"a",
"shape",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/vector_renderer.go#L143-L145 |
25,513 | wcharczuk/go-chart | vector_renderer.go | drawPath | func (vr *vectorRenderer) drawPath(s Style) {
vr.c.Path(strings.Join(vr.p, "\n"), vr.s.GetFillAndStrokeOptions())
vr.p = []string{} // clear the path
} | go | func (vr *vectorRenderer) drawPath(s Style) {
vr.c.Path(strings.Join(vr.p, "\n"), vr.s.GetFillAndStrokeOptions())
vr.p = []string{} // clear the path
} | [
"func",
"(",
"vr",
"*",
"vectorRenderer",
")",
"drawPath",
"(",
"s",
"Style",
")",
"{",
"vr",
".",
"c",
".",
"Path",
"(",
"strings",
".",
"Join",
"(",
"vr",
".",
"p",
",",
"\"",
"\\n",
"\"",
")",
",",
"vr",
".",
"s",
".",
"GetFillAndStrokeOptions... | // drawPath draws a path. | [
"drawPath",
"draws",
"a",
"path",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/vector_renderer.go#L163-L166 |
25,514 | wcharczuk/go-chart | vector_renderer.go | Circle | func (vr *vectorRenderer) Circle(radius float64, x, y int) {
vr.c.Circle(x, y, int(radius), vr.s.GetFillAndStrokeOptions())
} | go | func (vr *vectorRenderer) Circle(radius float64, x, y int) {
vr.c.Circle(x, y, int(radius), vr.s.GetFillAndStrokeOptions())
} | [
"func",
"(",
"vr",
"*",
"vectorRenderer",
")",
"Circle",
"(",
"radius",
"float64",
",",
"x",
",",
"y",
"int",
")",
"{",
"vr",
".",
"c",
".",
"Circle",
"(",
"x",
",",
"y",
",",
"int",
"(",
"radius",
")",
",",
"vr",
".",
"s",
".",
"GetFillAndStro... | // Circle implements the interface method. | [
"Circle",
"implements",
"the",
"interface",
"method",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/vector_renderer.go#L169-L171 |
25,515 | wcharczuk/go-chart | vector_renderer.go | Text | func (vr *vectorRenderer) Text(body string, x, y int) {
vr.c.Text(x, y, body, vr.s.GetTextOptions())
} | go | func (vr *vectorRenderer) Text(body string, x, y int) {
vr.c.Text(x, y, body, vr.s.GetTextOptions())
} | [
"func",
"(",
"vr",
"*",
"vectorRenderer",
")",
"Text",
"(",
"body",
"string",
",",
"x",
",",
"y",
"int",
")",
"{",
"vr",
".",
"c",
".",
"Text",
"(",
"x",
",",
"y",
",",
"body",
",",
"vr",
".",
"s",
".",
"GetTextOptions",
"(",
")",
")",
"\n",
... | // Text draws a text blob. | [
"Text",
"draws",
"a",
"text",
"blob",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/vector_renderer.go#L189-L191 |
25,516 | wcharczuk/go-chart | vector_renderer.go | MeasureText | func (vr *vectorRenderer) MeasureText(body string) (box Box) {
if vr.s.GetFont() != nil {
vr.fc = &font.Drawer{
Face: truetype.NewFace(vr.s.GetFont(), &truetype.Options{
DPI: vr.dpi,
Size: vr.s.FontSize,
}),
}
w := vr.fc.MeasureString(body).Ceil()
box.Right = w
box.Bottom = int(drawing.Points... | go | func (vr *vectorRenderer) MeasureText(body string) (box Box) {
if vr.s.GetFont() != nil {
vr.fc = &font.Drawer{
Face: truetype.NewFace(vr.s.GetFont(), &truetype.Options{
DPI: vr.dpi,
Size: vr.s.FontSize,
}),
}
w := vr.fc.MeasureString(body).Ceil()
box.Right = w
box.Bottom = int(drawing.Points... | [
"func",
"(",
"vr",
"*",
"vectorRenderer",
")",
"MeasureText",
"(",
"body",
"string",
")",
"(",
"box",
"Box",
")",
"{",
"if",
"vr",
".",
"s",
".",
"GetFont",
"(",
")",
"!=",
"nil",
"{",
"vr",
".",
"fc",
"=",
"&",
"font",
".",
"Drawer",
"{",
"Fac... | // MeasureText uses the truetype font drawer to measure the width of text. | [
"MeasureText",
"uses",
"the",
"truetype",
"font",
"drawer",
"to",
"measure",
"the",
"width",
"of",
"text",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/vector_renderer.go#L194-L212 |
25,517 | wcharczuk/go-chart | vector_renderer.go | Save | func (vr *vectorRenderer) Save(w io.Writer) error {
vr.c.End()
_, err := w.Write(vr.b.Bytes())
return err
} | go | func (vr *vectorRenderer) Save(w io.Writer) error {
vr.c.End()
_, err := w.Write(vr.b.Bytes())
return err
} | [
"func",
"(",
"vr",
"*",
"vectorRenderer",
")",
"Save",
"(",
"w",
"io",
".",
"Writer",
")",
"error",
"{",
"vr",
".",
"c",
".",
"End",
"(",
")",
"\n",
"_",
",",
"err",
":=",
"w",
".",
"Write",
"(",
"vr",
".",
"b",
".",
"Bytes",
"(",
")",
")",... | // Save saves the renderer's contents to a writer. | [
"Save",
"saves",
"the",
"renderer",
"s",
"contents",
"to",
"a",
"writer",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/vector_renderer.go#L225-L229 |
25,518 | wcharczuk/go-chart | vector_renderer.go | getStrokeDashArray | func (c *canvas) getStrokeDashArray(s Style) string {
if len(s.StrokeDashArray) > 0 {
var values []string
for _, v := range s.StrokeDashArray {
values = append(values, fmt.Sprintf("%0.1f", v))
}
return "stroke-dasharray=\"" + strings.Join(values, ", ") + "\""
}
return ""
} | go | func (c *canvas) getStrokeDashArray(s Style) string {
if len(s.StrokeDashArray) > 0 {
var values []string
for _, v := range s.StrokeDashArray {
values = append(values, fmt.Sprintf("%0.1f", v))
}
return "stroke-dasharray=\"" + strings.Join(values, ", ") + "\""
}
return ""
} | [
"func",
"(",
"c",
"*",
"canvas",
")",
"getStrokeDashArray",
"(",
"s",
"Style",
")",
"string",
"{",
"if",
"len",
"(",
"s",
".",
"StrokeDashArray",
")",
">",
"0",
"{",
"var",
"values",
"[",
"]",
"string",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
... | // getStrokeDashArray returns the stroke-dasharray property of a style. | [
"getStrokeDashArray",
"returns",
"the",
"stroke",
"-",
"dasharray",
"property",
"of",
"a",
"style",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/vector_renderer.go#L289-L298 |
25,519 | wcharczuk/go-chart | vector_renderer.go | getFontFace | func (c *canvas) getFontFace(s Style) string {
family := "sans-serif"
if s.GetFont() != nil {
name := s.GetFont().Name(truetype.NameIDFontFamily)
if len(name) != 0 {
family = fmt.Sprintf(`'%s',%s`, name, family)
}
}
return fmt.Sprintf("font-family:%s", family)
} | go | func (c *canvas) getFontFace(s Style) string {
family := "sans-serif"
if s.GetFont() != nil {
name := s.GetFont().Name(truetype.NameIDFontFamily)
if len(name) != 0 {
family = fmt.Sprintf(`'%s',%s`, name, family)
}
}
return fmt.Sprintf("font-family:%s", family)
} | [
"func",
"(",
"c",
"*",
"canvas",
")",
"getFontFace",
"(",
"s",
"Style",
")",
"string",
"{",
"family",
":=",
"\"",
"\"",
"\n",
"if",
"s",
".",
"GetFont",
"(",
")",
"!=",
"nil",
"{",
"name",
":=",
"s",
".",
"GetFont",
"(",
")",
".",
"Name",
"(",
... | // GetFontFace returns the font face for the style. | [
"GetFontFace",
"returns",
"the",
"font",
"face",
"for",
"the",
"style",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/vector_renderer.go#L301-L310 |
25,520 | wcharczuk/go-chart | vector_renderer.go | styleAsSVG | func (c *canvas) styleAsSVG(s Style) string {
sw := s.StrokeWidth
sc := s.StrokeColor
fc := s.FillColor
fs := s.FontSize
fnc := s.FontColor
if s.ClassName != "" {
var classes []string
classes = append(classes, s.ClassName)
if !sc.IsZero() {
classes = append(classes, "stroke")
}
if !fc.IsZero() {
... | go | func (c *canvas) styleAsSVG(s Style) string {
sw := s.StrokeWidth
sc := s.StrokeColor
fc := s.FillColor
fs := s.FontSize
fnc := s.FontColor
if s.ClassName != "" {
var classes []string
classes = append(classes, s.ClassName)
if !sc.IsZero() {
classes = append(classes, "stroke")
}
if !fc.IsZero() {
... | [
"func",
"(",
"c",
"*",
"canvas",
")",
"styleAsSVG",
"(",
"s",
"Style",
")",
"string",
"{",
"sw",
":=",
"s",
".",
"StrokeWidth",
"\n",
"sc",
":=",
"s",
".",
"StrokeColor",
"\n",
"fc",
":=",
"s",
".",
"FillColor",
"\n",
"fs",
":=",
"s",
".",
"FontS... | // styleAsSVG returns the style as a svg style or class string. | [
"styleAsSVG",
"returns",
"the",
"style",
"as",
"a",
"svg",
"style",
"or",
"class",
"string",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/vector_renderer.go#L313-L366 |
25,521 | wcharczuk/go-chart | seq/time.go | Days | func (ts timeSequence) Days(days int) []time.Time {
var values []time.Time
for day := days; day >= 0; day-- {
values = append(values, time.Now().AddDate(0, 0, -day))
}
return values
} | go | func (ts timeSequence) Days(days int) []time.Time {
var values []time.Time
for day := days; day >= 0; day-- {
values = append(values, time.Now().AddDate(0, 0, -day))
}
return values
} | [
"func",
"(",
"ts",
"timeSequence",
")",
"Days",
"(",
"days",
"int",
")",
"[",
"]",
"time",
".",
"Time",
"{",
"var",
"values",
"[",
"]",
"time",
".",
"Time",
"\n",
"for",
"day",
":=",
"days",
";",
"day",
">=",
"0",
";",
"day",
"--",
"{",
"values... | // Days generates a seq of timestamps by day, from -days to today. | [
"Days",
"generates",
"a",
"seq",
"of",
"timestamps",
"by",
"day",
"from",
"-",
"days",
"to",
"today",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/time.go#L15-L21 |
25,522 | wcharczuk/go-chart | seq/time.go | HoursFilled | func (ts timeSequence) HoursFilled(xdata []time.Time, ydata []float64) ([]time.Time, []float64) {
start, end := util.Time.StartAndEnd(xdata...)
totalHours := util.Time.DiffHours(start, end)
finalTimes := ts.Hours(start, totalHours+1)
finalValues := make([]float64, totalHours+1)
var hoursFromStart int
for i, xd ... | go | func (ts timeSequence) HoursFilled(xdata []time.Time, ydata []float64) ([]time.Time, []float64) {
start, end := util.Time.StartAndEnd(xdata...)
totalHours := util.Time.DiffHours(start, end)
finalTimes := ts.Hours(start, totalHours+1)
finalValues := make([]float64, totalHours+1)
var hoursFromStart int
for i, xd ... | [
"func",
"(",
"ts",
"timeSequence",
")",
"HoursFilled",
"(",
"xdata",
"[",
"]",
"time",
".",
"Time",
",",
"ydata",
"[",
"]",
"float64",
")",
"(",
"[",
"]",
"time",
".",
"Time",
",",
"[",
"]",
"float64",
")",
"{",
"start",
",",
"end",
":=",
"util",... | // HoursFilled adds zero values for the data bounded by the start and end of the xdata array. | [
"HoursFilled",
"adds",
"zero",
"values",
"for",
"the",
"data",
"bounded",
"by",
"the",
"start",
"and",
"end",
"of",
"the",
"xdata",
"array",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/time.go#L36-L50 |
25,523 | wcharczuk/go-chart | drawing/flattener.go | Flatten | func Flatten(path *Path, flattener Flattener, scale float64) {
// First Point
var startX, startY float64
// Current Point
var x, y float64
var i int
for _, cmp := range path.Components {
switch cmp {
case MoveToComponent:
x, y = path.Points[i], path.Points[i+1]
startX, startY = x, y
if i != 0 {
f... | go | func Flatten(path *Path, flattener Flattener, scale float64) {
// First Point
var startX, startY float64
// Current Point
var x, y float64
var i int
for _, cmp := range path.Components {
switch cmp {
case MoveToComponent:
x, y = path.Points[i], path.Points[i+1]
startX, startY = x, y
if i != 0 {
f... | [
"func",
"Flatten",
"(",
"path",
"*",
"Path",
",",
"flattener",
"Flattener",
",",
"scale",
"float64",
")",
"{",
"// First Point",
"var",
"startX",
",",
"startY",
"float64",
"\n",
"// Current Point",
"var",
"x",
",",
"y",
"float64",
"\n",
"var",
"i",
"int",
... | // Flatten convert curves into straight segments keeping join segments info | [
"Flatten",
"convert",
"curves",
"into",
"straight",
"segments",
"keeping",
"join",
"segments",
"info"
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/flattener.go#L24-L66 |
25,524 | wcharczuk/go-chart | drawing/flattener.go | MoveTo | func (p *SegmentedPath) MoveTo(x, y float64) {
p.Points = append(p.Points, x, y)
// TODO need to mark this point as moveto
} | go | func (p *SegmentedPath) MoveTo(x, y float64) {
p.Points = append(p.Points, x, y)
// TODO need to mark this point as moveto
} | [
"func",
"(",
"p",
"*",
"SegmentedPath",
")",
"MoveTo",
"(",
"x",
",",
"y",
"float64",
")",
"{",
"p",
".",
"Points",
"=",
"append",
"(",
"p",
".",
"Points",
",",
"x",
",",
"y",
")",
"\n",
"// TODO need to mark this point as moveto",
"}"
] | // MoveTo implements the path interface. | [
"MoveTo",
"implements",
"the",
"path",
"interface",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/flattener.go#L74-L77 |
25,525 | wcharczuk/go-chart | drawing/flattener.go | LineTo | func (p *SegmentedPath) LineTo(x, y float64) {
p.Points = append(p.Points, x, y)
} | go | func (p *SegmentedPath) LineTo(x, y float64) {
p.Points = append(p.Points, x, y)
} | [
"func",
"(",
"p",
"*",
"SegmentedPath",
")",
"LineTo",
"(",
"x",
",",
"y",
"float64",
")",
"{",
"p",
".",
"Points",
"=",
"append",
"(",
"p",
".",
"Points",
",",
"x",
",",
"y",
")",
"\n",
"}"
] | // LineTo implements the path interface. | [
"LineTo",
"implements",
"the",
"path",
"interface",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/flattener.go#L80-L82 |
25,526 | wcharczuk/go-chart | xaxis.go | GetTickPosition | func (xa XAxis) GetTickPosition(defaults ...TickPosition) TickPosition {
if xa.TickPosition == TickPositionUnset {
if len(defaults) > 0 {
return defaults[0]
}
return TickPositionUnderTick
}
return xa.TickPosition
} | go | func (xa XAxis) GetTickPosition(defaults ...TickPosition) TickPosition {
if xa.TickPosition == TickPositionUnset {
if len(defaults) > 0 {
return defaults[0]
}
return TickPositionUnderTick
}
return xa.TickPosition
} | [
"func",
"(",
"xa",
"XAxis",
")",
"GetTickPosition",
"(",
"defaults",
"...",
"TickPosition",
")",
"TickPosition",
"{",
"if",
"xa",
".",
"TickPosition",
"==",
"TickPositionUnset",
"{",
"if",
"len",
"(",
"defaults",
")",
">",
"0",
"{",
"return",
"defaults",
"... | // GetTickPosition returns the tick position option for the axis. | [
"GetTickPosition",
"returns",
"the",
"tick",
"position",
"option",
"for",
"the",
"axis",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/xaxis.go#L46-L54 |
25,527 | wcharczuk/go-chart | first_value_annotation.go | FirstValueAnnotation | func FirstValueAnnotation(innerSeries ValuesProvider, vfs ...ValueFormatter) AnnotationSeries {
var vf ValueFormatter
if len(vfs) > 0 {
vf = vfs[0]
} else if typed, isTyped := innerSeries.(ValueFormatterProvider); isTyped {
_, vf = typed.GetValueFormatters()
} else {
vf = FloatValueFormatter
}
var firstVal... | go | func FirstValueAnnotation(innerSeries ValuesProvider, vfs ...ValueFormatter) AnnotationSeries {
var vf ValueFormatter
if len(vfs) > 0 {
vf = vfs[0]
} else if typed, isTyped := innerSeries.(ValueFormatterProvider); isTyped {
_, vf = typed.GetValueFormatters()
} else {
vf = FloatValueFormatter
}
var firstVal... | [
"func",
"FirstValueAnnotation",
"(",
"innerSeries",
"ValuesProvider",
",",
"vfs",
"...",
"ValueFormatter",
")",
"AnnotationSeries",
"{",
"var",
"vf",
"ValueFormatter",
"\n",
"if",
"len",
"(",
"vfs",
")",
">",
"0",
"{",
"vf",
"=",
"vfs",
"[",
"0",
"]",
"\n"... | // FirstValueAnnotation returns an annotation series of just the first value of a value provider as an annotation. | [
"FirstValueAnnotation",
"returns",
"an",
"annotation",
"series",
"of",
"just",
"the",
"first",
"value",
"of",
"a",
"value",
"provider",
"as",
"an",
"annotation",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/first_value_annotation.go#L6-L37 |
25,528 | wcharczuk/go-chart | bar_chart.go | box | func (bc BarChart) box() Box {
dpr := bc.Background.Padding.GetRight(10)
dpb := bc.Background.Padding.GetBottom(50)
return Box{
Top: bc.Background.Padding.GetTop(20),
Left: bc.Background.Padding.GetLeft(20),
Right: bc.GetWidth() - dpr,
Bottom: bc.GetHeight() - dpb,
}
} | go | func (bc BarChart) box() Box {
dpr := bc.Background.Padding.GetRight(10)
dpb := bc.Background.Padding.GetBottom(50)
return Box{
Top: bc.Background.Padding.GetTop(20),
Left: bc.Background.Padding.GetLeft(20),
Right: bc.GetWidth() - dpr,
Bottom: bc.GetHeight() - dpb,
}
} | [
"func",
"(",
"bc",
"BarChart",
")",
"box",
"(",
")",
"Box",
"{",
"dpr",
":=",
"bc",
".",
"Background",
".",
"Padding",
".",
"GetRight",
"(",
"10",
")",
"\n",
"dpb",
":=",
"bc",
".",
"Background",
".",
"Padding",
".",
"GetBottom",
"(",
"50",
")",
... | // box returns the chart bounds as a box. | [
"box",
"returns",
"the",
"chart",
"bounds",
"as",
"a",
"box",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/bar_chart.go#L436-L446 |
25,529 | wcharczuk/go-chart | drawing/dasher.go | NewDashVertexConverter | func NewDashVertexConverter(dash []float64, dashOffset float64, flattener Flattener) *DashVertexConverter {
var dasher DashVertexConverter
dasher.dash = dash
dasher.currentDash = 0
dasher.dashOffset = dashOffset
dasher.next = flattener
return &dasher
} | go | func NewDashVertexConverter(dash []float64, dashOffset float64, flattener Flattener) *DashVertexConverter {
var dasher DashVertexConverter
dasher.dash = dash
dasher.currentDash = 0
dasher.dashOffset = dashOffset
dasher.next = flattener
return &dasher
} | [
"func",
"NewDashVertexConverter",
"(",
"dash",
"[",
"]",
"float64",
",",
"dashOffset",
"float64",
",",
"flattener",
"Flattener",
")",
"*",
"DashVertexConverter",
"{",
"var",
"dasher",
"DashVertexConverter",
"\n",
"dasher",
".",
"dash",
"=",
"dash",
"\n",
"dasher... | // NewDashVertexConverter creates a new dash converter. | [
"NewDashVertexConverter",
"creates",
"a",
"new",
"dash",
"converter",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/dasher.go#L4-L11 |
25,530 | wcharczuk/go-chart | drawing/dasher.go | LineTo | func (dasher *DashVertexConverter) LineTo(x, y float64) {
dasher.lineTo(x, y)
} | go | func (dasher *DashVertexConverter) LineTo(x, y float64) {
dasher.lineTo(x, y)
} | [
"func",
"(",
"dasher",
"*",
"DashVertexConverter",
")",
"LineTo",
"(",
"x",
",",
"y",
"float64",
")",
"{",
"dasher",
".",
"lineTo",
"(",
"x",
",",
"y",
")",
"\n",
"}"
] | // LineTo implements the pathbuilder interface. | [
"LineTo",
"implements",
"the",
"pathbuilder",
"interface",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/dasher.go#L23-L25 |
25,531 | wcharczuk/go-chart | drawing/dasher.go | MoveTo | func (dasher *DashVertexConverter) MoveTo(x, y float64) {
dasher.next.MoveTo(x, y)
dasher.x, dasher.y = x, y
dasher.distance = dasher.dashOffset
dasher.currentDash = 0
} | go | func (dasher *DashVertexConverter) MoveTo(x, y float64) {
dasher.next.MoveTo(x, y)
dasher.x, dasher.y = x, y
dasher.distance = dasher.dashOffset
dasher.currentDash = 0
} | [
"func",
"(",
"dasher",
"*",
"DashVertexConverter",
")",
"MoveTo",
"(",
"x",
",",
"y",
"float64",
")",
"{",
"dasher",
".",
"next",
".",
"MoveTo",
"(",
"x",
",",
"y",
")",
"\n",
"dasher",
".",
"x",
",",
"dasher",
".",
"y",
"=",
"x",
",",
"y",
"\n... | // MoveTo implements the pathbuilder interface. | [
"MoveTo",
"implements",
"the",
"pathbuilder",
"interface",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/dasher.go#L28-L33 |
25,532 | wcharczuk/go-chart | drawing/path.go | LastPoint | func (p *Path) LastPoint() (x, y float64) {
return p.x, p.y
} | go | func (p *Path) LastPoint() (x, y float64) {
return p.x, p.y
} | [
"func",
"(",
"p",
"*",
"Path",
")",
"LastPoint",
"(",
")",
"(",
"x",
",",
"y",
"float64",
")",
"{",
"return",
"p",
".",
"x",
",",
"p",
".",
"y",
"\n",
"}"
] | // LastPoint returns the current point of the current path | [
"LastPoint",
"returns",
"the",
"current",
"point",
"of",
"the",
"current",
"path"
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/path.go#L62-L64 |
25,533 | wcharczuk/go-chart | drawing/path.go | LineTo | func (p *Path) LineTo(x, y float64) {
if len(p.Components) == 0 { //special case when no move has been done
p.MoveTo(0, 0)
}
p.appendToPath(LineToComponent, x, y)
p.x = x
p.y = y
} | go | func (p *Path) LineTo(x, y float64) {
if len(p.Components) == 0 { //special case when no move has been done
p.MoveTo(0, 0)
}
p.appendToPath(LineToComponent, x, y)
p.x = x
p.y = y
} | [
"func",
"(",
"p",
"*",
"Path",
")",
"LineTo",
"(",
"x",
",",
"y",
"float64",
")",
"{",
"if",
"len",
"(",
"p",
".",
"Components",
")",
"==",
"0",
"{",
"//special case when no move has been done",
"p",
".",
"MoveTo",
"(",
"0",
",",
"0",
")",
"\n",
"}... | // LineTo adds a line to the current path | [
"LineTo",
"adds",
"a",
"line",
"to",
"the",
"current",
"path"
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/path.go#L74-L81 |
25,534 | wcharczuk/go-chart | drawing/path.go | QuadCurveTo | func (p *Path) QuadCurveTo(cx, cy, x, y float64) {
if len(p.Components) == 0 { //special case when no move has been done
p.MoveTo(0, 0)
}
p.appendToPath(QuadCurveToComponent, cx, cy, x, y)
p.x = x
p.y = y
} | go | func (p *Path) QuadCurveTo(cx, cy, x, y float64) {
if len(p.Components) == 0 { //special case when no move has been done
p.MoveTo(0, 0)
}
p.appendToPath(QuadCurveToComponent, cx, cy, x, y)
p.x = x
p.y = y
} | [
"func",
"(",
"p",
"*",
"Path",
")",
"QuadCurveTo",
"(",
"cx",
",",
"cy",
",",
"x",
",",
"y",
"float64",
")",
"{",
"if",
"len",
"(",
"p",
".",
"Components",
")",
"==",
"0",
"{",
"//special case when no move has been done",
"p",
".",
"MoveTo",
"(",
"0"... | // QuadCurveTo adds a quadratic bezier curve to the current path | [
"QuadCurveTo",
"adds",
"a",
"quadratic",
"bezier",
"curve",
"to",
"the",
"current",
"path"
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/path.go#L84-L91 |
25,535 | wcharczuk/go-chart | drawing/path.go | Copy | func (p *Path) Copy() (dest *Path) {
dest = new(Path)
dest.Components = make([]PathComponent, len(p.Components))
copy(dest.Components, p.Components)
dest.Points = make([]float64, len(p.Points))
copy(dest.Points, p.Points)
dest.x, dest.y = p.x, p.y
return dest
} | go | func (p *Path) Copy() (dest *Path) {
dest = new(Path)
dest.Components = make([]PathComponent, len(p.Components))
copy(dest.Components, p.Components)
dest.Points = make([]float64, len(p.Points))
copy(dest.Points, p.Points)
dest.x, dest.y = p.x, p.y
return dest
} | [
"func",
"(",
"p",
"*",
"Path",
")",
"Copy",
"(",
")",
"(",
"dest",
"*",
"Path",
")",
"{",
"dest",
"=",
"new",
"(",
"Path",
")",
"\n",
"dest",
".",
"Components",
"=",
"make",
"(",
"[",
"]",
"PathComponent",
",",
"len",
"(",
"p",
".",
"Components... | // Copy make a clone of the current path and return it | [
"Copy",
"make",
"a",
"clone",
"of",
"the",
"current",
"path",
"and",
"return",
"it"
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/path.go#L138-L146 |
25,536 | wcharczuk/go-chart | drawing/path.go | Clear | func (p *Path) Clear() {
p.Components = p.Components[0:0]
p.Points = p.Points[0:0]
return
} | go | func (p *Path) Clear() {
p.Components = p.Components[0:0]
p.Points = p.Points[0:0]
return
} | [
"func",
"(",
"p",
"*",
"Path",
")",
"Clear",
"(",
")",
"{",
"p",
".",
"Components",
"=",
"p",
".",
"Components",
"[",
"0",
":",
"0",
"]",
"\n",
"p",
".",
"Points",
"=",
"p",
".",
"Points",
"[",
"0",
":",
"0",
"]",
"\n",
"return",
"\n",
"}"
... | // Clear reset the path | [
"Clear",
"reset",
"the",
"path"
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/path.go#L149-L153 |
25,537 | wcharczuk/go-chart | drawing/path.go | String | func (p *Path) String() string {
s := ""
j := 0
for _, cmd := range p.Components {
switch cmd {
case MoveToComponent:
s += fmt.Sprintf("MoveTo: %f, %f\n", p.Points[j], p.Points[j+1])
j = j + 2
case LineToComponent:
s += fmt.Sprintf("LineTo: %f, %f\n", p.Points[j], p.Points[j+1])
j = j + 2
case Qu... | go | func (p *Path) String() string {
s := ""
j := 0
for _, cmd := range p.Components {
switch cmd {
case MoveToComponent:
s += fmt.Sprintf("MoveTo: %f, %f\n", p.Points[j], p.Points[j+1])
j = j + 2
case LineToComponent:
s += fmt.Sprintf("LineTo: %f, %f\n", p.Points[j], p.Points[j+1])
j = j + 2
case Qu... | [
"func",
"(",
"p",
"*",
"Path",
")",
"String",
"(",
")",
"string",
"{",
"s",
":=",
"\"",
"\"",
"\n",
"j",
":=",
"0",
"\n",
"for",
"_",
",",
"cmd",
":=",
"range",
"p",
".",
"Components",
"{",
"switch",
"cmd",
"{",
"case",
"MoveToComponent",
":",
... | // String returns a debug text view of the path | [
"String",
"returns",
"a",
"debug",
"text",
"view",
"of",
"the",
"path"
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/path.go#L161-L186 |
25,538 | wcharczuk/go-chart | box.go | IsZero | func (b Box) IsZero() bool {
if b.IsSet {
return false
}
return b.Top == 0 && b.Left == 0 && b.Right == 0 && b.Bottom == 0
} | go | func (b Box) IsZero() bool {
if b.IsSet {
return false
}
return b.Top == 0 && b.Left == 0 && b.Right == 0 && b.Bottom == 0
} | [
"func",
"(",
"b",
"Box",
")",
"IsZero",
"(",
")",
"bool",
"{",
"if",
"b",
".",
"IsSet",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"b",
".",
"Top",
"==",
"0",
"&&",
"b",
".",
"Left",
"==",
"0",
"&&",
"b",
".",
"Right",
"==",
"0",
"&... | // IsZero returns if the box is set or not. | [
"IsZero",
"returns",
"if",
"the",
"box",
"is",
"set",
"or",
"not",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/box.go#L36-L41 |
25,539 | wcharczuk/go-chart | box.go | String | func (b Box) String() string {
return fmt.Sprintf("box(%d,%d,%d,%d)", b.Top, b.Left, b.Right, b.Bottom)
} | go | func (b Box) String() string {
return fmt.Sprintf("box(%d,%d,%d,%d)", b.Top, b.Left, b.Right, b.Bottom)
} | [
"func",
"(",
"b",
"Box",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"b",
".",
"Top",
",",
"b",
".",
"Left",
",",
"b",
".",
"Right",
",",
"b",
".",
"Bottom",
")",
"\n",
"}"
] | // String returns a string representation of the box. | [
"String",
"returns",
"a",
"string",
"representation",
"of",
"the",
"box",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/box.go#L44-L46 |
25,540 | wcharczuk/go-chart | box.go | GetTop | func (b Box) GetTop(defaults ...int) int {
if !b.IsSet && b.Top == 0 {
if len(defaults) > 0 {
return defaults[0]
}
return 0
}
return b.Top
} | go | func (b Box) GetTop(defaults ...int) int {
if !b.IsSet && b.Top == 0 {
if len(defaults) > 0 {
return defaults[0]
}
return 0
}
return b.Top
} | [
"func",
"(",
"b",
"Box",
")",
"GetTop",
"(",
"defaults",
"...",
"int",
")",
"int",
"{",
"if",
"!",
"b",
".",
"IsSet",
"&&",
"b",
".",
"Top",
"==",
"0",
"{",
"if",
"len",
"(",
"defaults",
")",
">",
"0",
"{",
"return",
"defaults",
"[",
"0",
"]"... | // GetTop returns a coalesced value with a default. | [
"GetTop",
"returns",
"a",
"coalesced",
"value",
"with",
"a",
"default",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/box.go#L49-L57 |
25,541 | wcharczuk/go-chart | box.go | GetLeft | func (b Box) GetLeft(defaults ...int) int {
if !b.IsSet && b.Left == 0 {
if len(defaults) > 0 {
return defaults[0]
}
return 0
}
return b.Left
} | go | func (b Box) GetLeft(defaults ...int) int {
if !b.IsSet && b.Left == 0 {
if len(defaults) > 0 {
return defaults[0]
}
return 0
}
return b.Left
} | [
"func",
"(",
"b",
"Box",
")",
"GetLeft",
"(",
"defaults",
"...",
"int",
")",
"int",
"{",
"if",
"!",
"b",
".",
"IsSet",
"&&",
"b",
".",
"Left",
"==",
"0",
"{",
"if",
"len",
"(",
"defaults",
")",
">",
"0",
"{",
"return",
"defaults",
"[",
"0",
"... | // GetLeft returns a coalesced value with a default. | [
"GetLeft",
"returns",
"a",
"coalesced",
"value",
"with",
"a",
"default",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/box.go#L60-L68 |
25,542 | wcharczuk/go-chart | box.go | GetRight | func (b Box) GetRight(defaults ...int) int {
if !b.IsSet && b.Right == 0 {
if len(defaults) > 0 {
return defaults[0]
}
return 0
}
return b.Right
} | go | func (b Box) GetRight(defaults ...int) int {
if !b.IsSet && b.Right == 0 {
if len(defaults) > 0 {
return defaults[0]
}
return 0
}
return b.Right
} | [
"func",
"(",
"b",
"Box",
")",
"GetRight",
"(",
"defaults",
"...",
"int",
")",
"int",
"{",
"if",
"!",
"b",
".",
"IsSet",
"&&",
"b",
".",
"Right",
"==",
"0",
"{",
"if",
"len",
"(",
"defaults",
")",
">",
"0",
"{",
"return",
"defaults",
"[",
"0",
... | // GetRight returns a coalesced value with a default. | [
"GetRight",
"returns",
"a",
"coalesced",
"value",
"with",
"a",
"default",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/box.go#L71-L79 |
25,543 | wcharczuk/go-chart | box.go | GetBottom | func (b Box) GetBottom(defaults ...int) int {
if !b.IsSet && b.Bottom == 0 {
if len(defaults) > 0 {
return defaults[0]
}
return 0
}
return b.Bottom
} | go | func (b Box) GetBottom(defaults ...int) int {
if !b.IsSet && b.Bottom == 0 {
if len(defaults) > 0 {
return defaults[0]
}
return 0
}
return b.Bottom
} | [
"func",
"(",
"b",
"Box",
")",
"GetBottom",
"(",
"defaults",
"...",
"int",
")",
"int",
"{",
"if",
"!",
"b",
".",
"IsSet",
"&&",
"b",
".",
"Bottom",
"==",
"0",
"{",
"if",
"len",
"(",
"defaults",
")",
">",
"0",
"{",
"return",
"defaults",
"[",
"0",... | // GetBottom returns a coalesced value with a default. | [
"GetBottom",
"returns",
"a",
"coalesced",
"value",
"with",
"a",
"default",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/box.go#L82-L90 |
25,544 | wcharczuk/go-chart | box.go | Aspect | func (b Box) Aspect() float64 {
return float64(b.Width()) / float64(b.Height())
} | go | func (b Box) Aspect() float64 {
return float64(b.Width()) / float64(b.Height())
} | [
"func",
"(",
"b",
"Box",
")",
"Aspect",
"(",
")",
"float64",
"{",
"return",
"float64",
"(",
"b",
".",
"Width",
"(",
")",
")",
"/",
"float64",
"(",
"b",
".",
"Height",
"(",
")",
")",
"\n",
"}"
] | // Aspect returns the aspect ratio of the box. | [
"Aspect",
"returns",
"the",
"aspect",
"ratio",
"of",
"the",
"box",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/box.go#L109-L111 |
25,545 | wcharczuk/go-chart | box.go | Clone | func (b Box) Clone() Box {
return Box{
IsSet: b.IsSet,
Top: b.Top,
Left: b.Left,
Right: b.Right,
Bottom: b.Bottom,
}
} | go | func (b Box) Clone() Box {
return Box{
IsSet: b.IsSet,
Top: b.Top,
Left: b.Left,
Right: b.Right,
Bottom: b.Bottom,
}
} | [
"func",
"(",
"b",
"Box",
")",
"Clone",
"(",
")",
"Box",
"{",
"return",
"Box",
"{",
"IsSet",
":",
"b",
".",
"IsSet",
",",
"Top",
":",
"b",
".",
"Top",
",",
"Left",
":",
"b",
".",
"Left",
",",
"Right",
":",
"b",
".",
"Right",
",",
"Bottom",
"... | // Clone returns a new copy of the box. | [
"Clone",
"returns",
"a",
"new",
"copy",
"of",
"the",
"box",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/box.go#L114-L122 |
25,546 | wcharczuk/go-chart | box.go | IsBiggerThan | func (b Box) IsBiggerThan(other Box) bool {
return b.Top < other.Top ||
b.Bottom > other.Bottom ||
b.Left < other.Left ||
b.Right > other.Right
} | go | func (b Box) IsBiggerThan(other Box) bool {
return b.Top < other.Top ||
b.Bottom > other.Bottom ||
b.Left < other.Left ||
b.Right > other.Right
} | [
"func",
"(",
"b",
"Box",
")",
"IsBiggerThan",
"(",
"other",
"Box",
")",
"bool",
"{",
"return",
"b",
".",
"Top",
"<",
"other",
".",
"Top",
"||",
"b",
".",
"Bottom",
">",
"other",
".",
"Bottom",
"||",
"b",
".",
"Left",
"<",
"other",
".",
"Left",
... | // IsBiggerThan returns if a box is bigger than another box. | [
"IsBiggerThan",
"returns",
"if",
"a",
"box",
"is",
"bigger",
"than",
"another",
"box",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/box.go#L125-L130 |
25,547 | wcharczuk/go-chart | box.go | Grow | func (b Box) Grow(other Box) Box {
return Box{
Top: util.Math.MinInt(b.Top, other.Top),
Left: util.Math.MinInt(b.Left, other.Left),
Right: util.Math.MaxInt(b.Right, other.Right),
Bottom: util.Math.MaxInt(b.Bottom, other.Bottom),
}
} | go | func (b Box) Grow(other Box) Box {
return Box{
Top: util.Math.MinInt(b.Top, other.Top),
Left: util.Math.MinInt(b.Left, other.Left),
Right: util.Math.MaxInt(b.Right, other.Right),
Bottom: util.Math.MaxInt(b.Bottom, other.Bottom),
}
} | [
"func",
"(",
"b",
"Box",
")",
"Grow",
"(",
"other",
"Box",
")",
"Box",
"{",
"return",
"Box",
"{",
"Top",
":",
"util",
".",
"Math",
".",
"MinInt",
"(",
"b",
".",
"Top",
",",
"other",
".",
"Top",
")",
",",
"Left",
":",
"util",
".",
"Math",
".",... | // Grow grows a box based on another box. | [
"Grow",
"grows",
"a",
"box",
"based",
"on",
"another",
"box",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/box.go#L149-L156 |
25,548 | wcharczuk/go-chart | box.go | Shift | func (b Box) Shift(x, y int) Box {
return Box{
Top: b.Top + y,
Left: b.Left + x,
Right: b.Right + x,
Bottom: b.Bottom + y,
}
} | go | func (b Box) Shift(x, y int) Box {
return Box{
Top: b.Top + y,
Left: b.Left + x,
Right: b.Right + x,
Bottom: b.Bottom + y,
}
} | [
"func",
"(",
"b",
"Box",
")",
"Shift",
"(",
"x",
",",
"y",
"int",
")",
"Box",
"{",
"return",
"Box",
"{",
"Top",
":",
"b",
".",
"Top",
"+",
"y",
",",
"Left",
":",
"b",
".",
"Left",
"+",
"x",
",",
"Right",
":",
"b",
".",
"Right",
"+",
"x",
... | // Shift pushes a box by x,y. | [
"Shift",
"pushes",
"a",
"box",
"by",
"x",
"y",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/box.go#L159-L166 |
25,549 | wcharczuk/go-chart | box.go | Corners | func (b Box) Corners() BoxCorners {
return BoxCorners{
TopLeft: Point{b.Left, b.Top},
TopRight: Point{b.Right, b.Top},
BottomRight: Point{b.Right, b.Bottom},
BottomLeft: Point{b.Left, b.Bottom},
}
} | go | func (b Box) Corners() BoxCorners {
return BoxCorners{
TopLeft: Point{b.Left, b.Top},
TopRight: Point{b.Right, b.Top},
BottomRight: Point{b.Right, b.Bottom},
BottomLeft: Point{b.Left, b.Bottom},
}
} | [
"func",
"(",
"b",
"Box",
")",
"Corners",
"(",
")",
"BoxCorners",
"{",
"return",
"BoxCorners",
"{",
"TopLeft",
":",
"Point",
"{",
"b",
".",
"Left",
",",
"b",
".",
"Top",
"}",
",",
"TopRight",
":",
"Point",
"{",
"b",
".",
"Right",
",",
"b",
".",
... | // Corners returns the box as a set of corners. | [
"Corners",
"returns",
"the",
"box",
"as",
"a",
"set",
"of",
"corners",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/box.go#L169-L176 |
25,550 | wcharczuk/go-chart | box.go | Fit | func (b Box) Fit(other Box) Box {
ba := b.Aspect()
oa := other.Aspect()
if oa == ba {
return b.Clone()
}
bw, bh := float64(b.Width()), float64(b.Height())
bw2 := int(bw) >> 1
bh2 := int(bh) >> 1
if oa > ba { // ex. 16:9 vs. 4:3
var noh2 int
if oa > 1.0 {
noh2 = int(bw/oa) >> 1
} else {
noh2 = in... | go | func (b Box) Fit(other Box) Box {
ba := b.Aspect()
oa := other.Aspect()
if oa == ba {
return b.Clone()
}
bw, bh := float64(b.Width()), float64(b.Height())
bw2 := int(bw) >> 1
bh2 := int(bh) >> 1
if oa > ba { // ex. 16:9 vs. 4:3
var noh2 int
if oa > 1.0 {
noh2 = int(bw/oa) >> 1
} else {
noh2 = in... | [
"func",
"(",
"b",
"Box",
")",
"Fit",
"(",
"other",
"Box",
")",
"Box",
"{",
"ba",
":=",
"b",
".",
"Aspect",
"(",
")",
"\n",
"oa",
":=",
"other",
".",
"Aspect",
"(",
")",
"\n\n",
"if",
"oa",
"==",
"ba",
"{",
"return",
"b",
".",
"Clone",
"(",
... | // Fit is functionally the inverse of grow.
// Fit maintains the original aspect ratio of the `other` box,
// but constrains it to the bounds of the target box. | [
"Fit",
"is",
"functionally",
"the",
"inverse",
"of",
"grow",
".",
"Fit",
"maintains",
"the",
"original",
"aspect",
"ratio",
"of",
"the",
"other",
"box",
"but",
"constrains",
"it",
"to",
"the",
"bounds",
"of",
"the",
"target",
"box",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/box.go#L181-L218 |
25,551 | wcharczuk/go-chart | box.go | Constrain | func (b Box) Constrain(other Box) Box {
newBox := b.Clone()
newBox.Top = util.Math.MaxInt(newBox.Top, other.Top)
newBox.Left = util.Math.MaxInt(newBox.Left, other.Left)
newBox.Right = util.Math.MinInt(newBox.Right, other.Right)
newBox.Bottom = util.Math.MinInt(newBox.Bottom, other.Bottom)
return newBox
} | go | func (b Box) Constrain(other Box) Box {
newBox := b.Clone()
newBox.Top = util.Math.MaxInt(newBox.Top, other.Top)
newBox.Left = util.Math.MaxInt(newBox.Left, other.Left)
newBox.Right = util.Math.MinInt(newBox.Right, other.Right)
newBox.Bottom = util.Math.MinInt(newBox.Bottom, other.Bottom)
return newBox
} | [
"func",
"(",
"b",
"Box",
")",
"Constrain",
"(",
"other",
"Box",
")",
"Box",
"{",
"newBox",
":=",
"b",
".",
"Clone",
"(",
")",
"\n\n",
"newBox",
".",
"Top",
"=",
"util",
".",
"Math",
".",
"MaxInt",
"(",
"newBox",
".",
"Top",
",",
"other",
".",
"... | // Constrain is similar to `Fit` except that it will work
// more literally like the opposite of grow. | [
"Constrain",
"is",
"similar",
"to",
"Fit",
"except",
"that",
"it",
"will",
"work",
"more",
"literally",
"like",
"the",
"opposite",
"of",
"grow",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/box.go#L222-L231 |
25,552 | wcharczuk/go-chart | box.go | OuterConstrain | func (b Box) OuterConstrain(bounds, other Box) Box {
newBox := b.Clone()
if other.Top < bounds.Top {
delta := bounds.Top - other.Top
newBox.Top = b.Top + delta
}
if other.Left < bounds.Left {
delta := bounds.Left - other.Left
newBox.Left = b.Left + delta
}
if other.Right > bounds.Right {
delta := othe... | go | func (b Box) OuterConstrain(bounds, other Box) Box {
newBox := b.Clone()
if other.Top < bounds.Top {
delta := bounds.Top - other.Top
newBox.Top = b.Top + delta
}
if other.Left < bounds.Left {
delta := bounds.Left - other.Left
newBox.Left = b.Left + delta
}
if other.Right > bounds.Right {
delta := othe... | [
"func",
"(",
"b",
"Box",
")",
"OuterConstrain",
"(",
"bounds",
",",
"other",
"Box",
")",
"Box",
"{",
"newBox",
":=",
"b",
".",
"Clone",
"(",
")",
"\n",
"if",
"other",
".",
"Top",
"<",
"bounds",
".",
"Top",
"{",
"delta",
":=",
"bounds",
".",
"Top"... | // OuterConstrain is similar to `Constraint` with the difference
// that it applies corrections | [
"OuterConstrain",
"is",
"similar",
"to",
"Constraint",
"with",
"the",
"difference",
"that",
"it",
"applies",
"corrections"
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/box.go#L235-L257 |
25,553 | wcharczuk/go-chart | box.go | Box | func (bc BoxCorners) Box() Box {
return Box{
Top: util.Math.MinInt(bc.TopLeft.Y, bc.TopRight.Y),
Left: util.Math.MinInt(bc.TopLeft.X, bc.BottomLeft.X),
Right: util.Math.MaxInt(bc.TopRight.X, bc.BottomRight.X),
Bottom: util.Math.MaxInt(bc.BottomLeft.Y, bc.BottomRight.Y),
}
} | go | func (bc BoxCorners) Box() Box {
return Box{
Top: util.Math.MinInt(bc.TopLeft.Y, bc.TopRight.Y),
Left: util.Math.MinInt(bc.TopLeft.X, bc.BottomLeft.X),
Right: util.Math.MaxInt(bc.TopRight.X, bc.BottomRight.X),
Bottom: util.Math.MaxInt(bc.BottomLeft.Y, bc.BottomRight.Y),
}
} | [
"func",
"(",
"bc",
"BoxCorners",
")",
"Box",
"(",
")",
"Box",
"{",
"return",
"Box",
"{",
"Top",
":",
"util",
".",
"Math",
".",
"MinInt",
"(",
"bc",
".",
"TopLeft",
".",
"Y",
",",
"bc",
".",
"TopRight",
".",
"Y",
")",
",",
"Left",
":",
"util",
... | // Box return the BoxCorners as a regular box. | [
"Box",
"return",
"the",
"BoxCorners",
"as",
"a",
"regular",
"box",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/box.go#L265-L272 |
25,554 | wcharczuk/go-chart | box.go | Rotate | func (bc BoxCorners) Rotate(thetaDegrees float64) BoxCorners {
cx, cy := bc.Center()
thetaRadians := util.Math.DegreesToRadians(thetaDegrees)
tlx, tly := util.Math.RotateCoordinate(cx, cy, bc.TopLeft.X, bc.TopLeft.Y, thetaRadians)
trx, try := util.Math.RotateCoordinate(cx, cy, bc.TopRight.X, bc.TopRight.Y, thetaR... | go | func (bc BoxCorners) Rotate(thetaDegrees float64) BoxCorners {
cx, cy := bc.Center()
thetaRadians := util.Math.DegreesToRadians(thetaDegrees)
tlx, tly := util.Math.RotateCoordinate(cx, cy, bc.TopLeft.X, bc.TopLeft.Y, thetaRadians)
trx, try := util.Math.RotateCoordinate(cx, cy, bc.TopRight.X, bc.TopRight.Y, thetaR... | [
"func",
"(",
"bc",
"BoxCorners",
")",
"Rotate",
"(",
"thetaDegrees",
"float64",
")",
"BoxCorners",
"{",
"cx",
",",
"cy",
":=",
"bc",
".",
"Center",
"(",
")",
"\n\n",
"thetaRadians",
":=",
"util",
".",
"Math",
".",
"DegreesToRadians",
"(",
"thetaDegrees",
... | // Rotate rotates the box. | [
"Rotate",
"rotates",
"the",
"box",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/box.go#L303-L319 |
25,555 | wcharczuk/go-chart | box.go | Equals | func (bc BoxCorners) Equals(other BoxCorners) bool {
return bc.TopLeft.Equals(other.TopLeft) &&
bc.TopRight.Equals(other.TopRight) &&
bc.BottomRight.Equals(other.BottomRight) &&
bc.BottomLeft.Equals(other.BottomLeft)
} | go | func (bc BoxCorners) Equals(other BoxCorners) bool {
return bc.TopLeft.Equals(other.TopLeft) &&
bc.TopRight.Equals(other.TopRight) &&
bc.BottomRight.Equals(other.BottomRight) &&
bc.BottomLeft.Equals(other.BottomLeft)
} | [
"func",
"(",
"bc",
"BoxCorners",
")",
"Equals",
"(",
"other",
"BoxCorners",
")",
"bool",
"{",
"return",
"bc",
".",
"TopLeft",
".",
"Equals",
"(",
"other",
".",
"TopLeft",
")",
"&&",
"bc",
".",
"TopRight",
".",
"Equals",
"(",
"other",
".",
"TopRight",
... | // Equals returns if the box equals another box. | [
"Equals",
"returns",
"if",
"the",
"box",
"equals",
"another",
"box",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/box.go#L322-L327 |
25,556 | wcharczuk/go-chart | box.go | DistanceTo | func (p Point) DistanceTo(other Point) float64 {
dx := math.Pow(float64(p.X-other.X), 2)
dy := math.Pow(float64(p.Y-other.Y), 2)
return math.Pow(dx+dy, 0.5)
} | go | func (p Point) DistanceTo(other Point) float64 {
dx := math.Pow(float64(p.X-other.X), 2)
dy := math.Pow(float64(p.Y-other.Y), 2)
return math.Pow(dx+dy, 0.5)
} | [
"func",
"(",
"p",
"Point",
")",
"DistanceTo",
"(",
"other",
"Point",
")",
"float64",
"{",
"dx",
":=",
"math",
".",
"Pow",
"(",
"float64",
"(",
"p",
".",
"X",
"-",
"other",
".",
"X",
")",
",",
"2",
")",
"\n",
"dy",
":=",
"math",
".",
"Pow",
"(... | // DistanceTo calculates the distance to another point. | [
"DistanceTo",
"calculates",
"the",
"distance",
"to",
"another",
"point",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/box.go#L339-L343 |
25,557 | wcharczuk/go-chart | box.go | Equals | func (p Point) Equals(other Point) bool {
return p.X == other.X && p.Y == other.Y
} | go | func (p Point) Equals(other Point) bool {
return p.X == other.X && p.Y == other.Y
} | [
"func",
"(",
"p",
"Point",
")",
"Equals",
"(",
"other",
"Point",
")",
"bool",
"{",
"return",
"p",
".",
"X",
"==",
"other",
".",
"X",
"&&",
"p",
".",
"Y",
"==",
"other",
".",
"Y",
"\n",
"}"
] | // Equals returns if a point equals another point. | [
"Equals",
"returns",
"if",
"a",
"point",
"equals",
"another",
"point",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/box.go#L346-L348 |
25,558 | wcharczuk/go-chart | tick.go | Swap | func (t Ticks) Swap(i, j int) {
t[i], t[j] = t[j], t[i]
} | go | func (t Ticks) Swap(i, j int) {
t[i], t[j] = t[j], t[i]
} | [
"func",
"(",
"t",
"Ticks",
")",
"Swap",
"(",
"i",
",",
"j",
"int",
")",
"{",
"t",
"[",
"i",
"]",
",",
"t",
"[",
"j",
"]",
"=",
"t",
"[",
"j",
"]",
",",
"t",
"[",
"i",
"]",
"\n",
"}"
] | // Swap swaps two elements. | [
"Swap",
"swaps",
"two",
"elements",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/tick.go#L31-L33 |
25,559 | wcharczuk/go-chart | tick.go | Less | func (t Ticks) Less(i, j int) bool {
return t[i].Value < t[j].Value
} | go | func (t Ticks) Less(i, j int) bool {
return t[i].Value < t[j].Value
} | [
"func",
"(",
"t",
"Ticks",
")",
"Less",
"(",
"i",
",",
"j",
"int",
")",
"bool",
"{",
"return",
"t",
"[",
"i",
"]",
".",
"Value",
"<",
"t",
"[",
"j",
"]",
".",
"Value",
"\n",
"}"
] | // Less returns if i's value is less than j's value. | [
"Less",
"returns",
"if",
"i",
"s",
"value",
"is",
"less",
"than",
"j",
"s",
"value",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/tick.go#L36-L38 |
25,560 | wcharczuk/go-chart | tick.go | String | func (t Ticks) String() string {
var values []string
for i, tick := range t {
values = append(values, fmt.Sprintf("[%d: %s]", i, tick.Label))
}
return strings.Join(values, ", ")
} | go | func (t Ticks) String() string {
var values []string
for i, tick := range t {
values = append(values, fmt.Sprintf("[%d: %s]", i, tick.Label))
}
return strings.Join(values, ", ")
} | [
"func",
"(",
"t",
"Ticks",
")",
"String",
"(",
")",
"string",
"{",
"var",
"values",
"[",
"]",
"string",
"\n",
"for",
"i",
",",
"tick",
":=",
"range",
"t",
"{",
"values",
"=",
"append",
"(",
"values",
",",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
... | // String returns a string representation of the set of ticks. | [
"String",
"returns",
"a",
"string",
"representation",
"of",
"the",
"set",
"of",
"ticks",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/tick.go#L41-L47 |
25,561 | wcharczuk/go-chart | tick.go | GenerateContinuousTicks | func GenerateContinuousTicks(r Renderer, ra Range, isVertical bool, style Style, vf ValueFormatter) []Tick {
if vf == nil {
vf = FloatValueFormatter
}
var ticks []Tick
min, max := ra.GetMin(), ra.GetMax()
if ra.IsDescending() {
ticks = append(ticks, Tick{
Value: max,
Label: vf(max),
})
} else {
ti... | go | func GenerateContinuousTicks(r Renderer, ra Range, isVertical bool, style Style, vf ValueFormatter) []Tick {
if vf == nil {
vf = FloatValueFormatter
}
var ticks []Tick
min, max := ra.GetMin(), ra.GetMax()
if ra.IsDescending() {
ticks = append(ticks, Tick{
Value: max,
Label: vf(max),
})
} else {
ti... | [
"func",
"GenerateContinuousTicks",
"(",
"r",
"Renderer",
",",
"ra",
"Range",
",",
"isVertical",
"bool",
",",
"style",
"Style",
",",
"vf",
"ValueFormatter",
")",
"[",
"]",
"Tick",
"{",
"if",
"vf",
"==",
"nil",
"{",
"vf",
"=",
"FloatValueFormatter",
"\n",
... | // GenerateContinuousTicks generates a set of ticks. | [
"GenerateContinuousTicks",
"generates",
"a",
"set",
"of",
"ticks",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/tick.go#L50-L117 |
25,562 | wcharczuk/go-chart | matrix/matrix.go | New | func New(rows, cols int, values ...float64) *Matrix {
if len(values) == 0 {
return &Matrix{
stride: cols,
epsilon: DefaultEpsilon,
elements: make([]float64, rows*cols),
}
}
elems := make([]float64, rows*cols)
copy(elems, values)
return &Matrix{
stride: cols,
epsilon: DefaultEpsilon,
elemen... | go | func New(rows, cols int, values ...float64) *Matrix {
if len(values) == 0 {
return &Matrix{
stride: cols,
epsilon: DefaultEpsilon,
elements: make([]float64, rows*cols),
}
}
elems := make([]float64, rows*cols)
copy(elems, values)
return &Matrix{
stride: cols,
epsilon: DefaultEpsilon,
elemen... | [
"func",
"New",
"(",
"rows",
",",
"cols",
"int",
",",
"values",
"...",
"float64",
")",
"*",
"Matrix",
"{",
"if",
"len",
"(",
"values",
")",
"==",
"0",
"{",
"return",
"&",
"Matrix",
"{",
"stride",
":",
"cols",
",",
"epsilon",
":",
"DefaultEpsilon",
"... | // New returns a new matrix. | [
"New",
"returns",
"a",
"new",
"matrix",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L24-L39 |
25,563 | wcharczuk/go-chart | matrix/matrix.go | Identity | func Identity(order int) *Matrix {
m := New(order, order)
for i := 0; i < order; i++ {
m.Set(i, i, 1)
}
return m
} | go | func Identity(order int) *Matrix {
m := New(order, order)
for i := 0; i < order; i++ {
m.Set(i, i, 1)
}
return m
} | [
"func",
"Identity",
"(",
"order",
"int",
")",
"*",
"Matrix",
"{",
"m",
":=",
"New",
"(",
"order",
",",
"order",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"order",
";",
"i",
"++",
"{",
"m",
".",
"Set",
"(",
"i",
",",
"i",
",",
"1",
... | // Identity returns the identity matrix of a given order. | [
"Identity",
"returns",
"the",
"identity",
"matrix",
"of",
"a",
"given",
"order",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L42-L48 |
25,564 | wcharczuk/go-chart | matrix/matrix.go | Ones | func Ones(rows, cols int) *Matrix {
ones := make([]float64, rows*cols)
for i := 0; i < (rows * cols); i++ {
ones[i] = 1
}
return &Matrix{
stride: cols,
epsilon: DefaultEpsilon,
elements: ones,
}
} | go | func Ones(rows, cols int) *Matrix {
ones := make([]float64, rows*cols)
for i := 0; i < (rows * cols); i++ {
ones[i] = 1
}
return &Matrix{
stride: cols,
epsilon: DefaultEpsilon,
elements: ones,
}
} | [
"func",
"Ones",
"(",
"rows",
",",
"cols",
"int",
")",
"*",
"Matrix",
"{",
"ones",
":=",
"make",
"(",
"[",
"]",
"float64",
",",
"rows",
"*",
"cols",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"(",
"rows",
"*",
"cols",
")",
";",
"i",
"+... | // Ones returns an matrix of ones. | [
"Ones",
"returns",
"an",
"matrix",
"of",
"ones",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L56-L67 |
25,565 | wcharczuk/go-chart | matrix/matrix.go | Eye | func Eye(n int) *Matrix {
m := Zero(n, n)
for i := 0; i < len(m.elements); i += n + 1 {
m.elements[i] = 1
}
return m
} | go | func Eye(n int) *Matrix {
m := Zero(n, n)
for i := 0; i < len(m.elements); i += n + 1 {
m.elements[i] = 1
}
return m
} | [
"func",
"Eye",
"(",
"n",
"int",
")",
"*",
"Matrix",
"{",
"m",
":=",
"Zero",
"(",
"n",
",",
"n",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"m",
".",
"elements",
")",
";",
"i",
"+=",
"n",
"+",
"1",
"{",
"m",
".",
"eleme... | // Eye returns the eye matrix. | [
"Eye",
"returns",
"the",
"eye",
"matrix",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L70-L76 |
25,566 | wcharczuk/go-chart | matrix/matrix.go | NewFromArrays | func NewFromArrays(a [][]float64) *Matrix {
rows := len(a)
if rows == 0 {
return nil
}
cols := len(a[0])
m := New(rows, cols)
for row := 0; row < rows; row++ {
for col := 0; col < cols; col++ {
m.Set(row, col, a[row][col])
}
}
return m
} | go | func NewFromArrays(a [][]float64) *Matrix {
rows := len(a)
if rows == 0 {
return nil
}
cols := len(a[0])
m := New(rows, cols)
for row := 0; row < rows; row++ {
for col := 0; col < cols; col++ {
m.Set(row, col, a[row][col])
}
}
return m
} | [
"func",
"NewFromArrays",
"(",
"a",
"[",
"]",
"[",
"]",
"float64",
")",
"*",
"Matrix",
"{",
"rows",
":=",
"len",
"(",
"a",
")",
"\n",
"if",
"rows",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"cols",
":=",
"len",
"(",
"a",
"[",
"0",
"]",... | // NewFromArrays creates a matrix from a jagged array set. | [
"NewFromArrays",
"creates",
"a",
"matrix",
"from",
"a",
"jagged",
"array",
"set",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L79-L92 |
25,567 | wcharczuk/go-chart | matrix/matrix.go | String | func (m *Matrix) String() string {
buffer := bytes.NewBuffer(nil)
rows, cols := m.Size()
for row := 0; row < rows; row++ {
for col := 0; col < cols; col++ {
buffer.WriteString(f64s(m.Get(row, col)))
buffer.WriteRune(' ')
}
buffer.WriteRune('\n')
}
return buffer.String()
} | go | func (m *Matrix) String() string {
buffer := bytes.NewBuffer(nil)
rows, cols := m.Size()
for row := 0; row < rows; row++ {
for col := 0; col < cols; col++ {
buffer.WriteString(f64s(m.Get(row, col)))
buffer.WriteRune(' ')
}
buffer.WriteRune('\n')
}
return buffer.String()
} | [
"func",
"(",
"m",
"*",
"Matrix",
")",
"String",
"(",
")",
"string",
"{",
"buffer",
":=",
"bytes",
".",
"NewBuffer",
"(",
"nil",
")",
"\n",
"rows",
",",
"cols",
":=",
"m",
".",
"Size",
"(",
")",
"\n\n",
"for",
"row",
":=",
"0",
";",
"row",
"<",
... | // String returns a string representation of the matrix. | [
"String",
"returns",
"a",
"string",
"representation",
"of",
"the",
"matrix",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L102-L114 |
25,568 | wcharczuk/go-chart | matrix/matrix.go | WithEpsilon | func (m *Matrix) WithEpsilon(epsilon float64) *Matrix {
m.epsilon = epsilon
return m
} | go | func (m *Matrix) WithEpsilon(epsilon float64) *Matrix {
m.epsilon = epsilon
return m
} | [
"func",
"(",
"m",
"*",
"Matrix",
")",
"WithEpsilon",
"(",
"epsilon",
"float64",
")",
"*",
"Matrix",
"{",
"m",
".",
"epsilon",
"=",
"epsilon",
"\n",
"return",
"m",
"\n",
"}"
] | // WithEpsilon sets the epsilon on the matrix and returns a reference to the matrix. | [
"WithEpsilon",
"sets",
"the",
"epsilon",
"on",
"the",
"matrix",
"and",
"returns",
"a",
"reference",
"to",
"the",
"matrix",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L122-L125 |
25,569 | wcharczuk/go-chart | matrix/matrix.go | Each | func (m *Matrix) Each(action func(row, col int, value float64)) {
rows, cols := m.Size()
for row := 0; row < rows; row++ {
for col := 0; col < cols; col++ {
action(row, col, m.Get(row, col))
}
}
} | go | func (m *Matrix) Each(action func(row, col int, value float64)) {
rows, cols := m.Size()
for row := 0; row < rows; row++ {
for col := 0; col < cols; col++ {
action(row, col, m.Get(row, col))
}
}
} | [
"func",
"(",
"m",
"*",
"Matrix",
")",
"Each",
"(",
"action",
"func",
"(",
"row",
",",
"col",
"int",
",",
"value",
"float64",
")",
")",
"{",
"rows",
",",
"cols",
":=",
"m",
".",
"Size",
"(",
")",
"\n",
"for",
"row",
":=",
"0",
";",
"row",
"<",... | // Each applies the action to each element of the matrix in
// rows => cols order. | [
"Each",
"applies",
"the",
"action",
"to",
"each",
"element",
"of",
"the",
"matrix",
"in",
"rows",
"=",
">",
"cols",
"order",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L129-L136 |
25,570 | wcharczuk/go-chart | matrix/matrix.go | Round | func (m *Matrix) Round() *Matrix {
rows, cols := m.Size()
for row := 0; row < rows; row++ {
for col := 0; col < cols; col++ {
m.Set(row, col, roundToEpsilon(m.Get(row, col), m.epsilon))
}
}
return m
} | go | func (m *Matrix) Round() *Matrix {
rows, cols := m.Size()
for row := 0; row < rows; row++ {
for col := 0; col < cols; col++ {
m.Set(row, col, roundToEpsilon(m.Get(row, col), m.epsilon))
}
}
return m
} | [
"func",
"(",
"m",
"*",
"Matrix",
")",
"Round",
"(",
")",
"*",
"Matrix",
"{",
"rows",
",",
"cols",
":=",
"m",
".",
"Size",
"(",
")",
"\n",
"for",
"row",
":=",
"0",
";",
"row",
"<",
"rows",
";",
"row",
"++",
"{",
"for",
"col",
":=",
"0",
";",... | // Round rounds all the values in a matrix to it epsilon,
// returning a reference to the original | [
"Round",
"rounds",
"all",
"the",
"values",
"in",
"a",
"matrix",
"to",
"it",
"epsilon",
"returning",
"a",
"reference",
"to",
"the",
"original"
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L140-L148 |
25,571 | wcharczuk/go-chart | matrix/matrix.go | Arrays | func (m *Matrix) Arrays() [][]float64 {
rows, cols := m.Size()
a := make([][]float64, rows)
for row := 0; row < rows; row++ {
a[row] = make([]float64, cols)
for col := 0; col < cols; col++ {
a[row][col] = m.Get(row, col)
}
}
return a
} | go | func (m *Matrix) Arrays() [][]float64 {
rows, cols := m.Size()
a := make([][]float64, rows)
for row := 0; row < rows; row++ {
a[row] = make([]float64, cols)
for col := 0; col < cols; col++ {
a[row][col] = m.Get(row, col)
}
}
return a
} | [
"func",
"(",
"m",
"*",
"Matrix",
")",
"Arrays",
"(",
")",
"[",
"]",
"[",
"]",
"float64",
"{",
"rows",
",",
"cols",
":=",
"m",
".",
"Size",
"(",
")",
"\n",
"a",
":=",
"make",
"(",
"[",
"]",
"[",
"]",
"float64",
",",
"rows",
")",
"\n\n",
"for... | // Arrays returns the matrix as a two dimensional jagged array. | [
"Arrays",
"returns",
"the",
"matrix",
"as",
"a",
"two",
"dimensional",
"jagged",
"array",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L151-L163 |
25,572 | wcharczuk/go-chart | matrix/matrix.go | Size | func (m *Matrix) Size() (rows, cols int) {
rows = len(m.elements) / m.stride
cols = m.stride
return
} | go | func (m *Matrix) Size() (rows, cols int) {
rows = len(m.elements) / m.stride
cols = m.stride
return
} | [
"func",
"(",
"m",
"*",
"Matrix",
")",
"Size",
"(",
")",
"(",
"rows",
",",
"cols",
"int",
")",
"{",
"rows",
"=",
"len",
"(",
"m",
".",
"elements",
")",
"/",
"m",
".",
"stride",
"\n",
"cols",
"=",
"m",
".",
"stride",
"\n",
"return",
"\n",
"}"
] | // Size returns the dimensions of the matrix. | [
"Size",
"returns",
"the",
"dimensions",
"of",
"the",
"matrix",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L166-L170 |
25,573 | wcharczuk/go-chart | matrix/matrix.go | IsSquare | func (m *Matrix) IsSquare() bool {
return m.stride == (len(m.elements) / m.stride)
} | go | func (m *Matrix) IsSquare() bool {
return m.stride == (len(m.elements) / m.stride)
} | [
"func",
"(",
"m",
"*",
"Matrix",
")",
"IsSquare",
"(",
")",
"bool",
"{",
"return",
"m",
".",
"stride",
"==",
"(",
"len",
"(",
"m",
".",
"elements",
")",
"/",
"m",
".",
"stride",
")",
"\n",
"}"
] | // IsSquare returns if the row count is equal to the column count. | [
"IsSquare",
"returns",
"if",
"the",
"row",
"count",
"is",
"equal",
"to",
"the",
"column",
"count",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L173-L175 |
25,574 | wcharczuk/go-chart | matrix/matrix.go | IsSymmetric | func (m *Matrix) IsSymmetric() bool {
rows, cols := m.Size()
if rows != cols {
return false
}
for i := 0; i < rows; i++ {
for j := 0; j < i; j++ {
if m.Get(i, j) != m.Get(j, i) {
return false
}
}
}
return true
} | go | func (m *Matrix) IsSymmetric() bool {
rows, cols := m.Size()
if rows != cols {
return false
}
for i := 0; i < rows; i++ {
for j := 0; j < i; j++ {
if m.Get(i, j) != m.Get(j, i) {
return false
}
}
}
return true
} | [
"func",
"(",
"m",
"*",
"Matrix",
")",
"IsSymmetric",
"(",
")",
"bool",
"{",
"rows",
",",
"cols",
":=",
"m",
".",
"Size",
"(",
")",
"\n\n",
"if",
"rows",
"!=",
"cols",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"for",
"i",
":=",
"0",
";",
"i",
... | // IsSymmetric returns if the matrix is symmetric about its diagonal. | [
"IsSymmetric",
"returns",
"if",
"the",
"matrix",
"is",
"symmetric",
"about",
"its",
"diagonal",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L178-L193 |
25,575 | wcharczuk/go-chart | matrix/matrix.go | Get | func (m *Matrix) Get(row, col int) float64 {
index := (m.stride * row) + col
return m.elements[index]
} | go | func (m *Matrix) Get(row, col int) float64 {
index := (m.stride * row) + col
return m.elements[index]
} | [
"func",
"(",
"m",
"*",
"Matrix",
")",
"Get",
"(",
"row",
",",
"col",
"int",
")",
"float64",
"{",
"index",
":=",
"(",
"m",
".",
"stride",
"*",
"row",
")",
"+",
"col",
"\n",
"return",
"m",
".",
"elements",
"[",
"index",
"]",
"\n",
"}"
] | // Get returns the element at the given row, col. | [
"Get",
"returns",
"the",
"element",
"at",
"the",
"given",
"row",
"col",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L196-L199 |
25,576 | wcharczuk/go-chart | matrix/matrix.go | Set | func (m *Matrix) Set(row, col int, val float64) {
index := (m.stride * row) + col
m.elements[index] = val
} | go | func (m *Matrix) Set(row, col int, val float64) {
index := (m.stride * row) + col
m.elements[index] = val
} | [
"func",
"(",
"m",
"*",
"Matrix",
")",
"Set",
"(",
"row",
",",
"col",
"int",
",",
"val",
"float64",
")",
"{",
"index",
":=",
"(",
"m",
".",
"stride",
"*",
"row",
")",
"+",
"col",
"\n",
"m",
".",
"elements",
"[",
"index",
"]",
"=",
"val",
"\n",... | // Set sets a value. | [
"Set",
"sets",
"a",
"value",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L202-L205 |
25,577 | wcharczuk/go-chart | matrix/matrix.go | Col | func (m *Matrix) Col(col int) Vector {
rows, _ := m.Size()
values := make([]float64, rows)
for row := 0; row < rows; row++ {
values[row] = m.Get(row, col)
}
return Vector(values)
} | go | func (m *Matrix) Col(col int) Vector {
rows, _ := m.Size()
values := make([]float64, rows)
for row := 0; row < rows; row++ {
values[row] = m.Get(row, col)
}
return Vector(values)
} | [
"func",
"(",
"m",
"*",
"Matrix",
")",
"Col",
"(",
"col",
"int",
")",
"Vector",
"{",
"rows",
",",
"_",
":=",
"m",
".",
"Size",
"(",
")",
"\n",
"values",
":=",
"make",
"(",
"[",
"]",
"float64",
",",
"rows",
")",
"\n",
"for",
"row",
":=",
"0",
... | // Col returns a column of the matrix as a vector. | [
"Col",
"returns",
"a",
"column",
"of",
"the",
"matrix",
"as",
"a",
"vector",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L208-L215 |
25,578 | wcharczuk/go-chart | matrix/matrix.go | Row | func (m *Matrix) Row(row int) Vector {
_, cols := m.Size()
values := make([]float64, cols)
for col := 0; col < cols; col++ {
values[col] = m.Get(row, col)
}
return Vector(values)
} | go | func (m *Matrix) Row(row int) Vector {
_, cols := m.Size()
values := make([]float64, cols)
for col := 0; col < cols; col++ {
values[col] = m.Get(row, col)
}
return Vector(values)
} | [
"func",
"(",
"m",
"*",
"Matrix",
")",
"Row",
"(",
"row",
"int",
")",
"Vector",
"{",
"_",
",",
"cols",
":=",
"m",
".",
"Size",
"(",
")",
"\n",
"values",
":=",
"make",
"(",
"[",
"]",
"float64",
",",
"cols",
")",
"\n",
"for",
"col",
":=",
"0",
... | // Row returns a row of the matrix as a vector. | [
"Row",
"returns",
"a",
"row",
"of",
"the",
"matrix",
"as",
"a",
"vector",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L218-L225 |
25,579 | wcharczuk/go-chart | matrix/matrix.go | SubMatrix | func (m *Matrix) SubMatrix(i, j, rows, cols int) *Matrix {
return &Matrix{
elements: m.elements[i*m.stride+j : i*m.stride+j+(rows-1)*m.stride+cols],
stride: m.stride,
epsilon: m.epsilon,
}
} | go | func (m *Matrix) SubMatrix(i, j, rows, cols int) *Matrix {
return &Matrix{
elements: m.elements[i*m.stride+j : i*m.stride+j+(rows-1)*m.stride+cols],
stride: m.stride,
epsilon: m.epsilon,
}
} | [
"func",
"(",
"m",
"*",
"Matrix",
")",
"SubMatrix",
"(",
"i",
",",
"j",
",",
"rows",
",",
"cols",
"int",
")",
"*",
"Matrix",
"{",
"return",
"&",
"Matrix",
"{",
"elements",
":",
"m",
".",
"elements",
"[",
"i",
"*",
"m",
".",
"stride",
"+",
"j",
... | // SubMatrix returns a sub matrix from a given outer matrix. | [
"SubMatrix",
"returns",
"a",
"sub",
"matrix",
"from",
"a",
"given",
"outer",
"matrix",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L228-L234 |
25,580 | wcharczuk/go-chart | matrix/matrix.go | ScaleRow | func (m *Matrix) ScaleRow(row int, scale float64) {
startIndex := row * m.stride
for i := startIndex; i < m.stride; i++ {
m.elements[i] = m.elements[i] * scale
}
} | go | func (m *Matrix) ScaleRow(row int, scale float64) {
startIndex := row * m.stride
for i := startIndex; i < m.stride; i++ {
m.elements[i] = m.elements[i] * scale
}
} | [
"func",
"(",
"m",
"*",
"Matrix",
")",
"ScaleRow",
"(",
"row",
"int",
",",
"scale",
"float64",
")",
"{",
"startIndex",
":=",
"row",
"*",
"m",
".",
"stride",
"\n",
"for",
"i",
":=",
"startIndex",
";",
"i",
"<",
"m",
".",
"stride",
";",
"i",
"++",
... | // ScaleRow applies a scale to an entire row. | [
"ScaleRow",
"applies",
"a",
"scale",
"to",
"an",
"entire",
"row",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L237-L242 |
25,581 | wcharczuk/go-chart | matrix/matrix.go | SwapRows | func (m *Matrix) SwapRows(i, j int) {
var vi, vj float64
for col := 0; col < m.stride; col++ {
vi = m.Get(i, col)
vj = m.Get(j, col)
m.Set(i, col, vj)
m.Set(j, col, vi)
}
} | go | func (m *Matrix) SwapRows(i, j int) {
var vi, vj float64
for col := 0; col < m.stride; col++ {
vi = m.Get(i, col)
vj = m.Get(j, col)
m.Set(i, col, vj)
m.Set(j, col, vi)
}
} | [
"func",
"(",
"m",
"*",
"Matrix",
")",
"SwapRows",
"(",
"i",
",",
"j",
"int",
")",
"{",
"var",
"vi",
",",
"vj",
"float64",
"\n",
"for",
"col",
":=",
"0",
";",
"col",
"<",
"m",
".",
"stride",
";",
"col",
"++",
"{",
"vi",
"=",
"m",
".",
"Get",... | // SwapRows swaps a row in the matrix in place. | [
"SwapRows",
"swaps",
"a",
"row",
"in",
"the",
"matrix",
"in",
"place",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L255-L263 |
25,582 | wcharczuk/go-chart | matrix/matrix.go | Augment | func (m *Matrix) Augment(m2 *Matrix) (*Matrix, error) {
mr, mc := m.Size()
m2r, m2c := m2.Size()
if mr != m2r {
return nil, ErrDimensionMismatch
}
m3 := Zero(mr, mc+m2c)
for row := 0; row < mr; row++ {
for col := 0; col < mc; col++ {
m3.Set(row, col, m.Get(row, col))
}
for col := 0; col < m2c; col++ {... | go | func (m *Matrix) Augment(m2 *Matrix) (*Matrix, error) {
mr, mc := m.Size()
m2r, m2c := m2.Size()
if mr != m2r {
return nil, ErrDimensionMismatch
}
m3 := Zero(mr, mc+m2c)
for row := 0; row < mr; row++ {
for col := 0; col < mc; col++ {
m3.Set(row, col, m.Get(row, col))
}
for col := 0; col < m2c; col++ {... | [
"func",
"(",
"m",
"*",
"Matrix",
")",
"Augment",
"(",
"m2",
"*",
"Matrix",
")",
"(",
"*",
"Matrix",
",",
"error",
")",
"{",
"mr",
",",
"mc",
":=",
"m",
".",
"Size",
"(",
")",
"\n",
"m2r",
",",
"m2c",
":=",
"m2",
".",
"Size",
"(",
")",
"\n",... | // Augment concatenates two matrices about the horizontal. | [
"Augment",
"concatenates",
"two",
"matrices",
"about",
"the",
"horizontal",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L266-L283 |
25,583 | wcharczuk/go-chart | matrix/matrix.go | Copy | func (m *Matrix) Copy() *Matrix {
m2 := &Matrix{stride: m.stride, epsilon: m.epsilon, elements: make([]float64, len(m.elements))}
copy(m2.elements, m.elements)
return m2
} | go | func (m *Matrix) Copy() *Matrix {
m2 := &Matrix{stride: m.stride, epsilon: m.epsilon, elements: make([]float64, len(m.elements))}
copy(m2.elements, m.elements)
return m2
} | [
"func",
"(",
"m",
"*",
"Matrix",
")",
"Copy",
"(",
")",
"*",
"Matrix",
"{",
"m2",
":=",
"&",
"Matrix",
"{",
"stride",
":",
"m",
".",
"stride",
",",
"epsilon",
":",
"m",
".",
"epsilon",
",",
"elements",
":",
"make",
"(",
"[",
"]",
"float64",
","... | // Copy returns a duplicate of a given matrix. | [
"Copy",
"returns",
"a",
"duplicate",
"of",
"a",
"given",
"matrix",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L286-L290 |
25,584 | wcharczuk/go-chart | matrix/matrix.go | DiagonalVector | func (m *Matrix) DiagonalVector() Vector {
rows, cols := m.Size()
rank := minInt(rows, cols)
values := make([]float64, rank)
for index := 0; index < rank; index++ {
values[index] = m.Get(index, index)
}
return Vector(values)
} | go | func (m *Matrix) DiagonalVector() Vector {
rows, cols := m.Size()
rank := minInt(rows, cols)
values := make([]float64, rank)
for index := 0; index < rank; index++ {
values[index] = m.Get(index, index)
}
return Vector(values)
} | [
"func",
"(",
"m",
"*",
"Matrix",
")",
"DiagonalVector",
"(",
")",
"Vector",
"{",
"rows",
",",
"cols",
":=",
"m",
".",
"Size",
"(",
")",
"\n",
"rank",
":=",
"minInt",
"(",
"rows",
",",
"cols",
")",
"\n",
"values",
":=",
"make",
"(",
"[",
"]",
"f... | // DiagonalVector returns a vector from the diagonal of a matrix. | [
"DiagonalVector",
"returns",
"a",
"vector",
"from",
"the",
"diagonal",
"of",
"a",
"matrix",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L293-L302 |
25,585 | wcharczuk/go-chart | matrix/matrix.go | Diagonal | func (m *Matrix) Diagonal() *Matrix {
rows, cols := m.Size()
rank := minInt(rows, cols)
m2 := New(rank, rank)
for index := 0; index < rank; index++ {
m2.Set(index, index, m.Get(index, index))
}
return m2
} | go | func (m *Matrix) Diagonal() *Matrix {
rows, cols := m.Size()
rank := minInt(rows, cols)
m2 := New(rank, rank)
for index := 0; index < rank; index++ {
m2.Set(index, index, m.Get(index, index))
}
return m2
} | [
"func",
"(",
"m",
"*",
"Matrix",
")",
"Diagonal",
"(",
")",
"*",
"Matrix",
"{",
"rows",
",",
"cols",
":=",
"m",
".",
"Size",
"(",
")",
"\n",
"rank",
":=",
"minInt",
"(",
"rows",
",",
"cols",
")",
"\n",
"m2",
":=",
"New",
"(",
"rank",
",",
"ra... | // Diagonal returns a matrix from the diagonal of a matrix. | [
"Diagonal",
"returns",
"a",
"matrix",
"from",
"the",
"diagonal",
"of",
"a",
"matrix",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L305-L314 |
25,586 | 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 ... | 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 ... | [
"func",
"(",
"m",
"*",
"Matrix",
")",
"Equals",
"(",
"other",
"*",
"Matrix",
")",
"bool",
"{",
"if",
"other",
"==",
"nil",
"&&",
"m",
"!=",
"nil",
"{",
"return",
"false",
"\n",
"}",
"else",
"if",
"other",
"==",
"nil",
"{",
"return",
"true",
"\n",... | // Equals returns if a matrix equals another matrix. | [
"Equals",
"returns",
"if",
"a",
"matrix",
"equals",
"another",
"matrix",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L317-L341 |
25,587 | wcharczuk/go-chart | matrix/matrix.go | L | func (m *Matrix) L() *Matrix {
rows, cols := m.Size()
m2 := New(rows, cols)
for row := 0; row < rows; row++ {
for col := row; col < cols; col++ {
m2.Set(row, col, m.Get(row, col))
}
}
return m2
} | go | func (m *Matrix) L() *Matrix {
rows, cols := m.Size()
m2 := New(rows, cols)
for row := 0; row < rows; row++ {
for col := row; col < cols; col++ {
m2.Set(row, col, m.Get(row, col))
}
}
return m2
} | [
"func",
"(",
"m",
"*",
"Matrix",
")",
"L",
"(",
")",
"*",
"Matrix",
"{",
"rows",
",",
"cols",
":=",
"m",
".",
"Size",
"(",
")",
"\n",
"m2",
":=",
"New",
"(",
"rows",
",",
"cols",
")",
"\n",
"for",
"row",
":=",
"0",
";",
"row",
"<",
"rows",
... | // L returns the matrix with zeros below the diagonal. | [
"L",
"returns",
"the",
"matrix",
"with",
"zeros",
"below",
"the",
"diagonal",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L344-L353 |
25,588 | 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 +... | 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 +... | [
"func",
"(",
"m",
"*",
"Matrix",
")",
"Multiply",
"(",
"m2",
"*",
"Matrix",
")",
"(",
"m3",
"*",
"Matrix",
",",
"err",
"error",
")",
"{",
"if",
"m",
".",
"stride",
"*",
"m2",
".",
"stride",
"!=",
"len",
"(",
"m2",
".",
"elements",
")",
"{",
"... | // math operations
// Multiply multiplies two matrices. | [
"math",
"operations",
"Multiply",
"multiplies",
"two",
"matrices",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L371-L387 |
25,589 | 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
... | 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
... | [
"func",
"(",
"m",
"*",
"Matrix",
")",
"Pivotize",
"(",
")",
"*",
"Matrix",
"{",
"pv",
":=",
"make",
"(",
"[",
"]",
"int",
",",
"m",
".",
"stride",
")",
"\n\n",
"for",
"i",
":=",
"range",
"pv",
"{",
"pv",
"[",
"i",
"]",
"=",
"i",
"\n",
"}",
... | // Pivotize does something i'm not sure what. | [
"Pivotize",
"does",
"something",
"i",
"m",
"not",
"sure",
"what",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L390-L417 |
25,590 | 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 : (... | 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 : (... | [
"func",
"(",
"m",
"*",
"Matrix",
")",
"Times",
"(",
"m2",
"*",
"Matrix",
")",
"(",
"*",
"Matrix",
",",
"error",
")",
"{",
"mr",
",",
"mc",
":=",
"m",
".",
"Size",
"(",
")",
"\n",
"m2r",
",",
"m2c",
":=",
"m2",
".",
"Size",
"(",
")",
"\n\n",... | // Times returns the product of a matrix and another. | [
"Times",
"returns",
"the",
"product",
"of",
"a",
"matrix",
"and",
"another",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L420-L441 |
25,591 | 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.eleme... | 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.eleme... | [
"func",
"(",
"m",
"*",
"Matrix",
")",
"LU",
"(",
")",
"(",
"l",
",",
"u",
",",
"p",
"*",
"Matrix",
")",
"{",
"l",
"=",
"Zero",
"(",
"m",
".",
"stride",
",",
"m",
".",
"stride",
")",
"\n",
"u",
"=",
"Zero",
"(",
"m",
".",
"stride",
",",
... | // Decompositions
// LU performs the LU decomposition. | [
"Decompositions",
"LU",
"performs",
"the",
"LU",
"decomposition",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L446-L473 |
25,592 | wcharczuk/go-chart | matrix/matrix.go | Transpose | func (m *Matrix) Transpose() *Matrix {
rows, cols := m.Size()
m2 := Zero(cols, rows)
for i := 0; i < rows; i++ {
for j := 0; j < cols; j++ {
m2.Set(j, i, m.Get(i, j))
}
}
return m2
} | go | func (m *Matrix) Transpose() *Matrix {
rows, cols := m.Size()
m2 := Zero(cols, rows)
for i := 0; i < rows; i++ {
for j := 0; j < cols; j++ {
m2.Set(j, i, m.Get(i, j))
}
}
return m2
} | [
"func",
"(",
"m",
"*",
"Matrix",
")",
"Transpose",
"(",
")",
"*",
"Matrix",
"{",
"rows",
",",
"cols",
":=",
"m",
".",
"Size",
"(",
")",
"\n",
"m2",
":=",
"Zero",
"(",
"cols",
",",
"rows",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"ro... | // Transpose flips a matrix about its diagonal, returning a new copy. | [
"Transpose",
"flips",
"a",
"matrix",
"about",
"its",
"diagonal",
"returning",
"a",
"new",
"copy",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/matrix/matrix.go#L550-L559 |
25,593 | wcharczuk/go-chart | value.go | Values | func (vs Values) Values() []float64 {
values := make([]float64, len(vs))
for index, v := range vs {
values[index] = v.Value
}
return values
} | go | func (vs Values) Values() []float64 {
values := make([]float64, len(vs))
for index, v := range vs {
values[index] = v.Value
}
return values
} | [
"func",
"(",
"vs",
"Values",
")",
"Values",
"(",
")",
"[",
"]",
"float64",
"{",
"values",
":=",
"make",
"(",
"[",
"]",
"float64",
",",
"len",
"(",
"vs",
")",
")",
"\n",
"for",
"index",
",",
"v",
":=",
"range",
"vs",
"{",
"values",
"[",
"index",... | // Values returns the values. | [
"Values",
"returns",
"the",
"values",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/value.go#L16-L22 |
25,594 | 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 o... | 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 o... | [
"func",
"(",
"vs",
"Values",
")",
"Normalize",
"(",
")",
"[",
"]",
"Value",
"{",
"var",
"output",
"[",
"]",
"Value",
"\n",
"var",
"total",
"float64",
"\n\n",
"for",
"_",
",",
"v",
":=",
"range",
"vs",
"{",
"total",
"+=",
"v",
".",
"Value",
"\n",
... | // Normalize returns the values normalized. | [
"Normalize",
"returns",
"the",
"values",
"normalized",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/value.go#L30-L48 |
25,595 | 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)).Fo... | 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)).Fo... | [
"func",
"formatTime",
"(",
"v",
"interface",
"{",
"}",
",",
"dateFormat",
"string",
")",
"string",
"{",
"if",
"typed",
",",
"isTyped",
":=",
"v",
".",
"(",
"time",
".",
"Time",
")",
";",
"isTyped",
"{",
"return",
"typed",
".",
"Format",
"(",
"dateFor... | // TimeValueFormatterWithFormat is a ValueFormatter for timestamps with a given format. | [
"TimeValueFormatterWithFormat",
"is",
"a",
"ValueFormatter",
"for",
"timestamps",
"with",
"a",
"given",
"format",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/value_formatter.go#L40-L51 |
25,596 | wcharczuk/go-chart | value_formatter.go | IntValueFormatter | func IntValueFormatter(v interface{}) string {
switch v.(type) {
case int:
return strconv.Itoa(v.(int))
case int64:
return strconv.FormatInt(v.(int64), 10)
case float32:
return strconv.FormatInt(int64(v.(float32)), 10)
case float64:
return strconv.FormatInt(int64(v.(float64)), 10)
default:
return ""
}
... | go | func IntValueFormatter(v interface{}) string {
switch v.(type) {
case int:
return strconv.Itoa(v.(int))
case int64:
return strconv.FormatInt(v.(int64), 10)
case float32:
return strconv.FormatInt(int64(v.(float32)), 10)
case float64:
return strconv.FormatInt(int64(v.(float64)), 10)
default:
return ""
}
... | [
"func",
"IntValueFormatter",
"(",
"v",
"interface",
"{",
"}",
")",
"string",
"{",
"switch",
"v",
".",
"(",
"type",
")",
"{",
"case",
"int",
":",
"return",
"strconv",
".",
"Itoa",
"(",
"v",
".",
"(",
"int",
")",
")",
"\n",
"case",
"int64",
":",
"r... | // IntValueFormatter is a ValueFormatter for float64. | [
"IntValueFormatter",
"is",
"a",
"ValueFormatter",
"for",
"float64",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/value_formatter.go#L54-L67 |
25,597 | 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 {
retu... | 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 {
retu... | [
"func",
"FloatValueFormatterWithFormat",
"(",
"v",
"interface",
"{",
"}",
",",
"floatFormat",
"string",
")",
"string",
"{",
"if",
"typed",
",",
"isTyped",
":=",
"v",
".",
"(",
"int",
")",
";",
"isTyped",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"floatF... | // FloatValueFormatterWithFormat is a ValueFormatter for float64 with a given format. | [
"FloatValueFormatterWithFormat",
"is",
"a",
"ValueFormatter",
"for",
"float64",
"with",
"a",
"given",
"format",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/value_formatter.go#L84-L98 |
25,598 | wcharczuk/go-chart | time_series.go | GetValues | func (ts TimeSeries) GetValues(index int) (x, y float64) {
x = util.Time.ToFloat64(ts.XValues[index])
y = ts.YValues[index]
return
} | go | func (ts TimeSeries) GetValues(index int) (x, y float64) {
x = util.Time.ToFloat64(ts.XValues[index])
y = ts.YValues[index]
return
} | [
"func",
"(",
"ts",
"TimeSeries",
")",
"GetValues",
"(",
"index",
"int",
")",
"(",
"x",
",",
"y",
"float64",
")",
"{",
"x",
"=",
"util",
".",
"Time",
".",
"ToFloat64",
"(",
"ts",
".",
"XValues",
"[",
"index",
"]",
")",
"\n",
"y",
"=",
"ts",
".",... | // GetValues gets x, y values at a given index. | [
"GetValues",
"gets",
"x",
"y",
"values",
"at",
"a",
"given",
"index",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/time_series.go#L45-L49 |
25,599 | wcharczuk/go-chart | time_series.go | GetFirstValues | func (ts TimeSeries) GetFirstValues() (x, y float64) {
x = util.Time.ToFloat64(ts.XValues[0])
y = ts.YValues[0]
return
} | go | func (ts TimeSeries) GetFirstValues() (x, y float64) {
x = util.Time.ToFloat64(ts.XValues[0])
y = ts.YValues[0]
return
} | [
"func",
"(",
"ts",
"TimeSeries",
")",
"GetFirstValues",
"(",
")",
"(",
"x",
",",
"y",
"float64",
")",
"{",
"x",
"=",
"util",
".",
"Time",
".",
"ToFloat64",
"(",
"ts",
".",
"XValues",
"[",
"0",
"]",
")",
"\n",
"y",
"=",
"ts",
".",
"YValues",
"["... | // GetFirstValues gets the first values. | [
"GetFirstValues",
"gets",
"the",
"first",
"values",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/time_series.go#L52-L56 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.