init
This commit is contained in:
13
resource/render/templates/components.html
Normal file
13
resource/render/templates/components.html
Normal file
@@ -0,0 +1,13 @@
|
||||
{% import 'macro' as macro %}
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{{ chart.page_title }}</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
{{ macro.gen_components_content(chart) }}
|
||||
|
||||
</body>
|
||||
</html>
|
||||
231
resource/render/templates/macro
Normal file
231
resource/render/templates/macro
Normal file
@@ -0,0 +1,231 @@
|
||||
{%- macro render_chart_content(c) -%}
|
||||
<div id="{{ c.chart_id }}" class="chart-container" style="width:{{ c.width }}; height:{{ c.height }}; {{ c.horizontal_center }}"></div>
|
||||
{% if c._geo_json_name and c._geo_json %}
|
||||
<script>
|
||||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define(['exports', 'echarts'], factory);
|
||||
} else if (typeof exports === 'object' && typeof exports.nodeName !== 'string') {
|
||||
// CommonJS
|
||||
factory(exports, require('echarts'));
|
||||
} else {
|
||||
// Browser globals
|
||||
factory({}, root.echarts);
|
||||
}
|
||||
}(this, function (exports, echarts) {
|
||||
var log = function (msg) {
|
||||
if (typeof console !== 'undefined') {
|
||||
console && console.error && console.error(msg);
|
||||
}
|
||||
}
|
||||
if (!echarts) {
|
||||
log('ECharts is not Loaded');
|
||||
return;
|
||||
}
|
||||
if (!echarts.registerMap) {
|
||||
log('ECharts Map is not loaded')
|
||||
return;
|
||||
}
|
||||
echarts.registerMap('{{ c._geo_json_name }}', {{ c._geo_json }});
|
||||
}));
|
||||
</script>
|
||||
{% endif %}
|
||||
<script>
|
||||
{% if c._is_tab_chart %}
|
||||
document.getElementById('{{ c.chart_id }}').style.width = document.getElementById('{{ c.chart_id }}').parentNode.clientWidth + 'px';
|
||||
{% endif %}
|
||||
var chart_{{ c.chart_id }} = echarts.init(
|
||||
document.getElementById('{{ c.chart_id }}'), '{{ c.theme }}', {renderer: '{{ c.renderer }}'});
|
||||
{% for js in c.js_functions.items %}
|
||||
{{ js }}
|
||||
{% endfor %}
|
||||
var option_{{ c.chart_id }} = {{ c.json_contents }};
|
||||
chart_{{ c.chart_id }}.setOption(option_{{ c.chart_id }});
|
||||
{% if c._is_geo_chart %}
|
||||
var bmap = chart_{{ c.chart_id }}.getModel().getComponent('bmap').getBMap();
|
||||
{% if c.bmap_js_functions %}
|
||||
{% for fn in c.bmap_js_functions.items %}
|
||||
{{ fn }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if c.width.endswith('%') %}
|
||||
window.addEventListener('resize', function(){
|
||||
chart_{{ c.chart_id }}.resize();
|
||||
})
|
||||
{% endif %}
|
||||
</script>
|
||||
{%- endmacro %}
|
||||
|
||||
{%- macro render_notebook_charts(charts, libraries) -%}
|
||||
<script>
|
||||
require([{{ libraries | join(', ') }}], function(echarts) {
|
||||
{% for c in charts %}
|
||||
{% if c._component_type not in ("table", "image") %}
|
||||
var chart_{{ c.chart_id }} = echarts.init(
|
||||
document.getElementById('{{ c.chart_id }}'), '{{ c.theme }}', {renderer: '{{ c.renderer }}'});
|
||||
{% for js in c.js_functions.items %}
|
||||
{{ js }}
|
||||
{% endfor %}
|
||||
var option_{{ c.chart_id }} = {{ c.json_contents }};
|
||||
chart_{{ c.chart_id }}.setOption(option_{{ c.chart_id }});
|
||||
{% if c._is_geo_chart %}
|
||||
var bmap = chart_{{ c.chart_id }}.getModel().getComponent('bmap').getBMap();
|
||||
bmap.addControl(new BMap.MapTypeControl());
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
});
|
||||
</script>
|
||||
{%- endmacro %}
|
||||
|
||||
{%- macro render_chart_dependencies(c) -%}
|
||||
{% for dep in c.dependencies %}
|
||||
<script type="text/javascript" src="{{ dep }}"></script>
|
||||
{% endfor %}
|
||||
{%- endmacro %}
|
||||
|
||||
{%- macro render_chart_css(c) -%}
|
||||
{% for dep in c.css_libs %}
|
||||
<link rel="stylesheet" href="{{ dep }}">
|
||||
{% endfor %}
|
||||
{%- endmacro %}
|
||||
|
||||
{%- macro display_tablinks(chart) -%}
|
||||
<div class="tab">
|
||||
{% for c in chart %}
|
||||
<button class="tablinks" onclick="showChart(event, '{{ c.chart_id }}')">{{ c.tab_name }}</button>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{%- endmacro %}
|
||||
|
||||
{%- macro switch_tabs() -%}
|
||||
<script>
|
||||
(function() {
|
||||
containers = document.getElementsByClassName("chart-container");
|
||||
if(containers.length > 0) {
|
||||
containers[0].style.display = "block";
|
||||
}
|
||||
})()
|
||||
|
||||
function showChart(evt, chartID) {
|
||||
let containers = document.getElementsByClassName("chart-container");
|
||||
for (let i = 0; i < containers.length; i++) {
|
||||
containers[i].style.display = "none";
|
||||
}
|
||||
|
||||
let tablinks = document.getElementsByClassName("tablinks");
|
||||
for (let i = 0; i < tablinks.length; i++) {
|
||||
tablinks[i].className = "tablinks";
|
||||
}
|
||||
|
||||
document.getElementById(chartID).style.display = "block";
|
||||
evt.currentTarget.className += " active";
|
||||
}
|
||||
</script>
|
||||
{%- endmacro %}
|
||||
|
||||
{%- macro generate_tab_css() %}
|
||||
<style>
|
||||
.tab {
|
||||
overflow: hidden;
|
||||
border: 1px solid #ccc;
|
||||
background-color: #f1f1f1;
|
||||
}
|
||||
|
||||
.tab button {
|
||||
background-color: inherit;
|
||||
float: left;
|
||||
border: none;
|
||||
outline: none;
|
||||
cursor: pointer;
|
||||
padding: 12px 16px;
|
||||
transition: 0.3s;
|
||||
}
|
||||
|
||||
.tab button:hover {
|
||||
background-color: #ddd;
|
||||
}
|
||||
|
||||
.tab button.active {
|
||||
background-color: #ccc;
|
||||
}
|
||||
|
||||
.chart-container {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.chart-container:nth-child(n+2) {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
{%- endmacro %}
|
||||
|
||||
{%- macro gen_components_content(chart) %}
|
||||
{% if chart._component_type == "table" %}
|
||||
<style>
|
||||
.fl-table {
|
||||
margin: 20px;
|
||||
border-radius: 5px;
|
||||
font-size: 12px;
|
||||
border: none;
|
||||
border-collapse: collapse;
|
||||
max-width: 100%;
|
||||
white-space: nowrap;
|
||||
word-break: keep-all;
|
||||
}
|
||||
|
||||
.fl-table th {
|
||||
text-align: left;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.fl-table tr {
|
||||
display: table-row;
|
||||
vertical-align: inherit;
|
||||
border-color: inherit;
|
||||
}
|
||||
|
||||
.fl-table tr:hover td {
|
||||
background: #00d1b2;
|
||||
color: #F8F8F8;
|
||||
}
|
||||
|
||||
.fl-table td, .fl-table th {
|
||||
border-style: none;
|
||||
border-top: 1px solid #dbdbdb;
|
||||
border-left: 1px solid #dbdbdb;
|
||||
border-bottom: 3px solid #dbdbdb;
|
||||
border-right: 1px solid #dbdbdb;
|
||||
padding: .5em .55em;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.fl-table td {
|
||||
border-style: none;
|
||||
font-size: 15px;
|
||||
vertical-align: center;
|
||||
border-bottom: 1px solid #dbdbdb;
|
||||
border-left: 1px solid #dbdbdb;
|
||||
border-right: 1px solid #dbdbdb;
|
||||
height: 30px;
|
||||
}
|
||||
|
||||
.fl-table tr:nth-child(even) {
|
||||
background: #F8F8F8;
|
||||
}
|
||||
</style>
|
||||
<div id="{{ chart.chart_id }}" class="chart-container" style="">
|
||||
<p class="title" {{ chart.title_opts.title_style }}> {{ chart.title_opts.title }}</p>
|
||||
<p class="subtitle" {{ chart.title_opts.subtitle_style }}> {{ chart.title_opts.subtitle }}</p>
|
||||
{{ chart.html_content }}
|
||||
</div>
|
||||
{% elif chart._component_type == "image" %}
|
||||
<div id="{{ chart.chart_id }}" class="chart-container" style="">
|
||||
<p class="title" {{ chart.title_opts.title_style }}> {{ chart.title_opts.title }}</p>
|
||||
<p class="subtitle" {{ chart.title_opts.subtitle_style }}> {{ chart.title_opts.subtitle }}</p>
|
||||
<img {{ chart.html_content }}/>
|
||||
</div>
|
||||
{% endif %}
|
||||
{%- endmacro %}
|
||||
5
resource/render/templates/nb_components.html
Normal file
5
resource/render/templates/nb_components.html
Normal file
@@ -0,0 +1,5 @@
|
||||
{% import 'macro' as macro %}
|
||||
|
||||
{% for chart in charts %}
|
||||
{{ macro.gen_components_content(chart) }}
|
||||
{% endfor %}
|
||||
49
resource/render/templates/nb_jupyter_globe.html
Normal file
49
resource/render/templates/nb_jupyter_globe.html
Normal file
@@ -0,0 +1,49 @@
|
||||
<script>
|
||||
require.config({
|
||||
paths: {
|
||||
{{ config_items | join(', ') }}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
{% for chart in charts %}
|
||||
<div id="{{ chart.chart_id }}" style="width:{{ chart.width }}; height:{{ chart.height }};"></div>
|
||||
{% endfor %}
|
||||
|
||||
|
||||
<script>
|
||||
require([{{ libraries | join(', ') }}], function(echarts) {
|
||||
{% for c in charts %}
|
||||
var canvas_{{ c.chart_id }} = document.createElement('canvas');
|
||||
var mapChart_{{ c.chart_id }} = echarts.init(
|
||||
canvas_{{ c.chart_id }}, '{{ c.theme }}', {width: 4096, height: 2048, renderer: '{{ c.renderer }}'});
|
||||
var mapOption_{{ c.chart_id }} = {{ c.json_contents }};
|
||||
mapChart_{{ c.chart_id }}.setOption(mapOption_{{ c.chart_id }});
|
||||
var chart_{{ c.chart_id }} = echarts.init(
|
||||
document.getElementById('{{ c.chart_id }}'), '{{ c.theme }}', {renderer: '{{ c.renderer }}'});
|
||||
{% for js in c.js_functions.items %}
|
||||
{{ js }}
|
||||
{% endfor %}
|
||||
var option_{{ c.chart_id }} = {
|
||||
"globe": {
|
||||
"show": true,
|
||||
"baseTexture": mapChart_{{ c.chart_id }},
|
||||
shading: 'lambert',
|
||||
light: {
|
||||
ambient: {
|
||||
intensity: 0.6
|
||||
},
|
||||
main: {
|
||||
intensity: 0.2
|
||||
}
|
||||
}
|
||||
|
||||
}};
|
||||
chart_{{ c.chart_id }}.setOption(option_{{ c.chart_id }});
|
||||
{% endfor %}
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
16
resource/render/templates/nb_jupyter_lab.html
Normal file
16
resource/render/templates/nb_jupyter_lab.html
Normal file
@@ -0,0 +1,16 @@
|
||||
{% import 'macro' as macro %}
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
</head>
|
||||
<body>
|
||||
{% for chart in charts %}
|
||||
{% if chart._component_type in ("table", "image") %}
|
||||
{{ macro.gen_components_content(chart) }}
|
||||
{% else %}
|
||||
{{ macro.render_chart_content(chart) }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</body>
|
||||
</html>
|
||||
20
resource/render/templates/nb_jupyter_lab_tab.html
Normal file
20
resource/render/templates/nb_jupyter_lab_tab.html
Normal file
@@ -0,0 +1,20 @@
|
||||
{% import 'macro' as macro %}
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
</head>
|
||||
<body>
|
||||
{{ macro.generate_tab_css() }}
|
||||
{{ macro.display_tablinks(charts) }}
|
||||
|
||||
{% for chart in charts %}
|
||||
{% if chart._component_type in ("table", "image") %}
|
||||
{{ macro.gen_components_content(chart) }}
|
||||
{% else %}
|
||||
{{ macro.render_chart_content(chart) }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{{ macro.switch_tabs() }}
|
||||
</body>
|
||||
</html>
|
||||
21
resource/render/templates/nb_jupyter_notebook.html
Normal file
21
resource/render/templates/nb_jupyter_notebook.html
Normal file
@@ -0,0 +1,21 @@
|
||||
{% import 'macro' as macro %}
|
||||
|
||||
<script>
|
||||
require.config({
|
||||
paths: {
|
||||
{{ config_items | join(', ') }}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
{% for chart in charts %}
|
||||
{% if chart._component_type in ("table", "image") %}
|
||||
{{ macro.gen_components_content(chart) }}
|
||||
{% else %}
|
||||
<div id="{{ chart.chart_id }}" style="width:{{ chart.width }}; height:{{ chart.height }};"></div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{{ macro.render_notebook_charts(charts, libraries) }}
|
||||
26
resource/render/templates/nb_jupyter_notebook_tab.html
Normal file
26
resource/render/templates/nb_jupyter_notebook_tab.html
Normal file
@@ -0,0 +1,26 @@
|
||||
{% import 'macro' as macro %}
|
||||
|
||||
<script>
|
||||
require.config({
|
||||
paths: {
|
||||
{{ config_items | join(', ') }}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
{{ macro.generate_tab_css() }}
|
||||
{{ macro.display_tablinks(charts) }}
|
||||
|
||||
{% for chart in charts %}
|
||||
{% if chart._component_type in ("table", "image") %}
|
||||
{{ macro.gen_components_content(chart) }}
|
||||
{% else %}
|
||||
<div id="{{ chart.chart_id }}" class="chart-container"
|
||||
style="width:{{ chart.width }}; height:{{ chart.height }};"></div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{{ macro.render_notebook_charts(charts, libraries) }}
|
||||
{{ macro.switch_tabs() }}
|
||||
13
resource/render/templates/nb_nteract.html
Normal file
13
resource/render/templates/nb_nteract.html
Normal file
@@ -0,0 +1,13 @@
|
||||
{% import 'macro' as macro %}
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
{{ macro.render_chart_dependencies(chart) }}
|
||||
</head>
|
||||
<body>
|
||||
{% for c in chart %}
|
||||
{{ macro.render_chart_content(c) }}
|
||||
{% endfor %}
|
||||
</body>
|
||||
</html>
|
||||
12
resource/render/templates/simple_chart.html
Normal file
12
resource/render/templates/simple_chart.html
Normal file
@@ -0,0 +1,12 @@
|
||||
{% import 'macro' as macro %}
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{{ chart.page_title }}</title>
|
||||
{{ macro.render_chart_dependencies(chart) }}
|
||||
</head>
|
||||
<body {% if chart.fill_bg %}style="background-color: {{ chart.bg_color }}" {% endif %}>
|
||||
{{ macro.render_chart_content(chart) }}
|
||||
</body>
|
||||
</html>
|
||||
42
resource/render/templates/simple_globe.html
Normal file
42
resource/render/templates/simple_globe.html
Normal file
@@ -0,0 +1,42 @@
|
||||
{% import 'macro' as macro %}
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{{ chart.page_title }}</title>
|
||||
{{ macro.render_chart_dependencies(chart) }}
|
||||
</head>
|
||||
<body>
|
||||
<div id="{{ chart.chart_id }}" style="width:{{ chart.width }}; height:{{ chart.height }};"></div>
|
||||
<script>
|
||||
var canvas_{{ chart.chart_id }} = document.createElement('canvas');
|
||||
var mapChart_{{ chart.chart_id }} = echarts.init(
|
||||
canvas_{{ chart.chart_id }}, '{{ chart.theme }}', {width: 4096, height: 2048, renderer: '{{ chart.renderer }}'});
|
||||
{% for js in chart.js_functions.items %}
|
||||
{{ js }}
|
||||
{% endfor %}
|
||||
var mapOption_{{ chart.chart_id }} = {{ chart.json_contents }};
|
||||
mapChart_{{ chart.chart_id }}.setOption(mapOption_{{ chart.chart_id }});
|
||||
|
||||
var chart_{{ chart.chart_id }} = echarts.init(
|
||||
document.getElementById('{{ chart.chart_id }}'), '{{ chart.theme }}', {renderer: '{{ chart.renderer }}'});
|
||||
var options_{{ chart.chart_id }} = {
|
||||
"globe": {
|
||||
"show": true,
|
||||
"baseTexture": mapChart_{{ chart.chart_id }},
|
||||
shading: 'lambert',
|
||||
light: {
|
||||
ambient: {
|
||||
intensity: 0.6
|
||||
},
|
||||
main: {
|
||||
intensity: 0.2
|
||||
}
|
||||
}
|
||||
|
||||
}};
|
||||
chart_{{ chart.chart_id }}.setOption(options_{{ chart.chart_id }});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
34
resource/render/templates/simple_page.html
Normal file
34
resource/render/templates/simple_page.html
Normal file
@@ -0,0 +1,34 @@
|
||||
{% import 'macro' as macro %}
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{{ chart.page_title }}</title>
|
||||
{{ macro.render_chart_dependencies(chart) }}
|
||||
{{ macro.render_chart_css(chart) }}
|
||||
</head>
|
||||
<body {% if chart.page_border_color !='' %}style="background-color: {{ chart.page_border_color }}" {% endif %}>
|
||||
<style>.box { {{ chart.layout }} } </style>
|
||||
{% if chart.download_button %}
|
||||
<button onclick="downloadCfg()">Save Config</button>
|
||||
{% endif %}
|
||||
<div class="box">
|
||||
{% for c in chart %}
|
||||
{% if c._component_type in ("table", "image") %}
|
||||
{{ macro.gen_components_content(c) }}
|
||||
{% else %}
|
||||
{{ macro.render_chart_content(c) }}
|
||||
{% endif %}
|
||||
{% for _ in range(chart.page_interval) %}
|
||||
{% if chart.remove_br is false %}<br/>{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
<script>
|
||||
{% for js in chart.js_functions.items %}
|
||||
{{ js }}
|
||||
{% endfor %}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
36
resource/render/templates/simple_tab.html
Normal file
36
resource/render/templates/simple_tab.html
Normal file
@@ -0,0 +1,36 @@
|
||||
{% import 'macro' as macro %}
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{{ chart.page_title }}</title>
|
||||
{{ macro.render_chart_dependencies(chart) }}
|
||||
{{ macro.render_chart_css(chart) }}
|
||||
</head>
|
||||
<body {% if chart.bg_color !='' %}style="background-color: {{ chart.bg_color }}" {% endif %}>
|
||||
{% if chart.use_custom_tab_css is not true %}
|
||||
{{ macro.generate_tab_css() }}
|
||||
{% else %}
|
||||
<style>{{ chart.tab_custom_css }}</style>
|
||||
{% endif %}
|
||||
{{ macro.display_tablinks(chart) }}
|
||||
|
||||
<div class="box">
|
||||
{% for c in chart %}
|
||||
{% if c._component_type in ("table", "image") %}
|
||||
{{ macro.gen_components_content(c) }}
|
||||
{% else %}
|
||||
{{ macro.render_chart_content(c) }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<script>
|
||||
{% for js in chart.js_functions.items %}
|
||||
{{ js }}
|
||||
{% endfor %}
|
||||
|
||||
</script>
|
||||
{{ macro.switch_tabs() }}
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user