Robert Crocker

Craft obsessed developer who designs.

← Back to the lab

31Sparkline

II · Drawing with SVG

A chart that draws itself on hover, scaled with normalize().

Hover

Source

4 files
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>CodeSandbox</title>
  </head>
  <body>
    <style>
      svg {
        fill: none;
        stroke: hsl(272 90% 76%);
        stroke-width: 3px;
        stroke-linecap: round;
        stroke-linejoin: round;
        overflow: visible;
      }
      svg:hover polyline {
        stroke-dashoffset: 0;
        transition: stroke-dashoffset 1s ease-in-out;
      }
      polyline {
        stroke-dasharray: 844;
        stroke-dashoffset: 844;
      }
    </style>

    <svg aria-hidden="true">
      <polyline class="sparkLine" />
    </svg>
  </body>
</html>