Skip to content

Commit

Permalink
Adds visual regression testing. Fixes #57.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ændrew Rininsland committed Mar 27, 2018
1 parent 8960d37 commit 85bad79
Show file tree
Hide file tree
Showing 18 changed files with 6,727 additions and 514 deletions.
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"presets": [
["@babel/env", {
["@babel/preset-env", {
"targets": {
"node": "current"
}
Expand Down
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"indent": ["error", 4]
},
"env": {
"browser": true
"browser": true,
"jest": true
}
}
40 changes: 21 additions & 19 deletions build/g-axis.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3')) :
typeof define === 'function' && define.amd ? define(['exports', 'd3'], factory) :
(factory((global.gAxis = global.gAxis || {}),global.d3));
}(this, function (exports,d3) { 'use strict';
(factory((global.gAxis = {}),global.d3));
}(this, (function (exports,d3) { 'use strict';

function xDate () {
let banding;
Expand Down Expand Up @@ -210,7 +210,7 @@
.attr('y', 0)
.attr('height', plotHeight)
.attr('x', d => scale(d.date))
.attr('width', d => d.width)
.attr('width', d => d.width);
}

xLabel.selectAll('.domain').remove();
Expand Down Expand Up @@ -611,7 +611,7 @@
if (banding) {
bands = scale.ticks(numTicks);
if (tickValues) {
let bands = xAxis.tickValues()
let bands = xAxis.tickValues();
}
bands = bands.map((d,i) => {
return{
Expand All @@ -621,7 +621,7 @@
})
.filter((d, i) => {
return i % 2 === 0;
})
});

function getBandWidth(index) {
if (index === bands.length-1) {
Expand All @@ -637,7 +637,7 @@
.attr('y', 0)
.attr('height', plotHeight)
.attr('x', d => scale(d.pos))
.attr('width', d => d.width)
.attr('width', d => d.width);
}

xLabel.selectAll('.tick')
Expand Down Expand Up @@ -711,7 +711,7 @@
return axis;
};
axis.tickFormat = (d) => {
customFormat = d
customFormat = d;
scale.tickFormat(d);
return axis;
};
Expand Down Expand Up @@ -1062,7 +1062,7 @@
axisLabel.append('text')
.attr('y', getVerticle(defaultLabel.vert))
.attr('x', getHorizontal(align, defaultLabel.hori))
.text(defaultLabel.tag)
.text(defaultLabel.tag);

const text = axisLabel.selectAll('text');
const width = (text.node().getBBox().width) / 2;
Expand Down Expand Up @@ -1113,7 +1113,7 @@
})
.filter((d, i) => {
return i % 2 === 0;
})
});

function getBandWidth(index) {
if (index === 0) {
Expand All @@ -1129,7 +1129,7 @@
.attr('x', 0)
.attr('width', plotWidth - labelWidth)
.attr('y', d => scale(d.pos))
.attr('height', d => d.height)
.attr('height', d => d.height);
}

yLabel.selectAll('.tick')
Expand Down Expand Up @@ -1205,7 +1205,7 @@
return axis;
};
axis.tickFormat = (d) => {
customFormat = d
customFormat = d;
scale.tickFormat(d);
return axis;
};
Expand Down Expand Up @@ -1320,7 +1320,7 @@
axisLabel.append('text')
.attr('y', getVerticle(defaultLabel.vert))
.attr('x', getHorizontal(align, defaultLabel.hori))
.text(defaultLabel.tag)
.text(defaultLabel.tag);

const text = axisLabel.selectAll('text');
const width = (text.node().getBBox().width) / 2;
Expand Down Expand Up @@ -1593,7 +1593,7 @@
.attr('transform', `translate(${(labelWidth)},0)`)
.style('text-anchor', 'end');
}
else {yLabel.selectAll('text').style('text-anchor', 'end')}
else {yLabel.selectAll('text').style('text-anchor', 'end');}

if (minorAxis) {
yLabelMinor = parent.append('g')
Expand Down Expand Up @@ -1632,7 +1632,7 @@
axisLabel.append('text')
.attr('y', getVerticle(defaultLabel.vert))
.attr('x', getHorizontal(align, defaultLabel.hori))
.text(defaultLabel.tag)
.text(defaultLabel.tag);

const text = axisLabel.selectAll('text');
const width = (text.node().getBBox().width) / 2;
Expand Down Expand Up @@ -1694,9 +1694,6 @@
.append('rect')
.attr('x', 0)
.attr('width', (d) => {
if (align === 'left ') {
plotWidth - labelWidth;
}
return plotWidth - labelWidth - rem;
})
.attr('y', d => scale(d.date))
Expand Down Expand Up @@ -1859,7 +1856,7 @@
return axis;
};
axis.tickFormat = (d) => {
customFormat = d
customFormat = d;
scale.tickFormat(d);
return axis;
};
Expand Down Expand Up @@ -1954,6 +1951,11 @@
return axis;
}

/**
* g-axis
* 2017 Bob Haslett, ft-interactive
*/

exports.xDate = xDate;
exports.xLinear = xLinear;
exports.xOrdinal = xAxisOrdinal;
Expand All @@ -1963,4 +1965,4 @@

Object.defineProperty(exports, '__esModule', { value: true });

}));
})));
Loading

0 comments on commit 85bad79

Please sign in to comment.