pyrochlore / obsidian-tracker

A plugin tracks occurrences and numbers in your notes
MIT License
1.37k stars 229 forks source link

Can I do math to calculate a y-axis value? #311

Closed larryfast closed 8 months ago

larryfast commented 10 months ago

I have a Y value in seconds but would like the Chart to show Minutes. Is there a syntax for dividing by 60?

Desired Behavior

Currently I'm extracting the Y-value from JSON text: {"total":{"name":"meditationT","totalTime":4347},"entries": ... } using searchTarget: '.meditationT[^:]:(?\d+)'

Is there any magic syntax allowing me to generate a calculated Y value? In my case I want to divide by 60 to get a value in minutes instead of seconds.

Context

The source values are generated by a Timer plugin. I click Start...Stop and the plugin calculates total time in seconds. The plugin keeps a static record of start-stop & total times in a JSON record.
It would be great if I could graph this as Minutes instead of seconds.
FWIW, here's a more complete example of the JSON. This is a single line in my .md files.

{"total":{"name":"meditationT","totalTime":7},"entries":[{"name":"Segment 1","startTime":1706129847,"endTime":1706129854,"subEntries":null}],"editEnabled":true,"format":"hh:mm"}
lazyguru commented 9 months ago

You might be able to use JS to inject the calculation into the dataview

lazyguru commented 8 months ago

I re-read this again and I don't think my previous suggestion would work. This sounds like something that would need to be added to the plugin to support some kind of conversion (like either "modifier" entry where you pass a value to modify the dataset by and then a "modifer_action" where you specify how the value is modified [division, addition, subtraction, ...]). Depending on how this is implemented it could get fairly complex. It's not something I personally need so it wouldn't be something I would do, however if you or someone else opens a PR with a solution I'll consider merging it

larryfast commented 8 months ago

Thanks for the update. At the moment I living with it as is. I'll ping you if put some energy into designing a solution. And I REALLY appreciate the wonderful plugin you created!

lazyguru commented 8 months ago

No worries. And @pyrochlore created it. I'm just maintaining it at the moment because I also found it really useful and @pyrochlore was too busy (life happens 😊)