summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-ui/src/util/timeline.js
diff options
context:
space:
mode:
Diffstat (limited to 'opendc-web/opendc-web-ui/src/util/timeline.js')
-rw-r--r--opendc-web/opendc-web-ui/src/util/timeline.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/opendc-web/opendc-web-ui/src/util/timeline.js b/opendc-web/opendc-web-ui/src/util/timeline.js
new file mode 100644
index 00000000..7c8a3ef0
--- /dev/null
+++ b/opendc-web/opendc-web-ui/src/util/timeline.js
@@ -0,0 +1,9 @@
+export function convertTickToPercentage(tick, maxTick) {
+ if (maxTick === 0) {
+ return '0%'
+ } else if (tick > maxTick) {
+ return (maxTick / (maxTick + 1)) * 100 + '%'
+ }
+
+ return (tick / (maxTick + 1)) * 100 + '%'
+}