2017-10-26 8 views
1

joke-uiを使用してサイズ変更可能なdiv id="myMenu"を含む単純なhtmlページでBokehJSを使用しようとしています。私は、BokehJSプロットを含むid="myPlot"のdivは、ウィンドウの残りの部分を埋めるように動的にサイズ変更されることを望みます。jquery-uiサイズ変更イベントでBokehJSプロットのサイズ変更をトリガする方法は?

sizing_mode:'stretch_both'を使用しているにもかかわらず、BokehJSプロットのサイズ変更をトリガーできる唯一の方法は、手動でウェブブラウザウィンドウのサイズを変更することです。

javascriptを使用してBokehJSプロットのサイズを変更することはできますか?使用する関数は何でしょうか?プランは、カスタムjquery-ui resizeイベントハンドラでその関数を使用することになります。

EDIT:Githubで提供されるソリューションを使用して更新された例。ありがとう!

<html> 
<head> 
    <link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" type="text/css" /> 
    <script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.js"></script> 
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> 

    <link rel="stylesheet" href="https://cdn.pydata.org/bokeh/release/bokeh-0.12.10.css" type="text/css" /> 
    <script type="text/javascript" src="https://cdn.pydata.org/bokeh/release/bokeh-0.12.10.js"></script> 
    <script type="text/javascript" src="https://cdn.pydata.org/bokeh/release/bokeh-api-0.12.10.js"></script> 
    <!-- The order of CSS and JS imports above is important. --> 

</head> 
<body> 
    <div style="display:table; width:100%; height:100%; margin:0px; border:0px; padding:0px;"> 
     <div style="display:table-row; width:100%; height:100%; margin:0px; border:0px; padding:0px;"> 
      <div id="myMenu" style="display:table-cell; width:25%; vertical-align:top; height:100%; margin:0px; border:0px; border-right:1px solid grey; padding:0px;"> 
       menu 
      </div> 
      <div id="myPlot" style="display:table-cell; height:100%; margin:0px; border:0px; padding:0px;"></div> 
     </div> 
    </div> 
    <script type="text/javascript"> 
    // data to plot 
    var source = new Bokeh.ColumnDataSource({ 
     data: { x: [0,1,2,3,4,5,6,7,8,9], y: [0,1,4,-2,2,5,0,2,1,1] } 
    }); 

    // make the plot and add some tools 
    var tools = "pan,crosshair,wheel_zoom,box_zoom,reset,save"; 

    var plot = Bokeh.Plotting.figure({ 
     title:"demo plot", 
     tools: tools, 
     toolbar_location:"above", 
     sizing_mode:"stretch_both" 
    }); 

    var scatterData = plot.line({ field: "x" }, { field: "y" }, { 
     source: source, 
     line_width: 2 
    }); 

    // Show the plot, appending it to the end of the current 
    // section of the document we are in. 
    var plot_view = Bokeh.Plotting.show(plot,document.getElementById("myPlot")); 

    //resizable left menu container 
    $('#myMenu').resizable({ 
     handles:'e', 
     resize: function(event,ui){plot_view.resize();} 
    }); 
    </script> 
</body> 
</html> 

答えて

関連する問題