Skip to content

Commit 97dca5a

Browse files
author
workaholicpanda
committed
Revert "fix: changelog updated, disabled SI formatting zero marks for Slider, RangeSlider, lint issues fixed"
This reverts commit a363691.
1 parent a363691 commit 97dca5a

File tree

4 files changed

+69
-283
lines changed

4 files changed

+69
-283
lines changed

CHANGELOG.md

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

5-
## [Unreleased]
6-
7-
- [#1763](https://github.com/plotly/dash/pull/1763):
8-
## Dash and Dash Renderer
9-
10-
- `Input`, `State`, and `Output` now accept components instead of ID strings and Dash `callback` will auto-generate the component's ID under-the-hood if not supplied. This allows usage like:
11-
12-
```python
13-
my_input = dcc.Input()
14-
my_output = html.Div()
15-
app.layout = html.Div([my_input, my_output])
16-
17-
@dash.callback(Output(my_output, 'children'), Input(my_input, 'value'))
18-
def update(value):
19-
return f'You have entered {value}'
20-
```
21-
22-
Or, if using Python >=3.8 you can use the `:=` walrus operator:
23-
```python
24-
app.layout = html.Div([
25-
my_input := dcc.Input(),
26-
my_output := html.Div()
27-
])
28-
29-
@dash.callback(Output(my_output, 'children'), Input(my_input, 'value'))
30-
def update(value):
31-
return f'You have entered {value}'
32-
33-
```
34-
## Dash Core Components
35-
36-
### Rearranged Keyword Arguments & Flexible Types
37-
**`Dropdown`, `RadioItem`, and `Checklist`**
38-
- Rearranged Keyword Arguments - `options` & `value` are now the first two keywords which means they can be supplied as positional arguments without the keyword. Supplying the keywords (`options=` and `value=`) is still supported.
39-
- Flexible Types - `options` can be supplied in two new forms:
40-
1. An array of `string|number|bool` where `label` and `value` are equal to the items in the list.
41-
2. A dictionary where the keys and values set as `value` and `label` respectively.
42-
43-
Before:
44-
45-
```python
46-
dcc.Dropdown(
47-
options=[
48-
{'label': 'New York', 'value': 'New York'},
49-
{'label': 'Montreal', 'value': 'Montreal'},
50-
],
51-
value='New York'
52-
)
53-
```
54-
or
55-
56-
```python
57-
dcc.Dropdown(
58-
options=[
59-
{'label': 'New York', 'value': 'NYC'},
60-
{'label': 'Montreal', 'value': 'MTL'},
61-
],
62-
value='New York'
63-
)
64-
```
65-
66-
After:
67-
68-
```python
69-
dcc.Dropdown(['New York', 'Montreal'], 'New York')
70-
```
71-
Or
72-
73-
```python
74-
dcc.Dropdown({'NYC': 'New York', 'MTL': 'Montreal'}, 'New York')
75-
```
76-
77-
**`RangeSlider` & `Slider`**
78-
- Rearranged Keyword Arugments - `min`, `max`, and `step` are now the first three keyword arguments which means they can be supplied as positional arguments without the keyword.
79-
- Flexible Types
80-
- `step` will be calculated implicitly if not given.
81-
- `marks` will be auto generated if not given. It will use `min` and `max` and will respect `step` if supplied. Auto generated marks labels are SI unit formatted. Around 5 human-readable marks will be created.
82-
- To remove the Slider's marks, set `marks=None`.
83-
84-
Before:
85-
86-
```python
87-
dcc.Slider(marks={1: 2, 2: 2, 3: 3})
88-
```
89-
90-
After:
91-
```python
92-
dcc.Slider(min=1, max=3, step=1)
93-
```
94-
Or equivalently:
95-
```python
96-
dcc.Slider(1, 3, 1)
97-
```
98-
Step can also be omitted and the `Slider` will attempt to create a nice, human readable step with SI units and around 5 marks:
99-
```python
100-
dcc.Slider(0, 100)
101-
```
102-
103-
The SI units used in `marks` are:
104-
105-
* `z` - zepto, 10⁻²¹
106-
* `a` - atto, 10⁻¹⁸
107-
* `f` - femto, 10⁻¹⁵
108-
* `p` - pico, 10⁻¹²
109-
* `n` - nano, 10⁻⁹
110-
* `µ` - micro, 10⁻⁶
111-
* `m` - milli, 10⁻³
112-
* `​` (none) - 10⁰
113-
* `k` - kilo, 10³
114-
* `M` - mega, 10⁶
115-
* `G` - giga, 10⁹
116-
* `T` - tera, 10¹²
117-
* `P` - peta, 10¹⁵
118-
* `E` - exa, 10¹⁸
119-
* `Z` - zetta, 10²¹
120-
121-
**`DataTable`**
122-
123-
- Rearranged Keyword Arguments - `data` and `columns` the first twokeyword arguments which means they can be supplied as positional arguments without the keyword.
124-
- Inferred Properties - If `columns` isn't supplied then it is extracted from the the first row in `data`
125-
126-
Before:
127-
128-
```python
129-
dash_table.DataTable(data=df.to_dict('records'), columns=[{'name': i, 'id': i} for i in df.columns])
130-
```
131-
After:
132-
133-
```python
134-
dash_table.DataTable(data=df.to_dict('records'))
135-
```
136-
137-
### New Component Properties
138-
139-
**`Checklist` & `RadioItems`**
140-
141-
- A new property `inline` appends `display: inline-block` to `labelStyle`.
142-
143-
```python
144-
dcc.Checklist(inline=True)
145-
```
146-
1475
## [2.0.0] - 2021-08-03
1486

1497
## Dash and Dash Renderer

components/dash-core-components/src/utils/computeSliderMarkers.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,7 @@ export const applyD3Format = (mark, min, max) => {
9090
const k_ten_factor = 3;
9191

9292
const ten_factor = Math.log10(Math.abs(mark));
93-
if (
94-
mark === 0 ||
95-
(ten_factor > mu_ten_factor && ten_factor < k_ten_factor)
96-
) {
93+
if (ten_factor > mu_ten_factor && ten_factor < k_ten_factor) {
9794
return String(mark);
9895
}
9996
const max_min_mean = (Math.abs(max) + Math.abs(min)) / 2;

components/dash-core-components/tests/integration/sliders/test_sliders_shorthands.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -157,30 +157,29 @@ def test_slsh002_sliders_marks_si_unit_format(dash_dcc):
157157
for n in range(-20, 20):
158158
min = 0
159159
max = pow(10, n)
160-
160+
161161
LAYOUT.extend(
162162
[
163163
html.Div(
164164
[
165+
165166
html.B(
166167
f"min={min}, max={max}(=10^{n})",
167168
style={"marginBottom": 15, "marginTop": 25},
168169
),
169-
(
170-
html.Div(
171-
"(Known issue: Slider does not seem to work for precision below 10^(-6))"
172-
)
173-
if n <= -6
174-
else None
175-
),
176-
html.Div("value is undefined"),
170+
(html.Div(
171+
'(Known issue: Slider does not seem to work for precision below 10^(-6))'
172+
) if n <= -6 else None),
173+
html.Div('value is undefined'),
177174
dcc.Slider(min, max),
178175
dcc.RangeSlider(min, max),
179-
html.Div(f"value=0.4 * 10^{n}"),
180-
dcc.Slider(min, max, value=0.4 * max),
176+
177+
html.Div(f'value=0.4 * 10^{n}'),
178+
dcc.Slider(min, max, value=0.4*max),
181179
dcc.RangeSlider(min, max, value[0.2 * max, 0.4 * max]),
182-
html.Div(f"value=0.5 * 10^{n}"),
183-
dcc.Slider(min, max, value=0.4 * max),
180+
181+
html.Div(f'value=0.5 * 10^{n}'),
182+
dcc.Slider(min, max, value=0.4*max),
184183
dcc.RangeSlider(min, max, value[0.2 * max, 0.5 * max]),
185184
]
186185
)

0 commit comments

Comments
 (0)