Created
December 15, 2016 20:17
-
-
Save NPashaP/4b64f2311e071b1f1e6120f01b6e4319 to your computer and use it in GitHub Desktop.
bar - fill by value
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: gpl-3.0 |
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> | |
<meta charset="utf-8"> | |
<style> | |
rect{ | |
} | |
</style> | |
<body> | |
<svg width="960" height="600"></svg> | |
<script src="https://d3js.org/d3.v4.min.js"></script> | |
<script src="http://vizjs.org/viz.v1.1.7.min.js"></script> | |
<script> | |
var data=[['A', 1],['A', 3],['B', 3],['C', -3],['D', 8]]; | |
var bar=viz.bar().data(data) | |
.fill(function(d){ return d.value < 0 ? '#FF7043': '#42A5F5';}); | |
var svg = d3.select("svg") | |
.append("g") | |
.attr("transform","translate(50,50)") | |
.call(bar); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment