changed x of data point to time interval since 1970
This commit is contained in:
@@ -337,7 +337,9 @@ struct StatsController: RouteCollection {
|
||||
|
||||
var cumulativeWinLossRatios = cumulativeWinLossRatios
|
||||
if !(stats.totalWins == 0 && stats.totalLosses == 0) {
|
||||
cumulativeWinLossRatios.append(DataPoint(x: "\(Utilities.monthToString(month: first.month)) \(first.day) \(first.year)", y: (totalWins/totalLosses).truncate(places: 2)))
|
||||
|
||||
let date = self.createDate(day: first.day, month: first.month, year: first.year)
|
||||
cumulativeWinLossRatios.append(DataPoint(x:date.timeIntervalSince1970 , y: (totalWins/totalLosses).truncate(places: 2)))
|
||||
}
|
||||
allDailyStats.append(DailyStats(day: first.day, month: first.month, year: first.year, stats: stats, cumulativeRatio: self.getRatio(num: totalWins, den: totalLosses)))
|
||||
return getRatios(remaining, allDailyStats:&allDailyStats, cumulativeWinLossRatios:&cumulativeWinLossRatios, eventLoop: eventLoop)
|
||||
@@ -371,6 +373,19 @@ struct StatsController: RouteCollection {
|
||||
return calendar.date(from: components)!
|
||||
}
|
||||
|
||||
private func createDate(day:Int, month:Int, year:Int) -> Date {
|
||||
let calendar = Calendar.current
|
||||
|
||||
var components = DateComponents()
|
||||
components.day = day
|
||||
components.month = month
|
||||
components.year = year
|
||||
components.hour = 0
|
||||
components.minute = 0
|
||||
|
||||
return calendar.date(from: components)!
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -12,10 +12,10 @@ import Fluent
|
||||
import Vapor
|
||||
|
||||
struct DataPoint : Content {
|
||||
var x:String
|
||||
var x:Double
|
||||
var y:Double
|
||||
|
||||
init(x:String, y:Double) {
|
||||
init(x:Double, y:Double) {
|
||||
self.x = x
|
||||
self.y = y
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user