Reading JSON file & visualising data #1225
metawops
started this conversation in
Show and tell
Replies: 1 comment
-
Nice! I didn't know Obsidian Chart exposed so much functionality. Looks great! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I wanted to visualise some data from a JSON file (actually the number of downloads of my own Obsidian plugin Table to CSV Exporter) and was struggling on how to read a local file in JavaScript inside a
dataviewjs
block.Turns out that Dataview has a handy function
dv.io.load()
that can load any text file. So I loaded the contents of the JSON file (which is located directly in my vault's main folder) into a string and parsed that into a JSON object, easy-peasy. 😊Creating a table out of this was then easy.
And by integrating the "Obsidian Graph" plugin I was able to visualise my plugin downloads in a simple line graph, too.
Here's the
dataviewjs
code block:And here's the (shortened) JSON file for reference:
I wrote a little Python script that gets the latest download numbers once a day (cron job) via a HTTP request and appends them to this JSON file which is then copied into my vault. 😊
This is the result from the preview (reading) pane in Obsidian (chart & table swapped):

Beta Was this translation helpful? Give feedback.
All reactions