2016-07-13 01:04:30 -04:00
|
|
|
package chart
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/blendlabs/go-assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestXAxisGetTicks(t *testing.T) {
|
|
|
|
assert := assert.New(t)
|
|
|
|
|
|
|
|
r, err := PNG(1024, 1024)
|
|
|
|
assert.Nil(err)
|
|
|
|
|
|
|
|
f, err := GetDefaultFont()
|
|
|
|
assert.Nil(err)
|
|
|
|
|
|
|
|
xa := XAxis{}
|
2016-07-21 17:11:27 -04:00
|
|
|
xr := &ContinuousRange{Min: 10, Max: 100, Domain: 1024}
|
2016-07-13 01:04:30 -04:00
|
|
|
styleDefaults := Style{
|
|
|
|
Font: f,
|
|
|
|
FontSize: 10.0,
|
|
|
|
}
|
|
|
|
vf := FloatValueFormatter
|
|
|
|
ticks := xa.GetTicks(r, xr, styleDefaults, vf)
|
|
|
|
assert.Len(ticks, 17)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestXAxisGetTicksWithUserDefaults(t *testing.T) {
|
|
|
|
assert := assert.New(t)
|
|
|
|
|
|
|
|
r, err := PNG(1024, 1024)
|
|
|
|
assert.Nil(err)
|
|
|
|
|
|
|
|
f, err := GetDefaultFont()
|
|
|
|
assert.Nil(err)
|
|
|
|
|
|
|
|
xa := XAxis{
|
2016-07-15 16:45:33 -04:00
|
|
|
Ticks: []Tick{{Value: 1.0, Label: "1.0"}},
|
2016-07-13 01:04:30 -04:00
|
|
|
}
|
2016-07-21 17:11:27 -04:00
|
|
|
xr := &ContinuousRange{Min: 10, Max: 100, Domain: 1024}
|
2016-07-13 01:04:30 -04:00
|
|
|
styleDefaults := Style{
|
|
|
|
Font: f,
|
|
|
|
FontSize: 10.0,
|
|
|
|
}
|
|
|
|
vf := FloatValueFormatter
|
|
|
|
ticks := xa.GetTicks(r, xr, styleDefaults, vf)
|
|
|
|
assert.Len(ticks, 1)
|
|
|
|
}
|