feat: support bar chart
This commit is contained in:
parent
3a9897f9ad
commit
6ae7e1d1b3
5 changed files with 112 additions and 8 deletions
10
range.go
10
range.go
|
|
@ -60,10 +60,20 @@ func NewRange(min, max float64, divideCount int) Range {
|
|||
}
|
||||
|
||||
func (r *Range) getHeight(value float64) int {
|
||||
v := (value - r.Min) / (r.Max - r.Min)
|
||||
return int(v * float64(r.Size))
|
||||
}
|
||||
|
||||
func (r *Range) getRestHeight(value float64) int {
|
||||
v := 1 - (value-r.Min)/(r.Max-r.Min)
|
||||
return int(v * float64(r.Size))
|
||||
}
|
||||
|
||||
func (r *Range) GetRange(index int) (float64, float64) {
|
||||
unit := float64(r.Size) / float64(r.divideCount)
|
||||
return unit * float64(index), unit * float64(index+1)
|
||||
}
|
||||
|
||||
func (r *Range) getWidth(value float64) int {
|
||||
v := value / (r.Max - r.Min)
|
||||
// 移至居中
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue