csv上传后,散景图不会出现在同一个django页面上
Posted
技术标签:
【中文标题】csv上传后,散景图不会出现在同一个django页面上【英文标题】:Bokeh plot does not appear on the same django page after csv upload 【发布时间】:2016-04-26 19:54:00 【问题描述】:相关:Embedding Bokeh plot in Django website results in blank page with no error message
除了这次我使用的是正确的版本。
我有代码,我只想看到一个带有上传按钮的网站,在上传 csv 后,在同一页面上会出现散景图。上传 csv 作品。使用调试器,我可以看到我有列表x_of_pixels
和y_of_pixels
,现在我应该能够简单地生成一个相对于另一个的散景图。
但是,上传后,没有出现错误,但也没有出现散景图。
这个函数在views.py中,在页面加载时调用
def list(request):
# ---------- from minimal-django-file-upload-example
newdoc = None
# Handle file upload
if request.method == 'POST':
form = DocumentForm(request.POST, request.FILES)
if form.is_valid():
newdoc = Document(docfile=request.FILES['docfile'])
newdoc.save()
# Redirect to the document list after POST
# return HttpResponseRedirect(reverse('myproject.myapp.views.list'))
else:
form = DocumentForm() # A empty, unbound form
documents = Document.objects.all()
csvfile = None
if len(documents) > 0:
if newdoc is None:
plot = figure()
script, div = components(plot, CDN)
else:
csvfile = newdoc.docfile.path
# read from csv
lines = []
with open(csvfile,"r") as f:
reader = csv.reader(f, delimiter = ",")
for row in reader:
lines.append(row)
x_of_pixels = []
y_of_pixels = []
x_value = 0
step = 1 #1.0/len(lines)
for row in lines:
y_value = float(row[0])
x_of_pixels.append(x_value)
y_of_pixels.append(y_value)
x_value += step
plot = figure()
plot.line(x_of_pixels, y_of_pixels, line_width=2)
script, div = components(plot, CDN)
else:
plot = figure()
script, div = components(plot, CDN)
# Render list page with the documents and the form
return render_to_response(
'list.html',
'documents': documents, 'form': form, 'the_script': script, 'the_div': div,
context_instance=RequestContext(request)
)
list.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Minimal Django File Upload Example</title>
<script src="http://cdn.bokeh.org/bokeh/release/bokeh-0.11.0.min.js"></script>
<link rel="stylesheet" href="http://cdn.bokeh.org/bokeh/release/bokeh-0.11.0.min.css">
the_script|safe
</head>
<body>
<!-- List of uploaded documents -->
% if documents %
<ul>
% for document in documents %
<li><a href=" document.docfile.url "> document.docfile.name </a></li>
% endfor %
</ul>
% else %
<p>No documents.</p>
% endif %
<!-- Upload form. Note enctype attribute! -->
<form action="% url "list" %" method="post" enctype="multipart/form-data">
% csrf_token %
<p> form.non_field_errors </p>
<p> form.docfile.label_tag form.docfile.help_text </p>
<p>
form.docfile.errors
form.docfile
</p>
<p><input type="submit" value="Upload"/></p>
</form>
the_div|safe
</body>
</html>
上传的文件按照following example 的预期显示,我在其中修改了上面的代码
我在上传 csv 后调试并返回 render_to_response 我有以下表单和脚本值
脚本:
<script type="text/javascript">
Bokeh.$(function()
var all_models = ["attributes": "plot": "subtype": "Figure", "type": "Plot", "id": "58794904-3226-4a3d-be06-0d2fefdd309e", "dimensions": ["width", "height"], "tags": [], "doc": null, "id": "57db162e-5877-4909-9014-3c699165bccb", "type": "PanTool", "id": "57db162e-5877-4909-9014-3c699165bccb", "attributes": "geometries": [], "tags": [], "doc": null, "id": "f85f7355-c842-4a9a-b8d0-1679ca49b96a", "type": "ToolEvents", "id": "f85f7355-c842-4a9a-b8d0-1679ca49b96a", "attributes": "tags": [], "doc": null, "renderers": [], "callback": null, "names": [], "id": "7357fef1-126a-446b-bc9c-4e19f8b7110f", "type": "DataRange1d", "id": "7357fef1-126a-446b-bc9c-4e19f8b7110f", "attributes": "plot": "subtype": "Figure", "type": "Plot", "id": "58794904-3226-4a3d-be06-0d2fefdd309e", "tags": [], "doc": null, "id": "91f37553-38cb-4682-9b57-e3853ccbedde", "type": "PreviewSaveTool", "id": "91f37553-38cb-4682-9b57-e3853ccbedde", "attributes": "plot": "subtype": "Figure", "type": "Plot", "id": "58794904-3226-4a3d-be06-0d2fefdd309e", "tags": [], "doc": null, "id": "68ca74ff-2109-492a-a3d1-49985275f75e", "type": "HelpTool", "id": "68ca74ff-2109-492a-a3d1-49985275f75e", "attributes": "line_color": "value": "#1f77b4", "line_width": "value": 2, "line_alpha": "value": 1.0, "doc": null, "tags": [], "y": "field": "y", "x": "field": "x", "id": "ba0507fa-cfc9-4e0e-a6c9-71911f0c628f", "type": "Line", "id": "ba0507fa-cfc9-4e0e-a6c9-71911f0c628f", "attributes": "plot": "subtype": "Figure", "type": "Plot", "id": "58794904-3226-4a3d-be06-0d2fefdd309e", "dimensions": ["width", "height"], "tags": [], "doc": null, "id": "55361a47-0c00-4708-ad60-f30eb5face60", "type": "WheelZoomTool", "id": "55361a47-0c00-4708-ad60-f30eb5face60", "attributes": "plot": "subtype": "Figure", "type": "Plot", "id": "58794904-3226-4a3d-be06-0d2fefdd309e", "tags": [], "doc": null, "id": "eb16229f-1179-49f7-811e-ec219fe37d99", "type": "ResizeTool", "id": "eb16229f-1179-49f7-811e-ec219fe37d99", "attributes": "plot": "subtype": "Figure", "type": "Plot", "id": "58794904-3226-4a3d-be06-0d2fefdd309e", "tags": [], "doc": null, "formatter": "type": "BasicTickFormatter", "id": "e9899588-262e-4531-9a54-cca8e870f01f", "ticker": "type": "BasicTicker", "id": "4b89319f-32b5-4230-a29e-1955e2487584", "id": "8f40d18b-ed3d-4904-9bb3-50492eaf2312", "type": "LinearAxis", "id": "8f40d18b-ed3d-4904-9bb3-50492eaf2312", "attributes": "line_color": "value": "#1f77b4", "line_width": "value": 2, "line_alpha": "value": 0.1, "doc": null, "tags": [], "y": "field": "y", "x": "field": "x", "id": "6cdffdad-b986-4471-9e39-786a0e663a03", "type": "Line", "id": "6cdffdad-b986-4471-9e39-786a0e663a03", "attributes": "doc": null, "id": "381a8e2d-8d9d-47b6-a950-615b10b0e65d", "tags": [], "type": "BasicTickFormatter", "id": "381a8e2d-8d9d-47b6-a950-615b10b0e65d", "attributes": "column_names": ["y", "x"], "tags": [], "doc": null, "selected": "2d": "indices": [], "1d": "indices": [], "0d": "indices": [], "flag": false, "callback": null, "data": "y": [346.01800537109375, 301.10101318359375, 290.2510070800781, 273.43902587890625, 263.635009765625, 219.71701049804688, 208.6840057373047, 194.84201049804688, 174.60800170898438, 172.82101440429688, 171.29000854492188, 161.91400146484375, 155.13400268554688, 154.51600646972656, 152.45101928710938, 130.87899780273438, 127.01300811767578, 124.02900695800781, 123.44900512695312, 121.52900695800781, 117.64100646972656, 111.00700378417969, 107.00601196289062, 102.16200256347656, 97.97200775146484, 96.56700134277344, 93.14000701904297, 90.73800659179688, 86.91800689697266, 86.13200378417969, 85.54700469970703, 83.2800064086914, 81.91100311279297, 78.37200164794922, 76.67300415039062, 72.34800720214844, 69.76700592041016, 68.82600402832031, 65.63700103759766, 62.92400360107422, 61.75100326538086, 58.49800491333008, 58.27900695800781, 57.90500259399414, 56.74200439453125, 56.49900436401367, 56.487003326416016, 56.46900177001953, 55.802001953125, 55.41100311279297, 55.13800048828125, 54.75199890136719, 54.52700424194336, 53.53400421142578, 52.51499938964844, 52.084999084472656, 51.038002014160156, 50.5670051574707, 48.31000518798828, 45.557003021240234, 45.397003173828125, 45.11300277709961, 45.09300231933594, 44.41800308227539, 44.406002044677734, 43.371002197265625, 41.519004821777344, 41.18600082397461, 40.906002044677734, 40.87300109863281, 40.17100143432617, 39.49400329589844, 39.45500183105469, 39.37000274658203, 39.263999938964844, 38.625999450683594, 38.454002380371094, 37.56800079345703, 37.207000732421875, 36.342002868652344, 35.209999084472656, 34.98400115966797, 34.34700012207031, 34.138999938964844, 32.698001861572266, 32.51300048828125, 31.816001892089844, 31.48200035095215, 31.41666603088379, 31.170001983642578], "x": [0, 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, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89], "id": "a125efaa-8772-4fd7-a422-b51aadb38528", "type": "ColumnDataSource", "id": "a125efaa-8772-4fd7-a422-b51aadb38528", "attributes": "plot": "subtype": "Figure", "type": "Plot", "id": "58794904-3226-4a3d-be06-0d2fefdd309e", "tags": [], "doc": null, "id": "3e895892-20e5-4e91-962f-82e646c47052", "type": "ResetTool", "id": "3e895892-20e5-4e91-962f-82e646c47052", "subtype": "Figure", "type": "Plot", "id": "58794904-3226-4a3d-be06-0d2fefdd309e", "attributes": "x_range": "type": "DataRange1d", "id": "e44661a3-e575-4b91-98f6-875b599c5bae", "right": [], "tags": [], "y_range": "type": "DataRange1d", "id": "7357fef1-126a-446b-bc9c-4e19f8b7110f", "renderers": ["type": "LinearAxis", "id": "8f40d18b-ed3d-4904-9bb3-50492eaf2312", "type": "Grid", "id": "5947fdee-31b2-4869-a64f-0c1bfd2def6e", "type": "LinearAxis", "id": "2a419e65-8287-43a8-8c5d-0c95b91571be", "type": "Grid", "id": "2b132b96-66c3-4f2d-b48d-828e9aaf2142", "type": "GlyphRenderer", "id": "d2f6a1e1-acc3-42e0-acef-a89d57e03c5e"], "extra_y_ranges": , "extra_x_ranges": , "tool_events": "type": "ToolEvents", "id": "f85f7355-c842-4a9a-b8d0-1679ca49b96a", "above": [], "doc": null, "id": "58794904-3226-4a3d-be06-0d2fefdd309e", "tools": ["type": "PanTool", "id": "57db162e-5877-4909-9014-3c699165bccb", "type": "WheelZoomTool", "id": "55361a47-0c00-4708-ad60-f30eb5face60", "type": "BoxZoomTool", "id": "df53972f-ab85-4031-84f2-ebb1b6f219c4", "type": "PreviewSaveTool", "id": "91f37553-38cb-4682-9b57-e3853ccbedde", "type": "ResizeTool", "id": "eb16229f-1179-49f7-811e-ec219fe37d99", "type": "ResetTool", "id": "3e895892-20e5-4e91-962f-82e646c47052", "type": "HelpTool", "id": "68ca74ff-2109-492a-a3d1-49985275f75e"], "below": ["type": "LinearAxis", "id": "8f40d18b-ed3d-4904-9bb3-50492eaf2312"], "left": ["type": "LinearAxis", "id": "2a419e65-8287-43a8-8c5d-0c95b91571be"], "attributes": "plot": "subtype": "Figure", "type": "Plot", "id": "58794904-3226-4a3d-be06-0d2fefdd309e", "tags": [], "doc": null, "formatter": "type": "BasicTickFormatter", "id": "381a8e2d-8d9d-47b6-a950-615b10b0e65d", "ticker": "type": "BasicTicker", "id": "7aee15cb-0bec-4465-bb50-dcd562e92cb6", "id": "2a419e65-8287-43a8-8c5d-0c95b91571be", "type": "LinearAxis", "id": "2a419e65-8287-43a8-8c5d-0c95b91571be", "attributes": "tags": [], "doc": null, "renderers": [], "callback": null, "names": [], "id": "e44661a3-e575-4b91-98f6-875b599c5bae", "type": "DataRange1d", "id": "e44661a3-e575-4b91-98f6-875b599c5bae", "attributes": "plot": "subtype": "Figure", "type": "Plot", "id": "58794904-3226-4a3d-be06-0d2fefdd309e", "dimensions": ["width", "height"], "tags": [], "doc": null, "id": "df53972f-ab85-4031-84f2-ebb1b6f219c4", "type": "BoxZoomTool", "id": "df53972f-ab85-4031-84f2-ebb1b6f219c4", "attributes": "plot": "subtype": "Figure", "type": "Plot", "id": "58794904-3226-4a3d-be06-0d2fefdd309e", "tags": [], "doc": null, "dimension": 0, "ticker": "type": "BasicTicker", "id": "4b89319f-32b5-4230-a29e-1955e2487584", "id": "5947fdee-31b2-4869-a64f-0c1bfd2def6e", "type": "Grid", "id": "5947fdee-31b2-4869-a64f-0c1bfd2def6e", "attributes": "nonselection_glyph": "type": "Line", "id": "6cdffdad-b986-4471-9e39-786a0e663a03", "data_source": "type": "ColumnDataSource", "id": "a125efaa-8772-4fd7-a422-b51aadb38528", "tags": [], "doc": null, "selection_glyph": null, "id": "d2f6a1e1-acc3-42e0-acef-a89d57e03c5e", "glyph": "type": "Line", "id": "ba0507fa-cfc9-4e0e-a6c9-71911f0c628f", "type": "GlyphRenderer", "id": "d2f6a1e1-acc3-42e0-acef-a89d57e03c5e", "attributes": "plot": "subtype": "Figure", "type": "Plot", "id": "58794904-3226-4a3d-be06-0d2fefdd309e", "tags": [], "doc": null, "dimension": 1, "ticker": "type": "BasicTicker", "id": "7aee15cb-0bec-4465-bb50-dcd562e92cb6", "id": "2b132b96-66c3-4f2d-b48d-828e9aaf2142", "type": "Grid", "id": "2b132b96-66c3-4f2d-b48d-828e9aaf2142", "attributes": "tags": [], "doc": null, "mantissas": [2, 5, 10], "id": "4b89319f-32b5-4230-a29e-1955e2487584", "num_minor_ticks": 5, "type": "BasicTicker", "id": "4b89319f-32b5-4230-a29e-1955e2487584", "attributes": "tags": [], "doc": null, "mantissas": [2, 5, 10], "id": "7aee15cb-0bec-4465-bb50-dcd562e92cb6", "num_minor_ticks": 5, "type": "BasicTicker", "id": "7aee15cb-0bec-4465-bb50-dcd562e92cb6", "attributes": "doc": null, "id": "e9899588-262e-4531-9a54-cca8e870f01f", "tags": [], "type": "BasicTickFormatter", "id": "e9899588-262e-4531-9a54-cca8e870f01f"];
Bokeh.load_models(all_models);
var plots = ['modeltype': 'Plot', 'elementid': '0e3c4757-9abe-4c0b-b9f4-09682fcb4ded', 'modelid': '58794904-3226-4a3d-be06-0d2fefdd309e'];
for (idx in plots)
var plot = plots[idx];
var model = Bokeh.Collections(plot.modeltype).get(plot.modelid);
Bokeh.logger.info('Realizing plot:')
Bokeh.logger.info(' - modeltype: ' + plot.modeltype);
Bokeh.logger.info(' - modelid: ' + plot.modelid);
Bokeh.logger.info(' - elementid: ' + plot.elementid);
var view = new model.default_view(
model: model,
el: '#' + plot.elementid
);
Bokeh.index[plot.modelid] = view;
);
</script>
如果您查看脚本,您会发现“数据”确实具有正确的 x 和 y 值:
"data": "y": [346.01800537109375, 301.10101318359375, 290.2510070800781, 273.43902587890625, 263.635009765625, 219.71701049804688, 208.6840057373047, 194.84201049804688, 174.60800170898438, 172.82101440429688, 171.29000854492188, 161.91400146484375, 155.13400268554688, 154.51600646972656, 152.45101928710938, 130.87899780273438, 127.01300811767578, 124.02900695800781, 123.44900512695312, 121.52900695800781, 117.64100646972656, 111.00700378417969, 107.00601196289062, 102.16200256347656, 97.97200775146484, 96.56700134277344, 93.14000701904297, 90.73800659179688, 86.91800689697266, 86.13200378417969, 85.54700469970703, 83.2800064086914, 81.91100311279297, 78.37200164794922, 76.67300415039062, 72.34800720214844, 69.76700592041016, 68.82600402832031, 65.63700103759766, 62.92400360107422, 61.75100326538086, 58.49800491333008, 58.27900695800781, 57.90500259399414, 56.74200439453125, 56.49900436401367, 56.487003326416016, 56.46900177001953, 55.802001953125, 55.41100311279297, 55.13800048828125, 54.75199890136719, 54.52700424194336, 53.53400421142578, 52.51499938964844, 52.084999084472656, 51.038002014160156, 50.5670051574707, 48.31000518798828, 45.557003021240234, 45.397003173828125, 45.11300277709961, 45.09300231933594, 44.41800308227539, 44.406002044677734, 43.371002197265625, 41.519004821777344, 41.18600082397461, 40.906002044677734, 40.87300109863281, 40.17100143432617, 39.49400329589844, 39.45500183105469, 39.37000274658203, 39.263999938964844, 38.625999450683594, 38.454002380371094, 37.56800079345703, 37.207000732421875, 36.342002868652344, 35.209999084472656, 34.98400115966797, 34.34700012207031, 34.138999938964844, 32.698001861572266, 32.51300048828125, 31.816001892089844, 31.48200035095215, 31.41666603088379, 31.170001983642578], "x": [0, 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, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89]
表格:
<tr><th><label for="id_docfile">Select a file:</label></th><td><input id="id_docfile" name="docfile" type="file" /></td></tr>
即使我在list.html
的标题和正文中指定了the_div
和the_script
变量,为什么我在上传后看不到散景图?
【问题讨论】:
【参考方案1】:您拥有的<script>
标签不是由 Bokeh 0.11
生成的。在 Bokeh 0.11
中不再有 all_models
,而是有 docs_json
。我只是在这里运行了示例(首先将INLINE
更改为CDN
):
https://github.com/bokeh/bokeh/blob/master/examples/embed/embed_multiple.py
在干净的 Bokeh 0.11
环境下,可以看到,脚本标签的格式不同:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Bokeh Scatter Plots</title>
<style> divfloat: left; </style>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-0.11.0.min.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-widgets-0.11.0.min.js"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-compiler-0.11.0.min.js"></script>
<script type="text/javascript">
Bokeh.set_log_level("info");
</script>
<link rel="stylesheet" href="https://cdn.bokeh.org/bokeh/release/bokeh-0.11.0.min.css" type="text/css" />
<link rel="stylesheet" href="https://cdn.bokeh.org/bokeh/release/bokeh-widgets-0.11.0.min.css" type="text/css" />
<script type="text/javascript">
Bokeh.$(function()
var docs_json = "3da19e3f-a1b7-401e-9d2a-56533d557c40": "title": "Bokeh Application", "version": "0.11.0", "roots": "references": ["attributes": , "id": "9ef34bd3-e753-4e23-9e23-edde0d2dea4f", "type": "BasicTicker", "attributes": , "id": "8a3a6a34-2625-40f1-a06e-fed595a639ee", "type": "BasicTicker", "attributes": "ticker": "id": "ccfff932-4c7f-43b0-b4a1-ca1e55a42b67", "type": "BasicTicker", "plot": "id": "40594e49-e943-4e24-956c-c1f438c65b18", "type": "Plot", "subtype": "Figure", "dimension": 1, "id": "abd5cd08-18d8-4864-9527-a881ad2a0e01", "type": "Grid", "attributes": "line_dash": [4, 4], "line_color": "value": "black", "level": "overlay", "line_alpha": "value": 1.0, "fill_alpha": "value": 0.5, "plot": null, "bottom_units": "screen", "line_width": "value": 2, "top_units": "screen", "fill_color": "value": "lightgrey", "right_units": "screen", "left_units": "screen", "render_mode": "css", "id": "8c05c0b6-2b44-4189-aecf-18994b80c50f", "type": "BoxAnnotation", "attributes": "ticker": "id": "8a3a6a34-2625-40f1-a06e-fed595a639ee", "type": "BasicTicker", "formatter": "id": "97d0aeac-4b86-46a0-a115-5bd013e0b286", "type": "BasicTickFormatter", "plot": "id": "ec8f4d1f-dbe7-4a28-bdf1-ae4ffcb3f160", "type": "Plot", "subtype": "Figure", "id": "c6398bb7-0729-40e7-8704-cf519eedb768", "type": "LinearAxis", "attributes": "nonselection_glyph": "id": "c4528e84-e62d-4740-a7cd-08e909231eca", "type": "Circle", "hover_glyph": null, "selection_glyph": null, "glyph": "id": "a980c6e7-2a10-42f0-ae6d-a76b4eb62851", "type": "Circle", "data_source": "id": "d7af2f01-1f24-4e47-b66f-dfb887b1521b", "type": "ColumnDataSource", "id": "95c20915-d0ea-47a6-b465-fada62bd6ad8", "type": "GlyphRenderer", "attributes": "overlay": "id": "8c05c0b6-2b44-4189-aecf-18994b80c50f", "type": "BoxAnnotation", "plot": "id": "ec8f4d1f-dbe7-4a28-bdf1-ae4ffcb3f160", "type": "Plot", "subtype": "Figure", "id": "2305e33d-7d10-42b3-9517-a374d7ae3ae8", "type": "BoxZoomTool", "attributes": "data": "y": [2, 4, 6, 9, 15, 18, 0, 8, 2, 25, 28], "x": [2, 5, 7, 15, 18, 19, 25, 28, 9, 10, 4], "callback": null, "column_names": ["x", "y"], "id": "826fd0c1-ffe8-40ba-b274-ae3a6f3a1c92", "type": "ColumnDataSource", "attributes": "ticker": "id": "39c5ea64-b755-4e59-844e-b6c576342dde", "type": "BasicTicker", "plot": "id": "00cdedbc-e91c-41af-93fe-a18e85fd8d4b", "type": "Plot", "subtype": "Figure", "id": "9a6cdb57-6cfb-47a3-b8b7-e22c25d9c6ac", "type": "Grid", "attributes": , "id": "b04c8874-77d0-4fc5-b194-9913f93b10fc", "type": "ToolEvents", "attributes": "ticker": "id": "fa980227-cb02-4944-9180-710dd167d36a", "type": "BasicTicker", "formatter": "id": "75752ae4-0fa7-4720-8855-0f5be2dd9000", "type": "BasicTickFormatter", "plot": "id": "40594e49-e943-4e24-956c-c1f438c65b18", "type": "Plot", "subtype": "Figure", "id": "bb0a1bfc-9551-4e7d-adce-8055d21314cd", "type": "LinearAxis", "attributes": "left": ["id": "c6398bb7-0729-40e7-8704-cf519eedb768", "type": "LinearAxis"], "y_range": "id": "7e01336a-6000-47cb-b34f-ac1a844beba0", "type": "Range1d", "renderers": ["id": "4a2a6e7d-6578-40c9-a84c-df8ff47a534a", "type": "LinearAxis", "id": "3592e7c0-444a-4272-9fd8-afac4d07ccbc", "type": "Grid", "id": "c6398bb7-0729-40e7-8704-cf519eedb768", "type": "LinearAxis", "id": "d62f7e64-ab5c-4b8a-90ee-a7d0d6a6bd52", "type": "Grid", "id": "8c05c0b6-2b44-4189-aecf-18994b80c50f", "type": "BoxAnnotation", "id": "95c20915-d0ea-47a6-b465-fada62bd6ad8", "type": "GlyphRenderer"], "x_range": "id": "24d53292-ad0f-4606-a175-cbd00e587035", "type": "Range1d", "tool_events": "id": "9388042b-c11d-467a-b15d-eb77b95fcd72", "type": "ToolEvents", "plot_width": 300, "plot_height": 300, "tools": ["id": "a62dadc7-7038-465c-a184-93e4d6cb654d", "type": "PanTool", "id": "81508c7c-f007-41ba-96d5-bd89ca1aaabb", "type": "WheelZoomTool", "id": "2305e33d-7d10-42b3-9517-a374d7ae3ae8", "type": "BoxZoomTool", "id": "f3488df3-6cae-4664-ba60-8bff4c063689", "type": "ResetTool", "id": "84443c64-e36f-4d9d-a3b3-d2153f2f7c06", "type": "PreviewSaveTool"], "below": ["id": "4a2a6e7d-6578-40c9-a84c-df8ff47a534a", "type": "LinearAxis"], "id": "ec8f4d1f-dbe7-4a28-bdf1-ae4ffcb3f160", "type": "Plot", "subtype": "Figure", "attributes": "overlay": "id": "08da54c6-1118-4302-b0be-379d30e1eaa2", "type": "BoxAnnotation", "plot": "id": "00cdedbc-e91c-41af-93fe-a18e85fd8d4b", "type": "Plot", "subtype": "Figure", "id": "03bc59e0-6eb7-4be9-8f49-52f64d15f47d", "type": "BoxZoomTool", "attributes": "line_dash": [4, 4], "line_color": "value": "black", "level": "overlay", "line_alpha": "value": 1.0, "fill_alpha": "value": 0.5, "plot": null, "bottom_units": "screen", "line_width": "value": 2, "top_units": "screen", "fill_color": "value": "lightgrey", "right_units": "screen", "left_units": "screen", "render_mode": "css", "id": "e1c83ae8-c542-473e-a405-418b544d8eee", "type": "BoxAnnotation", "attributes": , "id": "9388042b-c11d-467a-b15d-eb77b95fcd72", "type": "ToolEvents", "attributes": "plot": "id": "00cdedbc-e91c-41af-93fe-a18e85fd8d4b", "type": "Plot", "subtype": "Figure", "id": "0b0514ad-e825-405a-bc21-a3785c3b4ff7", "type": "PanTool", "attributes": "plot": "id": "ec8f4d1f-dbe7-4a28-bdf1-ae4ffcb3f160", "type": "Plot", "subtype": "Figure", "id": "81508c7c-f007-41ba-96d5-bd89ca1aaabb", "type": "WheelZoomTool", "attributes": "nonselection_glyph": "id": "727972c4-2b42-4eb8-8063-0af57a73fac0", "type": "Circle", "hover_glyph": null, "selection_glyph": null, "glyph": "id": "ebcf39df-0d08-4ff9-bd50-0eb239b51a9c", "type": "Circle", "data_source": "id": "50d963cf-ce68-4d52-af67-2d33bf00b597", "type": "ColumnDataSource", "id": "50e4d0ea-3902-471e-8416-e72067439c11", "type": "GlyphRenderer", "attributes": "plot": "id": "40594e49-e943-4e24-956c-c1f438c65b18", "type": "Plot", "subtype": "Figure", "id": "ec25949e-0a0f-450f-8574-e812b81be57b", "type": "PreviewSaveTool", "attributes": , "id": "ccfff932-4c7f-43b0-b4a1-ca1e55a42b67", "type": "BasicTicker", "attributes": "ticker": "id": "5f45406e-da91-4648-bb40-f86d24b9f678", "type": "BasicTicker", "plot": "id": "ec8f4d1f-dbe7-4a28-bdf1-ae4ffcb3f160", "type": "Plot", "subtype": "Figure", "id": "3592e7c0-444a-4272-9fd8-afac4d07ccbc", "type": "Grid", "attributes": , "id": "6a87bc83-f144-4c31-80d2-ecdc48efd88b", "type": "BasicTickFormatter", "attributes": "plot": "id": "00cdedbc-e91c-41af-93fe-a18e85fd8d4b", "type": "Plot", "subtype": "Figure", "id": "0efbfa71-4a9f-4dd7-bd9a-91468cd0786b", "type": "ResetTool", "attributes": "line_color": "value": "#1f77b4", "line_alpha": "value": 0.1, "fill_color": "value": "#1f77b4", "size": "value": 12, "units": "screen", "y": "field": "y", "fill_alpha": "value": 0.1, "x": "field": "x", "id": "727972c4-2b42-4eb8-8063-0af57a73fac0", "type": "Circle", "attributes": "line_color": "value": "#1f77b4", "line_alpha": "value": 0.1, "fill_color": "value": "#1f77b4", "size": "value": 12, "units": "screen", "y": "field": "y", "fill_alpha": "value": 0.1, "x": "field": "x", "id": "4324740d-3a82-488f-a9e5-b977e578c5ec", "type": "Circle", "attributes": "plot": "id": "ec8f4d1f-dbe7-4a28-bdf1-ae4ffcb3f160", "type": "Plot", "subtype": "Figure", "id": "84443c64-e36f-4d9d-a3b3-d2153f2f7c06", "type": "PreviewSaveTool", "attributes": "plot": "id": "ec8f4d1f-dbe7-4a28-bdf1-ae4ffcb3f160", "type": "Plot", "subtype": "Figure", "id": "f3488df3-6cae-4664-ba60-8bff4c063689", "type": "ResetTool", "attributes": "callback": null, "end": 30, "id": "7e01336a-6000-47cb-b34f-ac1a844beba0", "type": "Range1d", "attributes": "plot": "id": "00cdedbc-e91c-41af-93fe-a18e85fd8d4b", "type": "Plot", "subtype": "Figure", "id": "7295afb8-7482-4396-a764-052b8ec72868", "type": "WheelZoomTool", "attributes": , "id": "0dc08e07-584c-4ef6-a530-3e5bc2370433", "type": "BasicTickFormatter", "attributes": "plot": "id": "40594e49-e943-4e24-956c-c1f438c65b18", "type": "Plot", "subtype": "Figure", "id": "40f63935-2f78-44fe-bf9c-2d6d4fb7039b", "type": "ResetTool", "attributes": "plot": "id": "00cdedbc-e91c-41af-93fe-a18e85fd8d4b", "type": "Plot", "subtype": "Figure", "id": "8fe2733b-a96b-4b90-aa8a-2e36011e92fa", "type": "PreviewSaveTool", "attributes": , "id": "39c5ea64-b755-4e59-844e-b6c576342dde", "type": "BasicTicker", "attributes": "ticker": "id": "fa980227-cb02-4944-9180-710dd167d36a", "type": "BasicTicker", "plot": "id": "40594e49-e943-4e24-956c-c1f438c65b18", "type": "Plot", "subtype": "Figure", "id": "72d00523-affe-4441-bb1a-244283c951d6", "type": "Grid", "attributes": , "id": "75752ae4-0fa7-4720-8855-0f5be2dd9000", "type": "BasicTickFormatter", "attributes": "ticker": "id": "9ef34bd3-e753-4e23-9e23-edde0d2dea4f", "type": "BasicTicker", "formatter": "id": "6a87bc83-f144-4c31-80d2-ecdc48efd88b", "type": "BasicTickFormatter", "plot": "id": "00cdedbc-e91c-41af-93fe-a18e85fd8d4b", "type": "Plot", "subtype": "Figure", "id": "713469c5-87f9-427a-9200-5c5b6cc437b4", "type": "LinearAxis", "attributes": "plot": "id": "40594e49-e943-4e24-956c-c1f438c65b18", "type": "Plot", "subtype": "Figure", "id": "13869e41-fb6c-44a4-963c-63672a138c0e", "type": "PanTool", "attributes": "ticker": "id": "8a3a6a34-2625-40f1-a06e-fed595a639ee", "type": "BasicTicker", "plot": "id": "ec8f4d1f-dbe7-4a28-bdf1-ae4ffcb3f160", "type": "Plot", "subtype": "Figure", "dimension": 1, "id": "d62f7e64-ab5c-4b8a-90ee-a7d0d6a6bd52", "type": "Grid", "attributes": "line_dash": [4, 4], "line_color": "value": "black", "level": "overlay", "line_alpha": "value": 1.0, "fill_alpha": "value": 0.5, "plot": null, "bottom_units": "screen", "line_width": "value": 2, "top_units": "screen", "fill_color": "value": "lightgrey", "right_units": "screen", "left_units": "screen", "render_mode": "css", "id": "08da54c6-1118-4302-b0be-379d30e1eaa2", "type": "BoxAnnotation", "attributes": "line_color": "value": "blue", "line_alpha": "value": 0.5, "fill_color": "value": "blue", "size": "value": 12, "units": "screen", "y": "field": "y", "fill_alpha": "value": 0.5, "x": "field": "x", "id": "c073e00d-7afb-4806-bd87-152f44f77398", "type": "Circle", "attributes": "ticker": "id": "39c5ea64-b755-4e59-844e-b6c576342dde", "type": "BasicTicker", "formatter": "id": "67590b81-9f54-4735-8b66-1105cca4984d", "type": "BasicTickFormatter", "plot": "id": "00cdedbc-e91c-41af-93fe-a18e85fd8d4b", "type": "Plot", "subtype": "Figure", "id": "17caaa93-e03a-46c6-845d-f3b088d7969e", "type": "LinearAxis", "attributes": "ticker": "id": "ccfff932-4c7f-43b0-b4a1-ca1e55a42b67", "type": "BasicTicker", "formatter": "id": "6b3f4def-882f-4edf-b7d7-df027941018c", "type": "BasicTickFormatter", "plot": "id": "40594e49-e943-4e24-956c-c1f438c65b18", "type": "Plot", "subtype": "Figure", "id": "2135df5a-a7a3-4d8a-9742-715932f01fd0", "type": "LinearAxis", "attributes": , "id": "67590b81-9f54-4735-8b66-1105cca4984d", "type": "BasicTickFormatter", "attributes": , "id": "5f45406e-da91-4648-bb40-f86d24b9f678", "type": "BasicTicker", "attributes": "line_color": "value": "green", "line_alpha": "value": 0.5, "fill_color": "value": "green", "size": "value": 12, "units": "screen", "y": "field": "y", "fill_alpha": "value": 0.5, "x": "field": "x", "id": "ebcf39df-0d08-4ff9-bd50-0eb239b51a9c", "type": "Circle", "attributes": "line_color": "value": "#1f77b4", "line_alpha": "value": 0.1, "fill_color": "value": "#1f77b4", "size": "value": 12, "units": "screen", "y": "field": "y", "fill_alpha": "value": 0.1, "x": "field": "x", "id": "c4528e84-e62d-4740-a7cd-08e909231eca", "type": "Circle", "attributes": "callback": null, "end": 30, "id": "68764cb1-4a10-4137-bb1b-635eb0d9d803", "type": "Range1d", "attributes": "ticker": "id": "9ef34bd3-e753-4e23-9e23-edde0d2dea4f", "type": "BasicTicker", "plot": "id": "00cdedbc-e91c-41af-93fe-a18e85fd8d4b", "type": "Plot", "subtype": "Figure", "dimension": 1, "id": "ae919561-629c-4bbe-9603-e4b4181fe470", "type": "Grid", "attributes": "data": "y": [0, 8, 2, 4, 6, 9, 5, 6, 25, 28, 4, 7], "x": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], "callback": null, "column_names": ["x", "y"], "id": "d7af2f01-1f24-4e47-b66f-dfb887b1521b", "type": "ColumnDataSource", "attributes": , "id": "fa980227-cb02-4944-9180-710dd167d36a", "type": "BasicTicker", "attributes": "line_color": "value": "red", "line_alpha": "value": 0.5, "fill_color": "value": "red", "size": "value": 12, "units": "screen", "y": "field": "y", "fill_alpha": "value": 0.5, "x": "field": "x", "id": "a980c6e7-2a10-42f0-ae6d-a76b4eb62851", "type": "Circle", "attributes": "plot": "id": "ec8f4d1f-dbe7-4a28-bdf1-ae4ffcb3f160", "type": "Plot", "subtype": "Figure", "id": "a62dadc7-7038-465c-a184-93e4d6cb654d", "type": "PanTool", "attributes": "left": ["id": "713469c5-87f9-427a-9200-5c5b6cc437b4", "type": "LinearAxis"], "y_range": "id": "7e01336a-6000-47cb-b34f-ac1a844beba0", "type": "Range1d", "renderers": ["id": "17caaa93-e03a-46c6-845d-f3b088d7969e", "type": "LinearAxis", "id": "9a6cdb57-6cfb-47a3-b8b7-e22c25d9c6ac", "type": "Grid", "id": "713469c5-87f9-427a-9200-5c5b6cc437b4", "type": "LinearAxis", "id": "ae919561-629c-4bbe-9603-e4b4181fe470", "type": "Grid", "id": "08da54c6-1118-4302-b0be-379d30e1eaa2", "type": "BoxAnnotation", "id": "6cf91275-4e1b-4df5-ae1a-01a7238e5801", "type": "GlyphRenderer"], "x_range": "id": "24d53292-ad0f-4606-a175-cbd00e587035", "type": "Range1d", "tool_events": "id": "b04c8874-77d0-4fc5-b194-9913f93b10fc", "type": "ToolEvents", "plot_width": 300, "plot_height": 300, "tools": ["id": "0b0514ad-e825-405a-bc21-a3785c3b4ff7", "type": "PanTool", "id": "7295afb8-7482-4396-a764-052b8ec72868", "type": "WheelZoomTool", "id": "03bc59e0-6eb7-4be9-8f49-52f64d15f47d", "type": "BoxZoomTool", "id": "0efbfa71-4a9f-4dd7-bd9a-91468cd0786b", "type": "ResetTool", "id": "8fe2733b-a96b-4b90-aa8a-2e36011e92fa", "type": "PreviewSaveTool"], "below": ["id": "17caaa93-e03a-46c6-845d-f3b088d7969e", "type": "LinearAxis"], "id": "00cdedbc-e91c-41af-93fe-a18e85fd8d4b", "type": "Plot", "subtype": "Figure", "attributes": , "id": "6b3f4def-882f-4edf-b7d7-df027941018c", "type": "BasicTickFormatter", "attributes": "left": ["id": "2135df5a-a7a3-4d8a-9742-715932f01fd0", "type": "LinearAxis"], "y_range": "id": "aa64b839-0627-4ed7-8e46-c5ed905697cf", "type": "Range1d", "renderers": ["id": "bb0a1bfc-9551-4e7d-adce-8055d21314cd", "type": "LinearAxis", "id": "72d00523-affe-4441-bb1a-244283c951d6", "type": "Grid", "id": "2135df5a-a7a3-4d8a-9742-715932f01fd0", "type": "LinearAxis", "id": "abd5cd08-18d8-4864-9527-a881ad2a0e01", "type": "Grid", "id": "e1c83ae8-c542-473e-a405-418b544d8eee", "type": "BoxAnnotation", "id": "50e4d0ea-3902-471e-8416-e72067439c11", "type": "GlyphRenderer"], "x_range": "id": "68764cb1-4a10-4137-bb1b-635eb0d9d803", "type": "Range1d", "tool_events": "id": "9d887daf-fcb8-4b2c-8704-f51493516563", "type": "ToolEvents", "plot_width": 300, "plot_height": 300, "tools": ["id": "13869e41-fb6c-44a4-963c-63672a138c0e", "type": "PanTool", "id": "da638859-0011-4414-9cc8-2713af45a2a6", "type": "WheelZoomTool", "id": "f86fbc03-1d47-48c0-a6f4-399188a566b3", "type": "BoxZoomTool", "id": "40f63935-2f78-44fe-bf9c-2d6d4fb7039b", "type": "ResetTool", "id": "ec25949e-0a0f-450f-8574-e812b81be57b", "type": "PreviewSaveTool"], "below": ["id": "bb0a1bfc-9551-4e7d-adce-8055d21314cd", "type": "LinearAxis"], "id": "40594e49-e943-4e24-956c-c1f438c65b18", "type": "Plot", "subtype": "Figure", "attributes": "data": "y": [0, 8, 4, 6, 9, 15, 18, 19, 19, 25, 28], "x": [0, 1, 0, 8, 2, 4, 6, 9, 7, 8, 9], "callback": null, "column_names": ["x", "y"], "id": "50d963cf-ce68-4d52-af67-2d33bf00b597", "type": "ColumnDataSource", "attributes": "ticker": "id": "5f45406e-da91-4648-bb40-f86d24b9f678", "type": "BasicTicker", "formatter": "id": "0dc08e07-584c-4ef6-a530-3e5bc2370433", "type": "BasicTickFormatter", "plot": "id": "ec8f4d1f-dbe7-4a28-bdf1-ae4ffcb3f160", "type": "Plot", "subtype": "Figure", "id": "4a2a6e7d-6578-40c9-a84c-df8ff47a534a", "type": "LinearAxis", "attributes": "plot": "id": "40594e49-e943-4e24-956c-c1f438c65b18", "type": "Plot", "subtype": "Figure", "id": "da638859-0011-4414-9cc8-2713af45a2a6", "type": "WheelZoomTool", "attributes": , "id": "97d0aeac-4b86-46a0-a115-5bd013e0b286", "type": "BasicTickFormatter", "attributes": "overlay": "id": "e1c83ae8-c542-473e-a405-418b544d8eee", "type": "BoxAnnotation", "plot": "id": "40594e49-e943-4e24-956c-c1f438c65b18", "type": "Plot", "subtype": "Figure", "id": "f86fbc03-1d47-48c0-a6f4-399188a566b3", "type": "BoxZoomTool", "attributes": "callback": null, "end": 30, "id": "aa64b839-0627-4ed7-8e46-c5ed905697cf", "type": "Range1d", "attributes": , "id": "9d887daf-fcb8-4b2c-8704-f51493516563", "type": "ToolEvents", "attributes": "callback": null, "end": 30, "id": "24d53292-ad0f-4606-a175-cbd00e587035", "type": "Range1d", "attributes": "nonselection_glyph": "id": "4324740d-3a82-488f-a9e5-b977e578c5ec", "type": "Circle", "hover_glyph": null, "selection_glyph": null, "glyph": "id": "c073e00d-7afb-4806-bd87-152f44f77398", "type": "Circle", "data_source": "id": "826fd0c1-ffe8-40ba-b274-ae3a6f3a1c92", "type": "ColumnDataSource", "id": "6cf91275-4e1b-4df5-ae1a-01a7238e5801", "type": "GlyphRenderer"], "root_ids": ["ec8f4d1f-dbe7-4a28-bdf1-ae4ffcb3f160", "00cdedbc-e91c-41af-93fe-a18e85fd8d4b", "40594e49-e943-4e24-956c-c1f438c65b18"];
var render_items = ["docid": "3da19e3f-a1b7-401e-9d2a-56533d557c40", "modelid": "40594e49-e943-4e24-956c-c1f438c65b18", "elementid": "67ec5f6a-1b84-4484-bd65-5bcba302039d", "docid": "3da19e3f-a1b7-401e-9d2a-56533d557c40", "modelid": "00cdedbc-e91c-41af-93fe-a18e85fd8d4b", "elementid": "7ddd4cda-f6fe-494d-8baa-fe1a5f20acc1", "docid": "3da19e3f-a1b7-401e-9d2a-56533d557c40", "modelid": "ec8f4d1f-dbe7-4a28-bdf1-ae4ffcb3f160", "elementid": "ceb4ea8a-2a29-4d21-96c6-df9cb4c21e56"];
Bokeh.embed.embed_items(docs_json, render_items);
);
</script>
</head>
<body>
<div class="plotdiv" id="67ec5f6a-1b84-4484-bd65-5bcba302039d"></div>
<div class="plotdiv" id="7ddd4cda-f6fe-494d-8baa-fe1a5f20acc1"></div>
<div class="plotdiv" id="ceb4ea8a-2a29-4d21-96c6-df9cb4c21e56"></div>
</body>
</html>
I can only suggest that whatever user or environment your Django app is using, it is not importing Bokeh `0.11` when it calls `components`.
【讨论】:
有趣。这可能解释了为什么我在脚本中找不到“版本”字段。当脚本由 0.11.0 生成时,它至少会告诉您生成它的版本。我现在相当确定这是由于昨晚 PyCharm 5.0.4 #143.1919.1 更新造成的。如果我通过终端运行,一切正常,此外,昨天正确制作散景图的代码今天正在生成空白页。看到这里,我已经联系了支持:youtrack.jetbrains.com/issue/PY-16021以上是关于csv上传后,散景图不会出现在同一个django页面上的主要内容,如果未能解决你的问题,请参考以下文章