obsidian-tracker icon indicating copy to clipboard operation
obsidian-tracker copied to clipboard

Sleep tracker with 3 values

Open foenixp opened this issue 2 years ago • 7 comments

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:

  • sleep:: 2:00 am/11:00 am
  • sleeptime:: 9

I want to incorporate the sleeptime into the chart. image

foenixp avatar Jan 05 '23 16:01 foenixp

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

niamurrell avatar Jan 06 '23 23:01 niamurrell

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

PeterBeckley avatar Jan 30 '23 00:01 PeterBeckley

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.

foenixp avatar Jan 30 '23 19:01 foenixp

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)

PeterBeckley avatar Jan 30 '23 21:01 PeterBeckley

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.

foenixp avatar Jan 31 '23 15:01 foenixp

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

Raagaception avatar Jul 14 '23 18:07 Raagaception

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?

RomanMunar avatar Oct 02 '23 23:10 RomanMunar