Comments (1)
I encountered the same problem today. I was wondering if I should try to go to bed before midnight to make tracking easier. ๐ /j
TL;DR You could do one of:
- write your sleep times as something like
-00:30
if before midnight, or - create an auto-updated property field using another plugin which converts your sleep time into the above format.
What I realized was that using values like -01:30
made the chart render the way I wanted. If you're okay with using that notation in your notes, then it could be the way to go.
What I actually ended up doing involved another plugin called Metadata Menu. Using it, I set up an auto-updated property field in the frontmatter which converted my inputs into a format like [-00:30, 07:30]
with the values representing the time differences from the midnight of the day for that note. I had to do this because I've been recording my times in the full datetime format. In case it helps anyone, below is the code snippet I used for the property's formula.
// My input fields are something like:
// [go-to-bed:: 2024-01-30T00:30]
// [wake-up:: 2024-01-30T07:30]
(() => {
const goToBed = current["go-to-bed"];
const wakeUp = current["wake-up"];
if (!goToBed || !wakeUp) return "";
const midnight = current.file.day;
const sleepTime = goToBed < midnight
? midnight.diff(goToBed).toFormat("-hh:mm")
: goToBed.diff(midnight).toFormat("hh:mm");
const wakeUpTime = wakeUp.diff(midnight).toFormat("hh:mm");
return `[${sleepTime}, ${wakeUpTime}]`;
})()
If you're just recording times in formats like 23:00
, then you just need to convert the sleep time and use the original field for the wake-up time. If you're using Metadata Menu, the formula would be something like below. (Disclaimer: I haven't tested the code)
// Let's say you have the field as:
// sleep:: 23:30/07:30
(() => {
const sleep = current.sleep?.split("/");
if (!sleep?.length) return "";
const sleepTime = dv.luxon.Duration.fromISOTime(sleep[0]);
// No change if before 12:00 (adjust as needed)
return sleepTime.hours < 12 ? sleep[0] : dv.luxon.Duration.fromObject({ hours: 24 }).minus(sleepTime).toFormat("-hh:mm");
})()
Then, you could use the new field in the tracker code block.
IIRC, a plugin called MetaEdit also allows you to create an auto-updated property field. I haven't used it yet, so I'm not sure how to get that working for this.
I hope this helps anyone reading this!
from obsidian-tracker.
Related Issues (20)
- Request: Data Processing Enhancements HOT 2
- Can I shift (move up/down) or scale (inc. or dec.) a line in a graph please? HOT 1
- ''No valid date as X value found in notes 40 files are not in the right format.'' and ''Error parsing YAML'' HOT 4
- Is it possible to render line graphs with a shaded reference band?
- Can't mix searchType frontmatter and text - results in either only the first target rendering or a YAML parse error HOT 2
- Track values selected in list fields
- Can I do math to calculate a y-axis value? HOT 4
- Average Calculation Error? HOT 3
- Summary cannot display in a line graph๏ผ HOT 2
- Bar Chart shows bars with different widths HOT 1
- Date format(YYYYMMDD) not working properly for start/end Date HOT 2
- Frontmatter / property using boolean or checkbox HOT 2
- How to get the value in [key:: value] or (key:: value) ๏ผ HOT 2
- Date format(YYYYMMDD) not working properly for start/end Date
- "Thousand separator" not supported in expressions
- Use value set in frontmatter searchTarget AS the annotation
- yMin / yMax error when used in searchType: table
- Creating pie chart from calf_pain::<left_or_right>_side?
- Graph doesnt show lines between datapoints HOT 3
- Threshold is Ignored in Month Graphs When Using Scaled Colors
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from obsidian-tracker.