Skip to content

Commit 1991c7f

Browse files
committed
udpated changelog, removed TODOs, PEP-8 79 char line limit
1 parent 38f88ef commit 1991c7f

File tree

2 files changed

+25
-39
lines changed

2 files changed

+25
-39
lines changed

CHANGELOG.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
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+
## [2.4.2] - UNRELEASED
6+
### Added
7+
- New parameter `fill_percent` to the `.insert` method for the dashboards API. You can now insert a box into the dashboard layout and specify what proportion of the original container box it will occupy. Run `help(plotly.dashboard_objs.Dashboard.insert)` for more information on `fill_percent`.
8+
9+
## [2.4.1] - 2018-02-21
10+
### Fixed
11+
- The required shapefiles to generate the choropleths via `plotly.figure_factory.create_choropleth` are now shipped in the package data.
12+
13+
## [2.4.0] - 2018-02-16
14+
### Added
15+
- County Choropleth figure factory. Call `help(plotly.figure_factory.create_choropleth)` for examples and how to get started making choropleths of US counties with the Python API.
16+
17+
Note: Calling `plotly.figure_factory.create_choropleth` will fail with an IOError due to missing shapefiles see: https://github.com/plotly/plotly.py/blob/master/CHANGELOG.md#241---2018-02-21
18+
519
## [2.3.0] - 2018-01-25
620
### Fixed
721
- Merged [pull request](https://github.com/plotly/plotly.py/commit/a226e07393c158e01c34c050aaf492da9d77679a) that fixes `GraphWidget` for IPython > v6
@@ -663,4 +677,4 @@ it does.
663677
```
664678

665679
### Fixed
666-
- The height of the graph in `iplot` respects the figure's height in layout
680+
- The height of the graph in `iplot` respects the figure's height in layout

plotly/dashboard_objs/dashboard_objs.py

Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# default parameters for HTML preview
1919
MASTER_WIDTH = 500
2020
MASTER_HEIGHT = 500
21-
FONT_SIZE = 8
21+
FONT_SIZE = 9
2222

2323

2424
ID_NOT_VALID_MESSAGE = (
@@ -45,8 +45,6 @@ def _box(fileId='', shareKey=None, title=''):
4545
}
4646
return box
4747

48-
# old values
49-
# size=MASTER_HEIGHT, sizeUnit='px',
5048
def _container(box_1=None, box_2=None,
5149
size=50, sizeUnit='%',
5250
direction='vertical'):
@@ -122,13 +120,13 @@ def _draw_line_through_box(dashboard_html, top_left_x, top_left_y, box_w,
122120
return dashboard_html
123121

124122

125-
def _add_html_text(dashboard_html, text, top_left_x, top_left_y, box_w, box_h):
123+
def _add_html_text(dashboard_html, text, top_left_x, top_left_y, box_w,
124+
box_h):
126125
html_text = """<!-- Insert box numbers -->
127-
context.font = '{font_size}pt Times New Roman';
126+
context.font = '{}pt Times New Roman';
128127
context.textAlign = 'center';
129-
context.fillText({text}, {top_left_x} + 0.5*{box_w}, {top_left_y} + 0.5*{box_h});
130-
""".format(text=text, top_left_x=top_left_x, top_left_y=top_left_y,
131-
box_w=box_w, box_h=box_h, font_size=FONT_SIZE)
128+
context.fillText({}, {} + 0.5*{}, {} + 0.5*{});
129+
""".format(FONT_SIZE, text, top_left_x, box_w, top_left_y, box_h)
132130

133131
index_to_add_text = dashboard_html.find('</script>') - 1
134132
dashboard_html = (dashboard_html[:index_to_add_text] + html_text +
@@ -214,8 +212,6 @@ def __init__(self, content=None):
214212
self['version'] = content['version']
215213
self['settings'] = content['settings']
216214

217-
self._set_container_sizes()
218-
219215
def _compute_box_ids(self):
220216
box_ids_to_path = {}
221217
all_nodes = list(node_generator(self['layout']))
@@ -262,25 +258,6 @@ def _make_all_nodes_and_paths(self):
262258
all_paths.remove(path_second)
263259
return all_nodes, all_paths
264260

265-
# TODO: get rid by the end of PR
266-
# change name to init_container_size ?
267-
def _set_container_sizes(self):
268-
if self['layout'] is None:
269-
return
270-
271-
all_nodes, all_paths = self._make_all_nodes_and_paths()
272-
273-
# set dashboard_height proportional to max_path_len
274-
max_path_len = max(len(path) for path in all_paths)
275-
dashboard_height = 500 + 250 * max_path_len
276-
self['layout']['size'] = dashboard_height
277-
self['layout']['sizeUnit'] = 'px'
278-
279-
for path in all_paths:
280-
if len(path) != 0 and self._path_to_box(path)['type'] == 'split':
281-
self._path_to_box(path)['size'] = 50
282-
self._path_to_box(path)['sizeUnit'] = '%'
283-
284261
def _path_to_box(self, path):
285262
loc_in_dashboard = self['layout']
286263
for first_second in path:
@@ -298,12 +275,6 @@ def get_box(self, box_id):
298275
loc_in_dashboard = loc_in_dashboard[first_second]
299276
return loc_in_dashboard
300277

301-
def resize(self, dashboard_height):
302-
"""Sets the height (in pixels) of dashboard"""
303-
# TODO: problem when no box is inserted
304-
self['layout']['size'] = dashboard_height
305-
self['layout']['sizeUnit'] = 'px'
306-
307278
def get_preview(self):
308279
"""
309280
Returns JSON or HTML respresentation of the dashboard.
@@ -393,7 +364,8 @@ def get_preview(self):
393364
new_box_h = box_h * (fill_percent / 100.)
394365

395366
new_top_left_x_2 = top_left_x
396-
new_top_left_y_2 = top_left_y + box_h * (fill_percent / 100.)
367+
new_top_left_y_2 = (top_left_y +
368+
box_h * (fill_percent / 100.))
397369
new_box_w_2 = box_w
398370
new_box_h_2 = box_h * ((100 - fill_percent) / 100.)
399371

@@ -442,8 +414,8 @@ def insert(self, box, side='above', box_id=None, fill_percent=50):
442414
box from the given 'side' that the new box occupies. For example
443415
if you apply the method\n
444416
.insert(box=new_box, box_id=2, side='left', fill_percent=20)\n
445-
to a dashboard object, a new box is inserted 20% from the left side
446-
of the box with id #2. Run .get_preview() to see the box ids
417+
to a dashboard object, a new box is inserted 20% from the left
418+
side of the box with id #2. Run .get_preview() to see the box ids
447419
assigned to each box in the dashboard layout.
448420
Default = 50
449421
Example:

0 commit comments

Comments
 (0)