Skip to content

Commit 0b1edc0

Browse files
Issue 189 - Number formatting (#377)
1 parent 7c1dd41 commit 0b1edc0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1432
-149
lines changed

packages/dash-table/.circleci/config.yml

+14-2
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,15 @@ jobs:
142142

143143
"node":
144144
docker:
145-
- image: circleci/node:8.11.3
145+
- image: circleci/python:3.6.7-node
146146

147147
steps:
148148
- checkout
149149

150+
- run:
151+
name: Create virtual env
152+
command: python -m venv || virtualenv venv
153+
150154
- restore_cache:
151155
key: deps1-{{ .Branch }}-{{ checksum "package-lock.json" }}-{{ checksum "package.json" }}
152156

@@ -159,9 +163,17 @@ jobs:
159163
paths:
160164
- node_modules
161165

166+
- run:
167+
name: Install requirements
168+
command: |
169+
. venv/bin/activate
170+
pip install -r requirements-base.txt --quiet
171+
162172
- run:
163173
name: Run eslint
164-
command: npm run lint
174+
command: |
175+
. venv/bin/activate
176+
npm run lint
165177
when: always
166178

167179

+39-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,41 @@
11
{
2-
"tslint.jsEnable": true
2+
"tslint.jsEnable": true,
3+
"cSpell.allowCompoundWords": true,
4+
"cSpell.ignorePaths": [
5+
"**/package.json",
6+
"**/package-lock.json",
7+
"**/node_modules/**",
8+
"**/vscode-extension/**",
9+
"**/.git/**",
10+
".vscode",
11+
"typings"
12+
],
13+
"cSpell.ignoreRegExpList": [
14+
"'"
15+
],
16+
"cSpell.language": "en",
17+
"cSpell.diagnosticLevel": "Error",
18+
"cSpell.languageSettings": [
19+
{ "languageId": "*", "dictionaries": ["fonts", "css", "html", "npm", "typescript", "python"]}
20+
],
21+
"cSpell.words": [
22+
"atto",
23+
"deletable",
24+
"femto",
25+
"giga",
26+
"ints",
27+
"milli",
28+
"nully",
29+
"peta",
30+
"pico",
31+
"plotly",
32+
"selectable",
33+
"tera",
34+
"tooltips",
35+
"uneditable",
36+
"yocto",
37+
"yotta",
38+
"zepto",
39+
"zetta"
40+
]
341
}

packages/dash-table/CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ This project adheres to [Semantic Versioning](http://semver.org/).
99

1010
## [3.5.0] - 2019-02-25
1111
### Added
12+
[#189](https://github.com/plotly/dash-table/issues/189)
13+
- Added `format` nested prop to columns
14+
- Applied to columns with `type=numeric` (more to come)
15+
- Uses [d3-format](https://github.com/d3/d3-format) under the hood
16+
- `format.locale` for localization configuration
17+
- `format.prefix` for SI prefix configuration
18+
- `format.specifier` for formatting configuration
19+
- `format.separate_4digits` to configure grouping behavior for numbers with 4 digits or less
20+
- Python helpers (dash_table.FormatTemplate)
21+
- Added `locale_format` prop to table (default localization configuration, merged with column.format.locale)
22+
1223
[#342](https://github.com/plotly/dash-core/issues/342)
1324
- Added `column_type` condition to style `if`; allows applying styles based on the type of the column for props
1425
- `style_cell_conditional`

packages/dash-table/dash_table/DataTable.py

+27-4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,29 @@ class DataTable(Component):
1212
active.
1313
- columns (list; optional): Columns describes various aspects about each individual column.
1414
`name` and `id` are the only required parameters.
15+
- locale_format (optional): The localization specific formatting information applied to all columns in the table.
16+
17+
This prop is derived from the [d3.formatLocale](https://github.com/d3/d3-format#formatLocale) data structure specification.
18+
19+
When left unspecified, each individual nested prop will default to a pre-determined value.
20+
21+
'symbol': (default: ['$', '']) a list of two strings representing the
22+
prefix and suffix symbols. Typically used for currency, and implemented using d3's
23+
currency format, but you can use this for other symbols such as measurement units.
24+
'decimal': (default: '.') the string used for the decimal separator
25+
'group': (default: ',') the string used for the groups separator
26+
'grouping': (default: [3]) a list of integers representing the grouping pattern
27+
'numerals': a list of ten strings used as replacements for numbers 0-9
28+
'percent': (default: '%') the string used for the percentage symbol
29+
'separate_4digits': (default: True) separate integers with 4-digits or less. locale_format has the following type: dict containing keys 'symbol', 'decimal', 'group', 'grouping', 'numerals', 'percent', 'separate_4digits'.
30+
Those keys have the following types:
31+
- symbol (list; optional)
32+
- decimal (string; optional)
33+
- group (string; optional)
34+
- grouping (list; optional)
35+
- numerals (list; optional)
36+
- percent (string; optional)
37+
- separate_4digits (boolean; optional)
1538
- content_style (a value equal to: 'fit', 'grow'; optional): `content_style` toggles between a set of CSS styles for
1639
two common behaviors:
1740
- `fit`: The table container's width be equal to the width of its content.
@@ -208,7 +231,7 @@ class DataTable(Component):
208231
in the list. Higher priority (more specific) conditional
209232
tooltips should be put at the beginning of the list.
210233
211-
The `if` refers to the condtion that needs to be fulfilled
234+
The `if` refers to the condition that needs to be fulfilled
212235
in order for the associated tooltip configuration to be
213236
used. If multiple conditions are defined, all conditions
214237
must be met for the tooltip to be used by a cell.
@@ -387,12 +410,12 @@ class DataTable(Component):
387410
Subscribe to [https://github.com/plotly/dash-table/issues/168](https://github.com/plotly/dash-table/issues/168)
388411
for updates on the dropdown API."""
389412
@_explicitize_args
390-
def __init__(self, active_cell=Component.UNDEFINED, columns=Component.UNDEFINED, content_style=Component.UNDEFINED, css=Component.UNDEFINED, data=Component.UNDEFINED, data_previous=Component.UNDEFINED, data_timestamp=Component.UNDEFINED, editable=Component.UNDEFINED, end_cell=Component.UNDEFINED, id=Component.UNDEFINED, is_focused=Component.UNDEFINED, merge_duplicate_headers=Component.UNDEFINED, n_fixed_columns=Component.UNDEFINED, n_fixed_rows=Component.UNDEFINED, row_deletable=Component.UNDEFINED, row_selectable=Component.UNDEFINED, selected_cells=Component.UNDEFINED, selected_rows=Component.UNDEFINED, start_cell=Component.UNDEFINED, style_as_list_view=Component.UNDEFINED, pagination_mode=Component.UNDEFINED, pagination_settings=Component.UNDEFINED, navigation=Component.UNDEFINED, column_conditional_dropdowns=Component.UNDEFINED, column_static_dropdown=Component.UNDEFINED, column_static_tooltip=Component.UNDEFINED, column_conditional_tooltips=Component.UNDEFINED, tooltips=Component.UNDEFINED, tooltip_delay=Component.UNDEFINED, tooltip_duration=Component.UNDEFINED, filtering=Component.UNDEFINED, filtering_settings=Component.UNDEFINED, filtering_type=Component.UNDEFINED, filtering_types=Component.UNDEFINED, sorting=Component.UNDEFINED, sorting_type=Component.UNDEFINED, sorting_settings=Component.UNDEFINED, sorting_treat_empty_string_as_none=Component.UNDEFINED, style_table=Component.UNDEFINED, style_cell=Component.UNDEFINED, style_data=Component.UNDEFINED, style_filter=Component.UNDEFINED, style_header=Component.UNDEFINED, style_cell_conditional=Component.UNDEFINED, style_data_conditional=Component.UNDEFINED, style_filter_conditional=Component.UNDEFINED, style_header_conditional=Component.UNDEFINED, virtualization=Component.UNDEFINED, derived_viewport_data=Component.UNDEFINED, derived_viewport_indices=Component.UNDEFINED, derived_viewport_selected_rows=Component.UNDEFINED, derived_virtual_data=Component.UNDEFINED, derived_virtual_indices=Component.UNDEFINED, derived_virtual_selected_rows=Component.UNDEFINED, dropdown_properties=Component.UNDEFINED, **kwargs):
391-
self._prop_names = ['active_cell', 'columns', 'content_style', 'css', 'data', 'data_previous', 'data_timestamp', 'editable', 'end_cell', 'id', 'is_focused', 'merge_duplicate_headers', 'n_fixed_columns', 'n_fixed_rows', 'row_deletable', 'row_selectable', 'selected_cells', 'selected_rows', 'start_cell', 'style_as_list_view', 'pagination_mode', 'pagination_settings', 'navigation', 'column_conditional_dropdowns', 'column_static_dropdown', 'column_static_tooltip', 'column_conditional_tooltips', 'tooltips', 'tooltip_delay', 'tooltip_duration', 'filtering', 'filtering_settings', 'filtering_type', 'filtering_types', 'sorting', 'sorting_type', 'sorting_settings', 'sorting_treat_empty_string_as_none', 'style_table', 'style_cell', 'style_data', 'style_filter', 'style_header', 'style_cell_conditional', 'style_data_conditional', 'style_filter_conditional', 'style_header_conditional', 'virtualization', 'derived_viewport_data', 'derived_viewport_indices', 'derived_viewport_selected_rows', 'derived_virtual_data', 'derived_virtual_indices', 'derived_virtual_selected_rows', 'dropdown_properties']
413+
def __init__(self, active_cell=Component.UNDEFINED, columns=Component.UNDEFINED, locale_format=Component.UNDEFINED, content_style=Component.UNDEFINED, css=Component.UNDEFINED, data=Component.UNDEFINED, data_previous=Component.UNDEFINED, data_timestamp=Component.UNDEFINED, editable=Component.UNDEFINED, end_cell=Component.UNDEFINED, id=Component.UNDEFINED, is_focused=Component.UNDEFINED, merge_duplicate_headers=Component.UNDEFINED, n_fixed_columns=Component.UNDEFINED, n_fixed_rows=Component.UNDEFINED, row_deletable=Component.UNDEFINED, row_selectable=Component.UNDEFINED, selected_cells=Component.UNDEFINED, selected_rows=Component.UNDEFINED, start_cell=Component.UNDEFINED, style_as_list_view=Component.UNDEFINED, pagination_mode=Component.UNDEFINED, pagination_settings=Component.UNDEFINED, navigation=Component.UNDEFINED, column_conditional_dropdowns=Component.UNDEFINED, column_static_dropdown=Component.UNDEFINED, column_static_tooltip=Component.UNDEFINED, column_conditional_tooltips=Component.UNDEFINED, tooltips=Component.UNDEFINED, tooltip_delay=Component.UNDEFINED, tooltip_duration=Component.UNDEFINED, filtering=Component.UNDEFINED, filtering_settings=Component.UNDEFINED, filtering_type=Component.UNDEFINED, filtering_types=Component.UNDEFINED, sorting=Component.UNDEFINED, sorting_type=Component.UNDEFINED, sorting_settings=Component.UNDEFINED, sorting_treat_empty_string_as_none=Component.UNDEFINED, style_table=Component.UNDEFINED, style_cell=Component.UNDEFINED, style_data=Component.UNDEFINED, style_filter=Component.UNDEFINED, style_header=Component.UNDEFINED, style_cell_conditional=Component.UNDEFINED, style_data_conditional=Component.UNDEFINED, style_filter_conditional=Component.UNDEFINED, style_header_conditional=Component.UNDEFINED, virtualization=Component.UNDEFINED, derived_viewport_data=Component.UNDEFINED, derived_viewport_indices=Component.UNDEFINED, derived_viewport_selected_rows=Component.UNDEFINED, derived_virtual_data=Component.UNDEFINED, derived_virtual_indices=Component.UNDEFINED, derived_virtual_selected_rows=Component.UNDEFINED, dropdown_properties=Component.UNDEFINED, **kwargs):
414+
self._prop_names = ['active_cell', 'columns', 'locale_format', 'content_style', 'css', 'data', 'data_previous', 'data_timestamp', 'editable', 'end_cell', 'id', 'is_focused', 'merge_duplicate_headers', 'n_fixed_columns', 'n_fixed_rows', 'row_deletable', 'row_selectable', 'selected_cells', 'selected_rows', 'start_cell', 'style_as_list_view', 'pagination_mode', 'pagination_settings', 'navigation', 'column_conditional_dropdowns', 'column_static_dropdown', 'column_static_tooltip', 'column_conditional_tooltips', 'tooltips', 'tooltip_delay', 'tooltip_duration', 'filtering', 'filtering_settings', 'filtering_type', 'filtering_types', 'sorting', 'sorting_type', 'sorting_settings', 'sorting_treat_empty_string_as_none', 'style_table', 'style_cell', 'style_data', 'style_filter', 'style_header', 'style_cell_conditional', 'style_data_conditional', 'style_filter_conditional', 'style_header_conditional', 'virtualization', 'derived_viewport_data', 'derived_viewport_indices', 'derived_viewport_selected_rows', 'derived_virtual_data', 'derived_virtual_indices', 'derived_virtual_selected_rows', 'dropdown_properties']
392415
self._type = 'DataTable'
393416
self._namespace = 'dash_table'
394417
self._valid_wildcard_attributes = []
395-
self.available_properties = ['active_cell', 'columns', 'content_style', 'css', 'data', 'data_previous', 'data_timestamp', 'editable', 'end_cell', 'id', 'is_focused', 'merge_duplicate_headers', 'n_fixed_columns', 'n_fixed_rows', 'row_deletable', 'row_selectable', 'selected_cells', 'selected_rows', 'start_cell', 'style_as_list_view', 'pagination_mode', 'pagination_settings', 'navigation', 'column_conditional_dropdowns', 'column_static_dropdown', 'column_static_tooltip', 'column_conditional_tooltips', 'tooltips', 'tooltip_delay', 'tooltip_duration', 'filtering', 'filtering_settings', 'filtering_type', 'filtering_types', 'sorting', 'sorting_type', 'sorting_settings', 'sorting_treat_empty_string_as_none', 'style_table', 'style_cell', 'style_data', 'style_filter', 'style_header', 'style_cell_conditional', 'style_data_conditional', 'style_filter_conditional', 'style_header_conditional', 'virtualization', 'derived_viewport_data', 'derived_viewport_indices', 'derived_viewport_selected_rows', 'derived_virtual_data', 'derived_virtual_indices', 'derived_virtual_selected_rows', 'dropdown_properties']
418+
self.available_properties = ['active_cell', 'columns', 'locale_format', 'content_style', 'css', 'data', 'data_previous', 'data_timestamp', 'editable', 'end_cell', 'id', 'is_focused', 'merge_duplicate_headers', 'n_fixed_columns', 'n_fixed_rows', 'row_deletable', 'row_selectable', 'selected_cells', 'selected_rows', 'start_cell', 'style_as_list_view', 'pagination_mode', 'pagination_settings', 'navigation', 'column_conditional_dropdowns', 'column_static_dropdown', 'column_static_tooltip', 'column_conditional_tooltips', 'tooltips', 'tooltip_delay', 'tooltip_duration', 'filtering', 'filtering_settings', 'filtering_type', 'filtering_types', 'sorting', 'sorting_type', 'sorting_settings', 'sorting_treat_empty_string_as_none', 'style_table', 'style_cell', 'style_data', 'style_filter', 'style_header', 'style_cell_conditional', 'style_data_conditional', 'style_filter_conditional', 'style_header_conditional', 'virtualization', 'derived_viewport_data', 'derived_viewport_indices', 'derived_viewport_selected_rows', 'derived_virtual_data', 'derived_virtual_indices', 'derived_virtual_selected_rows', 'dropdown_properties']
396419
self.available_wildcard_properties = []
397420

398421
_explicit_args = kwargs.pop('_explicit_args')

0 commit comments

Comments
 (0)