Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
pyrochlore committed May 20, 2021
2 parents 4c56b50 + bd23fad commit f24b5b8
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 25 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ You can set the default folder location and date format in the plugin's settings
For more information about the dateFormat settings, check the [TestDateFormats example](https://github.com/pyrochlore/obsidian-tracker/blob/master/examples/TestDateFormats.md) and [moment.js string format](https://momentjs.com/docs/#/parsing/string-format/).

## Release Notes
### v1.5.1
- Fixed labels not shown in light theme
- Enhanced error handling for searchType 'table'

### v1.5.0
- New searchType 'table', searching records from a given table
- New searchType 'dvField', searching the inline fields used with Dataview plugin
Expand Down
14 changes: 12 additions & 2 deletions examples/ErrorMessages.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Error Messages
## YAML
Error parsing caused by the escaping character
Error parsing caused by the escaping character --> YAMLParsError: Missing closing "quote"
``` tracker
searchType: tag
searchTarget: "\"
Expand Down Expand Up @@ -125,4 +125,14 @@ searchType: frontmatter, frontmatter
searchTarget: bloodpressure[0], bloodpressure[1]
line:
titles: "Blood Pressure"
```
```

## Table
All dates are invalid, leads to an error message
``` tracker
searchType: table
searchTarget: data/Tables[4][0], data/Tables[4][1]
xDataset: 0
line:
lineColor: none, yellow
```
19 changes: 19 additions & 0 deletions examples/TestTable.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,22 @@ line:
showLegend: true
legendPosition: right
```

## Tables with Defects
``` tracker
searchType: table
searchTarget: data/Tables[2][0], data/Tables[2][1]
xDataset: 0
line:
lineColor: none, yellow
```

Wrong date format in Table
``` tracker
searchType: table
searchTarget: data/Tables[3][0], data/Tables[3][1]
xDataset: 0
line:
lineColor: none, yellow
```

25 changes: 25 additions & 0 deletions examples/data/Tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,28 @@
| 2021-05-08 | 6.25 @ 5.55 |
| 2021-05-09 | 6.25 @ 5.45 |
| 2021-05-10 | 6.35 @ 5.75 |

## Tables with Defects
More columns than need, graph still rendered

Date | Weight (kg) |
| - | - | -
| 2021-05-01 | 60.0 | 20.1 |
2021-05-02 | 62.1 | 20.5
| 2021-05-03 | 62.2 | 20.3 |

The row with wrong date format will be skipped

Date | Weight (kg) |
| - | - | -
| not a date | 60.0 | 20.1 |
2021-05-02 | 62.1 | 20.5
| 2021-05-03 | 62.2 | 20.3 |

All dates are invalid, leads to an error message

Date | Weight (kg) |
| - | - | -
| not a date | 60.0 | 20.1 |
not a date | 62.1 | 20.5
| not a date | 62.2 | 20.3 |
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-tracker",
"name": "Tracker",
"version": "1.5.0",
"version": "1.5.1",
"minAppVersion": "0.9.12",
"description": "A plugin tracks occurrences and numbers in your notes",
"author": "pyrochlore",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-tracker",
"version": "1.5.0",
"version": "1.5.1",
"description": "A plugin tracks occurrences and numbers in your notes",
"main": "main.js",
"scripts": {
Expand Down
58 changes: 40 additions & 18 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,8 @@ export default class Tracker extends Plugin {
let columnXDataset = xDatasetQuery.getAccessor(1);
if (columnXDataset >= numColumns) continue;
let xValues = [];


let indLine = 0;
for (let tableLine of tableLines) {
let dataRow = helper.trimByChar(tableLine.trim(), "|");
let dataRowSplitted = dataRow.split("|");
Expand All @@ -494,11 +495,28 @@ export default class Tracker extends Plugin {
}
}

xValues.push(date);
if (date.isValid()) {
xValues.push(date);
}
else {
xValues.push(null);
}

}
else {
xValues.push(null);
}
indLine++;
}
// console.log(xValues);

if (xValues.every(v => v === null)) {
let errorMessage = "No valid X value found";
renderErrorMessage(canvas, errorMessage);
el.appendChild(canvas);
return;
}

// get y data
for (let yDatasetQuery of yDatasetQueries) {
let columnOfInterest = yDatasetQuery.getAccessor(1);
Expand All @@ -516,14 +534,16 @@ export default class Tracker extends Plugin {
if (splitted.length === 1) {
let value = parseFloat(splitted[0]);
if (Number.isNumber(value)) {
this.addToDataMap(
dataMap,
xValues[indLine].format(
renderInfo.dateFormat
),
yDatasetQuery,
value
);
if (indLine < xValues.length && xValues[indLine]) {
this.addToDataMap(
dataMap,
xValues[indLine].format(
renderInfo.dateFormat
),
yDatasetQuery,
value
);
}
}
} else if (
splitted.length > yDatasetQuery.getAccessor(2) &&
Expand All @@ -534,14 +554,16 @@ export default class Tracker extends Plugin {
splitted[yDatasetQuery.getAccessor(2)].trim();
value = parseFloat(splittedPart);
if (Number.isNumber(value)) {
this.addToDataMap(
dataMap,
xValues[indLine].format(
renderInfo.dateFormat
),
yDatasetQuery,
value
);
if (indLine < xValues.length && xValues[indLine]) {
this.addToDataMap(
dataMap,
xValues[indLine].format(
renderInfo.dateFormat
),
yDatasetQuery,
value
);
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/rendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ function renderYAxis(
} else {
yAxisLabel.attr(
"y",
+yTickLength + maxTickLabelWidth + yAxisLabelSize.height / 2.0
+yTickLength + maxTickLabelWidth + yAxisLabelSize.height
);
}
if (yAxisLabelColor) {
Expand Down
2 changes: 1 addition & 1 deletion styles.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.theme-light {
--color-title: #000000;
--color-axis: #000000;
--font-axis-label: #000000;
--color-axis-label: #000000;
--color-tick-label: #000000;
--color-line: #000000;

Expand Down
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
"1.3.0": "0.9.12",
"1.4.0": "0.9.12",
"1.4.1": "0.9.12",
"1.5.0": "0.9.12"
"1.5.0": "0.9.12",
"1.5.1": "0.9.12"
}

0 comments on commit f24b5b8

Please sign in to comment.