Hallo Stephan,
I'm a bit late, but: thanks! It works! At least with counts up to 9 :-)
The missing parts for a real tag cloud implementation are AFAICS:
1) get min and max count over all tags (minCnt, maxCnt)
2) fit each count (cnt) into a corresponding font size range (minFontsize,
maxFontsize):
fontSize = minFontsize + (cnt – minCount) * (maxFontsize – minFontsize) /
(maxCount - minCount)
So much for the theory. Implementation is left as an exercise for the
reader :-)
Uwe
Am Dienstag, 1. April 2014 16:20:45 UTC+2 schrieb Stephan Hradek:
>
> I just created a "count" filter which WOULD help with this, but your idea
> is not well thought through. Imagine I have a 3 counts: 1, 10 and 100. The
> resulting sizes would be: "1.1em", "1.10em" and "1.100em". Would you be
> able to tell the difference? ;)
>
> For completeness sake, this is the source of my count filter:
>
> /*\
> title: $:/core/modules/filters/count.js
> type: application/javascript
> module-type: filteroperator
>
> Filter operator that gives the counts the current list's members
>
> \*/
> (function(){
>
> /*jslint node: true, browser: true */
> /*global $tw: false */
> "use strict";
>
> /*
> Export our filter function
> */
> exports.count = function(source,operator,options) {
> // count the source if it's not an array
> var count = 0;
> if(!$tw.utils.isArray(source)) {
> $tw.utils.each(source,function(element,title) {
> ++count;
> });
> return [ "" + count ];
> }
> // return array's length
> return [ "" + source.length ];
> };
>
> })();
>
>
>
> used like this (using your request)
>
> \define mySize()
> "font-size:$(cnt)$em"
> \end
>
> <$list filter="[tags[]!is[system]sort[title]]">
> <$set name="title" value={{!!title}}>
> <$list filter="[is[current]tagging[]count[]]">
> <$set name="cnt" value={{!!title}}>
> <span style=<<mySize>>>
> <$tiddler tiddler=<<title>>>
> <$transclude tiddler="$:/core/ui/TagTemplate"/>
> </$tiddler>
> </span>
> </$set>
> </$list>
> </$set>
> </$list>
>
>
>
> I'm not sure yet, whether to make it a plugin. Comments welcome.
>
>
>
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.