Ok, this might get me somewhere. I did some testing like so, but the 
classname is always black:

<$set name=number value=-5>

<$set name=cssclassname 
filter="[<<number>>sign[]match[-1]then[red-bold]else[black]]">

<span class=<<cssclassname>>><<number>></span>
</$set>
</$set>


There's also no guarantee if I go down this road that the text from the 
tiddler where I use formulas to make a calculation will be parsed as its 
resulting number, rather than just a weird string.

On Tuesday, 11 May 2021 at 01:13:34 UTC+1 TW Tones wrote:

> Quick tip
> If you get your number into a variable you can then use the sign operator 
> <https://tiddlywiki.com/#sign%20Operator> you could then have two or 
> three css classes defined and have a filter determine which of these three 
> css classes to apply to the display of the number, or use the result of the 
> sign in a list fillter, reveal widget etc...
>
> Untested thinking here
>
> <$set name=cssclassname 
> filter="[<number>sign[]match[-1]then[red-bold]else[black]]">
>
> <span class=<<cssclassname>>><<number>></span>
>
> Tones
>
> On Tuesday, 11 May 2021 at 07:04:04 UTC+10 [email protected] wrote:
>
>> Hi! First time posting. I've been trying to figure this out all day, but 
>> I have to concede I won't figure it out.
>>
>> My first big TW project is this personal budget calculator: 
>> https://trumad.github.io/budgetlywiki/
>>
>> I'd really love to make the "Budget delta" result green when it's a 
>> positive number, and red when it's a negative number. You can see how the 
>> delta is calculated by editing the " Budget Overview" tiddler:
>>
>> (= {{Income Total}} - {{Expenses Total}} =)
>>
>> And you can see that the tiddlers Income Total and Expenses Total each do 
>> their own calculations before one gets subtracted from the other. For 
>> example:
>>
>> (= sum([tag[Expenses]get[value]]) =)
>>
>> So what I tried to do was make a new tiddler called budgetDelta which 
>> would do the delta calculation. And then use the <$reveal widget to do a 
>> "lt" calculation on the budgetDelta tiddler:
>>
>> <$reveal type="lt" state="budgetDelta" text="0">
>> Less than 0!
>> </$reveal>
>>
>> However, it doesn't work if the budgetDelta tiddler has the formulas 
>> syntax in it. The calculation doesn't seem to be done. It maybe coerces the 
>> actual text of the formula to a number, and then decides whether it's less 
>> than 0, because if the calculations make the delta a minus number, it still 
>> doesn't register as being under 0. So I changed budgetDelta to just a plain 
>> integer in wikitext and it worked as expected. But obviously I need it to 
>> work as a formula, which the <$reveal widget uses to decide whether the 
>> value is less than 0.
>>
>> I guess maybe the formulas plugin doesn't work properly with reveal, and 
>> I should find another way. But I'm stumped.
>>
>> I hope I've been making some sense here. If anyone finds a way to make 
>> the text red if the number is less than 0, I'd be very grateful. It's 
>> obviously not a huge priority; the thing works as is. But I'm keen to learn 
>> what I'm doing wrong and how i can improve my TW knowledge. Thanks!
>>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/b212f8c2-38a9-4997-8fd9-e485da5aec64n%40googlegroups.com.

Reply via email to