mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-08 05:32:33 +01:00
🎨 Attribute View number column format https://github.com/siyuan-note/siyuan/issues/8764
This commit is contained in:
parent
2ac751dead
commit
65cbbc589d
3 changed files with 23 additions and 22 deletions
|
|
@ -766,7 +766,7 @@ func (table *Table) calcColNumber(col *TableColumn, colIndex int) {
|
|||
sum += row.Cells[colIndex].Value.Number.Content
|
||||
}
|
||||
}
|
||||
col.Calc.Result = &Value{Number: NewFormattedValueNumber(sum, NumberFormatNone)}
|
||||
col.Calc.Result = &Value{Number: NewFormattedValueNumber(sum, col.NumberFormat)}
|
||||
case CalcOperatorAverage:
|
||||
sum := 0.0
|
||||
count := 0
|
||||
|
|
@ -777,7 +777,7 @@ func (table *Table) calcColNumber(col *TableColumn, colIndex int) {
|
|||
}
|
||||
}
|
||||
if 0 != count {
|
||||
col.Calc.Result = &Value{Number: NewFormattedValueNumber(sum/float64(count), NumberFormatNone)}
|
||||
col.Calc.Result = &Value{Number: NewFormattedValueNumber(sum/float64(count), col.NumberFormat)}
|
||||
}
|
||||
case CalcOperatorMedian:
|
||||
values := []float64{}
|
||||
|
|
@ -789,9 +789,9 @@ func (table *Table) calcColNumber(col *TableColumn, colIndex int) {
|
|||
sort.Float64s(values)
|
||||
if len(values) > 0 {
|
||||
if len(values)%2 == 0 {
|
||||
col.Calc.Result = &Value{Number: NewFormattedValueNumber((values[len(values)/2-1]+values[len(values)/2])/2, NumberFormatNone)}
|
||||
col.Calc.Result = &Value{Number: NewFormattedValueNumber((values[len(values)/2-1]+values[len(values)/2])/2, col.NumberFormat)}
|
||||
} else {
|
||||
col.Calc.Result = &Value{Number: NewFormattedValueNumber(values[len(values)/2], NumberFormatNone)}
|
||||
col.Calc.Result = &Value{Number: NewFormattedValueNumber(values[len(values)/2], col.NumberFormat)}
|
||||
}
|
||||
}
|
||||
case CalcOperatorMin:
|
||||
|
|
@ -804,7 +804,7 @@ func (table *Table) calcColNumber(col *TableColumn, colIndex int) {
|
|||
}
|
||||
}
|
||||
if math.MaxFloat64 != min {
|
||||
col.Calc.Result = &Value{Number: NewFormattedValueNumber(min, NumberFormatNone)}
|
||||
col.Calc.Result = &Value{Number: NewFormattedValueNumber(min, col.NumberFormat)}
|
||||
}
|
||||
case CalcOperatorMax:
|
||||
max := -math.MaxFloat64
|
||||
|
|
@ -816,7 +816,7 @@ func (table *Table) calcColNumber(col *TableColumn, colIndex int) {
|
|||
}
|
||||
}
|
||||
if -math.MaxFloat64 != max {
|
||||
col.Calc.Result = &Value{Number: NewFormattedValueNumber(max, NumberFormatNone)}
|
||||
col.Calc.Result = &Value{Number: NewFormattedValueNumber(max, col.NumberFormat)}
|
||||
}
|
||||
case CalcOperatorRange:
|
||||
min := math.MaxFloat64
|
||||
|
|
@ -832,7 +832,7 @@ func (table *Table) calcColNumber(col *TableColumn, colIndex int) {
|
|||
}
|
||||
}
|
||||
if math.MaxFloat64 != min && -math.MaxFloat64 != max {
|
||||
col.Calc.Result = &Value{Number: NewFormattedValueNumber(max-min, NumberFormatNone)}
|
||||
col.Calc.Result = &Value{Number: NewFormattedValueNumber(max-min, col.NumberFormat)}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue