Say I have two strings in an array ["$1,076.54 USD", "554.00 USDC"]. How do I use Jinja and CSS to align these two strings with each other by the decimal point? I tried adding padding of 'X' ch but since the font isn't all the same size, they don't line up properly.
Related
I am trying to determine if, using just CSS, there is there a way to format floating point numbers to a specific number of digits to the right of the decimal point?
The reason I want to do this is that I need to use a website that displays a massive amount of continually updating data in tables. (Because the data is continually updating, I can't just export the data into a spreadsheet.)
The values are floating point and range from 0 to 9999. The number of fractional digits varies from 0 to 7. For the most part, I have no use for anything beyond hundredths (2 places to the right of the decimal point). The exception is for values ranging from 0 to 9, but I'm willing to forego that case, if necessary.
This is an tiny example of how the data is currently displayed:
9484.83
133.57643
1344.5432
9.5848274
58.48381
5989.1
1.5847493
1.348
As you can see, it's hard to read the data with that presentation. Ideally, I would like to use a CSS overlay to reformat that data as:
9484.83
133.57
1344.54
9.584
58.48
5989.10
1.584
1.348
If that's not possible, I'm fine with:
9484.83
133.57
1344.54
9.58
58.48
5989.10
1.58
1.34
Using CSS, I can easily enforce a maximum width for the HTML elements displaying the values. I can use em units to try to not get any digits partially displayed (not 100% effective though, unless forcing a monospaced font, which results in much less visible data in the viewport). But even using such techniques, I still wind up with values displayed as 58.4848.
Can CSS be used to solve this task?
While creating a math test on my site, I ran into an issue: An inline multi-line expression (equation), horizontally aligned at the equal signs, will be vertically centered on its row.
If the expression only takes up a single row, it works perfectly (even though I must use different fonts and sizes for the site and MathJax).
Is it possible to add a command (something like \valign) to the expression so that the row that contains the command becomes the one that is vertically aligned with the surrounding text?
For example:
\(\begin{align}2 \cdot x &= 8\\x &=\end{align}\)
… would be …
\(\begin{align}\valign 2 \cdot x &= 8\\x &=\end{align}\)
This is how it is now:
This is how I'd like it to be:
I have tried the following:
\raise -.6em {}
This has an effect, but the value is a guess and not exact. It is still a pixel off, and the larger I make the default value (rem), the greater the error.
I have fiddled with the vertical-align of the expression and set it to text-top while leaving the surrounding text at baseline. This is also not perfect. Sure, I can mess around with CSS until this expression looks good, but what about the next one?
The align environment is a display-level environment, and should not be used within in-line math expressions. Instead, you should use aligned, which takes an option that controls its vertical alignment. So
\(\begin{aligned}[t]2 \cdot x &= 8\\x &=\end{aligned}\)
would position the alignment so that its top line is on the same base line as the surrounding text.
Here is an example:
<script id="MathJax-script" src="https://cdn.jsdelivr.net/npm/mathjax#3/es5/tex-svg.js"></script>
a) \(\begin{aligned}[t] 2 \cdot x &= 8\\x &= 4\end{aligned}\)
In this case, the [t] means align to the top line. You could also use [b] to align to the bottom line.
I use a lot of calc() with percentage values (eg. calc((100vh / 8) + 20px)) in my project. So this results in a lot of decimal values (See image). So is it possible that there are not decimals? So 59.63 would be 60. I'm using SASS.
Best wishes,
Joeri
No, it's not possible while you are using relative units (%, em, rem, etc). When rendering they are recalculated to pixels and gets decimals values.
About css units you can read here.
But anyway brouser renders blocks with integer sizes: http://i.imgur.com/8nJe1BE.png In your case the real size of this block may be 60 to 60 pixels.
You can use the round function from SASS :
http://sass-lang.com/documentation/Sass/Script/Functions.html#round-instance_method
I calculate and print some big numbers on a QTextEdit; one number per row (paragraph). The numbers convert themselves to floating point literals like 3.45345e-08. The widget QTextEdit is wide enough, if it matters.
I need a setting that disables the floating-point-literals format of QTextEdit.
A simple question as i am developing a java application based on dcm4che ...
I want to calculate/find the "position" of a dicom image into its sequence (series). By position i mean to find if this image is first, second etc. in its series. More specifically i would like to calculate/find:
Number of slices into a Sequence
Position of each slice (dicom image) into the Sequence
For the first question i know i can use tag 0020,1002 (however it is not always populated) ... For the second one?
If you are dealing with volumetric image series, best way to order your series is to use the Image Position (Patient) (0020, 0032). This is a required Type 1 tag (should always have value) and it is part of the image plane module. It will contain the X, Y and Z values coordinates representing the upper left corner of the image in mm. If the slices are parallel to each other, only one value should change between the slices.
Please note that the Slice Location (0020, 1041) is an optional (Type 3) element and it may not exist in the DICOM file.
We use the InstanceNumber tag (0x0020, 0x0013) as our first choice for the slice position. If there is no InstanceNumber, or if they are all the same, then we use the SliceLocation tag (0x0020, 0x1041). If neither tag is available, then we give up.
We check the InstanceNumber tag such that the Max(InstanceNumber) - Min(InstanceNumber) + 1 is equal to the number of slices we have in the sequence (just in case some manufacturers start counting at 0 or 1, or even some other number). We check the SliceLocation the same way.
This max - min + 1 is then the number of slices in the sequence (substitute for tag ImagesInAcquisition 0x0020, 0x1002).
Without the ImagesInAcquisition tag, we have no way of knowing in advance how many slices to expect...
I would argue that if the slice location is available, use that. It will be more consistent with the image acquisition. If it is not available, then you'll have to use or compute from the image position (patient) attribute. Part 3 section C.7.6.2.1 has details on these attributes.
The main issue comes when you have a series that is oblique. If you just use the z-value of the image position (patient), it may not change by the slice thickenss/spacing between slices attributes, while the slice location typically will. That can cause confusion to end users.