Skip to content

Commit

Permalink
change Dot Size and graph MaxHistoSize calc in AutoHistoSize mode
Browse files Browse the repository at this point in the history
  • Loading branch information
lian committed May 5, 2017
1 parent fc3a962 commit d293adb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
3 changes: 2 additions & 1 deletion opengl/bookmap/bookmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ func (s *Bookmap) Render() {
stats := s.Graph.Book.Book.StateAsStats()
statsSlot.Fill(stats)
if s.MaxSizeHisto == 0 || s.AutoHistoSize {
s.MaxSizeHisto = round(statsSlot.MaxSize/2, 0)
//s.MaxSizeHisto = round(statsSlot.MaxSize/2, 0)
s.MaxSizeHisto = round(s.Graph.MaxHistoSize()*0.60, 0)
}

s.Graph.DrawTimeslots(gc, x, ((s.Texture.Height - s.RowHeight) / s.RowHeight), s.RowHeight, s.PriceScrollPosition, s.PriceSteps, s.MaxSizeHisto)
Expand Down
10 changes: 10 additions & 0 deletions opengl/bookmap/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ func NewGraph(db *bolt.DB, productID string, width, slotWidth, slotSteps int) *G
return g
}

func (g *Graph) MaxHistoSize() float64 {
var max float64
for _, slot := range g.Timeslots {
if slot.MaxSize > max {
max = slot.MaxSize
}
}
return max
}

func (g *Graph) ClearSlotRows() {
for _, slot := range g.Timeslots {
slot.Rows = make([]*TimeSlotRow, 0, len(slot.Rows))
Expand Down
4 changes: 2 additions & 2 deletions opengl/bookmap/graph_draw.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (g *Graph) DrawTradeDots(gc *draw2dimg.GraphicContext, x, rowHeight, priceP
angle := 360 * (math.Pi / 180.0)

xx := (cx + (float64(g.SlotWidth) / 2))
t := (slot.AskTradeSize / (maxSizeHisto / 2))
t := (slot.AskTradeSize / (maxSizeHisto * 0.8))
if t > 1.0 {
t = 1.0
}
Expand Down Expand Up @@ -76,7 +76,7 @@ func (g *Graph) DrawTradeDots(gc *draw2dimg.GraphicContext, x, rowHeight, priceP
angle := 360 * (math.Pi / 180.0)

xx := (cx + (float64(g.SlotWidth) / 2))
t := (slot.AskTradeSize / (maxSizeHisto / 2))
t := (slot.BidTradeSize / (maxSizeHisto * 0.8))
if t > 1.0 {
t = 1.0
}
Expand Down

0 comments on commit d293adb

Please sign in to comment.