-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changing the way viz templates are defined using macros instead
- Loading branch information
1 parent
6daf92e
commit 0bc2e71
Showing
6 changed files
with
67 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
{% block tail %}{% endblock %} | ||
</head> | ||
<body> | ||
{% block viz %} | ||
{% block viz_html %} | ||
{% endblock %} | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,42 @@ | ||
{% extends "panoramix/viz.html" %} | ||
{% macro viz_html(viz) %} | ||
{% set df = viz.df %} | ||
<table class="dataframe table table-striped table-bordered table-condensed"> | ||
<thead> | ||
<tr> | ||
{% for col in df.columns if not col.endswith('__perc') %} | ||
<th>{{ col }}</th> | ||
{% endfor %} | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for row in df.to_dict(orient="records") %} | ||
<tr> | ||
{% for col in df.columns if not col.endswith('__perc') %} | ||
{% if col + '__perc' in df.columns %} | ||
<td style="background-image: linear-gradient(to right, lightgrey, lightgrey {{ row[col+'__perc'] }}%, rgba(0,0,0,0) {{ row[col+'__perc'] }}%"> | ||
{{ row[col] }} | ||
</td> | ||
{% else %} | ||
<td>{{ row[col] }}</td> | ||
{% endif %} | ||
{% endfor %} | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
{% endmacro %} | ||
|
||
{% block viz %} | ||
{{ super() }} | ||
{% if not error_msg %} | ||
<table class="dataframe table table-striped table-bordered table-condensed"> | ||
<thead> | ||
<tr> | ||
{% for col in df.columns if not col.endswith('__perc') %} | ||
<th>{{ col }}</th> | ||
{% endfor %} | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for row in df.to_dict(orient="records") %} | ||
<tr> | ||
{% for col in df.columns if not col.endswith('__perc') %} | ||
{% if col + '__perc' in df.columns %} | ||
<td style="background-image: linear-gradient(to right, lightgrey, lightgrey {{ row[col+'__perc'] }}%, rgba(0,0,0,0) {{ row[col+'__perc'] }}%"> | ||
{{ row[col] }} | ||
</td> | ||
{% else %} | ||
<td>{{ row[col] }}</td> | ||
{% endif %} | ||
{% endfor %} | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
{% endif %} | ||
{% endblock %} | ||
|
||
{% block tail %} | ||
{{ super() }} | ||
<script> | ||
//$('table').css('background-color', 'white'); | ||
{% macro viz_js(viz) %} | ||
<script> | ||
//$('table').css('background-color', 'white'); | ||
$(document).ready(function() { | ||
var table = $('table').DataTable({ | ||
paging: false, | ||
}); | ||
table.column('-1').order( 'desc' ).draw(); | ||
var table = $('table').DataTable({ | ||
paging: false, | ||
}); | ||
table.column('-1').order( 'desc' ).draw(); | ||
}); | ||
</script> | ||
{% endblock %} | ||
</script> | ||
{% endmacro %} | ||
|
||
{% macro viz_css(viz) %} | ||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters