10000 added fill_percent to params for insert, swap and remove by Kully · Pull Request #946 · plotly/plotly.py · GitHub
[go: up one dir, main page]

Skip to content

added fill_percent to params for insert, swap and remove #946

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Mar 7, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter 8000

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
tests are working
  • Loading branch information
Kully committed Feb 26, 2018
commit c26b763cf7d344a768beb1a6cf818a1b04139d6e
17 changes: 9 additions & 8 deletions plotly/dashboard_objs/dashboard_objs.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,6 @@ def get_preview(self):

# determine the specs for resulting two box split
if is_horizontal:
print 'is horizontal'
new_top_left_x = top_left_x
new_top_left_y = top_left_y
new_box_w = box_w * (fill_percent / 100.)
Expand All @@ -388,7 +387,6 @@ def get_preview(self):
new_box_w_2 = box_w * ((100 - fill_percent) / 100.)
new_box_h_2 = box_h
else:
print 'is vertical'
new_top_left_x = top_left_x
new_top_left_y = top_left_y
new_box_w = box_w
Expand Down Expand Up @@ -440,11 +438,14 @@ def insert(self, box, side='above', box_id=None, fill_percent=50):
'left', and 'right'.
:param (int) box_id: the box id which is used as the reference box for
the insertion of the box.
:param (float) fill_percent: specifies the percentage of the box area
which the new box is occupying. The default is `fill_percent=50`
which splits the region into two equally sized pieces with `box`
and the box corresponding to `box_id` in this area of the layout.

:param (float) fill_percent: specifies the percentage of the container
box from the given 'side' that the new box occupies. For example
if you apply the method\n
.insert(box=new_box, box_id=2, side='left', fill_percent=20)\n
to a dashboard object, a new box is inserted 20% from the left side
of the box with id #2. Run .get_preview() to see the box ids
assigned to each box in the dashboard layout.
Default = 50
Example:
```
import plotly.dashboard_objs as dashboard
Expand All @@ -461,7 +462,7 @@ def insert(self, box, side='above', box_id=None, fill_percent=50):
my_dboard.insert(box_1, 'left', 1)
my_dboard.insert(box_1, 'below', 2)
my_dboard.insert(box_1, 'right', 3)
my_dboard.insert(box_1, 'above', 4)
my_dboard.insert(box_1, 'above', 4, fill_percent=30)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

screen shot 2018-02-28 at 11 29 07 am

does this output for the example look correct to you @Kully ? Not sure right/left or above/below is working

Copy link
Contributor Author
@Kully Kully Feb 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running the exact same code in my branch, I am getting this preview:
screen shot 2018-02-28 at 3 22 48 pm

My output is correct but yours is not. What could be different about our branches? (you are cloning from the latest commit I assume)

Copy link
Member
@cldougl cldougl Feb 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kully running on your branch in python 2.7 I get the desired output but in python 3.6 I get:
image
We should make this consistent across python versions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow, that's interesting -
I'll investigate that (and probably need to add better tests)


my_dboard.get_preview()
```
Expand Down
7 changes: 4 additions & 3 deletions plotly/tests/test_core/test_dashboard/test_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,12 @@ def test_dashboard_dict(self):
'sizeUnit': '%',
'type': 'split'},
'second': {'boxType': 'empty', 'type': 'box'},
'size': 1000,
'sizeUnit': 'px',
'type': 'split'},
'size': 500,
'sizeUnit': 'px',
'type': 'split'},
'settings': {},
'version': 2
}


self.assertEqual(dash['layout'], expected_dashboard['layout'])
0