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.

            
              <!--This example shows how to auto size a relatively sophisticated plot with plot.ly You can read more on my website danjcook.com/blog/2017/06/05/author-citations-predicted-by-readers-->
<body>
  <h0></h0>
<h2>About the plot</h2>
<p>The position and size for each data point is controlled by a single paper's read count and its position along the y-axis is controlled by how many times the paper was cited by other papers in the ScienceOpen.com database. If you hover your mouse above a point, it will show you the exact stats and the title for the data point, e.g. it gives the coded citation for the paper. You can download the imaginary data that I used for the plot <a href ='https://raw.githubusercontent.com/dnck/learn_to_code/master/test.csv'>here</a>. Javscript is pretty impressive!</p>
</body>


<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>


            
          
!
            
              body {
  height: 100%;
  background-color:   #5a656e;
}
body {
  color: #000000;
  text-align: left;
}

h1, h2, h3, h4, h4, h5, h6 {
   text-shadow: 0 2px 2px;
   rgba(0,0,0,.5);
}
            
          
!
            
              (function() {
var d3 = Plotly.d3;

var WIDTH_IN_PERCENT_OF_PARENT = 80,
    HEIGHT_IN_PERCENT_OF_PARENT = 60;

var gd3 = d3.select('h0').append('div').style({
        
        width: WIDTH_IN_PERCENT_OF_PARENT + '%',
        'margin-left': (100 - WIDTH_IN_PERCENT_OF_PARENT) / 2 + '%',
        height: HEIGHT_IN_PERCENT_OF_PARENT + 'vh',
        'margin-top': (100 - HEIGHT_IN_PERCENT_OF_PARENT) / 8 + 'vh'});

var gd = gd3.node();

  
		Plotly.d3.csv('https://raw.githubusercontent.com/dnck/learn_to_code/master/test.csv', 
			function(err, rows){
				var YEAR = 2016;
				var discipline = ['Discipline A', 'Discipline B', 'Discipline C', 'Discipline D', 'Discipline E'];
				var POP_TO_PX_SIZE = 0.25;
			function unpack(rows, key){
				return rows.map(function(row){
					return row[key];
				});
			}
			var data = discipline.map(function(discipline){
				var rowsFiltered = 
				rows.filter(function(row){
					return (row.discipline === discipline) && (+row.year === YEAR);
				});
						return{
								mode: 'markers',
								name: discipline,
								x: unpack(rowsFiltered, 'readCount'),  
								y: unpack(rowsFiltered, 'citedBy'),
								text: unpack(rowsFiltered, 'contentTitle'),
								marker:{sizemode: 'area', size: unpack(rowsFiltered, 'readCount'), sizeref: POP_TO_PX_SIZE}, 
						};
			});
			var layout = {
				title: 'Cited-by Count ~ Read Count',
				xaxis: {title: 'Read Count'},
				yaxis: {title: 'Cited by Count Total'},
				margin: {t: 50},
				autosize: true,
				hovermode: 'closest',
        paper_bgcolor:'rgba(90,101,110,0)',
        plot_bgcolor:'rgba(90,101,110,0)'
			};
			Plotly.plot(gd, data, layout, {showLink: false});
		});
  
window.onresize = function() {
    Plotly.Plots.resize(gd);
};

})();
            
          
!
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