Obsidian Tracker

repository·master·Indexed 24 days ago

https://github.com/pyrochlore/obsidian-tracker

A plugin for the Obsidian note-taking app that aggregates data from notes via frontmatter or inline fields and visualizes it using calendars, graphs, charts, and tables. It supports various search types including tags, Dataview fields, and regex patterns, and provides a powerful expression system for data processing and statistical summaries.

Tokens
37.7K
Snippets
141
Records
221
Agent score
83%

What's inside obsidian-tracker

  1. How data collection works in Obsidian Tracker

    master

    Obsidian Tracker collects data by reading YAML-formatted code blocks. To successfully collect data, you must provide at least two parameters: searchType and searchTarget.

    Supported searchType values include:

    • tag
    • frontmatter
    • frontmatter.exists
    • frontmatterlist
    • wiki
    • dvField
    • table
    • fileMeta
    • task
    • text

    The searchTarget must be provided according to the specific type selected in searchType.

  2. Handle multiple values in a single target (Value Tuples)

    master

    Since version 1.3.0, you can store multiple values in a single target separated by a slash (e.g., #bloodpressure:180/120mmHg). To access a specific value from this tuple, use bracket notation with the numeric index.

    Note: This numeric index notation is distinct from the bracket notation used in searchType: frontmatterlist, which uses brackets to match a string value against a list.

    You can customize the separator using the separator parameter.

  3. Use Wiki Link and Display search types

    master

    The Obsidian Tracker plugin supports searching for content within WikiLinks (e.g., [[link|display]]) using two specific searchType values:

    1. wiki.link: Targets the actual link destination (the part before the pipe |).
    2. wiki.display: Targets the display text (the part after the pipe |).
    3. wiki: A fallback type that attempts to parse the display text first, and if no display text exists, parses the link text.

    Example WikiLink structure: [[todo_family|To-Do @Family]]

    • Link text: todo_family
    • Display text: To-Do @Family
  4. Query tasks using searchType

    master

    The tracker code block allows you to collect and summarize task data within Obsidian. You can control which tasks are collected using the searchType parameter:

    • task: Collects all tasks matching the searchTarget.
    • task.all: Collects all tasks matching the searchTarget (alternative syntax).
    • task.done: Collects only completed tasks matching the searchTarget.
    • task.notdone: Collects only incomplete tasks matching the searchTarget.
    • Multiple types can be queried simultaneously by providing a comma-separated list (e.g., task.done, task.notdone).
    searchType: task.done
    searchTarget: Say I love you
    folder: diary
  5. Available rendering output types

    master

    To display collected data, you must provide at least one output parameter in your YAML code block. The plugin supports the following output types:

    • line or bar: Generates customizable charts to visualize variations in collected numbers over time.
    • summary: Creates a text block based on a template parameter. You can use expressions like {{sum()}} or {{maxStreak()}} within the template to generate statistical summaries.
    • bullet: Creates a bullet chart, useful for showing status, levels, performance, or progress as a gauge.
    • month: Creates a monthly view that circles dates exceeding a specific threshold and displays streaks.
    • pie: Creates a pie chart. This requires the data parameter for sectors, label and extLabel for displaying labels, and dataName for legend display names.
  6. How to use non-daily note file names as X values

    master

    Tracker does not require file names to contain dates, but it always requires a date source for X values. If your notes do not use date-based file names, you must specify an alternative source using searchType and searchTarget, and then mark that source as the X dataset by setting the xDataset parameter to its index.

    If you have no explicit date fields, you can use the file's metadata as a fallback:

    • cDate: Creation date
    • mDate: Modification date

    To use these, set the searchType to fileMeta and the searchTarget to either cDate or mDate.

  7. Handling missing values in expressions

    master

    In Tracker, missing values (null values) are ignored by functions like sum() or average(). However, performing arithmetic on a missing value (e.g., value + missing_value) will result in a missing value.

    To prevent this, you can:

    1. Use the penalty parameter in your tracker configuration to assign a default value to missing data.
    2. Use the setMissingValues(Dataset, number) expression function to explicitly replace nulls within an expression.

    Example: {{sum(setMissingValues(dataset(1), 0))}} replaces all missing values in dataset 1 with 0 before summing.

  8. Use mathematical operators in tracker expressions

    master

    You can perform arithmetic operations within the summary.template using double curly braces {{ ... }}. The plugin supports operations between numbers and datasets, as well as between two datasets.

    Number and Number

    Direct arithmetic on numbers: number + number

    Dataset and Number

    Performing arithmetic on a dataset results in a new dataset where the operation is applied to each element:

    • Dataset + number
    • Dataset - number
    • Dataset * number
    • Dataset / number
    • Dataset % number (modulo)

    Dataset and Dataset

    Adding two datasets results in a new dataset where each element is the sum of the corresponding elements from the two datasets: Dataset1 + Dataset2 (where Dataset[i] = Dataset1[i] + Dataset2[i])

    Note: Use the dataset(index) function to reference specific datasets in complex expressions.

    searchType: dvField
    searchTarget: dataviewTarget
    folder: /diary
    startDate: 2021-01-01
    endDate: 2021-01-03
    summary:
        template: 'Maximum value: {{max() * 2::i}}'
  9. Handle table defects and invalid data

    master

    The plugin has specific behaviors when encountering malformed Markdown tables or invalid data:

    1. Extra Columns: If a table contains more columns than required by the data structure, the graph will still render using the relevant columns.
    2. Invalid Date Formats: If a specific row contains a value that is not a valid date, that specific row will be skipped.
    3. All Invalid Dates: If all rows in a table contain invalid dates, the plugin will display an error message instead of rendering a graph.
  10. Provide array input to Tracker

    master

    Tracker supports two methods for providing array-style input:

    1. YAML Array Syntax: Use the standard YAML bracket notation: ['value1', 'value2', 'value3'].
    2. Comma-Separated Values: Use a list of values separated by commas: value1, value2, value3. You can also wrap this list in single quotes: 'value1, value2, value3'.
  11. Use frontmatterlist to track multiple habits in one property

    master

    The frontmatterlist search type allows you to track multiple distinct values (targets) that are stored within a single YAML property (e.g., a list of habits). The plugin searches the frontmatter for the specified property and checks if the list contains the value provided in the searchTarget using the syntax propertyName[value].

    Key behaviors:

    • Case Insensitivity: Searching for a value is case-insensitive. For example, searching for yoga will match yoga, Yoga, or YOGA in your frontmatter.
    • List Formats: It supports various YAML list formats, including single-line lists with or without square brackets (e.g., habits: [yoga, piano]), empty lists (habits: []), and multi-line lists:
      habits:
        - yoga
        - spanish
    searchType: frontmatterlist
    searchTarget: habits[yoga]
    folder: diary
    startDate: 2026-02-01
    endDate: 2026-02-28
    datasetName: Yoga
    month: