I have data in base 10 (decimal) format, and I need it displayed on the y-axis as hexadecimal (base 16). If I convert the data first d3 can't give me a linear scaled axis. Any ideas on how to go about this? I'd like to just call "toString(16)" somewhere, but I haven't figured out where to make it work. Thanks in advance!
You'll want to use axis.tickFormat() for your axis. The parameter is a format string, and hexadecimal is an "x" or and "X" depending on whether you want lowercase or uppercase letters.
Here's the documentation on axis.tickFormat() and here's the information on format strings.
Related
I would like to concatenate 2 values in the Zebra Programming Language (ZPL)
Var FN3 contains: 123456
This line currently prints the value 123456
^FO260,90^A0N,70,50^FN3^FS
^FO: field orientation, with coordinates.
^AON: font type and size
^FN3: variable
^FS: field stop
I tried this:
^FO260,90^A0N,70,50^FDP^FN3^FS
So we want to have printed: P123456
I cannot find any concatenate function or how to do this in the label.
Any tips or tricks or functions I do not know about?
The usual way to achieve that result is to use ^FT rather than ^FO, for example:
^FT260,160^A0N,70,50^FDP^FS^FT^A0N,70,50^FN3^FS
Note the second ^FT with empty parameters. That indicates to continue formatting the text where the last ^FT left off.
Unfortunately, using ^FT means you have to change your coordinates, specifically, your y values. ^FO positions from the upper left corner. ^FT positions from the baseline of the text.
I am working on conversion of pdf in to ZPL. I am using zebra programming language(zpl).
I am trying to control the barcode(any barcode) width using By command.
^By4 is giving lower width and ^By5 is going out of the box.
My use case is I want to achieve narrow bar width in float number(here 4.5). We can not pass float number in By command.
Please let me know if we can achieve this using some other method in ZPL.
You don't mention what barcode format you're using. Some of them, like 2of5, can also accept the ratio parameter for ^BY. The default is ^BY2,3, changing that to ^BY2,2 can make a smaller version:
^XA
^POI
^CFO,20
^BY5,3
^FO100,400
^BJN,100,Y,N
^FD200940^FS
^BY5,2
^FO100,700
^BJN,100,Y,N
^FD200940^FS
^XZ
This generates two barcodes in 2of5, one with the default ratio and one with a smaller ratio. The second one has a tighter barcode that uses less space. Valid values are 2.0-3.0 (although many round off to the same values) so there is some flexibility. Please note, this only works with barcode formats that are not fixed ratio formats.
You can check the manual page for ^BY in the ZPL programmers guide, p123, for the table that shows valid values and which ones round off to the same value (ie, 2.0 and 2.1 give the same results)
I'm using the ZPL - Zebra Programming Language to format a Code 93 barcode ^BA to reside within a label.
I know I can set the default module width using ^BY. My problem is that ^BY1 makes the barcode to small to read and ^BY2 makes it too large for the label.
This is the code:
^FO15,110^BY2,3,35^BAN,35,N^FD001EC0A688E2^FS
I wish I could use decimal values with ^BY but that doesn't seem to be possible.
Some barcodes as Code 128 ^BC have a mode parameter to pack the bar code better based on the data but ^BA doesn't have that.
I saw that some barcodes as QR (^BQ) do have a magnification factor parameter but that's also missing for ^BA.
Are there any other ways to set the width with smaller steps than ^BY?
The label is 38 mm wide and 19 mm tall and the DPI is 203 (8 dots/mm) and the data is always 12 hexadecimal characters [0-9 and A-F].
^BY does allow decimals in the second parameter (2.0 to 3.0) but that only applies to variable-ratio barcodes and code-93 is fixed-ratio.
The problem is that you need to think in terms of dots. Setting the narrow-bar width to 2 (as in ^BY2) means that the wide bar is then 4 or 6 dots (^BY2,2 or ^BY2,3) so the physical result is that the data content is always going to be (3 bars + 3 spaces)*datalength which translates to a particular number of dots.
The dot pitch is commonly 203dpi but 300dpi are available (you don't say which model you are using.) The barcode width when printed thus depends dirctly onthe amount of data and barcode type you are using. It's not like laser-printers where 1200dpi is common - the dots are six times bigger.
So - you'd need to say how wide you can handle, which model you are using and what your data characteristics are (your sample shows 12-character hexadecimal - are you using full ASCII or could you adjust and use numeric-only?) Are you stuck on code-93 or will some other encoding be OK?
Have you tried ^BY2,2? That will use a smaller ratio, but larger base.
If you want a more detailed answer you will need to provide: DPI, print width and max amount of data you are trying to encode.
I am trying to right justify a bar code I am printing using ZPL from a .Net program. Here is my current code:
^FO10,50^FB500,1,0,R,0^AO,40,40^BY3^BCN,100,Y,N,N^FD1234567^FS^XZ
The Field Block seems to be ignored when working with a bar code, but for text it justifies it correctly. Any ideas?
Newer Zebra firmware supports a third parameter on ^FO and ^FT. If you want to right justify something, specify the right edge as the x parameter, and include a 1 as the third parameter.
^XA
^BY3
^FO85,30^GB500,450,3^FS
^FO100,50^BCN,30,Y,N,N
^FD>;12345678^FS
^FO100,120N^BCN,30,Y,N,N
^FD>;123456^FS
^FO100,190^BCN,30,Y,N,N
^FD>;1234^FS
^FO570,260,1^BCN,30,Y,N,N
^FD>;12345678^FS
^FO570,330,1^BCN,30,Y,N,N
^FD>;123456^FS
^FO570,400,1^BY3^BCN,30,Y,N,N
^FD>;1234^FS
^XZ
We had the same issue at our company. The barcode doesn't respond to the Field Block. Based on your example since you are using ZPL commands directly to generate your barcode (as opposed to an image of a barcode), you could do something similar to how we did. We know roughly how wide the barcode is going to be based on the data we write to it. So we created a method to determine the x-axis location of the barcode based on our also known label widths.
For example: We use the s4M printers and estimate the full label width to be about 780 dots wide. So in order to left/center/right justify, we take the rough barcode (estimated) width and calculate accordingly (left is set to xaxis = 0, center is set to xaxis = ((780 - barcodeWidth) / 2), and right justified would be xaxis = (780 - barcodeWidth). It isn't a perfect solution but is very close at least for our needs. You could certainly be more precise in your algorithm by looking at more barcode setting information like the data square size, columns, rows, etc... depending on your needs.
If you were to come up with a solution of generating an image of a barcode (which is what we are also trying to come up with now) then you should be able to easily get the width of the barcode image using build in .net graphics functionality.
Using the stacked area chart as seen in this example
http://nvd3.com/ghpages/stackedArea.html
Trying to format the y-axis tick labels and the tooltip labels to be integers instead of floats. Tried changing the follow code from
chart.yAxis
.axisLabel('Users')
.tickFormat(d3.format(',.2f'));
to
chart.yAxis
.axisLabel('Users')
.tickFormat(d3.format(',.0d'));
Precision remains unchanged (still shows values to the hundredths place). I've followed the Github Wiki to no avail https://github.com/mbostock/d3/wiki/Formatting#wiki-d3_format
Any suggestions or hints will be greatly appreciated.
Looks like this isn't supported by nvd3 at the moment. See the offending line.
In addition, your format specification isn't quite right. As mentioned in the documentation, "d" ignores non-integer values. So you probably want ",.0f" instead, which means:
,: use commas to separate thousands.
.0: precision of zero (the exact meaning of this depends on which type is in use).
f: The type; in this case, Number.toFixed. This means a fixed number of digits (the precision) appear after the decimal point, and the number is rounded if necessary.
this one can format label text from float to integer.
for pie chart:
chart.pie.valueFormat(d3.format(',.0d'));
for line chart:
chart.yAxisTickFormat(d3.format(',.0d'));
The .tickFormat method on the .yAxis method doesn't update it properly. This is the work around I used:
chart.yAxisTickFormat(d3.format(',.0d'));
I have tried like this
.axisLabel('%').tickFormat(function(d) { return parseFloat(d).toFixed(1) + "%"; });
Its working for me.I am getting results with decimal points and percentage.