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 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.

Quick-add: + add another resource

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.

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 type="button" id="transition-axis">Transition axis</button>

<div id="container"></div>

              body {
  margin: 30px 0 0 30px;

#container {
  font-family: sans-serif;
  font-size: 13px;

svg line, svg path {
  stroke: #555;
  shape-rendering: crispEdges;

button {
  background-color: #E3EEFF;
  border: 1px solid #C3D5FF;
  padding: 7px;
  cursor: pointer;
              var container = d3.select("#container");

var height = 300,
    width = 100,
    margin = 20,
    yMax = 10;

var yScale = d3.scale.linear()
	.range([height - margin, margin])
	.domain([0, yMax]);

var yAxis = d3.svg.axis()

var svg = container.append("svg")
	.attr("width", 100)
	.attr("height", 300);

	.attr("id", "y-axis")
	.attr("transform", "translate(" + width/2 + ",0)")

function transition_axis() {
  // Alternate between 10 and 50 for yMax
  yMax = (yMax == 10 ? 50 : 10);

  // Update scale domain
  yScale.domain([0, yMax]);

 	// Grab y axis g element
  var axisEl = svg.select("#y-axis");
  // Update the axis

// Set up button click handler

d3.select("#transition-axis").on("click", transition_axis);

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