Skip to content

Instantly share code, notes, and snippets.

@hayd
Forked from mbostock/.block
Created December 13, 2013 00:59

Revisions

  1. @mbostock mbostock revised this gist Dec 4, 2013. 1 changed file with 0 additions and 0 deletions.
    Binary file added thumbnail.png
    Loading
    Sorry, something went wrong. Reload?
    Sorry, we cannot display this file.
    Sorry, this file is invalid so it cannot be displayed.
  2. @mbostock mbostock revised this gist Nov 5, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion index.html
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@
    }

    </style>
    <div id="chart"></div>
    <div class="chart"></div>
    <script src="http://d3js.org/d3.v3.min.js"></script>
    <script>

  3. @mbostock mbostock created this gist Nov 5, 2013.
    1 change: 1 addition & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    A basic HTML bar chart. Part of the [Let’s Make a Bar Chart](http://bost.ocks.org/mike/bar/) tutorial.
    32 changes: 32 additions & 0 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    <!DOCTYPE html>
    <meta charset="utf-8">
    <style>

    .chart div {
    font: 10px sans-serif;
    background-color: steelblue;
    text-align: right;
    padding: 3px;
    margin: 1px;
    color: white;
    }

    </style>
    <div id="chart"></div>
    <script src="http://d3js.org/d3.v3.min.js"></script>
    <script>

    var data = [4, 8, 15, 16, 23, 42];

    var x = d3.scale.linear()
    .domain([0, d3.max(data)])
    .range([0, 420]);

    d3.select(".chart")
    .selectAll("div")
    .data(data)
    .enter().append("div")
    .style("width", function(d) { return x(d) + "px"; })
    .text(function(d) { return d; });

    </script>