Merge branch 'master' of github.com:wcharczuk/go-chart
This commit is contained in:
commit
44990c63ed
6 changed files with 25 additions and 22 deletions
BIN
.DS_Store
vendored
BIN
.DS_Store
vendored
Binary file not shown.
17
.gitignore
vendored
17
.gitignore
vendored
|
@ -1 +1,18 @@
|
|||
# Binaries for programs and plugins
|
||||
*.exe
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
|
||||
# Test binary, build with `go test -c`
|
||||
*.test
|
||||
|
||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||
*.out
|
||||
|
||||
# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
|
||||
.glide/
|
||||
|
||||
# Other
|
||||
.vscode
|
||||
.DS_Store
|
||||
|
|
6
chart.go
6
chart.go
|
@ -317,9 +317,6 @@ func (c Chart) checkRanges(xr, yr, yra Range) error {
|
|||
if math.IsNaN(yDelta) {
|
||||
return errors.New("nan y-range delta")
|
||||
}
|
||||
if yDelta == 0 {
|
||||
return errors.New("zero y-range delta")
|
||||
}
|
||||
|
||||
if c.hasSecondarySeries() {
|
||||
yraDelta := yra.GetDelta()
|
||||
|
@ -329,9 +326,6 @@ func (c Chart) checkRanges(xr, yr, yra Range) error {
|
|||
if math.IsNaN(yraDelta) {
|
||||
return errors.New("nan secondary y-range delta")
|
||||
}
|
||||
if yraDelta == 0 {
|
||||
return errors.New("zero secondary y-range delta")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -443,22 +443,6 @@ func TestChartCheckRanges(t *testing.T) {
|
|||
assert.Nil(c.checkRanges(xr, yr, yra))
|
||||
}
|
||||
|
||||
func TestChartCheckRangesFailure(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
c := Chart{
|
||||
Series: []Series{
|
||||
ContinuousSeries{
|
||||
XValues: []float64{1.0, 2.0},
|
||||
YValues: []float64{3.14, 3.14},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
xr, yr, yra := c.getRanges()
|
||||
assert.NotNil(c.checkRanges(xr, yr, yra))
|
||||
}
|
||||
|
||||
func TestChartCheckRangesWithRanges(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
|
|
|
@ -93,12 +93,18 @@ func (m mathUtil) GetRoundToForDelta(delta float64) float64 {
|
|||
|
||||
// RoundUp rounds up to a given roundTo value.
|
||||
func (m mathUtil) RoundUp(value, roundTo float64) float64 {
|
||||
if roundTo < 0.000000000000001 {
|
||||
return value
|
||||
}
|
||||
d1 := math.Ceil(value / roundTo)
|
||||
return d1 * roundTo
|
||||
}
|
||||
|
||||
// RoundDown rounds down to a given roundTo value.
|
||||
func (m mathUtil) RoundDown(value, roundTo float64) float64 {
|
||||
if roundTo < 0.000000000000001 {
|
||||
return value
|
||||
}
|
||||
d1 := math.Floor(value / roundTo)
|
||||
return d1 * roundTo
|
||||
}
|
||||
|
|
|
@ -78,6 +78,7 @@ func TestRoundUp(t *testing.T) {
|
|||
assert.Equal(0.5, Math.RoundUp(0.49, 0.1))
|
||||
assert.Equal(1.0, Math.RoundUp(0.51, 1.0))
|
||||
assert.Equal(0.4999, Math.RoundUp(0.49988, 0.0001))
|
||||
assert.Equal(0.123, Math.RoundUp(0.123, 0))
|
||||
}
|
||||
|
||||
func TestRoundDown(t *testing.T) {
|
||||
|
@ -85,6 +86,7 @@ func TestRoundDown(t *testing.T) {
|
|||
assert.Equal(0.5, Math.RoundDown(0.51, 0.1))
|
||||
assert.Equal(1.0, Math.RoundDown(1.01, 1.0))
|
||||
assert.Equal(0.5001, Math.RoundDown(0.50011, 0.0001))
|
||||
assert.Equal(0.123, Math.RoundDown(0.123, 0))
|
||||
}
|
||||
|
||||
func TestPercentDifference(t *testing.T) {
|
||||
|
|
Loading…
Reference in a new issue