Skip to content

Commit 983aa13

Browse files
Issue 307 - Tooltip support (#338)
1 parent 58e2edf commit 983aa13

File tree

35 files changed

+3801
-2532
lines changed

35 files changed

+3801
-2532
lines changed

packages/dash-table/.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"presets": [
33
"@babel/preset-react"
4+
],
5+
"plugins": [
6+
"@babel/plugin-syntax-dynamic-import"
47
]
58
}

packages/dash-table/@Types/modules.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,13 @@ declare module 'fast-isnumeric' {
1313
const value: (value: any) => boolean;
1414

1515
export default value;
16+
}
17+
18+
declare class Remarkable {
19+
constructor();
20+
render(value: string): any;
21+
}
22+
23+
declare module 'remarkable' {
24+
export default Remarkable;
1625
}

packages/dash-table/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## [Unreleased]
6+
### Added
7+
[#307](https://github.com/plotly/dash-core/issues/307)
8+
- Added tooltip_delay and tooltip_duration props to tweak table's tooltips display behavior
9+
- Added tooltips, column_static_tooltip, column_conditional_tooltips to define the tooltip
10+
applicable to a certain cell in the table with nested props delay and duration to override
11+
table's default behavior
12+
513
## [3.2.0] - 2019-01-25
614
### Added
715
[#297](https://github.com/plotly/dash-core/issues/297)

packages/dash-table/dash_table/DataTable.py

Lines changed: 98 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,101 @@ class DataTable(Component):
171171
NOTE: The naming and the behavior of this option may change
172172
in the future.
173173
Tune in to [https://github.com/plotly/dash-table/issues/168](https://github.com/plotly/dash-table/issues/168)
174+
- column_static_tooltip (optional): `column_static_tooltip` represents the tooltip shown
175+
for different columns.
176+
The `property` name refers to the column ID.
177+
The `type` refers to the type of tooltip syntax used
178+
for the tooltip generation. Can either be `markdown`
179+
or `text`. Defaults to `text`.
180+
The `value` refers to the syntax-based content of
181+
the tooltip. This value is required.
182+
The `delay` represents the delay in milliseconds before
183+
the tooltip is shown when hovering a cell. This overrides
184+
the table's `tooltip_delay` property. If set to `null`,
185+
the tooltip will be shown immediately.
186+
The `duration` represents the duration in milliseconds
187+
during which the tooltip is shown when hovering a cell.
188+
This overrides the table's `tooltip_duration` property.
189+
If set to `null`, the tooltip will not disappear.
190+
191+
Alternatively, the value of the property can also be
192+
a plain string. The `text` syntax will be used in
193+
that case.. column_static_tooltip has the following type: dict with strings as keys and values of type dict containing keys 'delay', 'duration', 'type', 'value'.
194+
Those keys have the following types:
195+
- delay (number; optional)
196+
- duration (number; optional)
197+
- type (a value equal to: 'text', 'markdown'; optional)
198+
- value (string; required) | string
199+
- column_conditional_tooltips (list; optional): `column_conditional_tooltips` represents the tooltip shown
200+
for different columns and cells.
201+
202+
This property allows you to specify different tooltips for
203+
depending on certain conditions. For example, you may have
204+
different tooltips in the same column based on the value
205+
of a certain data property.
206+
207+
Priority is from first to last defined conditional tooltip
208+
in the list. Higher priority (more specific) conditional
209+
tooltips should be put at the beginning of the list.
210+
211+
The `if` refers to the condtion that needs to be fulfilled
212+
in order for the associated tooltip configuration to be
213+
used. If multiple conditions are defined, all conditions
214+
must be met for the tooltip to be used by a cell.
215+
216+
The `if` nested property `column_id` refers to the column
217+
ID that must be matched.
218+
The `if` nested property `row_index` refers to the index
219+
of the row in the source `data`.
220+
The `if` nested property `filter` refers to the query that
221+
must evaluate to True.
222+
223+
The `type` refers to the type of tooltip syntax used
224+
for the tooltip generation. Can either be `markdown`
225+
or `text`. Defaults to `text`.
226+
The `value` refers to the syntax-based content of
227+
the tooltip. This value is required.
228+
The `delay` represents the delay in milliseconds before
229+
the tooltip is shown when hovering a cell. This overrides
230+
the table's `tooltip_delay` property. If set to `null`,
231+
the tooltip will be shown immediately.
232+
The `duration` represents the duration in milliseconds
233+
during which the tooltip is shown when hovering a cell.
234+
This overrides the table's `tooltip_duration` property.
235+
If set to `null`, the tooltip will not disappear.
236+
- tooltips (dict with strings as keys and values of type list; optional): `tooltips` represents the tooltip shown
237+
for different columns and cells.
238+
The `property` name refers to the column ID. Each property
239+
contains a list of tooltips mapped to the source `data`
240+
row index.
241+
242+
The `type` refers to the type of tooltip syntax used
243+
for the tooltip generation. Can either be `markdown`
244+
or `text`. Defaults to `text`.
245+
The `value` refers to the syntax-based content of
246+
the tooltip. This value is required.
247+
The `delay` represents the delay in milliseconds before
248+
the tooltip is shown when hovering a cell. This overrides
249+
the table's `tooltip_delay` property. If set to `null`,
250+
the tooltip will be shown immediately.
251+
The `duration` represents the duration in milliseconds
252+
during which the tooltip is shown when hovering a cell.
253+
This overrides the table's `tooltip_duration` property.
254+
If set to `null`, the tooltip will not disappear.
255+
256+
Alternatively, the value of the property can also be
257+
a plain string. The `text` syntax will be used in
258+
that case.
259+
- tooltip_delay (number; optional): `tooltip_delay` represents the table-wide delay in milliseconds before
260+
the tooltip is shown when hovering a cell. If set to `null`, the tooltip
261+
will be shown immediately.
262+
263+
Defaults to 350.
264+
- tooltip_duration (number; optional): `tooltip_duration` represents the table-wide duration in milliseconds
265+
during which the tooltip will be displayed when hovering a cell. If
266+
set to `null`, the tooltip will not disappear.
267+
268+
Defaults to 2000.
174269
- filtering (a value equal to: 'fe', 'be', true, false; optional): The `filtering` property controls the behavior of the `filtering` UI.
175270
If `False`, then the filtering UI is not displayed
176271
If `fe` or True, then the filtering UI is displayed and the filtering
@@ -292,12 +387,12 @@ class DataTable(Component):
292387
Subscribe to [https://github.com/plotly/dash-table/issues/168](https://github.com/plotly/dash-table/issues/168)
293388
for updates on the dropdown API."""
294389
@_explicitize_args
295-
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, 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):
296-
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', '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']
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']
297392
self._type = 'DataTable'
298393
self._namespace = 'dash_table'
299394
self._valid_wildcard_attributes = []
300-
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', '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']
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']
301396
self.available_wildcard_properties = []
302397

303398
_explicit_args = kwargs.pop('_explicit_args')

0 commit comments

Comments
 (0)