Comments (6)
So here's an example. It's not that pretty, or efficient, but it works - if you move the slider, one of the bars will move up and down. It uses the @manipulate
macro from Interact.jl. Note in the dataset the $i
interpolated into the data array.
using Interact
@manipulate for i in 1:30
d3code = """
<g></g>
<style>
element {
height: 25px;
}
div.bar {
display: inline-block;
width: 20px;
height: 75px;
margin-right: 2px;
background-color: teal;
}
</style>
<script>
var dataset = [ 5, 10, 13, 19, 21, $i, 22, 18, 15, 13,
11, 12, 15, 20, 18, 17, 16, 18, 23, 25 ];
d3.select("g").selectAll("div")
.data(dataset)
.enter()
.append("div")
.attr("class", "bar")
.style("height", function(d) {
var barHeight = d * 5;
return barHeight + "px";
});
</script>
"""
IJulia.clear_output()
@d3_str d3code
end;
Anyway, at some point I will likely improve this, so we can leave this open for now.
from d3magic.jl.
n.b. you'll need to update to the latest version.
from d3magic.jl.
Thanks!
from d3magic.jl.
Is it possible to implement tooltip using D3Magic? Like this example . I am having some troubles to implement it, since it seems we cannot select body
in the JS code.
from d3magic.jl.
It seems IJulia.clear_output()
now also clears the slider. Any workaround?
from d3magic.jl.
@xiaohk I've added an example of how to use Interact/InteractNext in the README.
On the latest master (Pkg.update()
should get you there), I've added d3._select
and d3._selectAll
that allow you to select things outside the "sandbox" that D3Magic creates. So you can select <body>
with d3._select("body")
.
The example below should work, let me know how you go.
d3"""
<div class="example_div"></div>
<script>
var tooltip = d3._select("body")
.append("div")
.attr("class", "jjtooltip")
.style("position", "absolute")
.style("z-index", "10")
.style("visibility", "hidden")
.text("a simple tooltip");
var sampleSVG = d3.select(".example_div")
.append("svg:svg")
.attr("class", "sample")
.attr("width", 300)
.attr("height", 300);
d3.select(".example_div svg")
.append("svg:circle")
.attr("stroke", "black")
.attr("fill", "aliceblue")
.attr("r", 50)
.attr("cx", 52)
.attr("cy", 52)
.on("mouseover", function(){
return tooltip.style("visibility", "visible");
})
.on("mousemove", function(){
// debugger
return tooltip.style("top", (event.y-10)+"px").style("left",(event.x+10)+"px");
})
.on("mouseout", function(){return tooltip.style("visibility", "hidden");});
</script>
"""
from d3magic.jl.
Related Issues (3)
- Jupyter Lab HOT 3
- new error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from d3magic.jl.