Skip to content

Instantly share code, notes, and snippets.

@Fil
Last active May 17, 2017
Embed
What would you like to do?
Hello Lea (MAVO and D3 interaction)
license: mit

Testing interaction between MAVO and D3.

<!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