Hello Lea (MAVO and D3 interaction)
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
license: mit |
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
<!DOCTYPE html> | |
<head> | |
<meta charset="utf-8"> | |
<script src="https://d3js.org/d3.v4.min.js"></script> | |
<link rel='stylesheet' href='https://mavo.io/demos/style.css'> | |
<link rel='stylesheet' href='style.css'> | |
<script src="https://dev.mavo.io/dist/mavo.js"></script> | |
<link rel="stylesheet" href="https://dev.mavo.io/dist/mavo.css"> | |
<style> | |
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; } | |
h3 { border-top: 3px brown solid } | |
</style> | |
</head> | |
<body> | |
<h3>1. Mavo app</h3> | |
<div mv-app="elementStorage" mv-storage="#data"> | |
Edit me: | |
<span property="firstName">David</span> | |
<span property="lastName">Karger</span> | |
</div> | |
<h3>2. Mavo HTML data storage</h3> | |
<pre id="data">{ | |
"firstName": "Lea", | |
"lastName": "Verou" | |
}</pre> | |
<h3>3. d3 reading the storage</h3> | |
<p>placeholder</p> | |
<script> | |
d3.interval(function(e) { | |
d3.select('p').text( | |
'Hello ' + JSON.parse(d3.select("#data").text()).firstName | |
); | |
}) | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment