Skip to content

Fullscreen button to expand tables and charts#137

Merged
dcaminos merged 28 commits intostreamlit:developfrom
dcaminos:issue395/expand_to_fullscreen
Oct 8, 2019
Merged

Fullscreen button to expand tables and charts#137
dcaminos merged 28 commits intostreamlit:developfrom
dcaminos:issue395/expand_to_fullscreen

Conversation

@dcaminos
Copy link
Copy Markdown
Contributor

*Added new component FullScreenWrapper

Screen Shot 2019-09-18 at 4 00 03 PM (2)

Screen Shot 2019-09-18 at 4 00 10 PM (2)

Screen Shot 2019-09-18 at 4 00 20 PM (2)

Screen Shot 2019-09-18 at 4 00 23 PM (2)

@jrhone
Copy link
Copy Markdown
Contributor

jrhone commented Sep 19, 2019

I'm seeing a slight flicker of the button after expanding and resetting.

To reproduce try: expand dataframe -> move mouse below chart -> press escape

table: (el: SimpleElement) => (
<FullScreenWrapper width={width}>
{({ width, height }) => (
<Table element={el} width={width} height={height} />
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think table is responding to the height property.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, and width either, and I don't fixed it because I finded this comment on the code:

// TODO(tvst): Make tables have a max width with overflow: scroll (when

@tvst can you clarify this please?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@tvst can you comment on why table is not handling width or height?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tables don't have a height prop. So you should just remove it here.

As for width, I don't really recall what's up with that comment I wrote. The comment is now almost 1 year old, though, so you can't blame me! 😎

Copy link
Copy Markdown
Contributor

@tvst tvst left a comment

Choose a reason for hiding this comment

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

Just tried this out on my machine. It's so awesome 👏

Some comments about the UX:

  • Can you add the "expand" button to all types of plots? This means VegaLiteChart.tsx, DeckGlChart.tsx, GraphVizChart.tsx, PlotlyChart.tsx, and BokehChart.tsx
  • Can you add the "expand' button to images and videos too? ImageList.tsx and Video.tsx. Edit: actually videos already have a fullscreen button. No need to do anything there.
  • Add a tooltip on the button, that says "View fullscreen" and "Exit fullscreen"
  • When I go fullscreen and then rerun the app (by pressing r), the UI looks weird. I think it's because the fullscreen element is fading away. As a quick fix, can you make elements not fade when fullscreen?

Also, please run make headers to add the Apache header to all new files.

@@ -0,0 +1,32 @@
.streamlit-container .stFullScreenFrame--expanded {
position: fixed;
top: 0px;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Use 0 instead of 0px. Same below.

overflow: auto;
background: white;
z-index: 1000;
padding: 30px;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we make this smaller? Like 0.5rem?
(When I do this I still get a huge margin on the right and bottom sides. No idea why.)

background: white;
z-index: 1000;
padding: 30px;
padding-top: 80px;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Use the same value as the header height here. I believe that's 3.5rem (which includes some margin).

Also, please put 3.5rem as a variable in variables.scss and use it in header.scss and here.

.streamlit-container .stFullScreenFrame .stButton-enter {
position: absolute;
right: 10px;
top: 10px;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Look at header.scss and see what we use for the hamburger menu, make it a variable and use it here.

(Also, I think we don't use px as a unit for this things, but I may be mistaken...)

@dcaminos
Copy link
Copy Markdown
Contributor Author

@tvst should be better don't re run when you are in fullscreen?

"When I go fullscreen and then rerun the app (by pressing r), the UI looks weird. I think it's because the fullscreen element is fading away. As a quick fix, can you make elements not fade when fullscreen?"

@tvst
Copy link
Copy Markdown
Contributor

tvst commented Sep 20, 2019

When I go fullscreen and then rerun the app (by pressing r), the UI looks weird. I think it's because the fullscreen element is fading away. As a quick fix, can you make elements not fade when fullscreen?

@tvst should be better don't re run when you are in fullscreen?

In terms of user experience, I think it's best to allow rerunning when fullscreen. This way you if you have a time-varying script, you can zoom into a chart and keep rerunning the app to focus on how the reruns impact the chart.

But if that is too much work to get right (more than an afternoon), then it's OK to disallow it for now.

… PlotlyChart, BokehChart (now responsive) and ImageList
@dcaminos dcaminos requested review from jrhone and tvst September 23, 2019 21:13
public render = (): React.ReactNode => {
const width: number = this.props.element.get("width") || this.props.width

const height: number =
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't this use the same logic as the code block above for // Override or reset the graph height?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Is the same logic, this.props.element.get("height") have preference

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Above also uses this.originalHeight .. should it be a possible value for height here as well?

@tvst
Copy link
Copy Markdown
Contributor

tvst commented Sep 24, 2019

I just created a branch tweaking the styles for these new buttons to match the "copy" button that shows up when you hover over codeblocks. I also moved the buttons to the right of the elements rather than on top.

Please take a look and merge into your branch:
https://github.com/dcaminos/streamlit/compare/issue395/expand_to_fullscreen...tvst:issue395/tvst-styles?expand=1


interface Props {
width: number
height: number | undefined
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Unrelated to this line but the UI is a bit jumpy when expanding and resetting the graphviz charts (and probably other charts) but it's easy to see with the second chart in e2e/scripts/graphviz_chart.py

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, I agree about graphviz (no others charts). I guess is because D3 update the chart after component did update.


interface Props {
width: number
height: number | undefined
Copy link
Copy Markdown
Contributor

@jrhone jrhone Sep 24, 2019

Choose a reason for hiding this comment

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

  • I'm not seeing the expand button on the first 4 vega lite charts in e2e/scripts/vega_lite_chart.py, only the last 4, is this expected?
  • The charts expand to fullscreen height but not width, is this expected?
  • If you expand a chart, then set the width to 500, then re-run report, the chart will expand to the width but revert it's height. If you set the width before expanding the chart, it expands correctly. Very minor case.

Copy link
Copy Markdown
Contributor Author

@dcaminos dcaminos Sep 25, 2019

Choose a reason for hiding this comment

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

I'm not seeing the expand button on the first 4 vega lite charts

You are right, there are a bug with the opacity transition, I will try to solve it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The charts expand to fullscreen height but not width, is this expected?

That is right, because the user are specifying a width into the script

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If you expand a chart, then set the width to 500, then re-run report, the chart will expand to the width but revert it's height. If you set the width before expanding the chart, it expands correctly. Very minor case.

I will try to solve it

Copy link
Copy Markdown
Contributor

@tvst tvst left a comment

Choose a reason for hiding this comment

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

Looks good to me, after comments are addressed.

But since Jonathan left comments too, I'll let him be the one to click "approve"

index: number
}

const DEFAULT_HEIGHT = 400
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does this mean that when in normal non-fullscreen mode the default height for a Bokeh chart will be 400px? If so, I think we shouldn't do that. Instead, just let Bokeh choose the height of the chart. This way Bokeh charts in Streamlit will work just like Bokeh charts anywhere else.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same with the other charts below.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Before this PR, all Bokeh charts was 600px x 600px. Users must write the chart width and height on python code to set that values.

If we dont set a default, the height will be 600px. We can set the default on 600 or just remove the default value.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah I see. Yeah, I think removing the default makes sense. This way Bokeh decides what to use as default.

Same for other libraries in this PR.


componentDidMount() {
this.updateWindowDimensions()
window.addEventListener("resize", this.updateWindowDimensions)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice! Good thinking


updateWindowDimensions = () => {
this.setState({
fullwidth: window.innerWidth - this.convertRemToPixels(1.5), //0.75rem + 0.75rem
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Where is the 1.5 coming from? If we have it variables.scss then you can get it here with import { SCSS_VARS } from "autogen/scssVariables".

Otherwise, at least add a comment explaining where it comes from. And if there is some CSS file that this needs to be in sync with, add a comment in that file pointing to this.

Same below.

@dcaminos dcaminos requested review from jrhone and tvst September 26, 2019 19:03
@@ -0,0 +1,283 @@
{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remove file from PR and add to .gitignore

table: (el: SimpleElement) => (
<FullScreenWrapper width={width}>
{({ width, height }) => (
<Table element={el} width={width} height={height} />
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@tvst can you comment on why table is not handling width or height?

public render = (): React.ReactNode => {
const width: number = this.props.element.get("width") || this.props.width

const height: number =
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Above also uses this.originalHeight .. should it be a possible value for height here as well?

@jrhone
Copy link
Copy Markdown
Contributor

jrhone commented Sep 27, 2019

The expand icon is staying visible on a Vega lite chart after minimizing. It doesn't seem to disappear until you click somewhere off the chart. Is it expected?

@dcaminos
Copy link
Copy Markdown
Contributor Author

The expand icon is staying visible on a Vega lite chart after minimizing. It doesn't seem to disappear until you click somewhere off the chart. Is it expected?

@jrhone I saw it. I'm not sure if this is wrong. Is like a make, like "you was here"

But we can talk about this if you want.

@dcaminos
Copy link
Copy Markdown
Contributor Author

@tvst this is the bug I fixed with vega lite charts:
Screen Shot 2019-09-30 at 7 08 45 PM (2)
Screen Shot 2019-09-30 at 7 07 33 PM (2)

spec.width = width
spec.height = height
spec.padding = {
bottom: EMBED_PADDING,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Wait, this will override any padding the user adds, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes. Can they set a padding when write the chart? I that case, I can use that padding and this should be the default one.

@dcaminos
Copy link
Copy Markdown
Contributor Author

dcaminos commented Oct 1, 2019

@tvst I improved the vega-lite solution to do not override current padding

Copy link
Copy Markdown
Contributor

@tvst tvst left a comment

Choose a reason for hiding this comment

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

Leaving another partial review, as I haven't looked at everything yet. Will look through it all by tomorrow at noon. Apologies for the delay!

height={height}
/>
)}
</FullScreenWrapper>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you move these FullScreenWrappers into each element's component? It would be nice to keep this big switch statement lean.

table: (el: SimpleElement) => (
<FullScreenWrapper width={width}>
{({ width, height }) => (
<Table element={el} width={width} height={height} />
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tables don't have a height prop. So you should just remove it here.

As for width, I don't really recall what's up with that comment I wrote. The comment is now almost 1 year old, though, so you can't blame me! 😎


return (
<div className={`stFullScreenFrame${expanded ? "--expanded" : ""}`}>
<button
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is is possible to use a Reactstrap <Button> component? See the main menu and toolbar button for examples.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes I can, but I based on this button: https://github.com/dcaminos/streamlit/blob/58bd06cee4de0b403dbfff55de8a07aea79dbf4a/frontend/src/components/elements/CodeBlock/CopyButton.tsx#L46

We should create a "OverlayButton" component for both cases (and use Reactstrap), but I don't wanna do it on this PR (it's too big right now)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sounds good. Can you create an issue for this?

@dcaminos dcaminos requested a review from tvst October 7, 2019 19:51
@tvst
Copy link
Copy Markdown
Contributor

tvst commented Oct 8, 2019

There are some JS warnings, by the way:

./src/components/elements/CodeBlock/CopyButton.tsx
  Line 20:  'Button' is defined but never used  @typescript-eslint/no-unused-vars

./src/components/elements/VegaLiteChart/VegaLiteChart.tsx
  Line 29:  'max' is defined but never used  @typescript-eslint/no-unused-vars

@dcaminos dcaminos merged commit ed9dd36 into streamlit:develop Oct 8, 2019
@dcaminos dcaminos deleted the issue395/expand_to_fullscreen branch October 8, 2019 20:50
tconkling added a commit to tconkling/streamlit that referenced this pull request Oct 9, 2019
* develop:
  Fullscreen button to expand tables and charts (streamlit#137)
  Blacklist for hashing (streamlit#254)
  Adding utils and tests for hello.py (streamlit#261)
  Fix port-finding bugs (streamlit#280)
  Fix hello.py usage of os.path.join on a URL (streamlit#285)
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.

3 participants