Calling JS every update

I have written a variety of plugins to integrate charting libraries into TiddlyWiki. My latest discovery was a “pure CSS” table-to-chart library. I was impressed and made a TW plugin for it.

However, pure CSS doesn’t quite cut it - it needs a little JS help. What I need to do is run a little JS every time a tiddler is displayed or updated:

for (let e of document.querySelectorAll('.charts-css td')) {
  let n = Number.parseFloat(e.textContent);
  e.style[Number.isNan(n) ? 'removeProperty' : 'setProperty']('--value', n);
}

Does TiddlyWiki support such a thing?

1 Like

If you would make a widget instead of a macro, you could set class attributes with the render and refresh cycle, instead of a hack like this one.

There is a widget tutorial at the dev-edition