preview draw.sh
This commit is contained in:
41
cmd/clitest/draw.sh
Normal file
41
cmd/clitest/draw.sh
Normal file
@@ -0,0 +1,41 @@
|
||||
#! /bin/bash
|
||||
|
||||
cd "$(dirname "$(realpath "$BASH_SOURCE")")"
|
||||
|
||||
go run . \
|
||||
-json \
|
||||
-group-date ^20..-.. \
|
||||
-group-name '^[^:]*:[^:]*' \
|
||||
-like-name '(AssetAccount|Debts|Stock|Retirement)' \
|
||||
-foo reg \
|
||||
"$@" ./macro.d/* \
|
||||
| jq -c '.[] | {label: .name, x: .delta.Date, y: .balance[(.delta.Currency)], z: .delta.Currency}' \
|
||||
| grep '"z":"\$"' \
|
||||
| python3 -c '
|
||||
# line chart
|
||||
import matplotlib.pyplot as plt
|
||||
import json
|
||||
from sys import stdin
|
||||
|
||||
fig = plt.figure()
|
||||
plot = fig.add_subplot()
|
||||
|
||||
label_z_x_y = {}
|
||||
for line in stdin.readlines():
|
||||
if not line:
|
||||
continue
|
||||
d = json.loads(line)
|
||||
if not d["label"] in label_z_x_y:
|
||||
label_z_x_y[d["label"]] = {}
|
||||
if not d["z"] in label_z_x_y[d["label"]]:
|
||||
label_z_x_y[d["label"]][d["z"]] = {}
|
||||
label_z_x_y[d["label"]][d["z"]][d["x"]] = d["y"]
|
||||
for label in label_z_x_y:
|
||||
for z in label_z_x_y[label]:
|
||||
xs = sorted([i for i in label_z_x_y[label][z].keys()])
|
||||
ys = [label_z_x_y[label][z][x] for x in xs]
|
||||
plot.plot(xs, ys, label=f"{label} ({z})")
|
||||
|
||||
plot.legend()
|
||||
plt.show()
|
||||
'
|
||||
Reference in New Issue
Block a user