Skip to content

Commit

Permalink
Merge pull request #173 from molssi-seamm/dev
Browse files Browse the repository at this point in the history
Enhancements to line graphs
  • Loading branch information
seamm committed Aug 17, 2024
2 parents 4337f76 + 2a16215 commit 6248144
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 96 deletions.
4 changes: 4 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
=======
History
=======
2024.8.17 -- Enhancements to line graphs
* Added multiple axes to line graphs.
* Updated to correct version of plotly. 'latest' is actually not.

2024.7.28 -- Updating standard parameters for systems and configurations
* Cleaned up and add to the standard parameters used for naming system and
configurations. 'title' refers to the title in the file, if it exists.
Expand Down
2 changes: 1 addition & 1 deletion seamm/templates/band_structure.html_template
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div>

<script type="text/javascript">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<script src='https://cdn.plot.ly/plotly-2.34.0.min.js'></script>
<div id="b4d1ccf6-a731-4cfc-95dd-479f770eaa06" class="plotly-graph-div" style="height:100%; width:100%;"></div>
<script type="text/javascript">

Expand Down
12 changes: 12 additions & 0 deletions seamm/templates/line.graph_template
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,21 @@
{{ axis.start }},
{{ axis.stop }}
],
{%- if 'overlaying' in axis %}
"overlaying": "{{ axis.overlaying }}",
{%- endif %}
{%- if 'position' in axis %}
"position": "{{ axis.position }}",
{%- endif %}
{%- if 'range' in axis %}
"range": {{ axis.range|jsonify }},
{%- endif %}
{%- if 'side' in axis %}
"side": "{{ axis.side }}",
{%- endif %}
{%- if 'tickmode' in axis %}
"tickmode": "{{ axis.tickmode }}",
{%- endif %}
"title": {
"text": "{{ axis.label }}"
}
Expand Down
198 changes: 104 additions & 94 deletions seamm/templates/line.html_template
Original file line number Diff line number Diff line change
@@ -1,100 +1,110 @@
<html>
<head><meta charset="utf-8" /></head>
<body>
<head><meta charset="utf-8" /></head>
<body>
<div>

<script type="text/javascript">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>
<script src='https://cdn.plot.ly/plotly-2.34.0.min.js'></script>
<div id="b4d1ccf6-a731-4cfc-95dd-479f770eaa06" class="plotly-graph-div" style="height:100%; width:100%;"></div>
<script type="text/javascript">

<script type="text/javascript">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<div id="b4d1ccf6-a731-4cfc-95dd-479f770eaa06" class="plotly-graph-div" style="height:100%; width:100%;"></div>
<script type="text/javascript">

window.PLOTLYENV=window.PLOTLYENV || {};

if (document.getElementById("b4d1ccf6-a731-4cfc-95dd-479f770eaa06")) {
Plotly.newPlot(
'b4d1ccf6-a731-4cfc-95dd-479f770eaa06',
[
{%- for trace in traces %}
{
"hoverlabel": {
"namelength": 0
},
{%- if 'hovertemplate' in trace %}
"hovertemplate": "{{ trace.hovertemplate }}",
{%- else %}
"hovertemplate": "{{ trace.xlabel }}=%{x} {{ trace.xunits }}<br>{{ trace.ylabel }}=%{y} {{ trace.yunits }}",
{%- endif %}
"legendgroup": "",
{%- if 'showlegend' in trace %}
"showlegend": {{ trace.showlegend }},
{%- endif %}
"mode": "lines",
"line": {
"color": "{{ trace.color|default('#4dbd74') }}",
"dash": "{{ trace.dash|default('solid') }}",
"width": "{{ trace.width|default('1') }}"
},
{%- if 'fill' in trace %}
"fill": "{{ trace.fill }}",
{%- endif %}
{%- if 'fillcolor' in trace %}
"fillcolor": "{{ trace.color|default('lightgray') }}",
{%- endif %}
"name": "{{ trace.name }}",
"type": "scatter",
{%- if 'visible' in trace %}
"visible": "{{ trace.visible }}",
{%- endif %}
{%- if 'x' in trace %}
"x": {{ trace.x|jsonify }},
{%- else %}
"x0": {{ trace.x0 }},
"dx": {{ trace.dx }},
{%- endif %}
"xaxis": "{{ trace.xaxis }}",
"y": {{ trace.y|jsonify }},
"yaxis": "{{ trace.yaxis }}"
{%- if loop.last %}
}
{%- else %}
},
window.PLOTLYENV=window.PLOTLYENV || {};

if (document.getElementById("b4d1ccf6-a731-4cfc-95dd-479f770eaa06")) {
var data = [
{%- for trace in traces %}
{
"hoverlabel": {
"namelength": 0
},
{%- if 'hovertemplate' in trace %}
"hovertemplate": "{{ trace.hovertemplate }}",
{%- else %}
"hovertemplate": "{{ trace.xlabel }}=%{x} {{ trace.xunits }}<br>{{ trace.ylabel }}=%{y} {{ trace.yunits }}",
{%- endif %}
"legendgroup": "",
"mode": "lines",
{%- if 'showlegend' in trace %}
"showlegend": {{ trace.showlegend }},
{%- endif %}
"line": {
"color": "{{ trace.color|default('#4dbd74') }}",
"dash": "{{ trace.dash|default('solid') }}",
"width": "{{ trace.width|default('1') }}"
},
{%- if 'fill' in trace %}
"fill": "{{ trace.fill }}",
{%- endif %}
{%- if 'fillcolor' in trace %}
"fillcolor": "{{ trace.color|default('lightgray') }}",
{%- endif %}
"name": "{{ trace.name }}",
"type": "scatter",
{%- if 'visible' in trace %}
"visible": "{{ trace.visible }}",
{%- endif %}
{%- if 'x' in trace %}
"x": {{ trace.x|jsonify }},
{%- else %}
"x0": {{ trace.x0 }},
"dx": {{ trace.dx }},
{%- endif %}
{%- endfor %}
],
{
"hovermode": "x",
"legend": {
"title": "",
"tracegroupgap": 0
},
"title": {
"x": 0.5,
"text": "{{ title }}",
"xanchor": "center"
},
{%- for axis in axes %}
"{{ axis.name }}": {
"anchor": "{{ axis.anchor }}",
"domain": [
{{ axis.start }},
{{ axis.stop }}
],
{%- if 'range' in axis %}
"range": {{ axis.range|jsonify }},
{%- endif %}
"title": {
"text": "{{ axis.label }}"
}
{%- if loop.last %}
}
{%- else %}
},
{%- endif %}
{%- endfor %}
}
)
};
</script>
</div>
"xaxis": "{{ trace.xaxis }}",
"y": {{ trace.y|jsonify }},
"yaxis": "{{ trace.yaxis }}"
{%- if loop.last %}
}
{%- else %}
},
{%- endif %}
{%- endfor %}
];
var layout = {
"hovermode": "x",
"legend": {
"title": "",
"tracegroupgap": 0
},
"title": {
"x": 0.5,
"text": "{{ title }}",
"xanchor": "center"
},
{%- for axis in axes %}
"{{ axis.name }}": {
"anchor": "{{ axis.anchor }}",
"domain": [
{{ axis.start }},
{{ axis.stop }}
],
{%- if 'overlaying' in axis %}
"overlaying": "{{ axis.overlaying }}",
{%- endif %}
{%- if 'position' in axis %}
"position": "{{ axis.position }}",
{%- endif %}
{%- if 'range' in axis %}
"range": {{ axis.range|jsonify }},
{%- endif %}
{%- if 'side' in axis %}
"side": "{{ axis.side }}",
{%- endif %}
{%- if 'tickmode' in axis %}
"tickmode": "{{ axis.tickmode }}",
{%- endif %}
"title": {
"text": "{{ axis.label }}"
}
},
{%- endfor %}
};

Plotly.newPlot('b4d1ccf6-a731-4cfc-95dd-479f770eaa06', data, layout);
};
</script>
</div>
</body>
</html>



2 changes: 1 addition & 1 deletion seamm/templates/surface.html_template
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<body>
<div>
<script type="text/javascript">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<script src='https://cdn.plot.ly/plotly-2.34.0.min.js'></script>
<div id="b4d1ccf6-a731-4cfc-95dd-479f770eaa06" class="plotly-graph-div" style="height:100%; width:100%;"></div>
<script type="text/javascript">

Expand Down

0 comments on commit 6248144

Please sign in to comment.