Nov-17-2020, 01:07 PM
Hi all,
I would like to plot charts without using internet and I downloaded js file and put same as py file together.
I Using 3 methods to the js file.
only Method 2 is working, but I want to run the code without internet; where is my mistake?
I am running the code in Win 10 , python 3.7
full code as below;
I would like to plot charts without using internet and I downloaded js file and put same as py file together.
I Using 3 methods to the js file.
only Method 2 is working, but I want to run the code without internet; where is my mistake?
1 2 3 |
#raw_html += '<script src="{}"></script></head>'.format(local) #method 1 NOK #raw_html += '<script src="https://cdn.plot.ly/plotly-latest.min.js"></script></head>' #method 2 ok raw_html + = '<script type="text/javascript" src="file:///C:/Users/User/Desktop/testOfflineChart/plotly-latest.min.js"></script></head>' # method 3 NOK |

full code as below;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
import sys from PyQt5.QtWidgets import QApplication from PyQt5.QtWebEngineWidgets import QWebEngineView from PyQt5.QtCore import QDir, QUrl import plotly import plotly.graph_objs as go sys.argv.append( "--disable-web-security" ) app = QApplication(sys.argv) x1 = [ 10 , 3 , 4 , 5 , 20 , 4 , 3 ] trace1 = go.Box(x = x1) layout = go.Layout(showlegend = True ) data = [trace1] fig = go.Figure(data = data, layout = layout) path = QDir.current().filePath( 'plotly-latest.min.js' ) local = QUrl.fromLocalFile(path).toString() print (local) raw_html = '<html><head><meta charset="utf-8" />' #raw_html += '<script src="{}"></script></head>'.format(local) #method 1 NOK #raw_html += '<script src="https://cdn.plot.ly/plotly-latest.min.js"></script></head>' Method 2 #ok raw_html + = '<script type="text/javascript" src="file:///C:/Users/User/Desktop/testOfflineChart/plotly-latest.min.js"></script></head>' # method 3 NOK raw_html + = '<body>' raw_html + = plotly.offline.plot(fig, include_plotlyjs = False , output_type = 'div' ) raw_html + = '</body></html>' view = QWebEngineView() view.setHtml(raw_html) view.show() print (local) sys.exit(app.exec_()) |