css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              main(role="main")
    #entity-chart
        .form-container
            form#benchmarks
                fieldset(name="benchmarks", class="benchmarks")
                    .checkbox-wrap
                        label(href="#", for="league-average", class="benchmarks-label") Benchmark One
                            input(type="checkbox", name="benchmarks", id="league-average", class="benchmarks-checkbox")
                            span
                            span
                    .checkbox-wrap
                        label(href="#", for="top-10", class="benchmarks-label") Benchmark Two
                            input(type="checkbox", name="benchmarks", id="top-10", class="benchmarks-checkbox")
                            span
                            span
                        
                button(type="submit", value="random") Random
            
          
!
            
              // --- Variables
// ---------------------------------------------------

// color
$color-1: #e2e3e3; // light silver
$color-2: #969ca9; // slate
$color-3: #7aaec5; // accent blue light
$color-4: #5f96bb; // accent blue dark
$color-5: #efefef; // light white
$color-6: #e7e9ec; // darker white
$color-7: #d0d1d1; // grey
$color-8: #92b6c7; // lighter blue
$color-9: #9ea0a6; // grey text
$color-10: #699dc6; // button blue
$color-11: #e0e1e3; // shade grey

// fonts
$font-istok: 'Istok Web', sans-serif;

// --- end variables ---------------------------------

// --- Mixins
// ---------------------------------------------------

// transitions
@mixin transition($property, $duration) {
	-webkit-transition: $property $duration ease-in-out;
	-moz-transition: $property $duration ease-in-out;
	-o-transition: $property $duration ease-in-out;
  -ms-transition: $property $duration ease-in-out;
	transition: $property $duration ease-in-out;
}

@mixin gradient($from, $to) {
  background-color: $to;
  background-image: -moz-linear-gradient($from, $to);
  background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from($from), to($to));
  background-image: -webkit-linear-gradient($from, $to);
  background-image: -o-linear-gradient($from, $to);
}
@mixin gradient-horizontal-three-colors($start-color: $color-6, $mid-color: $color-5, $color-stop: 50%, $end-color: $color-6) {
  background-image: -webkit-gradient(left, linear, 0 0, 0 100%, from($start-color), color-stop($color-stop, $mid-color), to($end-color));
  background-image: -webkit-linear-gradient(left, $start-color, $mid-color $color-stop, $end-color);
  background-image: -moz-linear-gradient(left, $start-color, $mid-color $color-stop, $end-color);
  background-image: linear-gradient(to right, $start-color, $mid-color $color-stop, $end-color);
  background-repeat: no-repeat;
}

// clearfix
@mixin clearfix {
  &:after {
    content: "";
    display: table;
    clear: both; }
    *zoom: 1;
}

// --- end mixins ------------------------------------

// --- Base styles
// ---------------------------------------------------

// allow padding and border to be calc with width
// and reset margin/padding
* {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  @include gradient($color-1, $color-2);
  background-repeat: no-repeat;
  -webkit-tap-highlight-color: rgba(0,0,0,0);
  font-family: $font-istok;
  font-weight: 300;
  color: $color-9;
}

[role="main"] {
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
  -webkit-justify-content: center;
	-moz-justify-content: center;
  justify-content: center;
}

// --- end base styles -------------------------------

// -// --- Ishtar styles
// ---------------------------------------------------
#entity-chart {
  position: relative;
  margin: 10% 0;
  padding: 0 50px 30px 30px;
  border-radius: 4px;
  box-shadow: 0 40px 50px rgba(0,0,0,.3), inset 0 -5px 5px rgba(0,0,0,.3);
  border-top: 2px solid white;
  width: 850px;
  height: 500px;
  @include clearfix;
  @include gradient-horizontal-three-colors();
  
  &:before {
    content: '';
    position: absolute;
    z-index: 1;
    display: block;
    left: 0px;
    top: 10px;
    margin: 30px;
    height: 280px;
    width: 790px;
    @include gradient-horizontal-three-colors($start-color: $color-6, $mid-color: $color-11, $color-stop: 50%, $end-color: $color-6);
  }
  &:after {
    content: '';
    position: absolute;
    z-index: 1;
    display: block;
    left: 20px;
    top: 10px;
    margin: 30px;
    height: 1px;
    width: 750px;
    background: $color-7;
  }
}
svg {
  position: relative;
  z-index: 2;
}

#entity-chart line {
  stroke: $color-7;
}

#entity-chart text {
  fill: $color-8;
}
#entity-chart path {
  stroke: $color-8;
  stroke-width: 3px;
  fill: none;
}
#entity-chart circle {
  stroke: $color-4;
  fill: #fff;
  stroke-width: 3px;
}

#entity-chart circle:hover,
#entity-chart circle.active {
  stroke-width: 6px;
  cursor: pointer;
}

#entity-chart path[class*="average"],
#entity-chart path[class*="top"],
#entity-chart path[class*="bottom"] {
  stroke: $color-7;
}
#entity-chart circle[class*="average"],
#entity-chart circle[class*="top"],
#entity-chart circle[class*="bottom"] {
  fill: white;
  stroke: $color-7;
}

#entity-chart circle:hover {
  cursor: pointer;
  stroke: $color-4;
}
.tipsy {
  font-size: 14px;
  position: absolute;
  padding: 5px;
  margin-top: -8px;
  margin-left: 6.5px;
  z-index: 100000;
  text-shadow: 0 1px 1px rgba(0,0,0,.3);
}
.tipsy-inner {
  @include gradient($color-3, $color-4);
  color: #fff;
  max-width: 200px;
  padding: 5px 8px 4px 8px;
  text-align: center;
  box-shadow: 0 1px 2px rgba(0,0,0,.3);
  border-radius: 3px;
}
.tipsy-arrow {
  position: absolute;
  width: 0;
  height: 0;
  line-height: 0;
  border: 5px dashed $color-4;
}
.tipsy-arrow-s {
  border-top-color: $color-4;
}
.tipsy-s .tipsy-arrow {
  bottom: 0;
  left: 50%;
  margin-left: -5px;
  border-top-style: solid;
  border-bottom: none;
  border-left-color: transparent;
  border-right-color: transparent;
}

.form-container {
  text-rendering: geometricPrecision;
  position: absolute;
  bottom: 9px;
  left: 60px;
  height: 80px;
  width: 750px;
  text-shadow: 0 1px 1px rgba(255,255,255,.5);
  
  fieldset {
    border: none;
    @include clearfix;
  }
  .checkbox-wrap {
    float: left;
    font-size: 23px;
    padding-right: 18px;
    -webkit-user-select: none; 
    -moz-user-select: none; 
    -ms-user-select: none; 
    user-select: none;
  }
  input[type="checkbox"] {
    visibility: hidden;
  }
  label {
    padding-left: 51px;
    position: relative;
    
    span {
      @include transition(all, .2s);
      width: 43px;
      height: 23px;
      border-radius: 20px;
      display: inline-block;
      position: absolute;
      left: 0;
      top: 3px;
      
      &:first-of-type {
        background: $color-9;
        box-shadow: inset 0 0 2px rgba(0,0,0,.3);
      }
      &:last-of-type {
        position: absolute;
        width: 19px;
        height: 19px;
        border-radius: 19px;
        background: white;
        left: 2px;
        top: 5px;
      }
    }
    &.active {
      span {
        &:first-of-type {
          background: $color-4;
        }
        &:last-of-type {
          left: 22px;
        }
      }
    }
    &:hover {
      cursor: pointer;
    }
  }
  button {
    @include transition(background, .2s);
    background: $color-10;
    border-radius: 3px;
    border: 2px solid $color-10;
    padding: 10px 20px;
    position: relative;
    top: -42px;
    float: right;
    color: white;
    font-size: 22px;
    outline: none;
    
    &:hover,
    &:focus,
    &:active {
      cursor: pointer;
      background: darken($color-10, 5%);
    }
    &:active {
      @include transition(background, 0s);
      margin-top: 2px;
      margin-right: 2px;
      border-size: 1px;
      background: darken($color-10, 10%);
      font-size: 21px;
    }
  }
}
            
          
!
            
              // Dribbble rebound to CodePen crossover: http://drbl.in/jxHT

var w = 780,
  h = 350,
  vis = null,
  g,
  current,
  duration = 700,
  ease = "cubic-out",
  reset = [0,0,0,0,0,0,0,0,0,0,0,0,0];

function draw(id) {
	var data = generateData(),
	other_data = generateOtherData(),
	margin = 30,
	y = d3.scale.linear().domain([0, d3.max(data)]).range([0 + margin, h - 60]),
	x = d3.scale.linear().domain([0, data.length]).range([0 + margin, w + 50]),
	line = d3.svg.line()
	  .x(function(d,i) { return x(i); })
	  .y(function(d) { return -1 * y(d); });
		
	console.log(data);

	var vis = d3.select("#entity-chart").select("svg").select("g");
	
	if (vis.empty()) {
		vis = d3.select("#entity-chart")
		  .append("svg:svg")
		  .attr("width", w)
		  .attr("height", h);
          
        // -- had to remove drop shadows ---
        // -- made transitions all funky :( ---
        // filters go in defs element
        // var defs = vis.append("defs");
        // 
        // var filter = defs.append("filter")
        //     .attr("id", "drop-shadow")
        //     .attr("height", "135%");
        // 
        // filter.append("feGaussianBlur")
        //     .attr("in", "SourceAlpha")
        //     .attr("stdDeviation", 10)
        //     .attr("result", "blur");
        // 
        // filter.append("feOffset")
        //     .attr("in", "blur")
        //     .attr("dx", 0)
        //     .attr("dy", 10)
        //     .attr("result", "offsetBlur");
        // 
        // var feMerge = filter.append("feMerge");
        // 
        // feMerge.append("feMergeNode")
        //     .attr("in", "offsetBlur");     
        // feMerge.append("feMergeNode")
        //     .attr("in", "SourceGraphic");
			
		g = vis.append("svg:g")
		  .attr("transform", "translate(0, 350)");

		g.append("svg:line")
		  .attr("x1", x(0))
		  .attr("y1", -1 * y(0))
		  .attr("x2", x(w))
		  .attr("y2", -1 * y(0))
	
		g.selectAll(".xLabel")
		  .data(x.ticks(12))
		  .enter().append("svg:text")
		  .attr("class", "xLabel")
		  .text(String)
		  .attr("x", function(d) { return x(d-1) })
		  .attr("y", 0)
		  .attr("text-anchor", "middle");
	}
			
	g.append("svg:path")
		.attr("class", id)
		.attr("d", line(reset))
        // .style("filter", "url(#drop-shadow)")
		.transition().duration(duration).ease(ease)
		.attr("d", line(data));
						
	g.selectAll("dot")
		.data(data)
		.enter().append("circle")
		.attr("class", id)
		.attr("r", 6.5)
		.attr("cx", function(d,i) { return x(i); })
		.attr("cy", 0)
		.transition().duration(duration).ease(ease)
		.attr("cy", function(d) { return -1 * y(d); })
		.attr("title", function(d,i) { return x(i); });
			
		current = id;
		console.log("current = "+current, "data = "+data);
	
	$('svg circle').tipsy({ 
		gravity: 's', 
		html: true,
        fade: true,
        opacity: 0.95,
		title: function() {
		var d = this.__data__;
		var pDate = d.date;
		return 'Metric: ' + Math.floor(d); 
		}
	});
}

function removeData(id) {
	d3.selectAll("circle."+id)
		.transition().duration(duration).ease(ease)
		.attr("cy", 0)
		.attr("r", 0)
		.remove();
	d3.selectAll("path."+id).remove();
}

function generateData() {
	var data = [];
	for (var i = 0, l = 12; i < l; i++) {
	    data.push(Math.round(Math.random() * l))
	}
	return data;
}
function generateOtherData() {
	var other_data = [3,9,3,1,5,4,4,5,6,9,4,2];
	return other_data;
}
function subMetricChange() {
	$('.benchmarks-checkbox').on('change', function(e) {
		id = $(this).attr("id");
		if ($(this).is(":checked")) {
			$(this).parent().addClass("active");
			draw(id);
		} else {
			removeData(id);
			$(this).parent().removeClass("active");
		}
		e.preventDefault();
	});
	$('button[type="submit"]').on('click', function(e) {
		$('.benchmarks-checkbox').prop('checked', false);
		$('.benchmarks-label').removeClass("active");
		id = $(this).attr("id");
		$(".sub-metric-checkbox").parent().removeClass("active");
		d3.selectAll("circle")
			.transition().duration(duration).ease(ease)
			.attr("cy", 0)
			.attr("r", 0)
			.remove();
		d3.selectAll("path").remove();
		
		$(this).parent().addClass("active");
		draw(id);
		e.preventDefault();
	});
}
function pageInit() {
	$('#Scoring-Metric-1').addClass("first").attr("checked", "checked").parent().addClass("active");
	id = $('.sub-metric-checkbox.first').attr("id");
	draw(id);
}

$(document).ready( function() {
	subMetricChange();
	pageInit();
});

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console