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.

            
              <html>
	<body>
		<canvas id="mycanvas" width="1000" height="600" style="width:100%"></canvas>
		<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
				<script src="https://d28qoto45d39ov.cloudfront.net/arrastre/js/lodash.min.js"></script>
		<script src="https://d28qoto45d39ov.cloudfront.net/arrastre/js/d3.v3.min.js"></script>
		<script src="https://d28qoto45d39ov.cloudfront.net/arrastre/js/arrastre-util.js"></script>
		<script src="https://d28qoto45d39ov.cloudfront.net/arrastre/js/getdata.js"></script>
	</body>
</html>
            
          
!
            
              body {
  background: #000;
  margin: 0 auto;
  text-align: center;
  width: 96%;
}
            
          
!
            
              /*
BIGDATA

For a single skeleton, each joint position is represented with 3 points (one for each co-ordinate). Each joint has a unique colour.

The value of each co-ordinate is mapped to the y-axis. The x position is random.
*/

function BigData(canvas) {
  var width = 1000;
  var height = 600;

  var startTime = Date.now();

  // Set up color scale function
  var color = d3.scale.category20b();
  
  // Set up y-scale function
  var scale = d3.scale.linear().domain([-3, 6]).range([1000, 0]);

  // Set up scale to determine how much data will be displayed with respect to time
  var indexScale = d3.scale.threshold().domain([0, 54000, 70000, 84000, 120000, 154000, 167000, 200000, 230000]).range([0, 3, 10, 40, 10, 1, 60, 20, 10, 10]);

  var ctx = canvas.getContext('2d');
  ctx.fillStyle = "rgb(0,0,0)";
  ctx.fillRect(0, 0, this.width, this.height);
  
  this.draw = function(json) {
    if(json === undefined) {
      return;
    }

    // getDataOfSkeleton returns the x and y positions of each joint as a single array of values
    var data = getDataOfSkeleton(json, 0);
  
    // Fade the canvase
    ctx.fillStyle = "rgba(0, 0, 0, 0.02)";
    ctx.fillRect(0, 0, width, height);

    // Draw the points!
    var indexThreshold = indexScale(Date.now() - startTime);
    _.each(data, function(d, index) {
      if(index > indexThreshold)
        return;

      var x = Math.random() * width;
      var y = scale(d) % height;
      ctx.fillStyle = color(index % 20);
      drawCircle(ctx, x, y, 3);
    });
  };
};



// You can choose one of these to visualise a different dance
var DATASET_ALGORITHM = 'https://d10u56tzn9e9rq.cloudfront.net/algorithm_';

var DATASET_BINARY = 'https://d10u56tzn9e9rq.cloudfront.net/binary_';

var DATASET_WHOLEPIECE = 'https://d10u56tzn9e9rq.cloudfront.net/wholepiece_';

var dataFetcher = new ChunkedDataFetcher(DATASET_ALGORITHM);
var bigData = new BigData( document.getElementById('mycanvas'));
dataFetcher.drawFunction = function(json) {bigData.draw(json);}
            
          
!
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