Skip to content

Commit

Permalink
re-add c2a6341
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesrswift committed Aug 1, 2024
1 parent 9eee55d commit 1023912
Showing 1 changed file with 2 additions and 23 deletions.
25 changes: 2 additions & 23 deletions src/axes/ticks.typ
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,6 @@
$#round(value, digits)$
}

let format-sci(value, digits) = {
let exponent = if value != 0 {
calc.floor(calc.log(calc.abs(value), base: 10))
} else {
0
}

let ee = calc.pow(10, calc.abs(exponent + 1))
if exponent > 0 {
value = value / ee * 10
} else if exponent < 0 {
value = value * ee * 10
}

value = round(value, digits)
if exponent <= -1 or exponent >= 1 {
return $#value times 10^#exponent$
}
return $#value$
}

if type(value) != content {
let format = tic-options.at("format", default: "float")
if format == none {
Expand All @@ -44,11 +23,11 @@
} else if type(format) == function {
value = (format)(value)
} else if format == "sci" {
value = format-sci(value, tic-options.at("decimals", default: 2))
value = formats.sci(value, digits: tic-options.at("decimals", default: 2))
} else {
value = format-float(value, tic-options.at("decimals", default: 2))
}
} else {
} else if type(value) != content {
value = str(value)
}

Expand Down

0 comments on commit 1023912

Please sign in to comment.