change delta compute

This commit is contained in:
shoopea 2021-12-08 22:03:04 +08:00
parent 350d7cfb10
commit 55fa6be367
2 changed files with 20 additions and 21 deletions

33
bot.go
View File

@ -1050,23 +1050,22 @@ func botGraphValueDelta(m *tb.Message) {
}
for coID, v := range vals {
if len(v) <= 3 {
delete(vals, coID)
} else {
v0 := v[0].Y
v1 := v[1].Y
v2 := v[2].Y
for i := 3; i < len(v); i++ {
v0 = v1
v1 = v2
v2 = v[i].Y
v[i].Y = (v0+v1+v2)/3 - v1
if math.Abs(v[i].Y) > maxVal {
maxVal = math.Abs(v[i].Y)
}
}
vals[coID] = v[3:]
v2 := make(plotter.XYs, 0)
for i := 0; i < len(v); i = i + 3 {
v2 = append(v2, v[i])
}
vals[coID] = v2
}
for coID, v := range vals {
v0 := v[0].Y
for i := 1; i < len(v); i++ {
v[i].Y, v0 = v[i].Y-v0, v[i].Y
if math.Abs(v[i].Y) > maxVal {
maxVal = math.Abs(v[i].Y)
}
}
vals[coID] = v[1:]
}
if maxVal > 1000000000 {
@ -1083,7 +1082,7 @@ func botGraphValueDelta(m *tb.Message) {
logInfoDebug("botGraphValueDelta : unit set to %s (factor : %f)", unitName, unitFactor)
for coID, v := range vals {
for i := 1; i < len(vals)-1; i++ {
for i := 0; i < len(vals); i++ {
v[i].Y = v[i].Y / unitFactor
if math.IsNaN(v[i].Y) {
logInfoDebug("botGraphValueDelta : NaN : %d / %f", coID, v[i].X)

View File

@ -1,6 +1,6 @@
// Code generated by version.sh (@generated) DO NOT EDIT.
package main
var githash = "ef7af10"
var buildstamp = "2021-12-08_13:30:52"
var commits = "242"
var version = "ef7af10-b242 - 2021-12-08_13:30:52"
var githash = "350d7cf"
var buildstamp = "2021-12-08_14:02:46"
var commits = "243"
var version = "350d7cf-b243 - 2021-12-08_14:02:46"