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 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.

Quick-add: + add another resource

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.

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.

            
              <figure>
  <svg viewBox="0 0 120 10" preserveAspectRatio="xMidYMin">
  <g id="loading">
    <text y=5 x=50% font-size="2" text-anchor="middle">Fetching bug info</text>
  </g>
  </svg>
  <figcaption></figcaption>
</figure>
            
          
!
            
              @import url(https://fonts.googleapis.com/css?family=Libre+Baskerville:400italic);

* {
  box-sizing: border-box;  
}

body {
    background-color: rgba(10,20,0,0.03);
}

figcaption {
  padding: 0.5em 5em 0.5em 0.5em;
  display: inline-block;
  background-color: #03A9F4;
  color: #FFF;
  font-style: italic;
  font-family: 'Libre Baskerville', serif;
  border-radius: 0 0.5em 0.5em 0;
}

figcaption::before {
  content: '~ '
}

figcaption a, figcaption a:visited {
  color: inherit;
}

svg {
  margin: 0;
  width: 100vw;
  height: 100px;
}

.bug-line {
  cursor: pointer;
  animation: .2s linear appears;
}

@keyframes appears {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}
            
          
!
            
              
var COLORS = ["rgb(244, 67, 54)","rgb(156, 39, 176)","rgb(103, 58, 183)","rgb(63, 81, 181)","rgb(33, 150, 243)","rgb(3, 169, 244)","rgb(0, 188, 212)","rgb(233, 30, 99)","rgb(0, 150, 136)","rgb(76, 175, 80)","rgb(139, 195, 74)","rgb(255, 193, 7)","rgb(255, 152, 0)","rgb(255, 87, 34)","rgb(121, 85, 72)","rgb(96, 125, 139)"];
var userColor = {};

var svg = document.querySelector('svg');
const FIRST_WEEKDAY = new Date('2016-01-04');
const WEEK_INDEX = 0;
const X_PADDING = 10;
const BUGZILLA_API_URL = 'https://bugzilla.mozilla.org/rest/';
const BUG_ID = 1228080;

document.querySelector('figcaption').innerHTML =`<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=${BUG_ID}">Bug ${BUG_ID}</a>`;

var myHeaders = new Headers();
myHeaders.append('Accept', 'application/json');
var fetchParams = {
  mode: 'cors',
  method: 'GET',
  headers: myHeaders
};
var bugDetail = fetch(`${BUGZILLA_API_URL}bug/${BUG_ID}`,fetchParams)
.then((response) => response.json());
var bugHistory = fetch(`${BUGZILLA_API_URL}bug/${BUG_ID}/history`, fetchParams)
.then((response) => response.json());

Promise.all([bugDetail, bugHistory]).then(function(results){
  console.log(results);
  var bugData = results[0].bugs[0];
  bugData.history = results[1].bugs[0].history;
  console.log(bugData);
  drawBug(bugData);
})
.catch((e) => console.error(e))


var firstTime = FIRST_WEEKDAY.getTime() + ( WEEK_INDEX * 1000 * 60 * 60 * 24 * 7);



function drawBug(bug){
    var bugColor = '#FFECB4';
    var startPoint = 0 + X_PADDING;
    var endDate = new Date();
    if(bug.cf_last_resolved){
      endDate = (new Date(bug.cf_last_resolved));
    }
    
  function getPositionFromDate(date){
    
    var length = 100;
    var a = length  / (endDate.getTime() - firstTime);
    var delta = (startPoint - firstTime) * a;

    return (date.getTime() * a) + delta;
  }
  
  
    var y = 5;
  
    var bugGroup = document.createElementNS("http://www.w3.org/2000/svg", "g");
    bugGroup.classList.add('bug-line'); 
  
console.log(bug)
    var assignLine = document.createElementNS("http://www.w3.org/2000/svg", "line");
    assignLine.setAttribute('x1', startPoint); 
    assignLine.setAttribute('y1', y);
    assignLine.setAttribute('x2', getPositionFromDate(endDate));
    assignLine.setAttribute('y2', y);
    assignLine.setAttribute('stroke', bugColor);
    assignLine.setAttribute('stroke-width', 4);
    assignLine.setAttribute('stroke-linecap', 'round');
    bugGroup.appendChild(assignLine);
  
    if(bug.cf_last_resolved){
      var endCircle = document.createElementNS("http://www.w3.org/2000/svg", "circle");
      endCircle.setAttribute('cx', getPositionFromDate(endDate) );
      endCircle.setAttribute('cy', y);
      endCircle.setAttribute('r', 1.5);
      endCircle.setAttribute('fill', '#B2A47D'); 
      endCircle.setAttribute('title',`RESOLVED ${bug.cf_last_resolved}`)
      bugGroup.appendChild(endCircle);
    } 

  
    var bugLine = document.createElementNS("http://www.w3.org/2000/svg", "line");
    bugLine.setAttribute('title', `Bug ${bug.id} - ${bug.summary}`); 
    bugLine.setAttribute('x1', getPositionFromDate(new Date(bug.creation_time))); 
    bugLine.setAttribute('y1', y);
    bugLine.setAttribute('x2', getPositionFromDate(endDate));
    bugLine.setAttribute('y2', y);
    bugLine.setAttribute('stroke', '#B2A47D');
    bugLine.setAttribute('stroke-width', 0.5);
    bugLine.setAttribute('stroke-linecap', 'round');
    bugGroup.appendChild(bugLine);
  
    bug.history.forEach(function(historyEntry, idx){
      if(! userColor[historyEntry.who]){
        userColor[historyEntry.who] = COLORS.shift();
      }
      var entryColor = userColor[historyEntry.who];
      
      var entryCircle = document.createElementNS("http://www.w3.org/2000/svg", "circle");
      var entryDate = new Date(historyEntry.when);
      var entryPoint = getPositionFromDate(entryDate);
      entryCircle.setAttribute('cx',entryPoint);
      entryCircle.setAttribute('cy', y);
      entryCircle.setAttribute('r', 1);
      entryCircle.setAttribute('fill', entryColor);

      entryCircle.setAttribute('title', `${historyEntry.when} - ${historyEntry.who} : ${historyEntry.changes.map((item) => (item.field_name + " " + item.added)).join(' - ')}`); 
      bugGroup.appendChild(entryCircle);
    });
  svg.querySelector('#loading').remove();
  svg.appendChild(bugGroup);
}
            
          
!
999px
Loading ..................

Console