Update linechart.go

This commit is contained in:
韩拓 2017-01-05 23:45:31 +08:00 committed by GitHub
parent f63e0cdd3f
commit e9579197a7
1 changed files with 12 additions and 0 deletions

View File

@ -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)
} }