Use percent '%' as an argument of SASS function - css

I need to pass '%' unit sign as an argument for my mixin. While passing 'px'/'vh' etcetera has no problem, compiler refuses to work with percent sign.
With px there is no problem.
The same problem exists if I want to add percentage sign after function call.
This seems weird because it works perfectly with another units.
Is there a way to use percentage sign without modifying the output of a function?

In both cases you can use interpolation.
width: nth($params, $i)#{'%'};
and
#include scrollable-table-by-every-column-width(#{'%'}, auto, 15, 10, 20, 20, 15, 15, 5);
UPD
In a case where you need percents after function call you can use percentage function as well. But you need to keep in mind that this function literally does num * 100. So in this case with
width: nth($params, $i) +%;
You can do next:
percentage(nth($params, $i) / 100) //assuming you passed already calculated percents (not 0.2, 0.3.., but 20, 30...)
But this doesn't resolve problem when you want to pass percentage sign as an argument.

Related

Xquery transform string to same number but with decimal dot

I am working with xQuery version 1.0 and I'm trying to transform a string of numbers to the same number but with a decimal dot. But here's my problem. The decimal dot should be placed according to a certain element value.
The message I'm trying to transform:
<AMOUNT
<VALUE>34221</VALUE>
<NUMOFDEC>1</NUMOFDEC>
<SIGN>+</SIGN>
<CURRENCY>EUR</CURRENCY>
<DRCR>C</DRCR>
</AMOUNT>
What I'm trying to achieve:
<prefix:Rates
<prefix:Amount currency="EUR">3422.1</prefix:Amount>
</prefix:Rates>
What did I try:
<prefix:Rates>
<prefix:Amount currency="{ data(AMOUNT/CURRENCY) }">{ ((data(AMOUNT/VALUE) div 10)) }</prefix:Amount>
</prefix:Rates>
The problem with the above transformation is that it's not dynamic. But as you can see there is an element <NUMOFDEC>1</NUMOFDEC>. Can I use that value in a certain formula to place the decimal dot according to this value?
EDIT (19th october 2022):
As a another user mentioned, there is recursion. Let's take this recursion from user #Michael Kay:
declare function f:two-to-the($n as xs:integer) as xs:integer {
if ($n = 0) then 1 else 2 * f:two-to-the($n - 1)
};
So how will I be able to apply this to my situation?
(div math:pow(10, AMOUNT/NUMOFDEC)) might do but I don't recall whether XQuery 1 supports the math namespace mathematical functions, namespace is e.g. math="http://www.w3.org/2005/xpath-functions/math", it might depend on your XQuery processor, I guess.
So I found a solution with an if-else statement. Unfortunately as another user mentioned, the mat:pow fucntion is not supported by Xquery 1.0.
Solution:
<prefix:Amount>{
(for $decimal in (data(AMOUNT/NUMOFDEC))
return if ($decimal = '1')
then ((data(AMOUNT/VALUE)) div 10)
else if ($decimal = '2')
then ((data(AMOUNT/VALUE)) div 100)
else ($decimal = '3')
then ((data(AMOUNT/VALUE)) div 1000)
else ((data(AMOUNT/VALUE)) div 10000))
}</prefix:Amount>
Is it fully dynamic? no. But it will do the trick for now.
EDIT (19th october 2022): The following recursion works!:
declare function xf:ten-to-the($decimal as xs:integer) as xs:integer {
if ($decimal = 0) then 1 else 10 * xf:ten-to-the($decimal - 1)
};

How to multiply a value, returned by a shortcode in Wordpress?

So I can't get my head around this. I am basically using a plugin that has the following shortcode
Example: [valueABC] which is equal to 40.
Now I want to multiply the value by 2, so the output with be 40*2 = 80 on the frontend. But can't figure out how to do it without hard coding it in PHP.
Try This:
function vx_summation(){
$vxtr=10;
return $vxtr;
}
add_shortcode('summation_shortcode','vx_summation');
function vx_preview_summation(){
$vxtr = do_shortcode('[summation_shortcode]');
return $vxtr*3;
}
add_shortcode('preview_summation_shortcode','vx_preview_summation');
[preview_summation_shortcode]
OR you can Follow this Documentation:
https://developer.wordpress.org/reference/functions/do_shortcode/

get custom value from point series data

I am adding data to scatter series like below , how do we receive the custom parameter value I add here
series.add({
x: 0,
y: 22,
color: ColorRGBA(255, 0, 0),
size: 10,
rotation: 45,
value: "custom message",
});
From the above series how do I extract the value "custom message" .. basically is there anyway to get it ? so I can to use it in table formatter like below .
series.setCursorResultTableFormatter((builder, series, xValue, yValue,value) => {
return builder.addRow(value).addRow(series.getValue());
});
Also another doubt is can we change shape of series dynamically like we change color and size ?
With v.3.1 this kind of logic is not supplied out of the box.
To implement it you'd need to add some kind of custom logic which finds your custom data based on the X and Y information.
In next release, v.3.2 we'll add an extra parameter to cursor result table formatters, so you can use it like follows:
series.setCursorResultTableFormatter((builder, series, x, y, dataPoint) => {
// `dataPoint` has all same information as user supplied, size, rotation, value or anything.
return builder.addRow(x).addRow(y).addRow(dataPoint.value);
});
Please note that these custom properties (size, rotation, value, etc.) will only be included when cursor interpolation is disabled.
At this time v.3.2 is scheduled for late September, but this could change.
2nd question about changing shape of point series, we currently don't have active plans to change this, but when there is enough motivation it will be improved on.

Computed Property that uses itself to compute its value?

I want to have a computed property that tracks that historical max of another property. Both these attributes are a member of an ndb class.
My naive approach was the following:
number = ndb.IntegerProperty(default=0)
highest_ever_number = ndb.ComputedProperty(lambda self: self.highest_ever_number if self.highest_ever_number >= self.number else self.number)
The intent was to set the highest_ever_number to a new number if number ever surpassed highest_ever_number.
This doesn't work because highest_ever_number is initially unset. I cannot set it to a default value using "default=0". Is there a workaround to this?
Thanks
I don't think you can use such conditions inside a Computed Property. This whole functionality can be done within a function, so it doesn't need to be a ComputedProperty. A better alternative to this problem could be to create a class method and call it whenever necessary.
Instead of using a computed property, you should use a normal IntegerProperty but use a _pre_put hook (https://cloud.google.com/appengine/docs/standard/python/ndb/modelclass#hooks) to verify/update highest_ever_number.
I can't test it right now, but this might do the trick:
number = ndb.IntegerProperty(default=0)
highest_ever_number = ndb.ComputedProperty(lambda self: self.highest_ever_number if
self.highest_ever_number and self.highest_ever_number >= self.number else self.number)

add % value programmatically

I have the following code which gives me an error. I want to add the width property programmatically and in %:
firstcombo.width = 90%;
But that gives me the following error:
1084 syntax error expecting
rightparen before colon
What is the correct syntax?
Try:
firstcombo.percentWidth = 90;
The width combobox property is a Number. you need to set it accordingly.
Something like firstCombo.width = .9 * X where X is the value you want 90% of.

Resources