Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aftaug/13c76ac552d9876d6c56516d46f67c6f to your computer and use it in GitHub Desktop.
Save aftaug/13c76ac552d9876d6c56516d46f67c6f to your computer and use it in GitHub Desktop.

Revisions

  1. @markcaron markcaron revised this gist Aug 26, 2016. 1 changed file with 12 additions and 3 deletions.
    15 changes: 12 additions & 3 deletions figure-donut-chart-with-key.html
    Original file line number Diff line number Diff line change
    @@ -14,21 +14,30 @@
    .chart-text {
    /*font: 16px/1.4em "Montserrat", Arial, sans-serif;*/
    fill: #000;
    transform: translateY(.25em);
    -moz-transform: translateY(0.25em);
    -ms-transform: translateY(0.25em);
    -webkit-transform: translateY(0.25em);
    transform: translateY(0.25em);
    }

    .chart-number {
    font-size: 0.6em;
    line-height: 1;
    text-anchor: middle;
    dominant-baseline: ideographic;
    -moz-transform: translateY(-0.25em);
    -ms-transform: translateY(-0.25em);
    -webkit-transform: translateY(-0.25em);
    transform: translateY(-0.25em);
    }

    .chart-label {
    font-size: 0.2em;
    text-transform: uppercase;
    text-anchor: middle;
    dominant-baseline: mathematical;
    -moz-transform: translateY(0.7em);
    -ms-transform: translateY(0.7em);
    -webkit-transform: translateY(0.7em);
    transform: translateY(0.7em);
    }

    figure {
  2. @markcaron markcaron revised this gist Aug 5, 2016. 1 changed file with 39 additions and 32 deletions.
    71 changes: 39 additions & 32 deletions figure-donut-chart-with-key.html
    Original file line number Diff line number Diff line change
    @@ -35,6 +35,8 @@
    display: flex;
    justify-content: space-around;
    flex-direction: column;
    margin-left: -15px;
    margin-right: -15px;
    }

    @media (min-width: 768px) {
    @@ -43,17 +45,20 @@
    }
    }

    svg,
    .figure-content,
    .figure-key {
    flex: 1;
    padding-left: $grid-gutter-width / 2;
    padding-right: $grid-gutter-width / 2;
    padding-left: 15px;
    padding-right: 15px;
    align-self: center;
    }

    .figure-content svg {
    height: auto;
    }

    .figure-key {
    min-width: calc(8 / 12);
    padding-left: 30px;
    }

    .figure-key [class*="shape-"] {
    @@ -106,34 +111,36 @@
    </style>

    <figure>
    <svg width="100%" height="100%" viewBox="0 0 42 42" class="donut" aria-labelledby="beers-title beers-desc" role="img">
    <title id="beers-title">Beers in My Cellar</title>
    <desc id="beers-desc">Donut chart showing 10 total beers. Two beers are Imperial India Pale Ales, four beers are Belgian Quadrupels, and three are Russian Imperial Stouts. The last remaining beer is unlabeled.</desc>
    <circle class="donut-hole" cx="21" cy="21" r="15.91549430918954" fill="#fff" role="presentation"></circle>
    <circle class="donut-ring" cx="21" cy="21" r="15.91549430918954" fill="transparent" stroke="#d2d3d4" stroke-width="3" role="presentation"></circle>

    <circle class="donut-segment" cx="21" cy="21" r="15.91549430918954" fill="transparent" stroke="#ce4b99" stroke-width="3" stroke-dasharray="40 60" stroke-dashoffset="25" aria-labelledby="donut-segment-1-title donut-segment-1-desc">
    <title id="donut-segment-1-title">Belgian Quadrupels</title>
    <desc id="donut-segment-1-desc">Pink chart segment spanning 40% of the whole, which is 4 Belgian Quadrupels out of 10 total.</desc>
    </circle>
    <circle class="donut-segment" cx="21" cy="21" r="15.91549430918954" fill="transparent" stroke="#b1c94e" stroke-width="3" stroke-dasharray="20 80" stroke-dashoffset="85">
    <title id="donut-segment-2-title">Imperial India Pale Ales</title>
    <desc id="donut-segment-2-desc">Green chart segment spanning 20% of the whole, which is 2 Imperial India Pale Ales out of 10 total.</desc>
    </circle>
    <circle class="donut-segment" cx="21" cy="21" r="15.91549430918954" fill="transparent" stroke="#377bbc" stroke-width="3" stroke-dasharray="30 70" stroke-dashoffset="65">
    <title id="donut-segment-3-title">Russian Imperial Stouts</title>
    <desc id="donut-segment-3-desc">Blue chart segment spanning 3% of the whole, which is 3 Russian Imperial Stouts out of 10 total.</desc>
    </circle>
    <!-- unused 10% -->
    <g class="chart-text">
    <text x="50%" y="50%" class="chart-number">
    10
    </text>
    <text x="50%" y="50%" class="chart-label">
    Beers
    </text>
    </g>
    </svg>
    <div class="figure-content">
    <svg width="100%" height="100%" viewBox="0 0 42 42" class="donut" aria-labelledby="beers-title beers-desc" role="img">
    <title id="beers-title">Beers in My Cellar</title>
    <desc id="beers-desc">Donut chart showing 10 total beers. Two beers are Imperial India Pale Ales, four beers are Belgian Quadrupels, and three are Russian Imperial Stouts. The last remaining beer is unlabeled.</desc>
    <circle class="donut-hole" cx="21" cy="21" r="15.91549430918954" fill="#fff" role="presentation"></circle>
    <circle class="donut-ring" cx="21" cy="21" r="15.91549430918954" fill="transparent" stroke="#d2d3d4" stroke-width="3" role="presentation"></circle>

    <circle class="donut-segment" cx="21" cy="21" r="15.91549430918954" fill="transparent" stroke="#ce4b99" stroke-width="3" stroke-dasharray="40 60" stroke-dashoffset="25" aria-labelledby="donut-segment-1-title donut-segment-1-desc">
    <title id="donut-segment-1-title">Belgian Quadrupels</title>
    <desc id="donut-segment-1-desc">Pink chart segment spanning 40% of the whole, which is 4 Belgian Quadrupels out of 10 total.</desc>
    </circle>
    <circle class="donut-segment" cx="21" cy="21" r="15.91549430918954" fill="transparent" stroke="#b1c94e" stroke-width="3" stroke-dasharray="20 80" stroke-dashoffset="85">
    <title id="donut-segment-2-title">Imperial India Pale Ales</title>
    <desc id="donut-segment-2-desc">Green chart segment spanning 20% of the whole, which is 2 Imperial India Pale Ales out of 10 total.</desc>
    </circle>
    <circle class="donut-segment" cx="21" cy="21" r="15.91549430918954" fill="transparent" stroke="#377bbc" stroke-width="3" stroke-dasharray="30 70" stroke-dashoffset="65">
    <title id="donut-segment-3-title">Russian Imperial Stouts</title>
    <desc id="donut-segment-3-desc">Blue chart segment spanning 3% of the whole, which is 3 Russian Imperial Stouts out of 10 total.</desc>
    </circle>
    <!-- unused 10% -->
    <g class="chart-text">
    <text x="50%" y="50%" class="chart-number">
    10
    </text>
    <text x="50%" y="50%" class="chart-label">
    Beers
    </text>
    </g>
    </svg>
    </div>
    <figcaption class="figure-key">
    <p class="sr-only">Donut chart showing 10 total beers. Two beers are Imperial India Pale Ales, four beers are Belgian Quadrupels, and three are Russian Imperial Stouts. The last remaining beer is unlabeled.</p>

  3. @markcaron markcaron created this gist Aug 5, 2016.
    152 changes: 152 additions & 0 deletions figure-donut-chart-with-key.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,152 @@
    <style>
    @import url(https://fonts.googleapis.com/css?family=Montserrat:400);

    body {
    font: 16px/1.4em "Montserrat", Arial, sans-serif;
    }

    * {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    }

    .chart-text {
    /*font: 16px/1.4em "Montserrat", Arial, sans-serif;*/
    fill: #000;
    transform: translateY(.25em);
    }

    .chart-number {
    font-size: 0.6em;
    line-height: 1;
    text-anchor: middle;
    dominant-baseline: ideographic;
    }

    .chart-label {
    font-size: 0.2em;
    text-transform: uppercase;
    text-anchor: middle;
    dominant-baseline: mathematical;
    }

    figure {
    display: flex;
    justify-content: space-around;
    flex-direction: column;
    }

    @media (min-width: 768px) {
    figure {
    flex-direction: row;
    }
    }

    svg,
    .figure-key {
    flex: 1;
    padding-left: $grid-gutter-width / 2;
    padding-right: $grid-gutter-width / 2;
    align-self: center;
    }

    .figure-key {
    min-width: calc(8 / 12);
    padding-left: 30px;
    }

    .figure-key [class*="shape-"] {
    margin-right: 6px;
    }

    .figure-key-list {
    margin: 0;
    padding: 0;
    list-style: none;
    }

    .figure-key-list li {
    margin: 0 0 8px;
    padding: 0;
    }

    .shape-circle {
    display: inline-block;
    vertical-align: middle;
    width: 32px;
    height: 32px;
    -webkit-border-radius: 50%;
    -moz-border-radius: 50%;
    border-radius: 50%;
    }

    .shape-fuschia {
    background-color: #ce4b99;
    }

    .shape-lemon-lime {
    background-color: #b1c94e;
    }

    .shape-blue {
    background-color: #377bbc;
    }

    .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
    }
    </style>

    <figure>
    <svg width="100%" height="100%" viewBox="0 0 42 42" class="donut" aria-labelledby="beers-title beers-desc" role="img">
    <title id="beers-title">Beers in My Cellar</title>
    <desc id="beers-desc">Donut chart showing 10 total beers. Two beers are Imperial India Pale Ales, four beers are Belgian Quadrupels, and three are Russian Imperial Stouts. The last remaining beer is unlabeled.</desc>
    <circle class="donut-hole" cx="21" cy="21" r="15.91549430918954" fill="#fff" role="presentation"></circle>
    <circle class="donut-ring" cx="21" cy="21" r="15.91549430918954" fill="transparent" stroke="#d2d3d4" stroke-width="3" role="presentation"></circle>

    <circle class="donut-segment" cx="21" cy="21" r="15.91549430918954" fill="transparent" stroke="#ce4b99" stroke-width="3" stroke-dasharray="40 60" stroke-dashoffset="25" aria-labelledby="donut-segment-1-title donut-segment-1-desc">
    <title id="donut-segment-1-title">Belgian Quadrupels</title>
    <desc id="donut-segment-1-desc">Pink chart segment spanning 40% of the whole, which is 4 Belgian Quadrupels out of 10 total.</desc>
    </circle>
    <circle class="donut-segment" cx="21" cy="21" r="15.91549430918954" fill="transparent" stroke="#b1c94e" stroke-width="3" stroke-dasharray="20 80" stroke-dashoffset="85">
    <title id="donut-segment-2-title">Imperial India Pale Ales</title>
    <desc id="donut-segment-2-desc">Green chart segment spanning 20% of the whole, which is 2 Imperial India Pale Ales out of 10 total.</desc>
    </circle>
    <circle class="donut-segment" cx="21" cy="21" r="15.91549430918954" fill="transparent" stroke="#377bbc" stroke-width="3" stroke-dasharray="30 70" stroke-dashoffset="65">
    <title id="donut-segment-3-title">Russian Imperial Stouts</title>
    <desc id="donut-segment-3-desc">Blue chart segment spanning 3% of the whole, which is 3 Russian Imperial Stouts out of 10 total.</desc>
    </circle>
    <!-- unused 10% -->
    <g class="chart-text">
    <text x="50%" y="50%" class="chart-number">
    10
    </text>
    <text x="50%" y="50%" class="chart-label">
    Beers
    </text>
    </g>
    </svg>
    <figcaption class="figure-key">
    <p class="sr-only">Donut chart showing 10 total beers. Two beers are Imperial India Pale Ales, four beers are Belgian Quadrupels, and three are Russian Imperial Stouts. The last remaining beer is unlabeled.</p>

    <ul class="figure-key-list" aria-hidden="true" role="presentation">
    <li>
    <span class="shape-circle shape-fuschia"></span> Belgian Quadrupels (4)
    </li>
    <li>
    <span class="shape-circle shape-lemon-lime"></span> Imperial India Pale Ales (2)
    </li>
    <li>
    <span class="shape-circle shape-blue"></span> Russian Imperial Stouts (3)
    </li>
    </ul>
    </figcaption>
    </figure>