I am using a metric element and I want to add a percentage "%" label, so it looks like 45% for example, this is its default code expression
filters
| essql
query="SELECT round(cup * 100) as cup_percentage FROM \"demodata\" order by created_at desc limit 1"
| math "cup_percentage"
| metric ""
metricFont={font family="'Open Sans', Helvetica, Arial, sans-serif" size=48 align="center" color="#000000" weight="normal" underline=false italic=false}
labelFont={font family="'Open Sans', Helvetica, Arial, sans-serif" size=14 align="right" color="#000000" weight="normal" underline=false italic=false}
| render css=".canvasRenderEl {
}"
So I have seen in some examples and documentation I have to use markdown function, more or less like this:
| markdown {getCell "cup_percentage" row=0} "%"
But I have tried to plug it in without luck so far, it doesnt find the cup_percentage column, but the query should be correct
I found that using the formatnumber method worked out for me:
filters
| essql
query="SELECT round(cup * 100) as cup_percentage FROM \"demodata\" order by created_at desc limit 1"
| math "cup_percentage"
| formatnumber format="0.0%"
| metric ""
metricFont={font family="'Open Sans', Helvetica, Arial, sans-serif" size=48 align="center" color="#000000" weight="normal" underline=false italic=false}
labelFont={font family="'Open Sans', Helvetica, Arial, sans-serif" size=14 align="right" color="#000000" weight="normal" underline=false italic=false}
| render css=".canvasRenderEl {
}"
Related
So I can specify my fonts in my website style CSS, and then set the font-family:
#font-face {
font-family: "custom-helvetica";
src: url("/assets/HelveticaNeue.ttf");
src: url("/assets/HelveticaNeueBold.ttf");
src: url("/assets/HelveticaBlkIt.ttf");
}
#font-face {
font-family: "custom-tahoma";
src: url("/assets/Tahoma.ttf");
src: url("/assets/Tahomabd.ttf");
}
html {
font-family: Tahoma, Helvetica, Arial, sans-serif;
}
Here's an example piece of text:
Testing glyphs in PHP: ± µ ⁓ â ฿ ₿
So let's suppose that the font Helvetica contains all the glyphs in the example apart from ±, µ, ⁓ and that the font Tahoma contains all the glyphs in the example apart from â, ฿, ₿. Let's suppose that the font Arial contains every glyph in the example.
How does PHP/CSS work with this?
Will it apply Tahoma to the example and get this result? -
Testing glyphs in PHP: ± µ ⁓ ࠀ ࠀ ࠀ
Or will it decide that Arial is the only font that can render the entire string correctly, and apply that font to the whole string? Or will the font change dynamically throughout the string to adapt to any missing glyphs?
I use Bold, Medium and Normal font weights on my website, that's 700, 500 and 400 respectively.
I use Helvetica Neue font and as a fallback for systems that doesn't have it installed I want to use Open Sans. The problem is Open Sans doesn't have Medium style.
I want my elements that I used to define as font-weight: 500 have font-weight: 600 if the browser uses Open Sans. Is it possible somehow?
There's a similar question at Stack Overflow: How to set different font-weight for fallback font? but I'cant get the result I need using techniqe described in an accepted answer.
I need something like
#font-face {
font-family: 'semibold';
src: 'Helvetica Neue':500, 'Open Sans':600;
}
Not sure how to do it though.
You can't really define weight in a font-face declaration. Instead, font-weight is used there as a gatekeeper to match the font and not to pass styles to the element.
It seems like overkill, but you could use this JavaScript function by Sam Clarke as a starting point to see if the font is available, and then conditionally modify the font-weight following the logic that works best for your specific requirements.
For a simplified example with just these two fonts, you might set up the CSS like this:
#font-face {
font-family: h-semibold;
src: local('Helvetica Neue');
}
#font-face {
font-family: os-semibold;
src: local('Open Sans');
}
.semibold {
font-family: h-semibold, os-semibold;
}
.w5 {
font-weight: 500;
}
.w6 {
font-weight: 600;
}
Then, using the function linked above, you put something like this in your JS to conditionally load the weight classes depending on font support:
var semibold = document.querySelectorAll('.semibold');
if (isFontAvailable('h-semibold')) {
semibold.forEach(result => {
result.className += ' ' + 'w5';
});
} else {
semibold.forEach(result => {
result.className += ' ' + 'w6';
});
}
You'll doubtless work out a more elegant solution if you really need to carry it through.
we use Woocommerce to sell car parts.
Very often a customer writes an (important) Message into the textfield during the order process.
We get the "New Order" E-Mail from the System, but the message is not inlcuded.
How do we have to change the E-Mail Template to recieve the message from the customer?
Thank you for help
You can configure some details of the confirmation email in the WooCommerce settings area in Wp-Admin section: WooCommerce -> Settings -> Emails.
Also you can edit template files here:
wp-content/plugins/woocommerce/templates/emails
Important: Do not edit files inside plugin directory, because then your changes will be lost with first plugin update. This template can be overridden by copying it to
yourtheme/woocommerce/emails/template_name.php
So you can edit template file and attach your textfield data to email.
For the future if someone else is looking for an answer. If you're looking to add the customer note to the new order email, you can just use one of the action hooks instead of overriding the email template:
// Hook this function into woocommerce_email_order_meta
add_action( 'woocommerce_email_order_meta', 'woo_add_customer_note_to_email', 10, 3 );
function woo_add_customer_note_to_email( $order, $is_admin, $plain_text = false ) {
// Retrieve the customer note as a variable from the $order array.
$customer_note = $order->get_customer_note();
// You want to send those only to the Admin, or only customers, modify here. Right now it's only sending to admin emails.
if ( !$is_admin || $is_admin && empty($customer_note) ) {
return;
}
// Setup our html markup for inclusion in the email. Note, you should inline your styles, which is best practice for HTML emails.
echo '<div style="font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif; margin-top: 40px;"><h2 style=""color: #6a6057; display: block; font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif; font-size: 18px; font-weight: bold; line-height: 130%; margin: 0 0 18px; text-align: left;">Customer Notes</h2>';
echo '<blockquote><span style="color: #505050; font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif;">' . wpautop( wptexturize( $customer_note ) ) . '</span></blockquote>';
echo '</div>';
}
From this HTML body of a mail ,How can I retrieve only the body(Hi...Thank You) to a text box
<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, Sans-Serif;font-size:14px"><div>Hi...ThankYou</div></div></body></html>
Thank You
I suggest you to have a look at HTML parsing libraries like HtmlAgilityPack or CsQuery
Here is how it's done in CsQuery (the selector syntax is compatible with jquery):
Dim html = "<html><body><div style=""color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, Sans-Serif;font-size:14px""><div>Hi...ThankYou</div></div></body></html>"
Dim cs = CsQuery.CQ.Create(html)
Dim txt = cs("body>div>div").Text()
textBox.Text = txt
you can obtain CsQuery through Nuget using PM> Install-Package CsQuery -Version 1.3.4 command
You can use HtmlAgilityPack
var node = doc.DocumentNode.SelectNodes("/html/body/div/div");
I'd like to (temporarily) remove the units of my variables #baseLineHeight and #baseFontSize, so that I can divide them to get a relative line-height. This is what I've tried:
#baseFontSize: 12px;
#baseLineHeight: 18px;
font: #baseFontSize~"/"#baseLineHeight/#baseFontSize sans-serif;
Generates the following error:
Object #<Object> has no method 'toCSS' (Less::ParseError)
Preferred output:
font: 12px/1.5 sans-serif;
Meanwhile there seems to be a function for that:
http://lesscss.org/functions/#misc-functions-unit
Here the code from the comment, just for completeness. (thanks to cfx).
font: #baseFontSize~"/"unit(#baseLineHeight/#baseFontSize) sans-serif;
I missed the part of the documentation regarding JavaScript evaluation. This seems to solve my problem:
font: #baseFontSize~"/"`parseInt("#{baseLineHeight}") / parseInt("#{baseFontSize}")` sans-serif;
The other answers don't seem to actually work.
According to the LESS documentation, the unit() function will remove or change the unit of a dimension. Since the function only accepts a single dimension as a parameter (and an optional parameter), you would use the following:
unit((#baseLineHeight/#baseFontSize))
Because of strict math, you will notice that the line above may need to be wrapped in parenthesis so that the math is actually evaluated.
#baseFontSize: 12px;
#baseLineHeight: 18px;
p {
font: #baseFontSize ~"/" unit((#baseLineHeight/#baseFontSize)) sans-serif;
}
The LESS above will output the following, desired results:
p {
font: 12px / 1.5 sans-serif;
}