Skip to content

Commit

Permalink
Merge pull request #125 from lambdamusic/d3viz-refactor
Browse files Browse the repository at this point in the history
D3viz refactor
  • Loading branch information
lambdamusic committed Nov 16, 2022
2 parents 80a3331 + cfa677c commit 535c778
Show file tree
Hide file tree
Showing 17 changed files with 978 additions and 1,006 deletions.
6 changes: 3 additions & 3 deletions ontospy/gendocs/CONFIG.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@
},
{
"ID": "d3-bubble-chart",
"Title": "D3 Bubble chart [alpha]",
"Title": "D3 Bubble chart",
"Description": "@todo",
},
{
"ID": "d3-pack-hierarchy",
"Title": "D3 Pack hierarchy [alpha]",
"Title": "D3 Pack hierarchy",
"Description": "@todo",
},
{
"ID": "d3-bar-hierarchy",
"Title": "D3 Bar hierarchy [alpha]",
"Title": "D3 Bar hierarchy",
"Description": "@todo",
},
{
Expand Down
17 changes: 10 additions & 7 deletions ontospy/gendocs/jinja_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,16 @@ def slugify_filter(value):
@pass_eval_context
def linebreaks_filter(eval_ctx, value):
"""A filter for legacy django templates."""
if not value:
return ""
result = u'\n\n'.join(u'<p>%s</p>' % p.replace('\n', '<br>\n')
for p in _paragraph_re.split(escape(value)))
if eval_ctx.autoescape:
result = Markup(result)
return result
try:
if not value:
return ""
result = u'\n\n'.join(u'<p>%s</p>' % p.replace('\n', '<br>\n')
for p in _paragraph_re.split(escape(value)))
if eval_ctx.autoescape:
result = Markup(result)
return result
except:
return value

env.filters['linebreaks'] = linebreaks_filter

Expand Down
48 changes: 36 additions & 12 deletions ontospy/gendocs/media/templates/d3/d3_bar_hierarchy.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
background: white;
}


</style>

{% endblock custom_css %}
Expand All @@ -61,25 +62,48 @@



<div class="row header">




{% if TOTAL_CLASSES %}
<a href="index.html" class="{% if thispage=="classes" %}active{% endif %}">Classes ({{TOTAL_CLASSES}})</a>&nbsp;&nbsp;
{% endif %}

{% if TOTAL_PROPERTIES %}
<a href="properties.html" class="{% if thispage=="properties" %}active{% endif %}">Properties ({{TOTAL_PROPERTIES}})</a>&nbsp;&nbsp;
{% endif %}

{% if TOTAL_CONCEPTS %}
<a href="skos.html" class="{% if thispage=="concepts" %}active{% endif %}">Concepts ({{TOTAL_CONCEPTS}})</a>
{% endif %}




</div>


{% if TOTAL_CLASSES %}
<div class="row">
<h3>Classes ({{TOTAL_CLASSES}})</h3>
<div class="row">

<br /><br />
<div id="breadcrumbs">Branch:
<li class="bde">Owl:Thing</li>
</div>


<br /><br />
<div id="breadcrumbs">Branch:
<li class="bde">Owl:Thing</li>
</div>

<div class="col-md-12" id="graph_classes" style="margin-top: 10px;">

</div>
<!-- the graph -->

<div class="col-md-12" id="the_graph">


</div>
{% endif %}


</div>



Expand Down Expand Up @@ -124,7 +148,7 @@ <h3>Classes ({{TOTAL_CLASSES}})</h3>

<script type="text/javascript">

var root = {{JSON_DATA_CLASSES|safe}} ;
var root = {{JSON_DATA_OBJECTS|safe}} ;

var m = [80, 160, 0, 260], // top right bottom left
w = 1280 - m[1] - m[3], // width
Expand All @@ -142,7 +166,7 @@ <h3>Classes ({{TOTAL_CLASSES}})</h3>
.tickFormat(d3.format("d"))
.orient("top");

var svg = d3.select("#graph_classes").append("svg:svg")
var svg = d3.select("#the_graph").append("svg:svg")
.attr("width", w + m[1] + m[3])
.attr("height", h + m[0] + m[2])
.append("svg:g")
Expand Down
49 changes: 32 additions & 17 deletions ontospy/gendocs/media/templates/d3/d3_bubble_chart.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@
stroke-width: .5px;
}

{#note: June 20, 2016 removed to allow mousetips on all circles #}
{#circle.child {#}
{# pointer-events: none;#}
{# } #}


circle.child:hover {
stroke: #ff7f0e;
Expand All @@ -58,27 +53,48 @@



{% block main_content %}


{% block main_content %}

<div class="row header">




{% if TOTAL_CLASSES %}
<a href="index.html" class="{% if thispage=="classes" %}active{% endif %}">Classes ({{TOTAL_CLASSES}})</a>&nbsp;&nbsp;
{% endif %}

{% if TOTAL_PROPERTIES %}
<a href="properties.html" class="{% if thispage=="properties" %}active{% endif %}">Properties ({{TOTAL_PROPERTIES}})</a>&nbsp;&nbsp;
{% endif %}

{% if TOTAL_CONCEPTS %}
<a href="skos.html" class="{% if thispage=="concepts" %}active{% endif %}">Concepts ({{TOTAL_CONCEPTS}})</a>
{% endif %}




</div>

{% if TOTAL_CLASSES %}
<div class="row">
<h3>Classes ({{TOTAL_CLASSES}})</h3>
<div class="col-md-12" id="graph_classes">

<div class="row">

</div>
<!-- the graph -->

<div class="col-md-12" id="the_graph">


</div>
{% endif %}


</div>




{% endblock main_content %}
{% endblock main_content %}



Expand Down Expand Up @@ -124,7 +140,7 @@ <h3>Classes ({{TOTAL_CLASSES}})</h3>

<script type="text/javascript">

var root = {{JSON_DATA_CLASSES|safe}} ;
var root = {{JSON_DATA_OBJECTS|safe}} ;

var diameter = 960,
format = d3.format(",d"),
Expand All @@ -135,7 +151,7 @@ <h3>Classes ({{TOTAL_CLASSES}})</h3>
.size([diameter, diameter])
.padding(1.5);

var svg = d3.select("#graph_classes").append("svg")
var svg = d3.select("#the_graph").append("svg")
.attr("width", diameter)
.attr("height", diameter)
.attr("class", "bubble");
Expand Down Expand Up @@ -186,7 +202,6 @@ <h3>Classes ({{TOTAL_CLASSES}})</h3>
.style("text-anchor", "middle")
.style("pointer-events", "none")
.text(function(d) { return d.className.substring(0, d.r / 3); });
{# });#}

// Returns a flattened hierarchy containing all leaf nodes under the root.
function classes(root) {
Expand Down
Loading

0 comments on commit 535c778

Please sign in to comment.