Skip to content

Commit 2941b5d

Browse files
committed
Clean up handling of width/height controls
1 parent b05ee19 commit 2941b5d

13 files changed

+167
-57
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
example/**/* linguist-documentation
22
example/src/assets/codemirror.css linguist-vendored
33
example/src/assets/plotly-basic.min.js linguist-vendored
4+
example/src/assets/plotly.min.js linguist-vendored
45
build/* linguist-generated
56
lib/* linguist-generated

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ The only requirement is that plotly.js is loaded before you inject it. You may n
4343
| `fit` | `Boolean` | `false` | When true, fits plot to its parent container and updates on window resize |
4444
| `width` | `Number` | `undefined` | Width of the plot; overrides `fit` |
4545
| `height` | `Number` | `undefined` | Heigh of the plot; overrides `fit` |
46+
| `debug` | `Boolean` | `false` | Assign the graph div to `window.gd` for debugging |
4647

4748
### Event handler props
4849

build/plotlyjs-react.js

+35-26
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/plotlyjs-react.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/plotlyjs-react.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/src/assets/plotly.min.js

+78
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/src/components/code.js

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ require('../../../node_modules/codemirror/mode/javascript/javascript')
44

55
import styles from './code.css'
66

7+
require('insert-css')(`
8+
.ReactCodeMirror,
9+
.CodeMirror {
10+
height: 100%;
11+
}
12+
`)
13+
714
export default class Code extends Component {
815
render () {
916
const classes = [styles.codeContainer]

example/src/components/plot.js

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export default class Plot extends React.Component {
2424
onClick={e => console.log('plotly_click:', e)}
2525
onHover={e => console.log('plotly_hover:', e)}
2626
onUnhover={e => console.log('plotly_unhover:', e)}
27+
debug
2728
/>
2829
</div>
2930
);

example/src/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<link rel="stylesheet" type="text/css" href="assets/codemirror.css">
77
<link rel="stylesheet" type="text/css" href="assets/react-dat-gui.min.css">
88
<meta http-equiv="content-type" content="text/html; charset=UTF8">
9-
<script src="assets/plotly-basic.min.js"></script>
9+
<script src="assets/plotly.min.js"></script>
1010
</head>
1111
<body>
1212
<script src="index.js"></script>

lib/plotlyjs-react.js

+35-26
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/plotlyjs-react.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"envify": "^4.1.0",
5151
"fast-isnumeric": "^1.1.1",
5252
"husky": "^0.14.3",
53+
"insert-css": "^2.0.0",
5354
"lint-staged": "^4.0.2",
5455
"netlify-cli": "^1.2.2",
5556
"object-assign": "^4.1.1",

src/plotlyjs-react.jsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,15 @@ export default function createPlotlyComponent (Plotly) {
107107
} else if (!props.fit && this.resizeHandler) {
108108
window.removeEventListener('resize', this.resizeHandler);
109109
this.resizeHandler = null;
110-
111110
}
112111
}
113112

114113
getRef(el) {
115114
this.el = el;
115+
116+
if (this.props.debug && isBrowser) {
117+
window.gd = this.el;
118+
}
116119
}
117120

118121
// Attach and remove event handlers as they're added or removed from props:

0 commit comments

Comments
 (0)