Skip to content

Commit

Permalink
fix: merge
Browse files Browse the repository at this point in the history
  • Loading branch information
shortdiv committed Apr 28, 2017
2 parents 97b770a + 2f9b490 commit 050ec94
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 10 deletions.
6 changes: 6 additions & 0 deletions src/js/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,18 @@ Chart.prototype = {
markersArray.map(function(marker) {
var markerElem = document.createElementNS('http://www.w3.org/2000/svg', 'g');
var textElem = document.createElementNS('http://www.w3.org/2000/svg', 'g');
var connector = document.createElementNS('http://www.w3.org/2000/svg', 'path');
var circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
var text = document.createElementNS('http://www.w3.org/2000/svg', 'text');
circle.setAttribute('cx', marker.x);
circle.setAttribute('cy', marker.y);
circle.setAttribute('r', 5);
circle.setAttribute('fill', 'grey');
circle.setAttribute('class', 'marker-' + marker.markerCount);
var slidertopX = (self.width+self.margin.right+self.margin.left)/2 - 30;
var slidertopY = self.height+self.margin.bottom+1;
connector.setAttribute('d', 'M' + marker.x + " " + marker.y + " L" + slidertopX + " " + slidertopY);
connector.setAttribute('fill', '#FF1744');
text.innerHTML = marker.label;
text.setAttribute('x', marker.x + 15);
text.setAttribute('y', marker.y);
Expand All @@ -140,6 +145,7 @@ Chart.prototype = {
markerElem.setAttribute('class', 'marker-' + marker.markerCount);
textElem.setAttribute('class', 'text-' + marker.markerCount);

markerElem.appendChild(connector);
markerElem.appendChild(circle);
textElem.appendChild(text);

Expand Down
26 changes: 22 additions & 4 deletions src/js/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ DataFactory.prototype = {
* @returns {undefined}
*/
get: function(file) {
file = file ? file.data.url : undefined
return new Promise(function(resolve, reject) {
var req = new XMLHttpRequest();
req.open("GET", file, true)
Expand All @@ -127,12 +128,29 @@ DataFactory.prototype = {
fetchData: function(config) {
var self = this;
return new Promise(function(resolve, reject) {
self.get(config.data.url).then(function(response) {
parse(response, {'columns': true}, function(err, data) {
resolve(self.createDataObj(data, config))
self.get(config)
.then(function(response) {
parse(response, {'columns': true}, function(err, data) {
resolve(self.createDataObj(data, config))
})
}, function(reason) {
debugger;
self.errorMessage = reason
self.errorLog()
})
})
})
},
errorLog: function() {
var mustache = require('mustache');
const template =
"<div class='error'>" +
"<h3><span class='error-message'>{{ errorMessage }}</span></h3>" +
"</div>"
var rendered = mustache.render(template, this),
parser = new DOMParser(),
doc = parser.parseFromString(rendered, "text/html");

storyline.elem.append(doc.body.children[0])
}
}

Expand Down
1 change: 0 additions & 1 deletion src/js/slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ Slider.prototype = {
for(var i = 0; i < this.cards.length; i++) {
this.cardsElem.children[i].children[0].style.height = (this.height - this.NAV_HEIGHT - this.MARGIN*2) + "px";
this.cardsElem.children[i].style.width = w + "px";
this.cardsElem.children[i].style.border = this.MARGIN + "px solid white";
}
},
goToCard: function(number) {
Expand Down
5 changes: 5 additions & 0 deletions src/scss/_chart.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
svg {
&.canvas {
vertical-align: top;
}
}
8 changes: 6 additions & 2 deletions src/scss/_line.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ line {
}

path {
stroke: $color-grey--lighter !important;
stroke: $color-grey--lighter;
stroke-width: 2px;
z-index:0;
}
Expand Down Expand Up @@ -39,7 +39,7 @@ circle[class^="marker"] {
}

g[class^="marker-"], g[class^="text-"] {
text {
text, path {
opacity: 0;
}
&.active {
Expand All @@ -54,5 +54,9 @@ g[class^="marker-"], g[class^="text-"] {
opacity: 1;
stroke: $color-circle-active;
}
path {
stroke: $color-circle-active;
opacity: 1;
}
}
}
3 changes: 3 additions & 0 deletions src/scss/_slider.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
max-width: 500px;
box-sizing: border-box;
text-align: center;
&:not(:last-child) {
border-right: 20px solid white;
}

@media(max-width: 20em) {
width: 1000px;
Expand Down
3 changes: 0 additions & 3 deletions src/scss/_storyline.scss

This file was deleted.

1 change: 1 addition & 0 deletions src/scss/storyline.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
@import "default";
@import "line";
@import "slider";
@import "chart";

0 comments on commit 050ec94

Please sign in to comment.