obsidian-tracker
obsidian-tracker copied to clipboard
Issues with bools in the frontmatter not working as expected
Hello! Im just getting started using tracker and it is extremely powerful. However I've found that I'm limited in some of my usecases because I would like to have track my habits in my daily notes with bools as opposed to numbers. Like read: false.
As far as I've been able to underatand (at least for the month type) frontmatter and dvFields only supports numeric values, and would otherwise need to map their text to specific values using textMap. While this is fine, it would be nice if there was an option to allow True and False values to automatically map to 1 and 0 respectively.
If I'm missing something let me know! ATM I'm using the text target option as a work around (searching for 'read:: [tT]rue') but I will try the text mapping soon.
Thanks, and I hope this issue was appropriate to open!
Oh huh, just discovered some odd behavior(?)
When assigning true to a bool value in my frontmatter and attempting to use textValueMap to map True to 1 and False to 0, it returns the error No valid Y value found in notes
However doing the same with dvField works exactly as I had hoped.
Removing the textmap doesn't help, neither does assigning a default const. For some reason it's just refusing to read the bool as text in the front matter?
If I add on additional information (such as read: True, 1) and access it with read[0], then I'm able to map True to 1.
I'm not sure what's going on? Here's my code for both
frontmatter:
searchType: frontmatter
searchTarget: read
datasetName: Finished Daily
folder: Daily Notes
fitPanelWidth: True
textValueMap:
'[fF]alse': 0
'[tT]rue': 1
month:
startWeekOn: 'Mon'
color: tomato
headerMonthColor: peach
dimNotInMonth: false
todayRingColor: orange
selectedRingColor: steelblue
showSelectedValue: true
and the (working) dvField version
searchType: dvField
searchTarget: drew
datasetName: Draw Habit
folder: Daily Notes
fitPanelWidth: true
textValueMap:
'[fF]alse': 0
'[tT]rue': 1
month:
startWeekOn: 'Mon'
color: LightPink
headerMonthColor: LightPink
dimNotInMonth: true
todayRingColor: peach
selectedRingColor: purple
showSelectedValue: true
I'm starting to feel there's something i'm missing, I will change the title to reflect this
Sorry for the long wait. Will do some tests on this issue.
Thank you!! And no worries I understand we all got things going on ^^
When assigning true to a bool value in my frontmatter and attempting to use textValueMap to map True to 1 and False to 0, it returns the error
No valid Y value found in notesHowever doing the same with dvField works exactly as I had hoped. Removing the textmap doesn't help, neither does assigning a default const. For some reason it's just refusing to read the bool as text in the front matter?
These happened because the true/false values in YAML(frontmatter) were parsed as boolean by parseYaml function from Obsidian. We cannot get the original string values from the function.
The true/false values in dvField were parsed by our own function, thus I can decide how to use the collected string, convert it to boolean or not.
I'm thinking how to make them consistent and also fit your request. Any ideas are welcome.
Ah I see! That makes a lot of sense hahaha
I think just parsing the boolean values as 0 and 1 would be fine, since many languages will do that if they are converted to integers anyway! Then the user can manipulate the numbers as needed after the case, or just use them straight out of the box. That's just my reasoning however!
I would agreed with the parsing of dvField boolean into 0/1 as I have had to use the text mapping to be able to use my dvField in a calendar as well.
I concur it would be good to add it since it could work well with the Database Folder plugin that make it easy to create checkboxes but this plugin will only use boolean values. Therefore combining this plugin with Tracker is not possible right now.
would love to see an update here!