Python Forum
Read plotly-latest.min.js from local
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Read plotly-latest.min.js from local
#1
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?
#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
I am running the code in Win 10 , python 3.7 Wall
full code as below;
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_())
Reply
#2
anyone help?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  binning_endpoints ->plotly Luis_liverpool 0 808 Aug-09-2022, 10:13 AM
Last Post: Luis_liverpool
  Get latest version off website and save it as variable [SOLVED] AlphaInc 5 1,891 Nov-14-2021, 09:00 PM
Last Post: DeaD_EyE
  plotly expression problem Visiting 2 1,963 May-16-2021, 12:28 AM
Last Post: Visiting
  Running latest Python version on the Terminal (MAC) Damian 4 2,592 Mar-22-2021, 07:58 AM
Last Post: Damian
  Latest file with a pattern produces an error tester_V 4 3,121 Dec-10-2020, 02:14 AM
Last Post: tester_V
  Plotly library with AIX 6.X / 7.X ? HK2432 0 1,439 Jan-14-2020, 06:04 PM
Last Post: HK2432
  Plotly error - AttributeError: module 'plotly.plotly' has no attribute 'iplot' fernando_santos 0 5,558 Jul-24-2019, 02:35 PM
Last Post: fernando_santos
  How to save latest time stamp in a file? redwood 12 7,053 Jul-11-2019, 11:03 AM
Last Post: redwood
  Python ftp server get the latest sub-directory name muzamalrana 1 3,399 Aug-08-2018, 11:40 PM
Last Post: muzamalrana
  How to install latest version of 'pygame' sylas 1 10,284 May-19-2018, 10:03 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020