Remove exponential notation formatting from termui. Fixes #35

pull/38/head
Miguel Mota 5 years ago
parent 599d2a226a
commit 0abaeb9e56
No known key found for this signature in database
GPG Key ID: 67EC1161588A00F9

@ -6,8 +6,8 @@ import (
"sync"
"time"
"github.com/gizak/termui"
"github.com/miguelmota/cointop/cointop/common/filecache"
"github.com/miguelmota/cointop/cointop/common/gizak/termui"
"github.com/miguelmota/cointop/cointop/common/timeutil"
)
@ -111,6 +111,9 @@ func (ct *Cointop) chartPoints(symbol string, name string) error {
if err != nil {
return nil
}
// NOTE: edit `termui.LineChart.shortenFloatVal(float64)` to not
// use exponential notation.
for i := range graphData.PriceUSD {
price := graphData.PriceUSD[i][1]
data = append(data, price)

@ -9,11 +9,11 @@ import (
"sync"
"time"
"github.com/gizak/termui"
"github.com/jroimartin/gocui"
"github.com/miguelmota/cointop/cointop/common/api"
"github.com/miguelmota/cointop/cointop/common/api/types"
"github.com/miguelmota/cointop/cointop/common/filecache"
"github.com/miguelmota/cointop/cointop/common/gizak/termui"
"github.com/miguelmota/cointop/cointop/common/table"
"github.com/patrickmn/go-cache"
log "github.com/sirupsen/logrus"

@ -158,9 +158,12 @@ func (s *Service) GetCoinGraphData(symbol, name string, start, end int64) (apity
if chart.Prices != nil {
for _, item := range *chart.Prices {
timestamp := float64(item[0])
price := float64(item[1])
priceUSD = append(priceUSD, []float64{
float64(item[0]),
float64(item[1]),
timestamp,
price,
})
}
}

@ -199,13 +199,13 @@ func (lc *LineChart) calcLabelX() {
func shortenFloatVal(x float64) string {
s := fmt.Sprintf("%.2f", x)
if len(s)-3 > 3 {
s = fmt.Sprintf("%.2e", x)
}
//if len(s)-3 > 3 {
//s = fmt.Sprintf("%.2e", x)
//}
if x < 0 {
s = fmt.Sprintf("%.2f", x)
}
//if x < 0 {
//s = fmt.Sprintf("%.2f", x)
//}
return s
}

@ -7,15 +7,15 @@ require (
github.com/gizak/termui v2.3.0+incompatible
github.com/google/pprof v0.0.0-20190502144155-8358a9778bd1 // indirect
github.com/jroimartin/gocui v0.4.0
github.com/maruel/panicparse v1.1.2-0.20180806203336-f20d4c4d746f // indirect
github.com/maruel/panicparse v1.1.2-0.20180806203336-f20d4c4d746f
github.com/mattn/go-colorable v0.1.1 // indirect
github.com/mattn/go-isatty v0.0.6 // indirect
github.com/mattn/go-runewidth v0.0.4 // indirect
github.com/mattn/go-runewidth v0.0.4
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
github.com/miguelmota/go-coinmarketcap v0.1.4
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/mitchellh/go-wordwrap v1.0.0
github.com/nsf/termbox v1.1.2 // indirect
github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d // indirect
github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/sirupsen/logrus v1.4.1
github.com/tomnomnom/xtermcolor v0.0.0-20160428124646-b78803f00a7e

Loading…
Cancel
Save