Skip to content

Commit

Permalink
Merge pull request #139 from carlos8f/cr/issue-138
Browse files Browse the repository at this point in the history
Cr/issue 138
  • Loading branch information
andredumas authored Aug 25, 2016
2 parents 2009de9 + bb52716 commit d8eefca
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 53 deletions.
24 changes: 6 additions & 18 deletions src/plot/axisannotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,31 +138,19 @@ function backgroundPath(accessor, axis, height, width, point, neg) {
if(height/2 < point) pt = height/2;
else h = height/2-point;

return [
'M', 0, value,
'l', neg*Math.max(axis.innerTickSize(), 1), -pt,
'l', 0, -h,
'l', neg*width, 0,
'l', 0, height,
'l', neg*-width, 0,
'l', 0, -h
].join(' ');
return 'M 0 ' + value + ' l ' + String(neg*Math.max(axis.innerTickSize(), 1)) + ' ' + String(-pt) +
' l 0 ' + String(-h) + ' l ' + (neg*width) + ' 0 l 0 ' + height +
' l ' + (neg*-width) + ' 0 l 0 ' + String(-h);
case 'top':
case 'bottom':
var w = 0;

if(width/2 < point) pt = width/2;
else w = width/2-point;

return [
'M', value, 0,
'l', -pt, neg*Math.max(axis.innerTickSize(), 1),
'l', -w, 0,
'l', 0, neg*height,
'l', width, 0,
'l', 0, neg*-height,
'l', -w, 0
].join(' ');
return 'M ' + value + ' 0 l ' + String(-pt) + ' ' + (neg*Math.max(axis.innerTickSize(), 1)) +
' l ' + String(-w) + ' 0 l 0 ' + String(neg*height) + ' l ' + width + ' 0 l 0 ' + (neg*-height) +
' l ' + String(-w) + ' 0';
default: throw "Unsupported axis.orient() = " + axis.orient();
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/plot/crosshair.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function horizontalPathLine(y, range) {
return function(d) {
if(d === null) return null;
var value = y(d);
return ['M', range[0], value, 'L', range[range.length-1], value].join(' ');
return 'M ' + range[0] + ' ' + value + ' L ' + range[range.length-1] + ' ' + value;
};
}

Expand All @@ -140,6 +140,6 @@ function verticalPathLine(x, range) {
var value = x(d),
sr = x.range();
if(value < Math.min(sr[0], sr[sr.length-1]) || value > Math.max(sr[0], sr[sr.length-1])) return null;
return ['M', value, range[0], 'L', value, range[range.length-1]].join(' ');
return 'M ' + value + ' ' + range[0] + ' L ' + value + ' ' + range[range.length-1];
};
}
8 changes: 2 additions & 6 deletions src/plot/macd.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,8 @@ module.exports = function(accessor_macd, plot, plotMixin) { // Injected depende
height = y(accessor.dif(d)) - zero,
xValue = x(accessor.d(d)) - width/2;

return [
'M', xValue, zero,
'l', 0, height,
'l', width, 0,
'l', 0, -height
].join(' ');
return 'M ' + xValue + ' ' + zero + ' l 0 ' + height + ' l ' + width +
' 0 l 0 ' + String(-height);
};
}

Expand Down
11 changes: 3 additions & 8 deletions src/plot/ohlc.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,9 @@ module.exports = function(d3_scale_linear, d3_extent, accessor_ohlc, plot, plotM
xPoint = x(accessor.d(d)),
xValue = xPoint - width/2;

return [
'M', xValue, open,
'l', width/2, 0,
'M', xPoint, y(accessor.h(d)),
'L', xPoint, y(accessor.l(d)),
'M', xPoint, close,
'l', width/2, 0
].join(' ');
return 'M ' + xValue + ' ' +
open + ' l ' + (width/2) + ' 0 M ' + xPoint + ' ' + y(accessor.h(d)) + ' L ' +
xPoint + ' ' + y(accessor.l(d)) + ' M ' + xPoint + ' ' + close + ' l ' + (width/2) + ' 0';
};
}

Expand Down
6 changes: 2 additions & 4 deletions src/plot/plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,8 @@ module.exports = function(d3_svg_line, d3_select) {
var firstDatum = d[0],
lastDatum = d[d.length-1];

return [
'M', x(accessor_date(firstDatum)), y(accessor_value(firstDatum)),
'L', x(accessor_date(lastDatum)), y(accessor_value(lastDatum))
].join(' ');
return 'M ' + x(accessor_date(firstDatum)) + ' ' + y(accessor_value(firstDatum)) +
' L ' + x(accessor_date(lastDatum)) + ' ' + y(accessor_value(lastDatum));
};
},

Expand Down
10 changes: 2 additions & 8 deletions src/plot/tick.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,8 @@ module.exports = function(d3_scale_linear, d3_extent, accessor_tick, plot, plotM
xPoint = x(accessor.d(d)),
xValue = xPoint - width/2;

return [
'M', xValue, high,
'l', width, 0,
'M', xPoint, high,
'L', xPoint, low,
'M', xValue, low,
'l', width, 0
].join(' ');
return 'M ' + xValue + ' ' + high + ' l ' + width + ' 0 M ' + xPoint + ' ' + high +
' L ' + xPoint + ' ' + low + ' M ' + xValue + ' ' + low + ' l ' + width + ' 0';
};
}

Expand Down
8 changes: 2 additions & 6 deletions src/plot/volume.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,8 @@ module.exports = function(accessor_volume, plot, plotMixin) { // Injected depen
height = y(vol) - zero,
xValue = x(accessor.d(d)) - width/2;

return [
'M', xValue, zero,
'l', 0, height,
'l', width, 0,
'l', 0, -height
].join(' ');
return 'M ' + xValue + ' ' + zero + ' l 0 ' + height + ' l ' + width +
' 0 l 0 ' + String(-height);
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/scale/financetime.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = function(d3_scale_linear, d3_time, d3_bisect, techan_util_rebin
* @returns {*}
*/
function scale(x, offset) {
var mappedIndex = dateIndexMap[+x];
var mappedIndex = dateIndexMap[x.getTime ? x.getTime() : +x];
offset = offset || 0;

// Make sure the value has been mapped, if not, determine if it's just before, round in, or just after domain
Expand Down

0 comments on commit d8eefca

Please sign in to comment.