introduces the Range interface (instead of a concrete type).
This commit is contained in:
parent
8af50213c3
commit
b0934ee2e3
27 changed files with 331 additions and 172 deletions
22
continuous_range_test.go
Normal file
22
continuous_range_test.go
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
package chart
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/blendlabs/go-assert"
|
||||
)
|
||||
|
||||
func TestRangeTranslate(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
values := []float64{1.0, 2.0, 2.5, 2.7, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0}
|
||||
r := ContinuousRange{Domain: 1000}
|
||||
r.Min, r.Max = MinAndMax(values...)
|
||||
|
||||
// delta = ~7.0
|
||||
// value = ~5.0
|
||||
// domain = ~1000
|
||||
// 5/8 * 1000 ~=
|
||||
assert.Equal(0, r.Translate(1.0))
|
||||
assert.Equal(1000, r.Translate(8.0))
|
||||
assert.Equal(572, r.Translate(5.0))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue