Created
January 6, 2016 14:02
-
-
Save fullstackplus/2b1cb8940c548780295d to your computer and use it in GitHub Desktop.
Vertical stacked bar charts (web standards only)
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
<!-- | |
This is a heavily modified version of Wilson Miner's Timeline Charts example from | |
A List Apart #256 (http://alistapart.com/article/accessibledatavisualization). Accomodates | |
a list of stacked subvalues within a single bar segment. | |
--> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" | |
"http://www.w3.org/TR/html4/strict.dtd"> | |
<html lang="en"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<title>Timeline / Accessible Data Examples</title> | |
<style type="text/css" media="screen"> | |
/* SETUP */ | |
* { | |
margin: 0; | |
padding: 0; | |
list-style-type: none; | |
} | |
body { | |
font-family: Helvetica, Arial, sans-serif; | |
color: #333; | |
} | |
a { | |
color: #2D7BB2; | |
text-decoration: none; | |
font-weight: bold; | |
} | |
a:hover { | |
color: #333; | |
} | |
h1, h2, h3 { | |
clear: both; | |
margin: 0 0 0.6em 0; | |
} | |
h3 { | |
color: #666; | |
} | |
section { | |
display: block; /* HTML5 shim */ | |
width: 20em; | |
margin: 0 auto; | |
padding: 1em 2em; | |
} | |
/* TIMELINE CHARTS */ | |
.timeline { | |
font-size: 1.5em; /* tweak to zoom in / out */ | |
height: 10em; | |
width: 53em; | |
} | |
.timeline > li { | |
position: relative; | |
display: inline-block; | |
width: 1.5em; | |
height: 8em; | |
} | |
.timeline > li a { | |
display: block; | |
height: 100%; | |
} | |
.timeline > li .label { | |
display: block; | |
position: absolute; | |
bottom: -2.5em; /* vertical offset */ | |
left: 0; | |
background: #fff; | |
width: 100%; | |
height: 2em; | |
line-height: 2em; | |
text-align: center; | |
font-size: .8em; /* adjust to match default */ | |
} | |
ul.values { | |
/* | |
Essential to set this element's height to that of the parent — | |
as its childrens' heights are sized relatively. | |
*/ | |
height: 100%; | |
} | |
ul.values li { | |
text-indent: -9999px; | |
overflow: hidden; | |
} | |
.red { background: red; } | |
.green { background: green; } | |
.yellow { background: yellow; } | |
</style> | |
</head> | |
<body> | |
<article> | |
<section class="vertical stacked bar chart"> | |
<h1>Timeline chart</h1> | |
<h2>Fruits eaten over time</h2> | |
<h3>December 2007</h4> | |
<ul class="timeline"> | |
<li> | |
<a href="http://www.example.com/2007/dec/1/" title="December 1, 2007: 40"> | |
<span class="label">1</span> | |
<ul class="values"> | |
<li class="red" style="height: 20%">(20%)</li> | |
<li class="green" style="height: 20%">(20%)</li> | |
<li class="yellow" style="height: 60%">(60%)</li> | |
</ul> | |
</a> | |
</li> | |
<li> | |
<a href="http://www.example.com/2007/dec/2/" title="December 2, 2007: 100"> | |
<span class="label">2</span> | |
<ul class="values"> | |
<li class="red" style="height: 60%">(60%)</li> | |
<li class="green" style="height: 10%">(10%)</li> | |
<li class="yellow" style="height: 30%">(30%)</li> | |
</ul> | |
</a> | |
</li> | |
<li> | |
<a href="http://www.example.com/2007/dec/3/" title="December 3, 2007: 150"> | |
<span class="label">3</span> | |
<ul class="values"> | |
<li class="red" style="height: 5%">(5%)</li> | |
<li class="green" style="height: 75%">(75%)</li> | |
<li class="yellow" style="height: 20%">(20%)</li> | |
</ul> | |
</a> | |
</li> | |
<li> | |
<a href="http://www.example.com/2007/dec/4/" title="December 4, 2007: 40"> | |
<span class="label">4</span> | |
<ul class="values"> | |
<li class="red" style="height: 60%">(60%)</li> | |
<li class="green" style="height: 30%">(30%)</li> | |
<li class="yellow" style="height: 10%">(10%)</li> | |
</ul> | |
</a> | |
</li> | |
<li> | |
<a href="http://www.example.com/2007/dec/5/" title="December 5, 2007: 100"> | |
<span class="label">5</span> | |
<ul class="values"> | |
<li class="red" style="height: 30%">(30%)</li> | |
<li class="green" style="height: 30%">(30%)</li> | |
<li class="yellow" style="height: 40%">(40%)</li> | |
</ul> | |
</a> | |
</li> | |
<li> | |
<a href="http://www.example.com/2007/dec/6/" title="December 6, 2007: 40"> | |
<span class="label">6</span> | |
<ul class="values"> | |
<li class="red" style="height: 50%">(50%)</li> | |
<li class="green" style="height: 20%">(20%)</li> | |
<li class="yellow" style="height: 30%">(30%)</li> | |
</ul> | |
</a> | |
</li> | |
</ul> | |
</section> | |
</article> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment