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.

            
              <html>
  <head>
    <script src="https://aframe.io/releases/0.7.0/aframe.min.js"></script>
  </head>
  <body style="background: #111;">
    <a-scene>
      <a-assets>
        <img id="groundTexture" src="https://cdn.aframe.io/a-painter/images/floor.jpg" crossorigin>
      </a-assets>
      
      <a-entity position="0 1 0" rotation="0 0 0">
        <a-entity camera look-controls wasd-controls>
          <a-entity cursor="fuse: true; fuseTimeout: 500"
                    position="0 0 -2"
                    geometry="primitive: ring; radiusInner: 0.02; radiusOuter: 0.027"
                    material="color: black; shader: flat">
          </a-entity>
    	  </a-entity>
      </a-entity>
    
      <a-cylinder id="ground" src="#groundTexture" radius="32" height="0.1"></a-cylinder>
    </a-scene>
  </body>
</html>
            
          
!
            
              // default alpha for bars
let alpha = 0.6;
const data = [ 19, 80, 30, 15, 55];
const dataText = [ 'A', 'B', 'C', 'D', 'E'];
// Scale the height of our bars using d3's linear scale
const hscale = d3.scaleLinear()
  .domain([0, d3.max(data)])
  .range([0, 3]);

// Select the scene object just like an svg
const scene = d3.select('a-scene');

// we use d3's enter/update/exit pattern to draw and bind our dom elements
const bars = scene.selectAll('a-box.bar').data(data);
// we set attributes on our cubes to determine how they are rendered
bars.enter().append('a-box').classed('bar', true)
  .attr('position', (d, i) => {
  const x =  i * 0.8 - (data.length / 2);
  const y = hscale(d)/2;
  const z = -3
  return x + " " + y + " " + z   
})
  .attr('width', (d) => 0.5)
  .attr('depth', (d) => 0.5)
  .attr('height', (d) => hscale(d))
  .attr('opacity', alpha)
  .attr('color', 'blue')
  .on("mouseenter", function(d,i) {
    d3.select(this).transition().duration(10)
      .attr('opacity', 0.9);

    d3.select(this).append("a-text")
      .attr('color', 'red')
      .attr('align', 'center')
      .attr('position', `0 ${(hscale(d) / 2 + 0.5)} 0`)
      .attr('scale', '1 1 1')
      .attr('value', `${dataText[i]}, ${d}`);
  })
  .on("mouseleave", function(d,i) {
    d3.select(this).transition().duration(1000)
      .attr('opacity', alpha);

    d3.select(this).select("a-text").remove();
  })
  

            
          
!
999px
Loading ..................

Console