Custom Ticks where Value is a time
garrettporter opened this issue · 1 comments
garrettporter commented
I am looking to set a custom tick for the start time and a custom tick for the end time, with no ticks between them. The problem is that a Tick value is type float64. How would I set ticks at specific times?
graph := chart.Chart{
XAxis: chart.XAxis{
ValueFormatter: chart.TimeValueFormatterWithFormat("Jan 2, 2006 15:04 MST"),
// How do I set custom ticks to time? Value is type float64.
Ticks: []chart.Tick{
{Value: time.Now().AddDate(0, 0, -10) Label: "then"},
{Value: time.Now(), Label: "now"},
},
},
Series: []chart.Series{
chart.TimeSeries{
XValues: []time.Time{
time.Now().AddDate(0, 0, -10),
time.Now().AddDate(0, 0, -9),
time.Now().AddDate(0, 0, -8),
time.Now().AddDate(0, 0, -7),
time.Now().AddDate(0, 0, -6),
time.Now().AddDate(0, 0, -5),
time.Now().AddDate(0, 0, -4),
time.Now().AddDate(0, 0, -3),
time.Now().AddDate(0, 0, -2),
time.Now().AddDate(0, 0, -1),
time.Now(),
},
YValues: []float64{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0},
},
},
}
My sample code is based off of this example in master
https://github.com/wcharczuk/go-chart/blob/master/examples/timeseries/main.go
StephanVerbeeck commented
Same problem here, anybody worked on this? (or find a work around)