Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <h4>Overview of total number of emails during a whole year</h5>
<div id='chart'></div>
              
            
!

CSS

              
                
              
            
!

JS

              
                let csv = (url) => new Promise((ok, ko) => d3.csv(url, (err, data) => err ? ko(err) : ok(data))); //check url 

let calendarData = csv('https://raw.githubusercontent.com/Geervesh/sift-ediscovery/patch-1/Datasets/Calendar/cal.csv'); //get data from doc in csv format

calendarData.then(data => {   //if url is ok proceed
  let allCalendarData = d3.nest()   //nest the data
  .entries(data)                    //use entries  
  .map(theData => {                 //map the data
    const date = new Date(theData.Date);    //change int into time format
    return{                 //assign the values               
      d: date,                    
      v: theData.totalEmails       
    };
  })
  
let chart = d3_rs_squares.html()
                         .type('calendar.days') //calendar type
                         .width(700)            //chage width 
                         .height(500)           //change height     
                         .color('brown')        //chart colour
                         .starting('utcMonday');  //starting week
                         
                              
                       
d3.select('#chart')
  .datum(allCalendarData)
  .call(chart);  
  

//this get the information of the position being hovered
let rstip = d3_rs_tip.body()
        .attr('class', 'd3-tip')
        .direction('n')
        .html(d => {
          let r = '';
          if(d.y){
           r = d.x+','+d.y
          }else{
            if(d.x.indexOf('@') > -1){
              r = d.x;
            }else{
              r = d3.timeFormat('%d %b')(new Date(d.x))
            }
            r += ',' + 'Emails:' + d.z  
          }
          return r;
        });  
  
  //display the infomation
d3.select('svg').call(rstip)
    d3.selectAll('.square')
      .on('mouseover', rstip.show)
      .on('mouseout', rstip.hide);
});



              
            
!
999px

Console