[TW5] Data Visualisation using SVG or Chartist.js

132 views
Skip to first unread message

Anders Hagen Jarmund

unread,
Aug 2, 2019, 2:52:05 PM8/2/19
to TiddlyWikiDev
Hi all! I am pretty new to TiddlyWiki, and was looking for data visualisation plugins, but as far as I could see, they are yet to be fully developed. The main target is to summarise data from several articles in scatter plots, being able to update the plot when new research arrive. Then I stumbled across the chartist.js library, which seems perfect (?). But I wasn't able to include the necessary scripts in my tiddlers; I added a tiddler with

and tagged it $:/tags/RawMarkup, and tried to add 
<div class="ct-chart ct-perfect-fourth"></div>
<script>
var data = {
  
// A labels array that can contain any sort of values
  labels
: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
  
// Our series array that contains series objects or in this case series data arrays
  series
: [
    
[5, 2, 4, 2, 0]
  
]
};


// Create a new line chart object where as first parameter we pass in a selector
// that is resolving to our chart container element. The Second parameter
// is the actual data object.
new Chartist.Line('.ct-chart', data);
</script>

into another tiddler, but no plot appeared.. I guess the problem is related to the latter script, but are there any simple workarounds to make it work? Or has the chartist.js to be loaded as a library?



As a side note; I guess it is simpler to use an approach combining CSS and SVG, such as https://css-tricks.com/how-to-make-charts-with-svg/ It seems quite easy to implement into macros, and may provide ok looking scatter plots.

Mat

unread,
Aug 2, 2019, 3:22:05 PM8/2/19
to TiddlyWikiDev
I vaguely recall someone mentioned scatter plots very recently. Possibly it was Jed / inmysocks

Otherwise I made graphs which is a pure TW+CSS approach. Now, it is probably NOT what you're after - I'd say it is not appropriate for data heavy use or more "sophisticated" applications. Rather it is made for showing quick graphs like in some presentation. Overall the whole plugin is also due for a full overhaul when 5.1.20 comes with its many new filter operators and even new CSS functions.

...but if you still want to try it out, you can get the scatter plot components under the Install tab and DnD the blue pill found at bottom-right. You'll probably also want x-axis, y-axis and Reference.

Your "items" to be plotted would be tiddlers holding an x and y field with their values and you would create the graph like so

<<graph "myfilter" scatter>>


<:-)

Mat

unread,
Aug 2, 2019, 3:22:31 PM8/2/19
to TiddlyWikiDev

Anders Hagen Jarmund

unread,
Aug 2, 2019, 5:13:17 PM8/2/19
to TiddlyWikiDev
That's wonderful, Mat! Thank you very much!

ajarmund

unread,
Aug 24, 2019, 7:02:13 AM8/24/19
to tiddly...@googlegroups.com
And now 5.1.20 has been released with mathematical operators! I tried to make a simple macro using SVG: http://folk.ntnu.no/anderhja/plotdemo.html

However, what is the best way to transclude a macro making a SVG in terms of scaling? I tried to make a tiddler calling the macro with type SVG for transclusion, but it didn't work, so maybe CSS is the way to go?


- Anders

Jed Carty

unread,
Aug 25, 2019, 3:56:25 AM8/25/19
to TiddlyWikiDev
I made some data visualisation plugins.


I should have some examples using chart.js and p5.js around somewhere but I have no idea where they are.

I have been working with d3.js in my day job so there will probably be some more d3 plugins at some point in the future.

Mohammad

unread,
Aug 26, 2019, 5:09:44 AM8/26/19
to TiddlyWikiDev
Hi Anders,
 This is wonderful! The feasibility was proved!
It is good if one can customize the size the marker and have a better hover effect.

--Mohammad

ajarmund

unread,
Aug 26, 2019, 8:24:00 AM8/26/19
to TiddlyWikiDev
Thank you! I updated the macro to have plot width and marker size as parameters as well. The hover effect should be customisable through the CSS stylesheet, but I guess the plugins by Jed will have more functionality

Best,
Anders

ajarmund

unread,
Aug 26, 2019, 8:26:50 AM8/26/19
to TiddlyWikiDev
Very nice, Jed! I think easy-to-use data visualisation tools will increase the value of tiddlywiki for use in research and academia a lot!

Best,
Anders

Mohammad

unread,
Aug 27, 2019, 3:02:00 AM8/27/19
to TiddlyWikiDev
This is great Anders!

Thanks for sharing!

Mohammad
Reply all
Reply to author
Forward
0 new messages