Pen Settings

HTML

CSS

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

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

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.

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

              
                <div id='description'>
  <h3><code>labelTime();</code></h3>
  <p>Change the time label on the chart to display different time format including day, date, month, etc.. Use different <a href = 'https://github.com/d3/d3-time-format/blob/master/README.md#locale_format' target="_blank">string specifiers</a> to display a certain time format. </p>
  <p>To apply UTC format, <code>d3.utcFormat(<i>specifier</i>)</code> is used as an argument and the specifier to display the time in UTC and when using Local Time only the string specifiers can be used since by default it is set to the Local Time format.</p>
  <p>Using:<button class='rs-btn--small rs-btn--selected' onclick='smartformatter()'>Smart Formatter</button><button class='rs-btn--small' onclick='week()'>String Specifiers</button><button class='rs-btn--small' onclick='utc()'>UTC time</button></p>
  <div id=info></div>
  <div id=infoChart></div>
</div> 


              
            
!

CSS

              
                #description{
  margin: 1em;
}
              
            
!

JS

              
                //redSift
//labelTime();
//change the epooch time format to human readable time
//example below shows changing epooch time to display month and date on the chart


var TIMES = [     //dataset with index in Epoch time
      {
        "l" : 1461456000000,
        "v" : [
          12,
          3
        ]
      },
      {
        "l" : 1461542400000,
        "v" : [
          5,
          11
        ]
      },
      {
        "l" : 1461628800000,
        "v" : [
          8,
          7
        ]
      },
      {
        "l" : 1461715200000,
        "v" : [
          18,
          5
        ]
      },
      {
        "l" : 1461801600000,
        "v" : [
          18,
          9
        ]
      },
      {
        "l" : 1461888000000,
        "v" : [
          8,
          17
        ]
      }]

//using the smart formatter              
let chart = d3_rs_lines.html()
                       .labelTime(d3_rs_lines.timeMultiFormat({
                                                    localtime: true
                                                              }));
d3.select('#info')
    .datum(TIMES)         
    .call(chart);

d3.select('#infoChart')
  .html('<p>This smartly displays the time using the <code>timeMultiFormat</code> function an arguement to labelTime. Set localtime to <code>true</code> to apply the smarter function.</p><p><code>.labelTime(d3_rs_lines.timeMultiFormat({localtime:}));</code></p>');
      
function smartformatter(){
//using the smart formatter              
let chart = d3_rs_lines.html()
                       .labelTime(d3_rs_lines.timeMultiFormat({
                                                    localtime: true
                                                              }));
d3.select('#info')
    .datum(TIMES)         
    .call(chart); 
  
d3.select('#infoChart')
  .html('<p>This smartly displays the time using the <code>timeMultiFormat</code> function an arguement to labelTime. Set localtime to <code>true</code> to apply the smarter function.</p><p><code>.labelTime(d3_rs_lines.timeMultiFormat({localtime:}));</code></p>');  
}

//using string specifiers 
function week(){
let chart = d3_rs_lines.html()
                       .labelTime('%b-%d');
d3.select('#info')
    .datum(TIMES)         
    .call(chart); 
  
d3.select('#infoChart')
    .html('<p>Using the string specifiers to set the calendar tick format.</p>');  
}

//Using UTC time
function utc(){
let chart = d3_rs_lines.html()
                       .labelTime(d3.utcFormat('%a'));
d3.select('#info')
    .datum(TIMES)         
    .call(chart); 
  
  d3.select('#infoChart')
  .html('<p>The chart displays the date and month converted from Epoch Time.</p><p><code>.labelTime(d3.utcFormat("%a"))</code><p>For Local Time format <code>.labelTime("%a");</code> would have been used.</p>');
}

// Generic function to toggle selected state of a button
d3.selectAll('button')
  .on('click', function() {
    let selected = this;
    d3.selectAll('button')
      .classed('rs-btn--selected', function() {
        return (selected === this);
      });
  });
              
            
!
999px

Console