aboutsummaryrefslogtreecommitdiff
path: root/build/css-slope-graphs/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'build/css-slope-graphs/index.html')
-rw-r--r--build/css-slope-graphs/index.html27
1 files changed, 2 insertions, 25 deletions
diff --git a/build/css-slope-graphs/index.html b/build/css-slope-graphs/index.html
index e4e2bd8..6fbfd97 100644
--- a/build/css-slope-graphs/index.html
+++ b/build/css-slope-graphs/index.html
@@ -3,11 +3,12 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
+ <meta name="color-scheme" content="dark light">
<link rel="icon" href="data:,">
<title>CSS Slope Graphs</title>
<link href="/atom.xml" type="application/atom+xml" rel="alternate" title="Atom feed for blog posts" />
<link href="/rss.xml" type="application/rss+xml" rel="alternate" title="RSS feed for blog posts" />
-<style>*{box-sizing:border-box;}body{font-family:sans-serif;line-height:1.33;margin:0 auto;max-width:650px;padding:1rem;}img{max-width:100%;}pre{border:1px solid;overflow:auto;padding:5px;}table{text-align:left;width:100%;}.footnotes{font-size:90%;}</style>
+<style>*{box-sizing:border-box;}body{font-family:sans-serif;line-height:1.33;margin:0 auto;max-width:650px;padding:1rem;}blockquote{background:rgba(0,0,0,0.1);border-left:4px solid;padding-left:5px;}img{max-width:100%;}pre{border:1px solid;overflow:auto;padding:5px;}table{text-align:left;width:100%;}.footnotes{font-size:90%;}</style>
</head>
<nav>
@@ -16,23 +17,14 @@
<main>
<h1 id="css-slope-graphs">CSS Slope Graphs</h1>
-
<p>2021-06-07</p>
-
<p><em>I am a huge sucker for simplistic and beautifully designed visual data on the web</em>. Most data tends to be graphed via line or bar systems - which is fine - but I think slope graphs are highly underrated. Let&#8217;s change that, shall we?</p>
-
<h2 id="the-demo">The Demo</h2>
-
<p>I&#8217;m basing this demo off the design patterns found in <a href="https://www.edwardtufte.com/tufte/books_vdqi">Edward Tufte&#8217;s visualization work</a>, specifically his slope graph designs:</p>
-
<p><a href="https://codepen.io/bradleytaunt/pen/jOBzXMe">Live CodePen Example</a></p>
-
<h2 id="the-html">The HTML</h2>
-
<p>For this concept we will actually be building this graph out of <code>tables</code> - crazy, right? The greatest benefit of rendering all the data inside of a <code>table</code> element is the ability to easily support smaller screens and mobile devices. Larger viewports will get to see the pretty slope graph, while those below a certain threshold will view a simple table.</p>
-
<p>(But more on that in the CSS section)</p>
-
<pre><code>&#60;p&#62;Sales of the leading frozen pizza brands of the United States from 2011 to 2017 (in million US dollars) &#60;br&#62;&#60;em&#62;Source: Statisa 2018&#60;&#47;em&#62;&#60;&#47;p&#62;
&#60;table&#62;
&#60;thead&#62;
@@ -71,13 +63,9 @@
&#60;&#47;tbody&#62;
&#60;&#47;table&#62;
</code></pre>
-
<p>As you can see, nothing too fancy is happpening here. Pay close attention to the <code>data-set</code> and <code>data-name</code> variables though - those will be important for the CSS portion of this design, mainly the rendering of the line elements.</p>
-
<h2 id="the-css">The CSS</h2>
-
<p>To avoid overwhelming your brain all-at-once, let&#8217;s break the CSS down into bite-sized chunks, starting with the base styling:</p>
-
<pre><code>@import url(&#39;https:&#47;&#47;opentype.netlify.com&#47;et-book&#47;index.css&#39;);
* {
box-sizing: border-box;
@@ -107,11 +95,8 @@ table {
width: 100%;
}
</code></pre>
-
<p>Pretty basic stuff.</p>
-
<p>Now we need to design how our slope graph will look on larger screens &#47; desktops. For this instance, we will target these larger devices with a <code>min-width</code> media query of <code>800px</code>. The rest of the CSS might look a little confusing but I assure you it is quite simple.</p>
-
<ol>
<li><p>On larger devices we hide the first <code>thead tr th</code> element with <code>display: none</code></p></li>
<li><p>The first and second <code>td</code> elements inside each <code>tbody</code> row need to be set as <code>position: absolute</code> to avoid duplicate content</p></li>
@@ -119,14 +104,12 @@ table {
<li><p>Remember that <code>data-set</code> variable? We now use that for our <code>:before</code> pseudo element for <code>table tbody tr td:nth-of-type(1)</code></p></li>
<li><p>Remember that <code>data-name</code> variable? We now use that for our <code>:before</code> pseudo element for <code>table tbody tr td:nth-of-type(3)</code></p></li>
<li><p>After that, you can see the simple customization we include to render the angle &#47; position of the slope lines and the corresponding labels</p>
-
<p>@media(min-width:800px) {
table {
display: block;
position: relative;
margin-bottom: 25rem;
}</p>
-
<pre><code>table thead th {
border-bottom: 1px solid lightgrey;
font-size: 24px;
@@ -217,12 +200,9 @@ tbody tr:nth-child(5):after {
width: 56%;
}
</code></pre>
-
<p>}</p></li>
</ol>
-
<p>All that&#8217;s left are some minor styles to make everything look nice on mobile:</p>
-
<pre><code>@media(max-width:800px) {
p {
margin: 2rem 0;
@@ -236,11 +216,8 @@ tbody tr:nth-child(5):after {
}
}
</code></pre>
-
<h2 id="not-the-most-practical">Not the most practical</h2>
-
<p>This slope graph concept is far from perfect for use in real-world situations. The fact that you need to manually render each point of data yourself makes this implementation quite annoying for more in-depth projects.</p>
-
<p>But it was fun to mess around with and create, so who cares!</p>
<footer role="contentinfo">
<h2>Menu Navigation</h2>