cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

              <button onClick="createOrUpdateSparklines()">Update</button>
<div id="example"></div>
              @import url(https://fonts.googleapis.com/css?family=Montserrat|Roboto+Slab);

* {
  font-family: 'Montserrat', sans-serif;
  text-transform: uppercase;

.category__label {
  font-family: 'Roboto Slab';
  text-transform: none;

.category {
    display: block;
    padding: 5px;

  .category__value {
    font-style: normal;
    text-transform: none;
    display: inline-block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    width: 30px;
    padding: 0 5px;

  .category__value {
    width: 50px;
    opacity: 0.6;

  .category__label {
    text-align: right;

  .sparkline__tooltip {
    font-size: 0.7em;
              function generateRandomData(seriesCount, datesCount) {
  return d3.range(seriesCount).map(function (d) {
    return {
      name: '#' + d,
      values: d3.range(datesCount).map(function (d) {
        return {
          label: d,
          value: Math.random(d)

var sparklinesConfig = {
  height: 20,
  width: 180

// Sparklines configuration
var sparklines = d3.toucan.sparklines()

function createOrUpdateSparklines() {
  var exampleElement = d3.selectAll('#example')

  // Adding some sample parents elements
  var categoriesSelection = exampleElement.selectAll('.category')
    .data(generateRandomData(10, 30), function(cat) {
      return cat.name;

  var newCategories = categoriesSelection
    .classed('category', true);

    .classed('category__label', true)

    .text(function (d) {
      return d.name;

  // Creating blocks that will contain sparklines
  var newSparklinesSelection = newCategories
    .classed('sparkline', true)
    .attr('height', sparklinesConfig.height)
    .attr('width', sparklinesConfig.width)

  // Binding data to them
  var sparklinesSelection = categoriesSelection.select('.sparkline')
    .datum(function (d) {
      return d.values;

    .classed('category__value', true)

  var valueFormatter = d3.format('.2p');
    .text(function (d) {
      return valueFormatter(d.values[d.values.length - 1].value);

  // Do the magic!

Loading ..................