-
Hugo Kerstens authoredHugo Kerstens authored
extra_markdown.tpl 1.51 KiB
{% extends 'markdown.tpl' %}
{%- block data_other -%}
{%- for type in output.data | filter_data_type -%}
{%- if type == 'application/vnd.plotly.v1+json' -%}
{%- set fname = output.metadata.filenames['application/vnd.plotly.v1+json'] -%}
{%- set plotly_url = fname | path2url -%}
{%- set div_id = fname.split('/') | last -%}
<div id="{{div_id}}"><img ></img></div>
<script>
window.addEventListener('load', function() {
Plotly.d3.json('../{{plotly_url}}', function(error, fig) {
Plotly.plot('{{div_id}}', fig.data, fig.layout).then(
function(value) {Plotly.relayout('{{div_id}}', {height: ' '})}
);
});
});
</script>
{%- endif -%}
{%- endfor -%}
{%- endblock -%}
{% block input %}
{% if cell.metadata.attributes and cell.metadata.attributes.initialize %}
<div class="thebelab-init-code">
<pre class="thebelab-code" data-executable="true" data-language="python">
{{cell.source}}
</pre>
</div>
{% endif %}
{% endblock %}
{% block data_svg %}
{% if cell.metadata.attributes and cell.metadata.attributes.editable == 'false' %}
{{ super() }}
{% else %}
<pre class="thebelab-code" data-executable="true" data-language="python">{{cell.source}}</pre>
<div class="thebelab-output" data-output="true" markdown="1">
{{ super() }}
</div>
<button class="thebelab-button thebelab-activate-button" onclick="initThebelab()">
Enable live code
</button>
{% endif %}
{% endblock %}
{% block error %}
{% endblock error %}
{% block stream %}
{%- if output.name == 'stdout' -%}
{{ output.text | indent }}
{%- endif -%}
{% endblock stream %}