mirror of https://github.com/zieckey/gochart.git
Fix a bug : trim spaces of the data
This commit is contained in:
parent
35014aec6e
commit
7ac81fe784
|
@ -5,6 +5,7 @@ import (
|
||||||
"github.com/zieckey/goini"
|
"github.com/zieckey/goini"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
const DataPrefix = "Data|"
|
const DataPrefix = "Data|"
|
||||||
|
@ -50,6 +51,7 @@ func LookupChartFiles(dir string) ([]string, error) {
|
||||||
if ok, err := filepath.Match("*.chart", f.Name()); err != nil {
|
if ok, err := filepath.Match("*.chart", f.Name()); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if ok {
|
} else if ok {
|
||||||
|
log.Printf("Add chart file %v", path)
|
||||||
files = append(files, path)
|
files = append(files, path)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -26,9 +26,10 @@ func (c *SplineChart) Parse(ini *goini.INI) (map[string]string, error) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
dd := strings.Split(v, ", ")
|
dd := strings.Split(v, ",")
|
||||||
jd := make([]interface{}, 0)
|
jd := make([]interface{}, 0)
|
||||||
for _, d := range dd {
|
for _, d := range dd {
|
||||||
|
d = strings.TrimSpace(d)
|
||||||
val, err := strconv.ParseFloat(d, 64)
|
val, err := strconv.ParseFloat(d, 64)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
jd = append(jd, val)
|
jd = append(jd, val)
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
package: github.com/zieckey/gochart
|
||||||
|
import:
|
||||||
|
- package: github.com/bitly/go-simplejson
|
||||||
|
- package: github.com/zieckey/goini
|
Loading…
Reference in New Issue