market hours range not quite working yet.

This commit is contained in:
Will Charczuk 2016-07-24 22:54:03 -07:00
parent 50a798f67f
commit 3bf31e45d3
2 changed files with 9 additions and 4 deletions

View File

@ -2,7 +2,7 @@ package chart
// GridLineProvider is a type that provides grid lines.
type GridLineProvider interface {
GetGridLines(ticks []Tick, isVertical bool) []GridLine
GetGridLines(ticks []Tick, isVertical bool, majorStyle, minorStyle Style) []GridLine
}
// GridLine is a line on a graph canvas.
@ -62,7 +62,12 @@ func (gl GridLine) Render(r Renderer, canvasBox Box, ra Range, defaults Style) {
func GenerateGridLines(ticks []Tick, majorStyle, minorStyle Style, isVertical bool) []GridLine {
var gl []GridLine
isMinor := false
for _, t := range ticks {
if len(ticks) < 3 {
return gl
}
for _, t := range ticks[1 : len(ticks)-1] {
s := majorStyle
if isMinor {
s = minorStyle

View File

@ -108,9 +108,9 @@ func (mhr MarketHoursRange) String() string {
// Translate maps a given value into the ContinuousRange space.
func (mhr MarketHoursRange) Translate(value float64) int {
valueTime := Float64ToTime(value)
valueTimeEastern := valueTime.In(date.Eastern())
deltaSeconds := date.CalculateMarketSecondsBetween(mhr.Min, mhr.Max, mhr.MarketOpen, mhr.MarketClose, mhr.HolidayProvider)
valueDelta := date.CalculateMarketSecondsBetween(mhr.Min, valueTime, mhr.MarketOpen, mhr.MarketClose, mhr.HolidayProvider)
valueDelta := date.CalculateMarketSecondsBetween(mhr.Min, valueTimeEastern, mhr.MarketOpen, mhr.MarketClose, mhr.HolidayProvider)
translated := int((float64(valueDelta) / float64(deltaSeconds)) * float64(mhr.Domain))
return translated
}