GithubHelp home page GithubHelp logo

zincplusplus / habit-tracker Goto Github PK

View Code? Open in Web Editor NEW
34.0 2.0 7.0 191 KB

License: GNU General Public License v3.0

JavaScript 16.96% TypeScript 65.60% CSS 17.43%
habit-tracker habit-tracking habits-tracking obsidian-plugin

habit-tracker's Introduction

image PRs Welcome code style: prettier

Habit Tracker 21

Introducing "Habit Tracker 21," an innovative plugin designed specifically for Obsidian. Have you ever wanted to develop new habits but struggled to keep yourself accountable? This plugin is your perfect solution.

"Habit Tracker 21" is built on the principle that it takes 21 days to form a new habit. With this tool, tracking your habits becomes a seamless process. It allows you to monitor your progress, providing a clear visualization of your commitment and consistency. It's a great way to motivate yourself as you see the habits you're forming over time.

How it works

  1. Create a folder for all your habits, e.g. Habits
  2. Create empty files inside that folder for each habit you want to track
  3. Enable the habit tracker UI by pasting the following code in your .md file:
```habittracker
{
	"path": "Habits/"
}
```

Make sure to specify the path you're using. You can point to one habit, or all habits that contain that path (including subfolders);

Parameters

  • path [mandatory]: a string containing a path to a folder or specific habit (aka .md file)

  • lastDisplayedDate [optional]: the date that is displayed in the chart

    • format: "YYYY-MM-DD"
    • defaults to today
    • example settings { "path": "Habits/", "lastDisplayedDate": "2023-12-27" }
  • daysToShow [optional]: how many dates to display in the chart

    • default: 21

    { "path": "Habits/", "daysToShow": "31" }

Example

Example

Tracking

To determine how much time I should invest in this project I use Bitly.com to track how many people use it. This is what I see #32 (comment)

This is the tracker that collects the least ammount of data that I could find, other than building a custom one. If you have any concerns please add a comment to the above ticket.

habit-tracker's People

Contributors

middric avatar vzinculescu avatar holroy avatar

Stargazers

Anthony Chen avatar José Luis avatar ppppp313 avatar RebyX avatar Domenico Luciani avatar  avatar  avatar  avatar Alex avatar Alejandro avatar  avatar ddd4.cloud avatar Kolja avatar Antonio Sarcevic avatar  avatar Ege Güneş avatar Amber Lewis avatar Roopesh Saravanan avatar Solarflame avatar Siddhanta avatar  avatar  avatar Dhruv avatar Nina Wildberry avatar Fran Casas avatar  avatar  avatar a13ph avatar Ayush  avatar Zhymabek Roman avatar Prakash avatar Vishal Dongre avatar scorpxyz avatar Jennifer Wilmott avatar

Watchers

zinc++ avatar  avatar

habit-tracker's Issues

Bug: Wrong data being displayed

First of all, thank you for creating this very elegant plugin (when it works).

It's the lightest, lowest-friction and, IMO most outcome-focused take on habit tracking I've seen to date, in or outside of Obsidian.

However, as of today it's completely failing for me:

This is my Habit Tracker code block in my daily note template:

{
	"path": "system/Habit Tracker 21",
	"lastDisplayedDate": "2024-04-15"
}

But I'm not seeing my recent completed habit boxes and the "current month" displayed ends at 30, when March has 31 days.

Screenshot here:

image

Add a "+ New habit" button

Instead of going to the folder and manually creating a new file, this button would create a new file for the habit from the UI. And if the folder doesn't exist, it could even create it for the user.

Improve README - Instructions to setup the plugin

This looks like a very nice plugin. However, I could not setup and use the plugin based on the instructions found on the README. Can you please provide detailed instructions on how to add the days for each habit?

So far, I have done the following:

  • Installed and enabled the plugin
  • Created the Habit folder
  • Created Habit/habit1.md and Habit/habit2.md
  • Created a md file in the root folder with the provided code block.

Also, I recentely started using the Obsidian.

Ignore File/Folder

I use folder notes plugin which would be convenient for this plugin because the code block could be attached to the folder note but instead it recognizes it as a habit itself:

image

If we can specify files to ignore that would be a big help to get started.

Habits in folder with number in name

The plugin doesn't show the habits if I put them in the following directory/folder:

"path": "2 Areas/habits/" 

It does work for the following folders:

  • "Areas/habits/"
  • "Two Areas/habits/"

Add tracking

Track how many people are on the latest version
Track each time a habit tracker is rendered

Option to freeze the first column

I use this plugin in my homepage of the vault. It's perfectly fine.

Only when on split panes that it's not easy to view. As today is furthest to the right, I can't see the first column (habit name).

The table should be able to fit the document width and scrollable, with the first column frozen.

Add letter indicating day of the week

Wondering if we could have the option of including a letter in the header of that tracker table that indicated day of the week.

Something like

T 23 W 24 T 25 F 26 S 27 S 28

This is so when I miss updating after a few days it's easier to backfill.

Single ticks not showing

I'm tracking the days I'm met my walking goal, but it doesn't show that I've met the goal on the 2024-03-08. The corresponding entries from that goal are as follows:

image

But in my daily notes it displays as:

image

It would be nice if just a single day also showed. :-D

Plugin is violating developer policies regarding telemetry

Hi @zincplusplus,

Since you posted about your analytics service on the forum I investigated your plugin and found that it violates our Developer policies

Plugins should not submit user data to third-party telemetry services from within Obsidian, even if the data collection is opt-in.
Please remove the offending code within 30 days and create a new release, otherwise this plugin will be removed from the community plugins directory.

Thanks,
— The Obsidian team

"lastDisplayedDate" If I put this sentence in, I get an error

After upgrading to v1.1.2
"lastDisplayedDate": "2023-12-28" - If I put this sentence in, I get an error
Codeblocks without this sentence will work fine.

Under console error message

Uncaught (in promise) SyntaxError: Expected ',' or '}' after property value in JSON at position 22
at JSON.parse ()
at new HabitTracker (plugin:habit-tracker-21:56:31)
at eval (plugin:habit-tracker-21:247:9)
at t.initDOM (app.js:1:1539674)
at t.toDOM (app.js:1:1141789)
at t.sync (app.js:1:351034)
at e.sync (app.js:1:332767)
at app.js:1:373556
at e.ignore (app.js:1:452767)
at t.updateInner (app.js:1:373338)
at t.update (app.js:1:373093)
at e.update (app.js:1:461415)
at e.dispatchTransactions (app.js:1:458098)
at e.dispatch (app.js:1:459981)
at r (app.js:1:1558455)
at run (app.js:1:1558678)

[Feature request ] Option to add notes to entries

What a great idea for a habit tracker and nicely implemented. It would be very useful to have also the ability to add comments to each day marked and this automatically added to the habit file so that mousing over a day marked in the calendar will have a popup with that note

Reduce space requirements for the entries property

I've been thinking about how it'll look when you've tracked your progress for some time, with how many rows you'll get in the entries property of a given habit. Today it occurred to me that this could be drastically used by switching the format slightly, and start using binary numbers for tracking if a habit has been done in a given month.

The gist of the idea is that you store one 32-bit number for each month you're tracking, where each bit corresponds to whether you've done it that particular day. I don't know if you know binary numbers, but the first 7 numbers are; 000 = 0, 001 = 1, 010 = 2, 011 = 3, 100 = 4, 101 = 5, 110 = 6 and 111 = 7. In our interpretation we'd store 7, aka 111, to indicate that we've done the habit the first three days of the month. If we didn't do it the second day we'd store 5, aka 101.

The actual setting/handling of the binary numbers can be easily done using bitwise operators, and this would mean that a given month could be stored in a single number. The only thing to decide then would be which of the following format would be most beneficial:

entries:
- 2024-02: 123098
- 2024-03: 65535
entries-2024-02: 123098
entries-2024-03: 65535

The main difference between these two is how they'll look natively with Obsidian:
image

Where the former is just going to be a data/json block, and the second variant will show the months and some seemingly random number after it.

Do this sound interesting? Do you want me to do a pull request implementing this? If so, which format would you like, and how do you suggest we tackle old data?

Trying to compile it, but it fails?!

Hi, I'm trying to compile habit-tracker from a cloned repository, in order to possibly create a PR related to the style settings, but I only get errors.

Neither npm run build nor npm run dev manages to create a new main.js. What do you use to compile your plugin?

Spacing after habit and limit days displayed

Hi! Not so much an issue as 2 quick questions, if that is alright.

  1. My listed habits are displaying a large space after:

image

Any idea what might be causing it/how to remove it?

  1. Is there a way to limit the number of days displayed? Say, display only the current week, rather than the last 21 days?

If you need any more details on the items above, just let me know. Thanks in advance for any help! :)

Provide a relative date function for lastDisplayDate

Hi here!

First of all, I love this plugin and the simplicity of creating a tracker based on folder structure. Thanks for making this!

I'm currently rendering the habit tracker in a template for my daily journaling and was wondering how, or if it's possible to use a relative date function as the input for lastDisplayedDate?

Say I open a file today, 21 days from now the final cell would be the 26th.

But if I open a file tomorrow, 21 days from then should be the 28th. But because lastDisplayedDate is set to a static date in my templates, each daily file has the same end date. Here's what it looks like when I don't provide lastDisplayedDate and try using the default "Today". The first day on the tracker starts on the 15th of last month and ends on today, instead of starting on today and ending 21 days from now.

image

Is that possible, or that outside the scope of the plugin?

Set start and/or end dates for habits

I'm just thinking if I keep adding habits the list could be long, and if I at some point in time decides to change my habit it would be nice to end the tracking of that habit.

It shouldn't be too hard to implement either, as you could just add a start-date and end-date into the habit file, and only include if the current date range displayed matches those dates. You wouldn't need to, but you could even mark it somehow in the table, that this habit started/ended at a given date (if that date is within the currently displayed range).

I'm thinking that doing this in combination with me adding the tracker into my daily notes with an end date of the day of the daily note, would be useful as I like to shift my focus every now and then on what I want to track and build a habit towards. If it's not implemented, the display for someone like me (shifting habits to track somewhat often) would fast be cluttered with habits I'm not interested in, or which are so second nature to me that it's not needed to track them anymore).

Obsidian must be restarted to update "today"

DEFAULT_SETTINGS.lastDisplayedDate is set when the plugin loads. By default its todays date via the getTodayDate function which is sensible default behaviour.

If you leave Obsidian open across days and leave this default behaviour then the chart is never updated to reflect the current date - you have to restart Obsidian to have it update.

DEFAULT_SETTINGS should perhaps be replaced with a getDefaultSettings function so that the value for lastDisplayedDate is re-evaluated each time its used by the loadSettings method?

I found a way to arrange the dates!!

Sorry for the bad translation, this is my first contribution about this

As you can see, July has 31 days, you just have to look at the calendar and check how many days the month brings

Captura de pantalla 2024-07-18 224007

  1. Add this code
{
	"path": "name of your folder/",
		 "lastDisplayedDate": "2024-07-31",
		"daysToShow": 31 	 
}
  1. Change the word "Name of your folder" to the directory where you have empty habit notes

I'll show you an example of how I'll do everything step by step with the month of November, If you notice, November of this year has 30 days, we only have to modify certain parameters in the code

Captura de pantalla 2024-07-18 225211

{
	"path": "name of your folder",
		 "lastDisplayedDate": "2024-11-30",
		"daysToShow": 30 	 
}
  1. Just change the name folder

Captura de pantalla 2024-07-18 225224

Could you please explain if you create one for each day and how it shows up in the date table?

Thank you for creating Hobby Tracker.

I only read the readme, so I don't know how it works.
What do you mean by creating a directory for each hobby and then creating an empty file?
Could you please explain if you create one for each day and how it shows up in the date table?

It seems like creating notes by date in a directory by hobby would create too many files, is this correct?

daysToShow doesn't work properly

Don't know why but I can't set a different amount of days to show:

This is the code

```habittracker
{
	"path": "Habits/", "daysToShow": "31"
}

This is how the plugin render it:

image

Plugin Version: 1.4.2
Obsidian Version: 1.6.5

With the debug option activated:

{
  "path": "Habits/",
  "lastDisplayedDate": "2024-07-07",
  "daysToShow": "31",
  "daysToLoad": "311",
  "rootElement": {},
  "habitsGoHere": {},
  "debug": true
}

Adjusting CSS

I think it would be fantastic to be able to adjust some CSS.

image

For example

  • max-width of the overall graph
  • lines between cells
  • font size

This could be done as a plugin setting or using the "Style Settings" plugin that many others take advantage of.

Adjust the number of days shown

It would be nice to adjust the number of days displayed. This would be nice to show a full month or more.

I would suggest making it an option in the codeblock so it's easy to changed depending on where it's being used.

{
	"path": "Habits/",
	"days": "31"
}

Tracker Pixel ????!

really love the plugin but the tracking pixel is completely unneccessary - not even sure what use that data would be to you - please remove or at least be transparent that your collecting data -

const trackingPixel = document.createElement("img");
trackingPixel.setAttribute("src", "https://bit.ly/habitttracker21-140");
el.parentElement.appendChild(trackingPixel);
new HabitTracker(src, el, ctx, this.app);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.