snapshot.
This commit is contained in:
parent
7bb82ae691
commit
e9a36274ac
23 changed files with 551 additions and 445 deletions
26
range.go
26
range.go
|
|
@ -3,23 +3,13 @@ package chart
|
|||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
|
||||
"github.com/blendlabs/go-util"
|
||||
)
|
||||
|
||||
// Tick represents a label on an axis.
|
||||
type Tick struct {
|
||||
RangeValue float64
|
||||
Label string
|
||||
}
|
||||
|
||||
// Range represents a continuous range,
|
||||
// Range represents a boundary for a set of numbers.
|
||||
type Range struct {
|
||||
Min float64
|
||||
Max float64
|
||||
Domain int
|
||||
Ticks []Tick
|
||||
Formatter Formatter
|
||||
Min float64
|
||||
Max float64
|
||||
Domain int
|
||||
}
|
||||
|
||||
// IsZero returns if the range has been set or not.
|
||||
|
|
@ -37,14 +27,6 @@ func (r Range) String() string {
|
|||
return fmt.Sprintf("Range [%.2f,%.2f] => %d", r.Min, r.Max, r.Domain)
|
||||
}
|
||||
|
||||
// Format formats the value based on the range's formatter.
|
||||
func (r Range) Format(v interface{}) string {
|
||||
if r.Formatter != nil {
|
||||
return r.Formatter(v)
|
||||
}
|
||||
return util.StringEmpty
|
||||
}
|
||||
|
||||
// Translate maps a given value into the range space.
|
||||
// An example would be a 600 px image, with a min of 10 and a max of 100.
|
||||
// Translate(50) would yield (50.0/90.0)*600 ~= 333.33
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue