Skip to content

Instantly share code, notes, and snippets.

View flunky's full-sized avatar

John C. Hart flunky

View GitHub Profile
@flunky
flunky / index.html
Last active March 24, 2017 18:32
SVG Manual Bar Chart using Translate
<!DOCTYPE html>
<style> .chart rect { fill: steelblue } </style>
<html><body><p>Here are the magic numbers from Lost:</p>
<svg class="chart" width="120" height="420">
<g transform="translate(0,380)">
<rect width="19" height="40"></rect>
</g>
<g transform="translate(20,340)">
@flunky
flunky / index.html
Created March 24, 2017 23:18
Javascript SVG Bar Chart
<!DOCTYPE html>
<style> .chart rect { fill: steelblue } </style>
<html><body>
<p>Here are the magic numbers from Lost: <span id="data"></span></p>
<svg class="chart" width="120" height="500">
<rect id="bar-1"></rect>
<rect id="bar-2"></rect>
<rect id="bar-3"></rect>
@flunky
flunky / README.md
Last active March 25, 2017 04:57
Manual SVG Bar Chart

This code creates a bar chart using an SVG node embedded in the HTML. The SVG node uses class "chart" which the style specification at the top refers to as ".chart" and specifies that rectangles should be filled with a steel blue color. The SVG node contains six rectangles, hard coded using "x" and "y" attributes for positioning, and "width" and "height" attributes for sizing. Note also that the SVG coordinate system has its origin in the upper-left corner, so that x values increase to the right and y values increase down from the top of the image.

@flunky
flunky / .block
Last active March 26, 2017 03:12
D3 SVG Bar Chart Using Scale
height: 350
@flunky
flunky / .block
Last active March 26, 2017 04:37
D3 SVG Bar Chart With Axes
height: 450
@flunky
flunky / index.html
Last active March 26, 2017 05:16
How much I'm impressed with my daughter Hannah
<!DOCTYPE html>
<script src="//d3js.org/d3.v3.min.js"></script>
<style>
.chart rect { fill: steelblue }
.axis path,
.axis line {
fill: none;
stroke: black;
shape-rendering: crispEdges;
@flunky
flunky / index.html
Last active April 8, 2017 18:54
D3 SVG Bar Chart Joining One Rect Per Datum
<!DOCTYPE html>
<script src="http://d3js.org/d3.v3.min.js"></script>
<style> .chart rect { fill: steelblue } </style>
<html><body>
<p>Here are the magic numbers from Lost: <span id="data"></span></p>
<svg class="chart" width="120" height="500">
<rect></rect>
<rect></rect>
@flunky
flunky / index.html
Last active April 8, 2017 19:03
D3 SVG Bar Chart Creating Rect Per Datum
<!DOCTYPE html>
<script src="http://d3js.org/d3.v3.min.js"></script>
<style> .chart rect { fill: steelblue } </style>
<html><body>
<p>Here are the magic numbers from Lost: <span id="data"></span></p>
<svg class="chart" width="120" height="500">
</svg>
@flunky
flunky / index.html
Last active April 15, 2017 04:08
D3 (v4) Bar Chart With Axes
<!DOCTYPE html>
<script src="http://d3js.org/d3.v4.min.js"></script>
<style> .chart rect { fill: steelblue } </style>
<html><body>
<p>Here are the magic numbers from Lost: <span id="data"></span></p>
<svg class="chart"></svg>
@flunky
flunky / .block
Last active April 22, 2017 15:42
The Vega-Lite Grammar of Interaction
license: gpl-3.0