Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactored and added custom average chart #3

Merged
merged 7 commits into from Apr 18, 2022

Conversation

oliviercarizzoni
Copy link

Hey, I hope you are doing great, before you merge read this !

So i wanted to put code in module and see possibilities in Obsidian, I ended up using the plugin CustomJS, and I added the custom chart type on average.

So in order to use:

  • About thoses changes, if you don't feel it, create a branch, refuse this merge and I will reopen a pull request to merge on the new branch, or find a way to import it in a branch.
  • Install CustomJS from Obsidian
  • Set Folder in options to point at Scripts/CustomJS folder
  • Set your settings, notably daysPath (names have changed don't worry)
  • That's it ?

Well almost, code gets more complicated when we refactor, I took CustomJS because it provides a unique path to look for modules in a simple way, with others solutions I would have needed to hardcode the path, eurghh.

  • The example is ready to use, but you have to pass parameters in a object to the function renderWeeklyChart, those params are described in the js file in the function description.
  • Parameters with default values don't need to be passed, default will be taken, you can of course override defaults in js.
  • type param allows you to make the chart on average, simply pass 'average' to have it, otherwise you can omit the param :)
  • variables and names have changed a bit, attributes is now an object instead of a map.
  • I included another function renderSingleAttrChart, it simply allows to render a single attr on daily basis, you can leave it there :)

CustomJS does not make things tricky, it simply loads the class and make them available anywhere. But that is the good thing, you can also import code in the same way in templater expressions to fully refactor.

And I think it is it, I hope this is not too complicated, feel free to ask for infos !

Best, Olivier

@mulfok
Copy link
Owner

mulfok commented Apr 18, 2022

Just wanted to say thanks from the bottom of my heart again! Your help truly never ceases to amaze me.

I've had a look at the changes and implemented them (with relative ease) into my own vault, but I've added some new stuff to the templates themselves, so I'll merge the changes you've made currently and write installation instructions once I've pushed my own template changes.

Thanks so much again!

@mulfok mulfok merged commit 3e7210a into mulfok:main Apr 18, 2022
@oliviercarizzoni
Copy link
Author

Hi, thanks for the compliment, my pleasure if you learn something new and useful !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants