|
|
|
@ -172,15 +172,17 @@ func (ct *Cointop) ChartPoints(symbol string, name string) error {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var labels []string
|
|
|
|
|
var data []float64
|
|
|
|
|
timeQuantum := timedata.CalculateTimeQuantum(cacheData) // will be 0 if <2 points
|
|
|
|
|
if timeQuantum > 0 {
|
|
|
|
|
// Resample cachedata
|
|
|
|
|
timeQuantum := timedata.CalculateTimeQuantum(cacheData)
|
|
|
|
|
newStart := cacheData[0][0] // use the first data point
|
|
|
|
|
newEnd := time.Unix(end, 0).Add(-timeQuantum)
|
|
|
|
|
timeData := timedata.ResampleTimeSeriesData(cacheData, newStart, float64(newEnd.UnixMilli()), chart.GetChartDataSize(maxX))
|
|
|
|
|
labels := timedata.BuildTimeSeriesLabels(timeData)
|
|
|
|
|
labels = timedata.BuildTimeSeriesLabels(timeData)
|
|
|
|
|
|
|
|
|
|
// Extract just the values from the data
|
|
|
|
|
var data []float64
|
|
|
|
|
for i := range timeData {
|
|
|
|
|
value := timeData[i][1]
|
|
|
|
|
if math.IsNaN(value) {
|
|
|
|
@ -188,6 +190,7 @@ func (ct *Cointop) ChartPoints(symbol string, name string) error {
|
|
|
|
|
}
|
|
|
|
|
data = append(data, value)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
chart.SetData(data)
|
|
|
|
|
chart.SetDataLabels(labels)
|
|
|
|
@ -282,12 +285,15 @@ func (ct *Cointop) PortfolioChart() error {
|
|
|
|
|
break // use the first one
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If there is data, resample and sum
|
|
|
|
|
var data []float64
|
|
|
|
|
var labels []string
|
|
|
|
|
if timeQuantum > 0 {
|
|
|
|
|
newStart := time.Unix(start, 0).Add(timeQuantum)
|
|
|
|
|
newEnd := time.Unix(end, 0).Add(-timeQuantum)
|
|
|
|
|
|
|
|
|
|
// Resample and sum data
|
|
|
|
|
var data []float64
|
|
|
|
|
var labels []string
|
|
|
|
|
for i, cacheData := range allCacheData {
|
|
|
|
|
coinData := timedata.ResampleTimeSeriesData(cacheData.data, float64(newStart.UnixMilli()), float64(newEnd.UnixMilli()), chart.GetChartDataSize(maxX))
|
|
|
|
|
if i == 0 {
|
|
|
|
@ -317,6 +323,7 @@ func (ct *Cointop) PortfolioChart() error {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
chart.SetData(data)
|
|
|
|
|
chart.SetDataLabels(labels)
|
|
|
|
|