Skip to Content
DataCards 2.2.4 is released 🎉

Number Card

Card type: number

Basic number card

The number card displays a number with an optional unit and formatting options.

In addition to the common parameters the number card has the following configuration options:

NameTypeRequiredDefaultDescription
valueint or floatYes-The value to be displayed.
unitstrNo-Text to be displayed under the number (e.g. % or €).
localesstrNo-Unicode locale identifier  (e.g. DE).
formatdictNo-Number formatting options  (See below)
descriptionstrNo-Extra text to be displayed above the value. Hidden when the card is too small.
fontSizestrNo-Custom font size to override automatic sizing (e.g. "2rem", "24px", "150%").
textAlignstrNo"right"Alignment of the number and unit text. Can be "left", "center", or "right".

format parameter

The format parameter can be used to customize the number formatting, following the Intl.NumberFormat  options. Here are some commonly-used options:

NameTypeRequiredDefaultDescription
stylestrNo"decimal"The number style to use. Can be "decimal" (plain number formatting), "currency", "percent", or "unit".
currencystrNo-The currency to use if the style is "currency". ISO currency codes, e.g. "EUR", "USD", "GBP", etc.
useGroupingboolNoFalseWhether to use grouping separators (e.g. 1,000 instead of 1000).
minimumFractionDigitsintNo0Minimum number of decimal places to display.
maximumFractionDigitsintNo2Maximum number of decimal places to display.
minimumSignificantDigitsintNo-Minimum number of significant digits to display.
maximumSignificantDigitsintNo-Maximum number of significant digits to display.
trailingZeroDisplaystrNo"auto"Whether to display trailing zeros. Can be "auto" (default), "stripIfInteger" (remove fraction digits if they are all zero)

Examples

Basic number card

datacards.publish.card( type='number', value=42, label='Number', description='Description', unit='Unit', logic_view_size=(2,1) )
Basic number card

Number card (financial)

An example of a number card formatted for financial purposes.

  • Currency formatting with € symbol
  • Grouping separators according to German conventions
  • Reduced font size
datacards.publish.card( type='number', value=1321321, label='Turnover', description='', unit='', logic_view_size=(2,1), locales="DE", format={"useGrouping": True, "style": "currency", "currency": "EUR", "trailingZeroDisplay": 'stripIfInteger'}, font_size="0.75rem" )
Number card for finance

Number card (percent)

A number card formatted with percent style and 1 decimal place. (Default is 2 decimal places).

datacards.publish.card( type='number', value=0.42312, label='Number', description='', unit='', logic_view_size=(2,1), format={"style": "percent", "maximumFractionDigits": 1} )
Number card for percent
Last updated on