commit
98cd4d7029
5 changed files with 331 additions and 0 deletions
@ -0,0 +1,28 @@ |
|||
input_path ?= $$HOME/notes/diary/running.csv |
|||
chart_json ?= chart.json |
|||
|
|||
.PHONY: format-data |
|||
format-data: tempelhof.csv ## Format data
|
|||
|
|||
tempelhof.csv: |
|||
csv-tools filter "$(input_path)" "track" "Tempelhof" | \
|
|||
csv-tools select - date distance time track rank | \
|
|||
csv-tools rank - "time" > "$@" |
|||
|
|||
.PHONY: create-chart |
|||
create-chart: ## Create new chart
|
|||
./create-chart "$(chart_json)" |
|||
|
|||
.PHONY: update-chart |
|||
update-chart: ## Update properties of an existing chart
|
|||
ifeq ($(chart_id),) |
|||
@echo "You must set the chart_id variable" |
|||
@echo "Example: make update chart_id=ABCdef" |
|||
@exit 1 |
|||
else |
|||
./update-chart "$(chart_id)" "$(chart_json)" |
|||
endif |
|||
|
|||
.PHONY: help |
|||
help: |
|||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-16s\033[0m %s\n", $$1, $$2}' |
@ -0,0 +1,194 @@ |
|||
{ |
|||
"language": "en-US", |
|||
"metadata": { |
|||
"annotate": { |
|||
"notes": "" |
|||
}, |
|||
"axes": { |
|||
"labels": "time_per_km_str", |
|||
"x": "date_parsed", |
|||
"y": "sec_per_km_float" |
|||
}, |
|||
"data": { |
|||
"changes": [ |
|||
{ |
|||
"column": 7, |
|||
"ignored": false, |
|||
"row": 0, |
|||
"value": "date" |
|||
}, |
|||
{ |
|||
"column": 9, |
|||
"ignored": false, |
|||
"row": 0, |
|||
"value": "time per km (sec)" |
|||
} |
|||
], |
|||
"column-format": { |
|||
"average": { |
|||
"ignore": true, |
|||
"number-append": "", |
|||
"number-divisor": 0, |
|||
"number-format": "auto", |
|||
"number-prepend": "", |
|||
"type": "auto" |
|||
}, |
|||
"date": { |
|||
"ignore": false, |
|||
"number-append": "", |
|||
"number-divisor": 0, |
|||
"number-format": "auto", |
|||
"number-prepend": "", |
|||
"type": "text" |
|||
}, |
|||
"note": { |
|||
"ignore": true, |
|||
"number-append": "", |
|||
"number-divisor": 0, |
|||
"number-format": "auto", |
|||
"number-prepend": "", |
|||
"type": "auto" |
|||
}, |
|||
"time": { |
|||
"ignore": false, |
|||
"number-append": "", |
|||
"number-divisor": 0, |
|||
"number-format": "auto", |
|||
"number-prepend": "", |
|||
"type": "text" |
|||
} |
|||
}, |
|||
"horizontal-header": true, |
|||
"transpose": false, |
|||
"upload-method": "copy", |
|||
"vertical-header": true |
|||
}, |
|||
"describe": { |
|||
"byline": "", |
|||
"computed-columns": [ |
|||
{ |
|||
"formula": "DATE(NUMBER(SUBSTR(date, 0, 4)), NUMBER(SUBSTR(date, 5, 2)), NUMBER(SUBSTR(date, 8, 2)))", |
|||
"name": "date_parsed" |
|||
}, |
|||
{ |
|||
"formula": "NUMBER(SUBSTR(time, 0, 2)) * 60 + NUMBER(SUBSTR(time, 3, 5)) + NUMBER(SUBSTR(time, 6, 8)) * 0.01", |
|||
"name": "time_sec" |
|||
}, |
|||
{ |
|||
"formula": "time_sec / distance", |
|||
"name": "sec_per_km_float" |
|||
}, |
|||
{ |
|||
"formula": "TRUNC(ROUND(sec_per_km_float) / 60)", |
|||
"name": "min_per_km" |
|||
}, |
|||
{ |
|||
"formula": "ROUND(sec_per_km_float) % 60", |
|||
"name": "sec_per_km" |
|||
}, |
|||
{ |
|||
"formula": "CONCAT(IF(min_per_km < 10, 0), min_per_km, \":\", IF(sec_per_km < 10, 0), sec_per_km)", |
|||
"name": "time_per_km_str" |
|||
} |
|||
], |
|||
"intro": "", |
|||
"number-append": "", |
|||
"number-divisor": 0, |
|||
"number-format": "-", |
|||
"number-prepend": "", |
|||
"source-name": "", |
|||
"source-url": "" |
|||
}, |
|||
"publish": { |
|||
"chart-height": 460.5, |
|||
"embed-height": 500, |
|||
"embed-width": 1000 |
|||
}, |
|||
"visualize": { |
|||
"area-fill-color-below": "#cccccc", |
|||
"area-fill-color-between": "#cccccc", |
|||
"auto-labels": true, |
|||
"base-color": 0, |
|||
"chart-type-set": true, |
|||
"color-base": "#47b641", |
|||
"color-key": { |
|||
"base": { |
|||
"color": "#47b641", |
|||
"def_lbl": "base", |
|||
"label": "base" |
|||
} |
|||
}, |
|||
"connector-lines": true, |
|||
"custom-area-fills": [], |
|||
"custom-colors": [], |
|||
"custom-range-x": ["", ""], |
|||
"custom-range-y": ["", ""], |
|||
"custom-ticks-x": "", |
|||
"custom-ticks-y": "", |
|||
"fill-below": false, |
|||
"fill-between": false, |
|||
"highlight-labeled": false, |
|||
"highlighted-series": [], |
|||
"highlighted-values": [], |
|||
"interpolation": "linear", |
|||
"label-colors": false, |
|||
"label-margin": 0, |
|||
"labeling": "right", |
|||
"line-dashes": [], |
|||
"line-symbols": false, |
|||
"line-symbols-on": "both", |
|||
"line-symbols-opacity": 1, |
|||
"line-symbols-shape": "circle", |
|||
"line-symbols-shape-multiple": [], |
|||
"line-symbols-size": 3.5, |
|||
"line-value-labels": false, |
|||
"line-widths": [], |
|||
"outlines": false, |
|||
"regression": false, |
|||
"regression-method": "linear", |
|||
"scale-y": "linear", |
|||
"shape": "fixed", |
|||
"show-tooltips": true, |
|||
"sticky-tooltips": false, |
|||
"text-annotations": [], |
|||
"tooltip": { |
|||
"body": "<b>date:</b> {{ date }}<br>\n<b>distance:</b> {{ distance }} km<br>\n<b>track:</b> {{ track }}<br>\n<b>time:</b> {{ time }}<br>\n<b>rank:</b> {{ rank }}", |
|||
"fields": { |
|||
"date": "date", |
|||
"date_parsed": "date_parsed", |
|||
"distance": "distance", |
|||
"min_per_km": "min_per_km", |
|||
"rank": "rank", |
|||
"sec_per_km": "sec_per_km", |
|||
"sec_per_km_float": "sec_per_km_float", |
|||
"time": "time", |
|||
"time_per_km_str": "time_per_km_str", |
|||
"time_sec": "time_sec", |
|||
"track": "track" |
|||
}, |
|||
"title": "{{ time_per_km_str }} min/km" |
|||
}, |
|||
"tooltip-number-format": "0,0.[00]", |
|||
"x-axis": { |
|||
"range": null |
|||
}, |
|||
"x-format": "YYYY|MMM", |
|||
"x-grid": "off", |
|||
"x-grid-lines": "on", |
|||
"x-tick-format": "YYYY", |
|||
"y-axis": { |
|||
"range": [0, 500] |
|||
}, |
|||
"y-format": "0", |
|||
"y-grid": "on", |
|||
"y-grid-format": "0,0.[00]", |
|||
"y-grid-label-align": "left", |
|||
"y-grid-labels": "auto", |
|||
"y-grid-lines": "on", |
|||
"y-grid-subdivide": true, |
|||
"y-pos": "left" |
|||
} |
|||
}, |
|||
"title": "Running", |
|||
"type": "d3-scatter-plot" |
|||
} |
@ -0,0 +1,25 @@ |
|||
#!/bin/bash |
|||
|
|||
if [[ $# -ne 1 ]]; then |
|||
echo "Usage: ${0##} <chart json path>" >&2 |
|||
exit 1 |
|||
fi |
|||
|
|||
if [[ -z "$API_URL" ]]; then |
|||
echo "Environment variable API_URL must be defined" >&2 |
|||
exit 1 |
|||
fi |
|||
|
|||
if [[ -z "$AUTH_TOKEN" ]]; then |
|||
echo "Environment variable AUTH_TOKEN must be defined" >&2 |
|||
exit 1 |
|||
fi |
|||
|
|||
chart_id=$1 |
|||
chart_json_path=$2 |
|||
|
|||
set -x |
|||
curl -X POST "$API_URL/v3/charts" \ |
|||
-H "Authorization:Bearer $AUTH_TOKEN" \ |
|||
-H "Content-Type: application/json" \ |
|||
--data "@$chart_json_path" | jq |
@ -0,0 +1,25 @@ |
|||
#!/bin/bash |
|||
|
|||
if [[ $# -ne 2 ]]; then |
|||
echo "Usage: ${0##} <chart id> <chart json path>" >&2 |
|||
exit 1 |
|||
fi |
|||
|
|||
if [[ -z "$API_URL" ]]; then |
|||
echo "Environment variable API_URL must be defined" >&2 |
|||
exit 1 |
|||
fi |
|||
|
|||
if [[ -z "$AUTH_TOKEN" ]]; then |
|||
echo "Environment variable AUTH_TOKEN must be defined" >&2 |
|||
exit 1 |
|||
fi |
|||
|
|||
chart_id=$1 |
|||
chart_json_path=$2 |
|||
|
|||
set -x |
|||
curl -X PATCH "$API_URL/v3/charts/$chart_id" \ |
|||
-H "Authorization:Bearer $AUTH_TOKEN" \ |
|||
-H "Content-Type: application/json" \ |
|||
--data "@$chart_json_path" | jq |
Loading…
Reference in new issue