Skip to content

Instantly share code, notes, and snippets.

@bradfordcondon
Last active December 22, 2017 21:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bradfordcondon/317fe6b4edd66ba3904ed2248f8b6134 to your computer and use it in GitHub Desktop.
Save bradfordcondon/317fe6b4edd66ba3904ed2248f8b6134 to your computer and use it in GitHub Desktop.
a very simple d3 plot
<!DOCTYPE html>
<style>
.axis .domain {
display: none;
}
</style>
<svg width="960" height="500"></svg>
<script src="https://d3js.org/d3.v3.min.js"></script>
<script>
var data = [{name: "one", property: "a", value: 100},
{name: "two", property: "a", value: 50},
{name: "two", property: "b", value: 20},
{name: "four", property: "b", value: 57}, ];
var svg = d3.select("svg")
var bars= svg.selectAll('.bar')
.data(data)
.enter()
.append('g')
.attr('transform', function (d, i) {
return 'translate(' + i* 20 + ',0)';
}).append('rect')
.style('fill', "red")
.style("height", function (d, i) {
return d.value})
.attr('width', 10)
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment