1; 2 3var d3 = Plotly.d3; 4 5var WIDTH_IN_PERCENT_OF_PARENT = 60, 6 HEIGHT_IN_PERCENT_OF_PARENT = 80; 7 8var gd3 = d3.select('body') 9 .append('div') 10 .style({ 11 width: WIDTH_IN_PERCENT_OF_PARENT + '%', 12 'margin-left': (100 - WIDTH_IN_PERCENT_OF_PARENT) / 2 + '%', 13 14 height: HEIGHT_IN_PERCENT_OF_PARENT + 'vh', 15 'margin-top': (100 - HEIGHT_IN_PERCENT_OF_PARENT) / 2 + 'vh' 16 }); 17 18var gd = gd3.node(); 19 20Plotly.plot(gd, plotlydata['data'], plotlydata['layout']); 21 22window.onresize = function() { 23 Plotly.Plots.resize(gd); 24}; 25 26}; 27 28window.onload = onload; 29</script> 30</head> 31<body> 32</body> 33</html>