tweaking xaxis gridline handling.
This commit is contained in:
parent
141327f898
commit
7951d97d82
|
@ -25,6 +25,22 @@ func readData() ([]time.Time, []float64) {
|
||||||
return xvalues, yvalues
|
return xvalues, yvalues
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func releases() []chart.GridLine {
|
||||||
|
lineStyle := chart.Style{
|
||||||
|
Show: true,
|
||||||
|
StrokeColor: chart.ColorAlternateGray,
|
||||||
|
StrokeWidth: 1.0,
|
||||||
|
}
|
||||||
|
return []chart.GridLine{
|
||||||
|
{Value: chart.TimeToFloat64(time.Date(2016, 8, 1, 9, 30, 0, 0, time.UTC)), IsVertical: true, Style: lineStyle},
|
||||||
|
{Value: chart.TimeToFloat64(time.Date(2016, 8, 2, 9, 30, 0, 0, time.UTC)), IsVertical: true, Style: lineStyle},
|
||||||
|
{Value: chart.TimeToFloat64(time.Date(2016, 8, 3, 9, 30, 0, 0, time.UTC)), IsVertical: true, Style: lineStyle},
|
||||||
|
{Value: chart.TimeToFloat64(time.Date(2016, 8, 4, 9, 30, 0, 0, time.UTC)), IsVertical: true, Style: lineStyle},
|
||||||
|
{Value: chart.TimeToFloat64(time.Date(2016, 8, 5, 9, 30, 0, 0, time.UTC)), IsVertical: true, Style: lineStyle},
|
||||||
|
{Value: chart.TimeToFloat64(time.Date(2016, 8, 6, 9, 30, 0, 0, time.UTC)), IsVertical: true, Style: lineStyle},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func drawChart(res http.ResponseWriter, req *http.Request) {
|
func drawChart(res http.ResponseWriter, req *http.Request) {
|
||||||
xvalues, yvalues := readData()
|
xvalues, yvalues := readData()
|
||||||
mainSeries := chart.TimeSeries{
|
mainSeries := chart.TimeSeries{
|
||||||
|
@ -87,6 +103,8 @@ func drawChart(res http.ResponseWriter, req *http.Request) {
|
||||||
XAxis: chart.XAxis{
|
XAxis: chart.XAxis{
|
||||||
Style: chart.StyleShow(),
|
Style: chart.StyleShow(),
|
||||||
ValueFormatter: chart.TimeHourValueFormatter,
|
ValueFormatter: chart.TimeHourValueFormatter,
|
||||||
|
GridMajorStyle: chart.StyleShow(),
|
||||||
|
GridLines: releases(),
|
||||||
},
|
},
|
||||||
Series: []chart.Series{
|
Series: []chart.Series{
|
||||||
mainSeries,
|
mainSeries,
|
||||||
|
|
2
xaxis.go
2
xaxis.go
|
@ -183,7 +183,7 @@ func (xa XAxis) Render(r Renderer, canvasBox Box, ra Range, defaults Style, tick
|
||||||
if gl.IsMinor {
|
if gl.IsMinor {
|
||||||
defaults = xa.GridMinorStyle
|
defaults = xa.GridMinorStyle
|
||||||
}
|
}
|
||||||
gl.Render(r, canvasBox, ra, defaults)
|
gl.Render(r, canvasBox, ra, gl.Style.InheritFrom(defaults))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user