<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://dimplejs.org/dist/dimple.v1.1.1.min.js"></script>
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/css/bootstrap.no-icons.min.css" rel="stylesheet">
<link href="http://netdna.bootstrapcdn.com/font-awesome/2.0/css/font-awesome.css" rel="stylesheet">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="https://code.jquery.com/jquery-3.0.0.js"></script>
<div class="dropdown">
<a id="dLabel" role="button" data-toggle="dropdown" class="btn btn-primary" data-target="#" href="/page.html">
MT <span class="caret"></span>
</a>
<ul class="dropdown-menu multi-level" role="menu" aria-labelledby="dropdownMenu">
<li class="dropdown-submenu">
<a tabindex="-1" href="#" >HotForex</a>
</li>
<li class="dropdown-submenu">
<a tabindex="-1" href="#" >Middle East</a>
</li>
</ul>
</div>
<div id="chartContainer">
<div id="chartContainer2" style="float:left;width:48%;"></div>
Was ich will:
var svg = dimple.newSvg("#chartContainer", 570, 400);
var data = [
{"Point":"France","Population":10.92,"Year":2013,"Percent":1.689,"continent":"HotForex"},
{"Point":"Germany","Population":82.13,"Year":2013,"Percent":0.689,"continent":"HotForex"},
{"Point":"France","Population":60.91,"Year":2000,"Percent":0.689,"continent":"HotForex"},
{"Point":"Germany","Population":2.21,"Year":2000,"Percent":3.689,"continent":"HotForex"},
{"Point":"Turkey","Population":75.01,"Year":2013,"Percent":1.689,"continent":"Middle East"},
{"Point":"Iran","Population":77.15,"Year":2013,"Percent":0.689,"continent":"Middle East"},
{"Point":"Turkey","Population":63.24,"Year":2000,"Percent":0.689,"continent":"Middle East"},
{"Point":"Iran","Population":65.85,"Year":2000,"Percent":3.689,"continent":"Middle East"},];
function getData(data, key) {
var extData = [];
if(key === "")
{
return data;
}
for(var i = 0; i < data.length; i++) {
if(data[i]["continent"] == key) {
extData.push(data[i]);
}
}
return extData;
}
var myChart = new dimple.chart(svg, getData(data,""));
var x = myChart.addCategoryAxis("x", ["Point","Year"]);
var y = myChart.addMeasureAxis("y", "Population");
var series1 = myChart.addSeries( "Point", dimple.plot.bar);
x.showGridlines = true;
var myLegend = myChart.addLegend(530, 100, 60, 300, "Right");
myChart.draw();
d3.selectAll('.dropdown-submenu > a').on("click", function(d) {
myChart.data = getData(data,this.text);
myChart.draw(500);
});
Output
300px
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |