2017-08-29 18 views
0

をミュートするとき、「未定義のプロパティを読み取ることができません 『pageX』」私はGUIを作成するためにPyQt5を使用していますし、このGUIに私がQWebEngineViewを使用してBokehグラフを可視化します。QWebEngineView:ボケ伝説

それが正常に動作しますが、私は「ミュート」を実装しようとしたときthisのような伝説が、私はエラーを取得:私は、showメソッドを使用する場合は

js: Uncaught TypeError: Cannot read property 'pageX' of undefined 

は、私は私のブラウザで期待した結果を取得します。しかし、私が保存を使用してQWebEngineViewに表示すると、私は上記のエラーが発生します。

アイデア?

QWebEngineViewにプロットして表示するように私のGuiクラスのスロット:

注意:バーとピザのプロットを無視し、それが

def plotGraph(self, df=None): 
    # Get parameters to plot 
    x = str(self.ui.comboBox_x_axis.currentText()) 
    y = str(self.ui.comboBox_y_axis.currentText()) 
    # Define axis types 
    try: 
     x_axis_type = str(
      self.ui.comboBox_plot_scale.currentText()).split('-')[0] 
     y_axis_type = str(
      self.ui.comboBox_plot_scale.currentText()).split('-')[1] 
    except: 
     x_axis_type = 'auto' 
     y_axis_type = 'auto' 
    # Define kind of graph 
    kind = str(self.ui.comboBox_plot_style.currentText()) 
    # For bar chart define groups 
    group = str(self.ui.comboBox_group.currentText()) 
    # Prepare data for plot 
    if (kind == 'bar' and group != "Don't group"): 
     data = df[[x, y, group]] 
    else: 
     data = df[[x, y]] 
     data = data.sort_values(x, axis=0) 
    # Dynamically define plot size 
    width = round(self.ui.webViewer.frameGeometry().width()) 
    height = round(self.ui.webViewer.frameGeometry().height()) 
    # Plot and save html 
    self.plot = self.graph.plot(
     data, kind, x_axis_type, y_axis_type, width, height) 
    self.plot_num = 1 
    # Display it at QWebEngineView 
    self.ui.webViewer.setUrl(QtCore.QUrl(
     "file:///C:/Users/eandrade_brp/Documents/git/tl-data-viewer/plot.html")) 

この問題に関連する散乱およびラインでありますここでは、すべてのボケプロットを扱うグラフクラスはまず、disclai

class Graph(object): 
    """docstring for ClassName""" 

    def __init__(self, file_name="plot.html"): 
     super(Graph, self).__init__() 
     output_file(file_name) 

    def plot(self, data, kind, x_axis_type, y_axis_type, width, height): 
     p = None 
     if kind == 'scatter' or kind == 'line': 
      layout, p = self.createFigure(
       data, kind, x_axis_type, y_axis_type, width, height) 
     elif kind == 'bar': 
      layout = self.plot_Bar(data, width, height) 
     elif kind == 'pizza': 
      layout = self.plot_Pizza(
       data, width, height) 
     # Show/save 
     save(layout) 
     return p 

    def createFigure(self, data, kind, x_axis_type, y_axis_type, width, height): 
     source, xdata, ydata, xvalues, yvalues = self.prepare_data(data) 
     # Define tool 
     tools = "pan, box_zoom, lasso_select, undo, redo" 
     wheel_zoom = WheelZoomTool() 
     hover = HoverTool(
      tooltips=[ 
       (data.columns[0],   '$x'), 
       (data.columns[1],   '$y')], 
      mode='mouse') 
     # Create first figure and customize 
     fig1 = figure(title="{} vs {}" .format(ydata, xdata), tools=tools, 
         x_axis_type=x_axis_type, y_axis_type=y_axis_type, 
         toolbar_location="right", plot_width=round(0.9 * width), 
         plot_height=round(0.75 * height)) 
     fig1.add_tools(wheel_zoom) 
     fig1.add_tools(hover) 
     fig1.toolbar.active_scroll = wheel_zoom 
     fig1.background_fill_color = "beige" 
     fig1.background_fill_alpha = 0.4 

     # Create second figure and customize 
     fig2 = figure(title='Overview', title_location="left", 
         x_axis_type=x_axis_type, y_axis_type=y_axis_type, 
         tools='', plot_width=round(0.9 * width), plot_height=round(0.25 * height)) 
     fig2.xaxis.major_tick_line_color = None 
     fig2.xaxis.minor_tick_line_color = None 
     fig2.yaxis.major_tick_line_color = None 
     fig2.yaxis.minor_tick_line_color = None 
     fig2.xaxis.major_label_text_color = None 
     fig2.yaxis.major_label_text_color = None 

     # Add View box to second figure 
     rect = Rect(x='x', y='y', width='width', height='height', fill_alpha=0.1, 
        line_color='black', fill_color='black') 
     fig2.add_glyph(source, rect) 

     # Add JS callBacks 
     self.JS_linkPlots(fig1, source) 

     # Plots 
     plots = self.plot_continuous(source, xvalues, yvalues, fig1, kind) 
     self.plot_continuous(source, xvalues, yvalues, fig2, kind) 
     s2 = ColumnDataSource(data=dict(ym=[0.5, 0.5])) 
     fig1.line(x=[0, 1], y='ym', color="orange", 
        line_width=5, alpha=0.6, source=s2) 

     # Add legends 
     legend = Legend(items=[ 
      (ydata, plots)], 
      location=(0, 0), 
      click_policy="mute") 
     # Add legend to fig layout 
     fig1.add_layout(legend, 'below') 
     # Layout 
     layout = col(fig1, fig2) 
     return layout, fig1 

    def plot_continuous(self, source, xvalues, yvalues, fig, kind, color=0): 
     if kind == 'scatter': 
      s = fig.scatter(
       xvalues, yvalues, 
       fill_color='white', fill_alpha=0.6, 
       line_color=Spectral10[color], size=8, 
       selection_color="firebrick", 
       nonselection_fill_alpha=0.2, 
       nonselection_fill_color="blue", 
       nonselection_line_color="firebrick", 
       nonselection_line_alpha=1.0) 
      return [s] 

     elif kind == 'line': 
      l = fig.line(
       xvalues, yvalues, line_width=2, color=Spectral10[color], alpha=0.8, 
       muted_color=Spectral10[color], muted_alpha=0.2) 

      s = fig.scatter(
       xvalues, yvalues, 
       fill_color="white", fill_alpha=0.6, 
       line_color=Spectral10[color], size=8, 
       selection_color="firebrick", 
       nonselection_fill_alpha=0.2, 
       nonselection_fill_color="blue", 
       nonselection_line_color="firebrick", 
       nonselection_line_alpha=1.0) 
      return [s, l] 
     else: 
      raise 'Wrong type of plot' 

    def prepare_data(self, data): 
     xdata = data.columns[0] 
     xvalues = data[xdata] 
     ydata = data.columns[1] 
     yvalues = data[ydata] 
     source = ColumnDataSource(data) 
     return source, xdata, ydata, xvalues, yvalues 

答えて

1

(私はいくつかの非必要なコードを省略)でありますmer: Bokehは、Qtブラウザウィジェットで完全にまたは部分的に機能することを主張していません。私たちは、単に継続的なテストの下でそのクレームを厳格に維持することができないように装備されているだけなので、それを作ることはできません。もし誰かがその機能の保守主義者として参入したいのであれば、将来的に我々はより強い支持を得ることができるでしょう。


ボケは、異なるプラットフォーム間での取り扱い均一な低レベルのイベントを提供するために、Hammer.jsサードパーティのライブラリを使用しています。 Bokehは、生成されるイベントにpageXpageYの属性があると予測しています。 Qtのブラウザウィジェットがこの期待を満たしておらず、あなたが見ているエラーにつながっているようです。 Bokehが使用するHammerのバージョンを更新すると、問題が解決する可能性があります。回避策を導入する可能性があります。いずれにしても、BokehJS自体に新しい作業が必要になります。

短い答えは:このインタラクティブな伝説はたぶん、Qtで作業するつもりはないということです。この問題を回避するには、BokehウィジェットまたはQtウィジェットを使用してグリフを表示し、インタラクティブな凡例機能に依存しないようにします。

長期的:長期的には、上記の考え方のいくつかを検討することができます。しかし、私たちは援助が必要です。 私たちは、潜在的な修正をテストするためにQtアプリケーションを構築するための帯域幅、能力、または経験を持っていません。コアデベロッパーと協力して解決策を見つけることができる場合は、issue trackerに問題を投稿してください。