Skip to content

demo code is not responsive #5396

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

Open
kenchan13 opened this issue Jan 12, 2021 · 2 comments
Open

demo code is not responsive #5396

kenchan13 opened this issue Jan 12, 2021 · 2 comments
Labels
bug something broken P3 backlog

Comments

@kenchan13
Copy link

Hello. I modify react plotly.js demo code to make it responsive.
It works when I changed the browser width but not the height.
I check html code, height always be 450px no matter how I change style={{height: '100%', width: '100%'}}

<div class="user-select-none svg-container" style="position: relative; width: 100%; height: 450px;" >

env:
"plotly.js": "^1.58.4",
"plotly.js-basic-dist": "^1.58.4",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-plotly.js": "^2.5.1",
"react-scripts": "4.0.1",

There is my code
`// import './App.css';
import React from 'react'

import Plotly from "plotly.js-basic-dist";
import createPlotlyComponent from "react-plotly.js/factory";
const Plot = createPlotlyComponent(Plotly);

class App extends React.Component {
render() {
return (
<Plot
config={{ displayModeBar: false, responsive: true }}
data={[
{
x: [1, 2, 3],
y: [2, 6, 3],
type: 'scatter',
mode: 'lines+markers',
marker: {color: 'red'},
},
{type: 'bar', x: [1, 2, 3], y: [2, 5, 3]},
]}
layout={ {autosize: true, title: 'A Fancy Plot'} }
useResizeHandler={true}
style={{height: '100%', width: '100%'}}
/>
);
}
}

export default App;
`

@yustiks
Copy link

yustiks commented Dec 11, 2023

I have the same problem with width

@yustiks
Copy link

yustiks commented Dec 11, 2023

I added the 'width' to the 'style':

        var graphDiv = document.getElementById('div-plot')
        graphDiv['style']['width'] = '88vw';

@gvwilson gvwilson self-assigned this Jul 12, 2024
@gvwilson gvwilson removed their assignment Aug 2, 2024
@gvwilson gvwilson changed the title demo code responsive issue demo code is not responsive Aug 9, 2024
@gvwilson gvwilson added bug something broken P3 backlog labels Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken P3 backlog
Projects
None yet
Development

No branches or pull requests

3 participants