pyrochlore / obsidian-tracker

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

Sleep tracker with 3 values #182

Open foenixp opened 1 year ago

foenixp commented 1 year ago

Hi, I wonder if it's possible to create a chart with 3 values on it, ideally 2 y-axis. I want to track both my sleep & wake up time, as well as the hours that i slept in one single chart. Right now I am able to make a chart with sleep and wake up time, is there a way to incorporate the slept hours in it? My code is:

searchType: dvField
searchTarget: sleep[0], sleep[1]
startDate: 2023-01-02 Monday
endDate: 2023-01-08 Sunday
folder: "folder"
fixedScale: 1.2
fitPanelWidth: false
valueShift: -24:00, 0
shiftOnlyValueLargerThan: 12:00, 0
datasetName: Sleep, WakeUp
line:
    title: "Sleep"
    yAxisLabel: "Time (24h)"
    lineColor: yellow, pink
    showPoint: true
    showLegend: true
    yMax: 12:00
    yMin: -06:00

My inline dataview keys and value are:

I want to incorporate the sleeptime into the chart. image

niamurrell commented 1 year ago

Not related to your question, but thanks for adding your example which turns out to be a good workaround to the display issue raised in #78

PeterBeckley commented 1 year ago

See the Blood Pressure Tracker in the examples. It utilizes two y-axes. Blood Pressure Tracker

foenixp commented 1 year ago

See the Blood Pressure Tracker in the examples. It utilizes two y-axes. Blood Pressure Tracker

Hi, I am using the 2 y-axes chart right now. I just wonder if there is a way tp have 3 values in one chart.

PeterBeckley commented 1 year ago

I understand what you're looking for now. Looking at all the examples, the Input Parameters, and Target Evaluation, it seems like it should be possible, but I could not get it to render a line chart no matter what I tried. My line charts are only rendered when I have an array with 2 items. The example below doesn't work but really seems like it should. Sorry I couldn't be more help.

searchType: dvField, dvField, dvField
searchTarget: sleep[0], sleep[1], sleep[2]
startDate: 2023-01-01
endDate: 2023-01-07
folder: /utils/Sandbox
fixedScale: 1.2
fitPanelWidth: false
datasetName: Sleep, Wake, Duration
valueShift: -24:00,0
shiftOnlyValueLargerThan: 12:00,0
line:
   title: Stuff
   yAxisLabel: Sleep, Wake, Duration
   yAxisUnit: Hrs
   yAxisColor: white, blue
   yMax: 12:00, 12:00, 4
   yMin: -06:00, -06:00, 0
   yAxisLocation: left, left, right
   lineColor: yellow, pink, teal
   showPoint: true
   showLegend: true

and inline data in this format sleep:: 21/5/8

Obsidian console shows this error (hopefully, this helps the developer):

plugin:obsidian-tracker:15
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'trim')
    at Jo (plugin:obsidian-tracker:15:154526)
    at eval (plugin:obsidian-tracker:15:177989)
    at vu.eval (plugin:obsidian-tracker:15:186780)
    at Generator.next (<anonymous>)
    at eval (plugin:obsidian-tracker:15:363)
    at new Promise (<anonymous>)
    at e (plugin:obsidian-tracker:15:108)
    at vu.postprocessor (plugin:obsidian-tracker:15:172004)
    at app.js:1:1018599
    at t.postProcess (app.js:1:1296170)
foenixp commented 1 year ago

I understand what you're looking for now. Looking at all the examples, the Input Parameters, and Target Evaluation, it seems like it should be possible, but I could not get it to render a line chart no matter what I tried. My line charts are only rendered when I have an array with 2 items. The example below doesn't work but really seems like it should. Sorry I couldn't be more help.

searchType: dvField, dvField, dvField
searchTarget: sleep[0], sleep[1], sleep[2]
startDate: 2023-01-01
endDate: 2023-01-07
folder: /utils/Sandbox
fixedScale: 1.2
fitPanelWidth: false
datasetName: Sleep, Wake, Duration
valueShift: -24:00,0
shiftOnlyValueLargerThan: 12:00,0
line:
   title: Stuff
   yAxisLabel: Sleep, Wake, Duration
   yAxisUnit: Hrs
   yAxisColor: white, blue
   yMax: 12:00, 12:00, 4
   yMin: -06:00, -06:00, 0
   yAxisLocation: left, left, right
   lineColor: yellow, pink, teal
   showPoint: true
   showLegend: true

and inline data in this format sleep:: 21/5/8

Obsidian console shows this error (hopefully, this helps the developer):

plugin:obsidian-tracker:15
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'trim')
    at Jo (plugin:obsidian-tracker:15:154526)
    at eval (plugin:obsidian-tracker:15:177989)
    at vu.eval (plugin:obsidian-tracker:15:186780)
    at Generator.next (<anonymous>)
    at eval (plugin:obsidian-tracker:15:363)
    at new Promise (<anonymous>)
    at e (plugin:obsidian-tracker:15:108)
    at vu.postprocessor (plugin:obsidian-tracker:15:172004)
    at app.js:1:1018599
    at t.postProcess (app.js:1:1296170)

Thank you for your help.

Raagaception commented 1 year ago

+1, need to accomplish the same goal as author. Please update if you were able to get it to work!

RomanMunar commented 1 year ago

I somehow made @PeterBeckley 's example work by removing valueShift, and shiftOnlyValueLargerThan properties. ?? Time is too varied to shift and limit the value? anyone knows the mechanism for that?