Reputation: 39
I'm trying to render a Bokeh chart on my html template view but unsuccessfully, any help would be appreciated. Thanks in advance.
This is the view class:
from bokeh.plotting import figure, show
from bokeh.embed import components
from bokeh.models import ColumnDataSource
from .models import FinancialInstrument, HistoricalData
class Offline(View):
'''Responsable to indicate the way to the Offline Analysis '''
form_class=HugeStatForm
template_name='charts/offline.html'
api_key = 'I0T0AM1MH4Y4X0DC'
def get(self, request):
user=request.user
historical_me=FinancialInstrument.objects.all()
form = self.form_class(historical_me=historical_me)
#instruments = FinancialInstrument.objects.all()
retrive=HistoricalData.objects.all()
get_symbol=retrive.filter(instrument__symbol="BTUSD")
x_values = [key.date for key in get_symbol]
y_values = [float(key.opening_price) for key in get_symbol]
source = ColumnDataSource(data=dict(dater=x_values,pricer=y_values))
plot = figure(title="New title",
x_axis_label="Date", y_axis_label="Max Price", x_axis_type="datetime")
plot.line(x='dater',y='pricer', source=source,line_width=1)
script, div = components(plot)
if user.is_authenticated:
return render(request,self.template_name, {'form':form,'script':script, 'div':div,})
return redirect('home')
This is a peace of my template view:
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-3.4.0.min.js" crossorigin="anonymous"></script>
<div class="col mx-0 px-0 d-flex justify-content-start">
<!-- Bottom Section Content -->
<!-- Chart goes here -->
{{ script | safe }}
{{ div | safe }}
</div>
When i load the page, it appears a blank chart and the console from the browser in the Developer mode says "bokeh-3.4.0.min.js:616 [bokeh 3.4.0] could not set initial ranges"
Here i have the list of the installed apps on my virtual environment:
Package Version
------------------------- -----------
aiohttp 3.9.3
aiosignal 1.3.1
alpha-vantage 2.3.1
appdirs 1.4.4
asgiref 3.8.1
asyncio 3.4.3
attrs 23.2.0
autobahn 23.6.2
Automat 22.10.0
beautifulsoup4 4.12.3
blinker 1.7.0
bokeh 3.4.0
bokeh-django 0.1.0
bottle 0.12.25
certifi 2024.2.2
cffi 1.16.0
channels 3.0.5
charset-normalizer 3.3.2
click 8.1.7
clr-loader 0.2.6
colorama 0.4.6
constantly 23.10.4
contourpy 1.2.1
cryptography 42.0.5
cycler 0.12.1
daphne 3.0.2
dash 2.9.3
dash-bootstrap-components 1.5.0
dash-core-components 2.0.0
dash-html-components 2.0.0
dash-table 5.0.0
Django 5.0.4
django-ranged-response 0.2.0
dpd_components 0.1.0
Flask 3.0.3
fonttools 4.51.0
frozendict 2.4.1
frozenlist 1.4.1
html5lib 1.1
hyperlink 21.0.0
idna 3.6
incremental 22.10.0
itsdangerous 2.1.2
Jinja2 3.1.3
kiwisolver 1.4.5
lightweight-charts 1.0.20
lxml 5.2.1
MarkupSafe 2.1.5
matplotlib 3.8.4
multidict 6.0.5
multitasking 0.0.11
mysqlclient 2.2.4
nest-asyncio 1.6.0
numpy 1.26.4
packaging 24.0
pandas 2.2.1
peewee 3.17.1
pillow 10.3.0
pip 23.2.1
proxy_tools 0.1.0
psycopg2 2.9.9
pyasn1 0.6.0
pyasn1_modules 0.4.0
pycparser 2.22
pyOpenSSL 24.1.0
pyparsing 3.1.2
python-dateutil 2.9.0.post0
pythonnet 3.0.3
pytz 2024.1
pywebview 5.0.5
PyYAML 6.0.1
requests 2.31.0
service-identity 24.1.0
setuptools 69.2.0
six 1.16.0
soupsieve 2.5
sqlparse 0.4.4
tenacity 8.2.3
tornado 6.4
Twisted 24.3.0
twisted-iocpsupport 1.0.4
txaio 23.1.1
typing_extensions 4.11.0
tzdata 2024.1
urllib3 2.2.1
webencodings 0.5.1
Werkzeug 3.0.2
xyzservices 2024.4.0
yarl 1.9.4
yfinance 0.2.37
zope.interface 6.2
Please, help me make my chart render.
Upvotes: 0
Views: 65