mirror of https://github.com/gizak/termui.git
Update linechart.go
This commit is contained in:
parent
f63e0cdd3f
commit
e9579197a7
12
linechart.go
12
linechart.go
|
@ -135,6 +135,7 @@ func (lc *LineChart) renderBraille() Buffer {
|
||||||
|
|
||||||
func (lc *LineChart) renderDot() Buffer {
|
func (lc *LineChart) renderDot() Buffer {
|
||||||
buf := NewBuffer()
|
buf := NewBuffer()
|
||||||
|
oy := -1
|
||||||
for i := 0; i < len(lc.Data) && i < lc.axisXWidth; i++ {
|
for i := 0; i < len(lc.Data) && i < lc.axisXWidth; i++ {
|
||||||
c := Cell{
|
c := Cell{
|
||||||
Ch: lc.DotStyle,
|
Ch: lc.DotStyle,
|
||||||
|
@ -143,6 +144,17 @@ func (lc *LineChart) renderDot() Buffer {
|
||||||
}
|
}
|
||||||
x := lc.innerArea.Min.X + lc.labelYSpace + 1 + i
|
x := lc.innerArea.Min.X + lc.labelYSpace + 1 + i
|
||||||
y := lc.innerArea.Min.Y + lc.innerArea.Dy() - 3 - int((lc.Data[i]-lc.bottomValue)/lc.scale+0.5)
|
y := lc.innerArea.Min.Y + lc.innerArea.Dy() - 3 - int((lc.Data[i]-lc.bottomValue)/lc.scale+0.5)
|
||||||
|
|
||||||
|
if oy != -1 {
|
||||||
|
u := 1
|
||||||
|
if oy > y {
|
||||||
|
u = -1
|
||||||
|
}
|
||||||
|
for i := oy; i != y; i += u {
|
||||||
|
buf.Set(x, i, c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
buf.Set(x, y, c)
|
buf.Set(x, y, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue