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.
Related
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.
I am plotting a sunburst donut and I cannot figure out why the total is incorrect.
library(sunburstR)
reports <- data.frame(
sequence = c("SVP-VP-Dir-end","SVP-VP-Dir-end","SVP-VP-Dir-end","SVP-VP-Dir-end","SVP-No VP-Dir-end","SVP-No VP-Dir-end","SVP-No VP-Dir-end"),
freq = as.numeric(c("167","60","51","32","5","1","1")))
sunburst(reports, count = TRUE)
It is supposed to be 100% 317 of 317 . Anyone know how to fix this? There is not much documentation on this great package.
Also, I would like it to have a default value in the center of donut.
If there is another way to create an interactive donut using R, please let me know.
Thanks you in advance.
It looks like the default function generating the message in the center of the donut rounds the total value to the nearest ten.
But you can customize this function using the explanation argument of sunburst. Oddly, the customized function (in javascript) must be provided as a string.
Try the following function:
custom.message = "function (d) {
root = d;
while (root.parent) {
root = root.parent
}
p = (100*d.value/root.value).toPrecision(3);
msg = p+' %<br/>'+d.value+' of '+root.value;
return msg;
}"
Now:
sunburst(reports, explanation = custom.message )
will generate the donut displaying exact total values. The count argument is no longer needed, as it is used by the default explanation function.
The value returned by custom.message is html code. As you can see, I've just inserted a line break (<br/>). You can modify the msg return value to further customize the look and feel.
I have a problem with the following code:
#viewport-large: 1440px;
#viewport-medium: 1366px;
#viewport-small: 1280px;
#type: medium;
#setting: ~"#{viewport-#{type}}";
#value: (#setting + 1); // here can't add 1
It will show an error message in the LESS compiler saying: "Operation on an invalid type".
Can anyone tell me why this is the case? What should I do?
The output of Less' CSS escape function (e() or ~"") is a string and you can't add a number to it. This is why the compiler reports Operation on invalid type.
So, instead of doing it that way make use of the double resolution (##) like in the below code block:
#viewport-large: 1440px;
#viewport-medium: 1366px;
#viewport-small: 1280px;
#type: medium;
#setting: "viewport-#{type}"; /* this won't resolve into 1336px as yet */
#value: ##setting + 1px; /* resolution to 1336px + addition happens here */
In this method, we just form the variable name and set it to the #setting variable (instead of setting a actual px value) and so the real px value's type remains unpolluted. In the next line when we use the double #, Less compiler would try to fetch the value that is held by the variable whose name is same as the value of #setting variable and immediately sum 1px to it instead of converting it to a String.
Note: If you have the Strict Math option (--strict-math) enabled then the addition operation must be wrapped inside extra braces like below. Else, it would plainly output a concatenated value like 1366px + 1px instead of performing the addition and outputting 1367px.
#value: (##setting + 1px);
The --strict-math setting is disabled by default but some of your projects could have enabled it.
I'm looking to generate placeholders and variables that can change depending on configured proportions such as the following:
$small-margin-top
$large-margin-top
$small-padding-bottom
Where each placeholder applies the corresponding, generated variable to the rule:
$small-margin-top
margin-top $marginsmall
$large-margin-top
margin-top $marginLarge
$small-padding-bottom
margin-bottom $marginSmall
I have statically defined the variables for now:
/* Margin */
$margin = 1rem
$marginsmall = $margin / $multiplier
$marginlarge = $margin * $multiplierLarge
$marginmini = $marginSmall / $multiplierLarge
But I get an error:
TypeError: expected "name" to be a string, but got ident:marginmini
properties = margin padding
proportions = mini small medium large
directions = top left bottom right
for property in properties
for proportion in proportions
for direction in directions
${property}-{direction}-{proportion}
{property}-{direction} lookup(property + proportion)
How can I generate placeholders for my proportions variable, such that the generated placeholders may be extended later (#extend $margin-large)?
EDIT: here is the working solution
The lookup bif accepts a string, and you are passing an ident (margin, padding, etc. without quotes). You can convert them to string by using concatenation. Also, you miss a $ sign:
properties = margin padding
proportions = mini small medium large
directions = top left bottom right
for property in properties
for proportion in proportions
for direction in directions
${proportion}-{property}-{direction}
{property}-{direction} lookup('$' + property + proportion)
I need to set the value of leading of text layer in Photoshop. I am first retrieving the selected text layer and then gets its value in a TextItem object. Then I get the value of the leading from a combo-box and set the value of leading using the following code.
var activeTextItem:TextItem = curLayer.textItem;
activeTextItem.leading = ComboBox.text.toString();
This code works fine when using on Windows. But when I try to execute the above code on Mac it always shows the leading as null object.
Can someone please guide me why I am not able to set the value of leading in Mac?
Thanks
I found the solution for this.
The leading has a value called Auto which by default has value a null. Therefore when I use the above code I am not able to set the value as leading parameter is null.
To overcome this I put a check that if leading is null value ie Auto then set the property useAutoLeading to false and once you set the value then again set the useAutoLeading property to true.
if("Auto" == ComboBox.text)
{
activeTextItem.useAutoLeading = false;
activeTextItem.leading = ComboBox.text.valueOf();
activeTextItem.useAutoLeading = true;
}
Thanks.