Compare commits

...

4 commits

4 changed files with 57 additions and 0 deletions

View file

@ -29,6 +29,11 @@
&:hover { &:hover {
background-color: transparent; background-color: transparent;
} }
svg, img {
height: 20px;
width: 20px;
}
} }
&__graphic { &__graphic {

View file

@ -899,6 +899,10 @@ func (r *ValueRollup) calcContents(calc *RollupCalc, destKey *Key) {
for _, v := range r.Contents { for _, v := range r.Contents {
if KeyTypeNumber == v.Type && nil != v.Number && v.Number.IsNotEmpty { if KeyTypeNumber == v.Type && nil != v.Number && v.Number.IsNotEmpty {
sum += v.Number.Content sum += v.Number.Content
} else {
content := v.String(false)
f, _ := util.Convert2Float(content)
sum += f
} }
} }
r.Contents = []*Value{{Type: KeyTypeNumber, Number: NewFormattedValueNumber(sum, destKey.NumberFormat)}} r.Contents = []*Value{{Type: KeyTypeNumber, Number: NewFormattedValueNumber(sum, destKey.NumberFormat)}}
@ -909,6 +913,11 @@ func (r *ValueRollup) calcContents(calc *RollupCalc, destKey *Key) {
if KeyTypeNumber == v.Type && nil != v.Number && v.Number.IsNotEmpty { if KeyTypeNumber == v.Type && nil != v.Number && v.Number.IsNotEmpty {
sum += v.Number.Content sum += v.Number.Content
count++ count++
} else {
content := v.String(false)
f, _ := util.Convert2Float(content)
sum += f
count++
} }
} }
if 0 < count { if 0 < count {
@ -919,6 +928,10 @@ func (r *ValueRollup) calcContents(calc *RollupCalc, destKey *Key) {
for _, v := range r.Contents { for _, v := range r.Contents {
if KeyTypeNumber == v.Type && nil != v.Number && v.Number.IsNotEmpty { if KeyTypeNumber == v.Type && nil != v.Number && v.Number.IsNotEmpty {
numbers = append(numbers, v.Number.Content) numbers = append(numbers, v.Number.Content)
} else {
content := v.String(false)
f, _ := util.Convert2Float(content)
numbers = append(numbers, f)
} }
} }
sort.Float64s(numbers) sort.Float64s(numbers)
@ -936,6 +949,12 @@ func (r *ValueRollup) calcContents(calc *RollupCalc, destKey *Key) {
if v.Number.Content < minVal { if v.Number.Content < minVal {
minVal = v.Number.Content minVal = v.Number.Content
} }
} else {
content := v.String(false)
f, _ := util.Convert2Float(content)
if f < minVal {
minVal = f
}
} }
} }
if math.MaxFloat64 != minVal { if math.MaxFloat64 != minVal {
@ -948,6 +967,12 @@ func (r *ValueRollup) calcContents(calc *RollupCalc, destKey *Key) {
if v.Number.Content > maxVal { if v.Number.Content > maxVal {
maxVal = v.Number.Content maxVal = v.Number.Content
} }
} else {
content := v.String(false)
f, _ := util.Convert2Float(content)
if f > maxVal {
maxVal = f
}
} }
} }
if -math.MaxFloat64 != maxVal { if -math.MaxFloat64 != maxVal {
@ -1004,6 +1029,15 @@ func (r *ValueRollup) calcContents(calc *RollupCalc, destKey *Key) {
isNotTime = true isNotTime = true
hasEndDate = false hasEndDate = false
} }
} else {
content := v.String(false)
f, _ := util.Convert2Float(content)
if f < minVal {
minVal = f
}
if f > maxVal {
maxVal = f
}
} }
} }
@ -1025,6 +1059,10 @@ func (r *ValueRollup) calcContents(calc *RollupCalc, destKey *Key) {
if 0 != earliest && 0 != latest { if 0 != earliest && 0 != latest {
r.Contents = []*Value{{Type: KeyTypeCreated, Created: NewFormattedValueCreated(earliest, latest, CreatedFormatDuration)}} r.Contents = []*Value{{Type: KeyTypeCreated, Created: NewFormattedValueCreated(earliest, latest, CreatedFormatDuration)}}
} }
default:
if math.MaxFloat64 != minVal && -math.MaxFloat64 != maxVal {
r.Contents = []*Value{{Type: KeyTypeNumber, Number: NewFormattedValueNumber(maxVal-minVal, destKey.NumberFormat)}}
}
} }
case CalcOperatorEarliest: case CalcOperatorEarliest:
if 1 > len(r.Contents) { if 1 > len(r.Contents) {

View file

@ -46,6 +46,7 @@ func BuiltInTemplateFuncs() (ret template.FuncMap) {
ret["ISOWeek"] = util.ISOWeek ret["ISOWeek"] = util.ISOWeek
ret["ISOYear"] = util.ISOYear ret["ISOYear"] = util.ISOYear
ret["ISOMonth"] = util.ISOMonth ret["ISOMonth"] = util.ISOMonth
ret["ISOWeekDate"] = util.ISOWeekDate
ret["pow"] = pow ret["pow"] = pow
ret["powf"] = powf ret["powf"] = powf
ret["log"] = log ret["log"] = log

View file

@ -80,6 +80,19 @@ func ISOMonth(date time.Time) int {
return int(monday.Month()) return int(monday.Month())
} }
// ISOWeekDate returns the date of the specified day of the week in the ISO 8601 week of date.
// day: Monday=1, ..., Sunday=7.
func ISOWeekDate(date time.Time, day int) time.Time {
weekday := int(date.Weekday())
if weekday == 0 {
weekday = 7
}
daysToMonday := weekday - 1
monday := date.AddDate(0, 0, -daysToMonday)
return monday.AddDate(0, 0, day-1)
}
func Millisecond2Time(t int64) time.Time { func Millisecond2Time(t int64) time.Time {
sec := t / 1000 sec := t / 1000
msec := t % 1000 msec := t % 1000