Lightweight bar chart sparklines using inline SVG. All sizing and colors are automatic based on typography / styling.
See index.html (on GitHub Pages) for examples.
- Include the script:
<script src="sparkcharts.js"></script>- Add the attribute
data-sparkchart="true"to any element with data:
<span data-sparkchart="true">10, 20, 30</span>Note: You may also use jsDelivr to source the library from GitHub1:
<script src="https://cdn.jsdelivr.net/gh/colinhb/sparkcharts.js@81df262/sparkcharts.js"></script>- Typography-responsive: Charts automatically scale with font-size
- CSS colors: Inherits color from CSS
colorproperty - Fixed scale: Optional max value, supplied after a
;:<span data-sparkchart="true">1, 2, 3; 10</span> - Accessible: Includes ARIA labels and tooltips
This library was developed to support easy "distribution reporting" of public opinion data online. For example, see this release.
Footnotes
-
I'm using a specific commit here. You should probably do the same. ↩