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

Conversation

Kully
Copy link
Contributor

@Kully Kully commented Feb 23, 2018

This PR accomplishes:

  • added fill_percent to params for insert, swap and remove
  • fix HTML preview to reflect fill_percent
  • update changelog
  • remove #TODOs from dashboard_objs.py

re: #711

@Kully
Copy link
Contributor Author

Kully commented Feb 26, 2018

@cldougl ready for a 👀

@cldougl
Copy link
Member

cldougl commented Feb 28, 2018

hey @Kully this looks good, I'm trying out some examples now! Are these changes intended to be backwards compatible?

CHANGELOG.md Outdated
@@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [2.4.2] - UNRELEASED
Copy link
Member

Choose a reason for hiding this comment

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

I would say this is more of added functionality than a bug fix (do you agree?) so I think it should be version 2.5.0 based on: https://semver.org/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree they are not bug fixes. The question I have now about my message below is if we consider these points as backwards-compatible. Functionally the API is the same and produces dashboards that look the same. I just had to modify a test or two.

Copy link
Member

Choose a reason for hiding this comment

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

Is there no way to add this functionality as an option rather than the default so that it remains backwards compatible?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think it's worth it. There was a technical issue with, before, using pixels as the metric for slicing up the boxes (since it was always in half) but the new param uses percentage to insert the boxes next to a pre-existing box

Copy link
Member

Choose a reason for hiding this comment

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

ok got it 👍

Copy link
Member

Choose a reason for hiding this comment

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

@Kully did you get a chance to update this to 2.5.0 and update plotly/version.py as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no thank you for reminding me

@Kully
Copy link
Contributor Author

Kully commented Feb 28, 2018

hey @Kully this looks good, I'm trying out some examples now! Are these changes intended to be backwards compatible?

As far as I know, yes. fill_percent is defaulted to 50, so it behaves the same way before the changes.

There are a couple technically non-backwards compatible things:

  • The main container in an init dashboard dashboard.Dashboard() that holds all the boxes has size in %, not px. It's a small technical thing.
  • the default height and width of the HTML preview are bigger.

@@ -440,7 +434,7 @@ def insert(self, box, side='above', box_id=None):
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)

@Kully
Copy link
Contributor Author

Kully commented Mar 2, 2018

@cldougl Now the API auto-sizes very similarly to the dashboard GUI. Ready for I believe a final look.

@cldougl
Copy link
Member

cldougl commented Mar 5, 2018

@Kully for python 2.7 and 3.6 I am getting this preview from the example:

screen shot 2018-03-05 at 11 12 14 am

Can you confirm that is correct? That is not what I was expecting from

my_dboard = dashboard.Dashboard()
my_dboard.insert(box_1)
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, fill_percent=30)

@cldougl
Copy link
Member

cldougl commented Mar 5, 2018

@Kully can you also add an example of the easiest way to add 4 vertical boxes of the same height?

screen shot 2018-03-05 at 11 20 24 am

@Kully
Copy link
Contributor Author

Kully commented Mar 5, 2018

@Kully can you also add an example of the easiest way to add 4 vertical boxes of the same height?

# 4 equally stacked vectical boxes
import plotly.dashboard_objs as dashboard

box_1 = {
    'type': 'box',
    'boxType': 'plot',
    'fileId': 'username:some#',
    'title': 'box 1'
}

my_dboard = dashboard.Dashboard()
my_dboard.insert(box_1)
my_dboard.insert(box_1, 'below', 1)
my_dboard.insert(box_1, 'below', 1)
my_dboard.insert(box_1, 'below', 3)

screen shot 2018-03-05 at 8 36 06 am

@Kully
Copy link
Contributor Author

Kully commented Mar 5, 2018

Can you confirm that is correct? That is not what I was expecting from

Yes this is correct.

This is perhaps the weakest point in the API currently. box_id numbers (the numbers that appear in the HTML preview and correspond to a box in the layout) are generated on-the-fly. This just means that you need to look at where the numbers are placed after each insertion/deletion of a box to appropriate reference the correct box_id.

Does this make sense?

@Kully Kully closed this Mar 5, 2018
@Kully Kully reopened this Mar 5, 2018
@Kully
Copy link
Contributor Author

Kully commented Mar 5, 2018

I am going to edit plotly/dashboard_objs/dashboard_objs.py now so that box_1 is rewritten as box_a to avoid confusion. You suggested a similar variable-renaming to the docs a while ago.

@cldougl
Copy link
Member

cldougl commented Mar 7, 2018

💃

@Kully Kully merged commit d6d777b into master Mar 7, 2018
@Kully Kully deleted the dashboard-percent branch March 7, 2018 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants