From e9579197a751394f54bf221c0213f603ff561b7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9F=A9=E6=8B=93?= Date: Thu, 5 Jan 2017 23:45:31 +0800 Subject: [PATCH 1/4] Update linechart.go --- linechart.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/linechart.go b/linechart.go index 1886114..7c720de 100644 --- a/linechart.go +++ b/linechart.go @@ -135,6 +135,7 @@ func (lc *LineChart) renderBraille() Buffer { func (lc *LineChart) renderDot() Buffer { buf := NewBuffer() + oy := -1 for i := 0; i < len(lc.Data) && i < lc.axisXWidth; i++ { c := Cell{ Ch: lc.DotStyle, @@ -143,6 +144,17 @@ func (lc *LineChart) renderDot() Buffer { } 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) + + 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) } From ee9a03159593b7362c5ec7d4fb034be6bdad4e74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9F=A9=E6=8B=93?= Date: Thu, 5 Jan 2017 23:47:12 +0800 Subject: [PATCH 2/4] Update linechart.go --- linechart.go | 1 + 1 file changed, 1 insertion(+) diff --git a/linechart.go b/linechart.go index 7c720de..c833a6c 100644 --- a/linechart.go +++ b/linechart.go @@ -154,6 +154,7 @@ func (lc *LineChart) renderDot() Buffer { buf.Set(x, i, c) } } + oy = y buf.Set(x, y, c) } From f0de1c55061b64e394a54c4c496d6c80e7b390d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9F=A9=E6=8B=93?= Date: Fri, 6 Jan 2017 00:27:43 +0800 Subject: [PATCH 3/4] Update linechart.go --- linechart.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linechart.go b/linechart.go index c833a6c..bf6ee8b 100644 --- a/linechart.go +++ b/linechart.go @@ -145,12 +145,12 @@ func (lc *LineChart) renderDot() Buffer { 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) - if oy != -1 { + if oy != -1 && oy != y{ u := 1 if oy > y { u = -1 } - for i := oy; i != y; i += u { + for i := oy + u; i != y; i += u { buf.Set(x, i, c) } } From 322b4a1dd44896b61591086c75ed33a29a05256e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9F=A9=E6=8B=93?= Date: Fri, 6 Jan 2017 01:13:08 +0800 Subject: [PATCH 4/4] Update linechart.go --- linechart.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/linechart.go b/linechart.go index bf6ee8b..3b731ff 100644 --- a/linechart.go +++ b/linechart.go @@ -151,7 +151,11 @@ func (lc *LineChart) renderDot() Buffer { u = -1 } for i := oy + u; i != y; i += u { - buf.Set(x, i, c) + dx := -1 + if u*(i-oy) >= u*(y-oy)/2 { + dx = 0 + } + buf.Set(x+dx, i, c) } } oy = y