Skip to content

Instantly share code, notes, and snippets.

@bherr2
Last active July 11, 2020 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bherr2/46fb3d45ce6c94eb72c577be9b068837 to your computer and use it in GitHub Desktop.
Save bherr2/46fb3d45ce6c94eb72c577be9b068837 to your computer and use it in GitHub Desktop.
mav-embed example: horizontal legend
license: MIT
height: 960
scrolling: no
border: yes
<!doctype html>
<html lang="en">
<!-- The containing element must have a non-percentage height -->
<body>
<div style="height: 50px">
<button onclick="setVisualization(0)">Scatter Plot</button>
<button onclick="setVisualization(1)">Geographic Map</button>
<button onclick="setVisualization(2)">Map of Science</button>
<button onclick="setVisualization(3)">Co-author Network</button>
</div>
<!-- Add a project -->
<mav-project id="proj1" href="https://gist.githubusercontent.com/bherr2/2e3e6c999575fe0fcd6cfaab42020e1b/raw/FourNetSciResearchers.yml"></mav-project>
<!-- Add a visualization referencing the project -->
<div style="height: calc(100vh - 345px);">
<mav-visualization project="#proj1"></mav-visualization>
</div>
<div style="overflow-x: scroll">
<mav-legend project="#proj1" orientation="horizontal"></mav-legend>
</div>
<!-- Add mav-embed javascript bundle -->
<script src="https://cdn.jsdelivr.net/npm/@dvl-fw/mav-embed/main-es5.js" nomodule></script>
<script src="https://cdn.jsdelivr.net/npm/@dvl-fw/mav-embed/main-es2015.js" type="module"></script>
<script>
function setVisualization(index) {
document.getElementsByTagName('mav-visualization')[0].setAttribute('index', index);
document.getElementsByTagName('mav-legend')[0].setAttribute('index', index);
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment